From 54f7234dcf779f2bb1566af4535442c28ff4cb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=96=91=EC=A2=85=EC=9B=90?= Date: Thu, 19 Sep 2024 10:28:40 +0900 Subject: [PATCH 1/2] [luci/service] Enhance handling CircleConst as reshape's shape 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 --- compiler/luci/service/src/Nodes/CircleReshape.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/luci/service/src/Nodes/CircleReshape.cpp b/compiler/luci/service/src/Nodes/CircleReshape.cpp index 0de10960b51..6e7baf74f87 100644 --- a/compiler/luci/service/src/Nodes/CircleReshape.cpp +++ b/compiler/luci/service/src/Nodes/CircleReshape.cpp @@ -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(axis); + if (const_shape_node->at(axis) < 0) + { + shape_by_input.dim(axis).unset(); + } } } else @@ -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(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; From 03cb6912ba9acfad2f40cf0457e3339ac7d3b56a Mon Sep 17 00:00:00 2001 From: Jongwon Yang <46333013+jongwonyang@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:51:39 +0900 Subject: [PATCH 2/2] [luci/service] Simplify boolean condition This commit simplifies boolean condition. ONE-DCO-Signed-off-by: Jongwon Yang Co-authored-by: SaeHie Park --- compiler/luci/service/src/Nodes/CircleReshape.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/luci/service/src/Nodes/CircleReshape.cpp b/compiler/luci/service/src/Nodes/CircleReshape.cpp index 6e7baf74f87..778f8d45762 100644 --- a/compiler/luci/service/src/Nodes/CircleReshape.cpp +++ b/compiler/luci/service/src/Nodes/CircleReshape.cpp @@ -143,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 (output_shape.dim(dim_index).known() == false) + if (not output_shape.dim(dim_index).known()) { LUCI_ASSERT(unknown_dim_index == UINT32_MAX, "More than one unknown dimension"); unknown_dim_index = dim_index;