diff --git a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp index 1f05ca0098c3da..ba73bcc8917437 100644 --- a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp +++ b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp @@ -364,13 +364,10 @@ CNNNetworkNGraphImpl::reshape(const std::map& bool parameter_replaced = false; for (size_t i = 0; i < params.size(); i++) { - const auto& param = params[i]; + auto& param = params[i]; if (inputShapes.find(param->get_friendly_name()) == inputShapes.end()) continue; - ::ngraph::PartialShape shape(inputShapes.at(param->get_friendly_name())); - auto newParam = std::make_shared<::ngraph::op::Parameter>(param->get_element_type(), shape); - newParam->set_friendly_name(param->get_friendly_name()); - _ngraph_function->replace_parameter(i, newParam); + param->set_partial_shape(inputShapes.at(param->get_friendly_name())); parameter_replaced = true; } if (parameter_replaced) diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp b/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp index 03529fd6785deb..8ddefc82d603fb 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp @@ -141,6 +141,35 @@ TEST_F(NGraphReshapeTests, ReshapeSpatialReLU) { ASSERT_EQ(ngraph->get_results()[0]->get_shape(), ngraph::Shape({1, 3, 25, 25})); } +TEST_F(NGraphReshapeTests, ReshapeSpatialReLUWithoutReplaceParameter) { + std::shared_ptr ngraph; + { + ngraph::PartialShape shape({1, 3, 22, 22}); + ngraph::element::Type type(ngraph::element::Type_t::f32); + auto param = std::make_shared(type, shape); + auto relu = std::make_shared(param); + auto result = std::make_shared(relu); + + ngraph::ParameterVector params = {param}; + ngraph::ResultVector results = {result}; + + ngraph = std::make_shared(results, params); + } + + ASSERT_EQ(ngraph->get_parameters()[0]->get_shape(), ngraph::Shape({1, 3, 22, 22})); + ASSERT_EQ(ngraph->get_results()[0]->get_shape(), ngraph::Shape({1, 3, 22, 22})); + + { + ngraph->get_parameters()[0]->set_partial_shape({1, 3, 25, 25}); + + ngraph->validate_nodes_and_infer_types(); + } + + ASSERT_EQ(ngraph->get_parameters()[0]->get_shape(), ngraph::Shape({1, 3, 25, 25})); + ASSERT_EQ(ngraph->get_results()[0]->get_shape(), ngraph::Shape({1, 3, 25, 25})); +} + + TEST_F(NGraphReshapeTests, CNNReshapeSpatialReLU) { std::shared_ptr ngraph; {