From 5b83a637af5fc4a03ffc8acb18d72d187beb1063 Mon Sep 17 00:00:00 2001 From: eshoguli Date: Tue, 12 Sep 2023 14:08:04 +0100 Subject: [PATCH] comments: fixes & refactoring --- .../src/batch_to_space.cpp | 10 ++++----- .../src/markup_precisions.cpp | 2 ++ .../src/space_to_batch.cpp | 9 ++++---- .../tests/batch_to_space_transformation.cpp | 4 ---- .../tests/layer_transformation.hpp | 22 ------------------- .../tests/space_to_batch_transformation.cpp | 4 ---- .../batch_to_space_transformation.cpp | 5 ----- .../space_to_batch_transformation.cpp | 5 ----- .../batch_to_space_transformation.cpp | 5 ----- .../space_to_batch_transformation.cpp | 5 ----- .../batch_to_space_transformation.hpp | 1 - .../space_to_batch_transformation.hpp | 1 - .../batch_to_space_transformation.cpp | 10 ++++----- .../space_to_batch_transformation.cpp | 10 ++++----- .../src/batch_to_space_function.cpp | 8 +++---- .../src/space_to_batch_function.cpp | 4 +--- 16 files changed, 22 insertions(+), 83 deletions(-) diff --git a/src/common/low_precision_transformations/src/batch_to_space.cpp b/src/common/low_precision_transformations/src/batch_to_space.cpp index b171fda76d3164..7bbb9dce2d54fd 100644 --- a/src/common/low_precision_transformations/src/batch_to_space.cpp +++ b/src/common/low_precision_transformations/src/batch_to_space.cpp @@ -6,9 +6,7 @@ #include #include -#include -#include - +#include #include #include "low_precision/network_helper.hpp" @@ -20,7 +18,7 @@ namespace low_precision { BatchToSpaceTransformation::BatchToSpaceTransformation(const Params& params) : LayerTransformation(params) { MATCHER_SCOPE(BatchToSpaceTransformation); - auto matcher = pattern::wrap_type(); + auto matcher = pattern::wrap_type(); ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) { auto op = m.get_match_root(); @@ -52,8 +50,8 @@ bool BatchToSpaceTransformation::transform(TransformationContext& context, ngrap return false; } - const std::shared_ptr pooling = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions); - moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions), false); + const std::shared_ptr op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions); + moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions), false); return true; } diff --git a/src/common/low_precision_transformations/src/markup_precisions.cpp b/src/common/low_precision_transformations/src/markup_precisions.cpp index 481d32904f9e9e..ad9d6ae5d30ce1 100644 --- a/src/common/low_precision_transformations/src/markup_precisions.cpp +++ b/src/common/low_precision_transformations/src/markup_precisions.cpp @@ -193,6 +193,7 @@ bool ngraph::pass::low_precision::MarkupPrecisions::isSupported(const std::share static std::unordered_set supportedOps = { { name() }, { name() }, + { name() }, { name() }, { name() }, // ? @@ -220,6 +221,7 @@ bool ngraph::pass::low_precision::MarkupPrecisions::isSupported(const std::share { name() }, // TODO: there are conditions { name() }, + { name() }, { name() }, { name() }, { name() }, diff --git a/src/common/low_precision_transformations/src/space_to_batch.cpp b/src/common/low_precision_transformations/src/space_to_batch.cpp index b993cc6ba5721d..716c771a8e4fac 100644 --- a/src/common/low_precision_transformations/src/space_to_batch.cpp +++ b/src/common/low_precision_transformations/src/space_to_batch.cpp @@ -6,8 +6,7 @@ #include #include -#include -#include +#include #include @@ -20,7 +19,7 @@ namespace low_precision { SpaceToBatchTransformation::SpaceToBatchTransformation(const Params& params) : LayerTransformation(params) { MATCHER_SCOPE(SpaceToBatchTransformation); - auto matcher = pattern::wrap_type(); + auto matcher = pattern::wrap_type(); ngraph::graph_rewrite_callback callback = [this](pattern::Matcher& m) { auto op = m.get_match_root(); @@ -52,8 +51,8 @@ bool SpaceToBatchTransformation::transform(TransformationContext& context, ngrap return false; } - const std::shared_ptr pooling = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions); - moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions), false); + const std::shared_ptr op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions); + moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions), false); return true; } diff --git a/src/common/low_precision_transformations/tests/batch_to_space_transformation.cpp b/src/common/low_precision_transformations/tests/batch_to_space_transformation.cpp index 0d98b11bc9303b..9bc87343fb722f 100644 --- a/src/common/low_precision_transformations/tests/batch_to_space_transformation.cpp +++ b/src/common/low_precision_transformations/tests/batch_to_space_transformation.cpp @@ -102,10 +102,6 @@ class BatchToSpaceTransformation : public LayerTransformation, TEST_P(BatchToSpaceTransformation, CompareFunctions) { actualFunction->validate_nodes_and_infer_types(); - const auto testValues = std::get<1>(GetParam()); - const auto output_precision = LayerTransformation::get_output_precision(actualFunction); - ASSERT_EQ(testValues.expected.preicsionAfterOperation, output_precision); - auto res = compare_functions(actualFunction, referenceFunction, true, false, false); ASSERT_TRUE(res.first) << res.second; diff --git a/src/common/low_precision_transformations/tests/layer_transformation.hpp b/src/common/low_precision_transformations/tests/layer_transformation.hpp index 9dae0c321854aa..be51793f91e7ef 100644 --- a/src/common/low_precision_transformations/tests/layer_transformation.hpp +++ b/src/common/low_precision_transformations/tests/layer_transformation.hpp @@ -217,28 +217,6 @@ class LayerTransformation : public ov::test::TestsCommon { return true; } - template - static ov::element::Type get_output_precision(const std::shared_ptr& model) { - auto result = ov::element::undefined; - for (const auto& op : model->get_ops()) { - if (ov::is_type(op)) { - if (result != ov::element::undefined) { - THROW_IE_LPT_EXCEPTION(*op) << "not one operation"; - } - if (op->get_output_size() != 1) { - THROW_IE_LPT_EXCEPTION(*op) << "not expected outputs count"; - } - result = op->get_output_element_type(0); - } - } - - if (result == ov::element::undefined) { - THROW_IE_LPT_EXCEPTION_BASE << "operation was not found"; - } - - return result; - } - protected: std::shared_ptr actualFunction; std::shared_ptr referenceFunction; diff --git a/src/common/low_precision_transformations/tests/space_to_batch_transformation.cpp b/src/common/low_precision_transformations/tests/space_to_batch_transformation.cpp index 25d20cfe80faec..1bcc95a524998a 100644 --- a/src/common/low_precision_transformations/tests/space_to_batch_transformation.cpp +++ b/src/common/low_precision_transformations/tests/space_to_batch_transformation.cpp @@ -101,10 +101,6 @@ class SpaceToBatchTransformation : public LayerTransformation, public testing::W TEST_P(SpaceToBatchTransformation, CompareFunctions) { actualFunction->validate_nodes_and_infer_types(); - const auto testValues = std::get<1>(GetParam()); - const auto output_precision = LayerTransformation::get_output_precision(actualFunction); - ASSERT_EQ(testValues.expected.preicsionAfterOperation, output_precision); - auto res = compare_functions(actualFunction, referenceFunction, true, false, false); ASSERT_TRUE(res.first) << res.second; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp index ccabe0179c3407..f378f334ebdee6 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp @@ -15,10 +15,6 @@ const std::vector netPrecisions = { // ngraph::element::f16 }; -const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() -}; - const std::vector params = { // per-tensor quantization { @@ -49,7 +45,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, BatchToSpaceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), BatchToSpaceTransformation::getTestCaseName); } // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp index bee750520a2f58..7870b21660f043 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp @@ -15,10 +15,6 @@ const std::vector netPrecisions = { // ngraph::element::f16 }; -const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() -}; - const std::vector params = { { { 1, 3, 100, 171 }, @@ -47,7 +43,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, SpaceToBatchTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_CPU), - ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), SpaceToBatchTransformation::getTestCaseName); } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp index fe9f298c4e100c..55912d15008c7b 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/batch_to_space_transformation.cpp @@ -15,10 +15,6 @@ const std::vector netPrecisions = { ngraph::element::f16 }; -const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams(), -}; - const std::vector params = { { { 4, 3, 50, 86 }, @@ -47,7 +43,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, BatchToSpaceTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), BatchToSpaceTransformation::getTestCaseName); } // namespace diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp index a3850df0986dc8..f5e3c1803dc5c9 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/space_to_batch_transformation.cpp @@ -15,10 +15,6 @@ const std::vector netPrecisions = { ngraph::element::f16 }; -const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams(), -}; - const std::vector params = { { { 1, 3, 100, 171 }, @@ -47,7 +43,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, SpaceToBatchTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ov::test::utils::DEVICE_GPU), - ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), SpaceToBatchTransformation::getTestCaseName); } // namespace diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/batch_to_space_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/batch_to_space_transformation.hpp index 90f80b08240fe3..a263b8831db131 100644 --- a/src/tests/functional/plugin/shared/include/low_precision_transformations/batch_to_space_transformation.hpp +++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/batch_to_space_transformation.hpp @@ -26,7 +26,6 @@ class BatchToSpaceTransformationParam { typedef std::tuple< ngraph::element::Type, std::string, - ngraph::pass::low_precision::LayerTransformation::Params, BatchToSpaceTransformationParam > BatchToSpaceTransformationParams; diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/space_to_batch_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/space_to_batch_transformation.hpp index 65580a6123d78d..d4065a52944f32 100644 --- a/src/tests/functional/plugin/shared/include/low_precision_transformations/space_to_batch_transformation.hpp +++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/space_to_batch_transformation.hpp @@ -26,7 +26,6 @@ class SpaceToBatchTransformationParam { typedef std::tuple< ngraph::element::Type, std::string, - ngraph::pass::low_precision::LayerTransformation::Params, SpaceToBatchTransformationParam > SpaceToBatchTransformationParams; diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/batch_to_space_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/batch_to_space_transformation.cpp index 88bd97371ff7ac..f438f507e0f36f 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/batch_to_space_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/batch_to_space_transformation.cpp @@ -16,20 +16,18 @@ namespace LayerTestsDefinitions { std::string BatchToSpaceTransformation::getTestCaseName(const testing::TestParamInfo& obj) { ngraph::element::Type input_type; std::string target_device; - ngraph::pass::low_precision::LayerTransformation::Params params; BatchToSpaceTransformationParam param; - std::tie(input_type, target_device, params, param) = obj.param; + std::tie(input_type, target_device, param) = obj.param; std::ostringstream result; - result << input_type << "_" << target_device << "_" << toString(params) << "_" << param.input_shape << "_" << param.fake_quantize; + result << input_type << "_" << target_device << "_" << param.input_shape << "_" << param.fake_quantize; return result.str(); } void BatchToSpaceTransformation::SetUp() { ngraph::element::Type input_type; - ngraph::pass::low_precision::LayerTransformation::Params params; BatchToSpaceTransformationParam param; - std::tie(input_type, targetDevice, params, param) = this->GetParam(); + std::tie(input_type, targetDevice, param) = this->GetParam(); function = ngraph::builder::subgraph::BatchToSpaceFunction::get( param.input_shape, @@ -43,7 +41,7 @@ void BatchToSpaceTransformation::SetUp() { void BatchToSpaceTransformation::Run() { LayerTestsCommon::Run(); - const auto params = std::get<3>(GetParam()); + const auto params = std::get<2>(GetParam()); auto actual_type = getRuntimePrecisionByType(params.layer_type); const auto expected_type = params.expected_kernel_type; if ((expected_type == "FP32") && (actual_type == "FP16")) { diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/space_to_batch_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/space_to_batch_transformation.cpp index a65e380786e225..efb1ae735f410f 100644 --- a/src/tests/functional/plugin/shared/src/low_precision_transformations/space_to_batch_transformation.cpp +++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/space_to_batch_transformation.cpp @@ -16,20 +16,18 @@ namespace LayerTestsDefinitions { std::string SpaceToBatchTransformation::getTestCaseName(const testing::TestParamInfo& obj) { ngraph::element::Type input_type; std::string target_device; - ngraph::pass::low_precision::LayerTransformation::Params params; SpaceToBatchTransformationParam param; - std::tie(input_type, target_device, params, param) = obj.param; + std::tie(input_type, target_device, param) = obj.param; std::ostringstream result; - result << input_type << "_" << target_device << "_" << toString(params) << "_" << param.input_shape << "_" << param.fake_quantize; + result << input_type << "_" << target_device << "_" << param.input_shape << "_" << param.fake_quantize; return result.str(); } void SpaceToBatchTransformation::SetUp() { ngraph::element::Type input_type; - ngraph::pass::low_precision::LayerTransformation::Params params; SpaceToBatchTransformationParam param; - std::tie(input_type, targetDevice, params, param) = this->GetParam(); + std::tie(input_type, targetDevice, param) = this->GetParam(); function = ngraph::builder::subgraph::SpaceToBatchFunction::get( param.input_shape, @@ -43,7 +41,7 @@ void SpaceToBatchTransformation::SetUp() { void SpaceToBatchTransformation::Run() { LayerTestsCommon::Run(); - const auto params = std::get<3>(GetParam()); + const auto params = std::get<2>(GetParam()); auto actual_type = getRuntimePrecisionByType(params.layer_type); const auto expected_type = params.expected_kernel_type; if ((expected_type == "FP32") && (actual_type == "FP16")) { diff --git a/src/tests/ngraph_helpers/lpt_ngraph_functions/src/batch_to_space_function.cpp b/src/tests/ngraph_helpers/lpt_ngraph_functions/src/batch_to_space_function.cpp index 42b71279f4a283..0d5021ee808bbc 100644 --- a/src/tests/ngraph_helpers/lpt_ngraph_functions/src/batch_to_space_function.cpp +++ b/src/tests/ngraph_helpers/lpt_ngraph_functions/src/batch_to_space_function.cpp @@ -27,7 +27,7 @@ std::shared_ptr BatchToSpaceFunction::get(const ngraph::Partia parent, std::make_shared(ngraph::element::i64, ngraph::Shape{ block_shape.size() }, block_shape), std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_begin.size() }, crops_begin), - std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_end.size()}, crops_end)); + std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_end.size() }, crops_end)); ngraph::ResultVector results{std::make_shared(parent)}; return std::make_shared(results, ngraph::ParameterVector{ input }, "BatchToSpaceFunction"); @@ -50,11 +50,9 @@ std::shared_ptr BatchToSpaceFunction::get(const ngraph::Partia parent, std::make_shared(ngraph::element::i64, ngraph::Shape{ block_shape.size() }, block_shape), std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_begin.size() }, crops_begin), - std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_end.size()}, crops_end)); + std::make_shared(ngraph::element::i64, ngraph::Shape{ crops_end.size() }, crops_end)); - if (!dequantization_after.empty()) { - parent = makeDequantization(parent, dequantization_after); - } + parent = makeDequantization(parent, dequantization_after); ngraph::ResultVector results{std::make_shared(parent)}; return std::make_shared(results, ngraph::ParameterVector{ input }, "BatchToSpaceFunction"); diff --git a/src/tests/ngraph_helpers/lpt_ngraph_functions/src/space_to_batch_function.cpp b/src/tests/ngraph_helpers/lpt_ngraph_functions/src/space_to_batch_function.cpp index 8757ee7cf572ba..ccbba4d1f2697d 100644 --- a/src/tests/ngraph_helpers/lpt_ngraph_functions/src/space_to_batch_function.cpp +++ b/src/tests/ngraph_helpers/lpt_ngraph_functions/src/space_to_batch_function.cpp @@ -52,9 +52,7 @@ std::shared_ptr SpaceToBatchFunction::get(const ngraph::Partia std::make_shared(ngraph::element::i64, ngraph::Shape{ pads_begin.size() }, pads_begin), std::make_shared(ngraph::element::i64, ngraph::Shape{ pads_end.size() }, pads_end)); - if (!dequantization_after.empty()) { - parent = makeDequantization(parent, dequantization_after); - } + parent = makeDequantization(parent, dequantization_after); ngraph::ResultVector results{std::make_shared(parent)}; return std::make_shared(results, ngraph::ParameterVector{ input }, "SpaceToBatchFunction");