From 0d05f87004258c0b2e269309f2c68c2dee326ea1 Mon Sep 17 00:00:00 2001 From: Yuan Hu Date: Tue, 5 Dec 2023 01:23:42 +0800 Subject: [PATCH] [CPU] fix issue that reshape node didn't update last second input value (#21369) * fix didn't udpate last second input issue Signed-off-by: HU Yuan2 * to match master code Signed-off-by: HU Yuan2 * fix review comment use parametrized test case instead of creating new test case Signed-off-by: HU Yuan2 --------- Signed-off-by: HU Yuan2 --- src/plugins/intel_cpu/src/nodes/reshape.cpp | 6 +++--- .../functional/single_layer_tests/shape_ops.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/reshape.cpp b/src/plugins/intel_cpu/src/nodes/reshape.cpp index d399b5bb5b5..4b9aea6967b 100644 --- a/src/plugins/intel_cpu/src/nodes/reshape.cpp +++ b/src/plugins/intel_cpu/src/nodes/reshape.cpp @@ -65,9 +65,6 @@ Reshape::Reshape(const std::shared_ptr& op, const GraphContext::CPtr c } bool Reshape::needShapeInfer() const { - if (inputShapesModified()) { - return true; - } const auto& mem = getParentEdgesAtPort(1)[0]->getMemory(); if (lastSecondInputValues.empty()) { lastSecondInputValues.resize(mem.getStaticDims()[0], 0); @@ -81,6 +78,9 @@ bool Reshape::needShapeInfer() const { return true; } } + if (inputShapesModified()) { + return true; + } return false; } diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp index a4be376f857..c7ddbab6e5c 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/shape_ops.cpp @@ -280,6 +280,20 @@ const auto params_EmptyTensor = ::testing::Combine(::testing::Values(shape_Empty INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_EmptyTensor, ShapeOpsCPUTest, params_EmptyTensor, ShapeOpsCPUTest::getTestCaseName); +// test cases about NeedShapeInfer return right result +inputDescription shape_NeedShapeInfer{{{-1, -1}, + {ngraph::Shape{640, 80}, ngraph::Shape{640, 80}, ngraph::Shape{1280, 40}, ngraph::Shape{1280, 40}}}, + {std::vector{320, 160}, std::vector{640, 80}, std::vector{320, 160}, std::vector{640, 80}}}; + +const auto params_NeedShapeInfer = ::testing::Combine(::testing::Values(shape_NeedShapeInfer), + ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(shapeNodeType::Reshape), + ::testing::Values(Precision::FP32), + ::testing::ValuesIn(secondInPrcs), + ::testing::Values(false)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_NeedShapeInfer, ShapeOpsCPUTest, params_NeedShapeInfer, ShapeOpsCPUTest::getTestCaseName); + } // namespace reshapeTest namespace squeezeTest {