From 02a9832a9065b2ae289bfa7edc8f709f6f19d2a3 Mon Sep 17 00:00:00 2001 From: Mateusz Bencer Date: Wed, 19 Mar 2025 17:32:27 +0100 Subject: [PATCH] [luci] Add additional negative unit test for Reshape 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 --- .../service/src/Nodes/CircleReshape.test.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/compiler/luci/service/src/Nodes/CircleReshape.test.cpp b/compiler/luci/service/src/Nodes/CircleReshape.test.cpp index 653cb690d18..51a011d51ae 100644 --- a/compiler/luci/service/src/Nodes/CircleReshape.test.cpp +++ b/compiler/luci/service/src/Nodes/CircleReshape.test.cpp @@ -135,6 +135,33 @@ TEST(ShapeRuleTest, reshape_should_infer) ASSERT_EQ(4, output_shape.dim(1).value()); } +TEST(ShapeRuleTest, reshape_zero_rank_mismatch_NEG) +{ + auto g = loco::make_graph(); + auto node_reshape = g->nodes()->create(); + auto tensor_input = g->nodes()->create(); + auto shape_by_input = g->nodes()->create(); + + tensor_input->dtype(loco::DataType::S32); + tensor_input->shape({2, 4}); + tensor_input->shape_status(luci::ShapeStatus::VALID); + + shape_by_input->dtype(loco::DataType::S32); + shape_by_input->size(3); + shape_by_input->at(0) = 2; + shape_by_input->at(1) = 2; + shape_by_input->at(2) = 0; + shape_by_input->shape_status(luci::ShapeStatus::VALID); + + node_reshape->tensor(tensor_input); + node_reshape->shape(shape_by_input); + + loco::TensorShape output_shape; + luci::sinf::Rule shape_inf_rule; + + ASSERT_THROW(shape_inf_rule.infer(node_reshape, output_shape), oops::InternalExn); +} + TEST(ShapeRuleTest, reshape_by_input_node) { auto g = loco::make_graph();