diff --git a/src/plugins/intel_gna/transformations/remove_converts.cpp b/src/plugins/intel_gna/transformations/remove_converts.cpp index ee154c17106..bd1e17afe9d 100644 --- a/src/plugins/intel_gna/transformations/remove_converts.cpp +++ b/src/plugins/intel_gna/transformations/remove_converts.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace GNAPluginNS { NGRAPH_RTTI_DEFINITION(RemoveInputConvert, "RemoveInputConvert", 0); @@ -72,7 +73,7 @@ namespace GNAPluginNS { return false; } - // the result presicion will be changed automaically + // the result precision will be changed automatically ngraph::replace_output_update_name(convert_node->output(0), convert_node->input_value(0)); return true; }; diff --git a/src/tests/unit/gna/ngraph/transformations/gna_remove_convert.cpp b/src/tests/unit/gna/ngraph/transformations/gna_remove_convert.cpp index 26d333ae12c..d0ff84be7d8 100644 --- a/src/tests/unit/gna/ngraph/transformations/gna_remove_convert.cpp +++ b/src/tests/unit/gna/ngraph/transformations/gna_remove_convert.cpp @@ -254,6 +254,45 @@ public: } }; +class RemoveOutputConvertConnectedToLayerTest: public RemoveOutputConvertTest { +public: + void SetUp() override { + std::tie(net_precision_, target_precision_) = this->GetParam(); + const ngraph::Shape input_shape{1, 10}; + // test function + { + auto input = ngraph::builder::makeParams(net_precision_, {input_shape, input_shape, input_shape, input_shape}); + auto mul1 = ngraph::builder::makeEltwise(input[0], input[1], ngraph::helpers::EltwiseTypes::ADD); + auto mul2 = ngraph::builder::makeEltwise(input[2], input[3], ngraph::helpers::EltwiseTypes::ADD); + auto mul3 = ngraph::builder::makeEltwise(mul1, mul2, ngraph::helpers::EltwiseTypes::ADD); + auto convert1 = ngraph::builder::makeConversion(mul1, target_precision_, ngraph::helpers::ConversionTypes::CONVERT); + auto convert2 = ngraph::builder::makeConversion(mul2, target_precision_, ngraph::helpers::ConversionTypes::CONVERT); + auto convert3 = ngraph::builder::makeConversion(mul3, target_precision_, ngraph::helpers::ConversionTypes::CONVERT); + auto result1 = std::make_shared(convert1); + auto result2 = std::make_shared(convert2); + auto result3 = std::make_shared(convert3); + + func_ = std::make_shared(ngraph::ResultVector{result1, result2, result3}, input, "multiple_output"); + } + + // ref function + { + auto input = ngraph::builder::makeParams(net_precision_, {input_shape, input_shape, input_shape, input_shape}); + auto mul1 = ngraph::builder::makeEltwise(input[0], input[1], ngraph::helpers::EltwiseTypes::ADD); + auto mul2 = ngraph::builder::makeEltwise(input[2], input[3], ngraph::helpers::EltwiseTypes::ADD); + auto mul3 = ngraph::builder::makeEltwise(mul1, mul2, ngraph::helpers::EltwiseTypes::ADD); + auto result1 = std::make_shared(mul1); + auto result2 = std::make_shared(mul2); + auto result3 = std::make_shared(mul3); + + ref_func_no_convert_ = std::make_shared(ngraph::ResultVector{result1, result2, result3}, input, "multiple_output"); + } + + // ref function convert should not be removed + ref_func_convert_ = ngraph::clone_function(*func_); + } +}; + ov::element::TypeVector netTypes = { ov::element::f16, ov::element::f32, @@ -294,6 +333,10 @@ TEST_P(RemoveMultiOutputsConvertTest, CompareWithRefs) { Run(); } +TEST_P(RemoveOutputConvertConnectedToLayerTest, CompareWithRefs) { + Run(); +} + INSTANTIATE_TEST_SUITE_P(TransformationTests, RemoveInputConvertTest, ::testing::Combine( ::testing::ValuesIn(netTypes), @@ -323,4 +366,10 @@ INSTANTIATE_TEST_SUITE_P(TransformationTests, RemoveMultiOutputsConvertTest, ::testing::ValuesIn(netTypes), ::testing::ValuesIn(targetTypes)), RemoveMultiOutputsConvertTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(TransformationTests, RemoveOutputConvertConnectedToLayerTest, + ::testing::Combine( + ::testing::ValuesIn(netTypes), + ::testing::ValuesIn(targetTypes)), + RemoveOutputConvertConnectedToLayerTest::getTestCaseName); } // namespace testing