Skip to content

Commit

Permalink
[luci/service] Enhance handling CircleConst as reshape's shape
Browse files Browse the repository at this point in the history
This commit improves handling `CircleConst` as the `shape` for the reshape operation.

- Use `known` explicitly instead of `static_cast` which can cause overflow.

ONE-DCO-1.0-Signed-off-by: Jongwon Yang <[email protected]>
  • Loading branch information
jongwonyang committed Sep 23, 2024
1 parent 9028169 commit 54f7234
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/luci/service/src/Nodes/CircleReshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ loco::TensorShape Algorithm::visit(const luci::CircleReshape *node)
for (uint32_t axis = 0; axis < shape_by_input.rank(); ++axis)
{
shape_by_input.dim(axis) = const_shape_node->at<S32>(axis);
if (const_shape_node->at<S32>(axis) < 0)
{
shape_by_input.dim(axis).unset();
}
}
}
else
Expand Down Expand Up @@ -139,7 +143,7 @@ loco::TensorShape Algorithm::visit(const luci::CircleReshape *node)
for (uint32_t dim_index = 0; dim_index < output_shape.rank(); ++dim_index)
{
const uint32_t dim_value = output_shape.dim(dim_index).value();
if (static_cast<int>(dim_value) == -1)
if (output_shape.dim(dim_index).known() == false)
{
LUCI_ASSERT(unknown_dim_index == UINT32_MAX, "More than one unknown dimension");
unknown_dim_index = dim_index;
Expand Down

0 comments on commit 54f7234

Please sign in to comment.