Skip to content

Commit de81bb4

Browse files
authoredMar 24, 2025
[luci] Add additional negative unit test for Reshape (#14859)
This commit adds additional unit test for negative scenario where "0" indicates not existing input dimension. ONE-DCO-1.0-Signed-off-by: Mateusz Bencer <m.bencer@partner.samsung.com>
1 parent eeab639 commit de81bb4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎compiler/luci/service/src/Nodes/CircleReshape.test.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,33 @@ TEST(ShapeRuleTest, reshape_should_infer)
135135
ASSERT_EQ(4, output_shape.dim(1).value());
136136
}
137137

138+
TEST(ShapeRuleTest, reshape_zero_rank_mismatch_NEG)
139+
{
140+
auto g = loco::make_graph();
141+
auto node_reshape = g->nodes()->create<luci::CircleReshape>();
142+
auto tensor_input = g->nodes()->create<luci::CircleInput>();
143+
auto shape_by_input = g->nodes()->create<luci::CircleConst>();
144+
145+
tensor_input->dtype(loco::DataType::S32);
146+
tensor_input->shape({2, 4});
147+
tensor_input->shape_status(luci::ShapeStatus::VALID);
148+
149+
shape_by_input->dtype(loco::DataType::S32);
150+
shape_by_input->size<loco::DataType::S32>(3);
151+
shape_by_input->at<loco::DataType::S32>(0) = 2;
152+
shape_by_input->at<loco::DataType::S32>(1) = 2;
153+
shape_by_input->at<loco::DataType::S32>(2) = 0;
154+
shape_by_input->shape_status(luci::ShapeStatus::VALID);
155+
156+
node_reshape->tensor(tensor_input);
157+
node_reshape->shape(shape_by_input);
158+
159+
loco::TensorShape output_shape;
160+
luci::sinf::Rule shape_inf_rule;
161+
162+
ASSERT_THROW(shape_inf_rule.infer(node_reshape, output_shape), oops::InternalExn);
163+
}
164+
138165
TEST(ShapeRuleTest, reshape_wrong_target_shape_NEG)
139166
{
140167
auto g = loco::make_graph();

0 commit comments

Comments
 (0)