From ba6df14743af2d92653bb6123fc1ba2e749be97b Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 11 Mar 2024 16:42:09 +0100 Subject: [PATCH 01/61] Add downgrade transformation --- .../convert_avg_pool_downgrade.hpp | 22 +++++ ...onvert_maxpool14_to_maxpool8_downgrade.hpp | 22 +++++ ...onvert_maxpool8_to_maxpool1_downgrade.hpp} | 0 .../common_optimizations.cpp | 6 +- .../convert_avg_pool_downgrade.cpp | 46 ++++++++++ .../convert_maxpool14_downgrade.cpp | 47 +++++++++++ ...ade.cpp => convert_maxpool8_downgrade.cpp} | 3 +- .../convert_avg_pool_downgrade.cpp | 84 +++++++++++++++++++ .../convert_maxpool14_downgrade_test.cpp | 71 ++++++++++++++++ ...pp => convert_maxpool8_downgrade_test.cpp} | 3 +- 10 files changed, 299 insertions(+), 5 deletions(-) create mode 100644 src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp create mode 100644 src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp rename src/common/transformations/include/transformations/op_conversions/{convert_maxpool_downgrade.hpp => convert_maxpool8_to_maxpool1_downgrade.hpp} (100%) create mode 100644 src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp create mode 100644 src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp rename src/common/transformations/src/transformations/op_conversions/{convert_maxpool_downgrade.cpp => convert_maxpool8_downgrade.cpp} (96%) create mode 100644 src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp create mode 100644 src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp rename src/common/transformations/tests/op_conversions/{convert_maxpool_downgrade_test.cpp => convert_maxpool8_downgrade_test.cpp} (94%) diff --git a/src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp new file mode 100644 index 00000000000000..366c5ef2f7f3bf --- /dev/null +++ b/src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ov { +namespace pass { +/** + * @ingroup ie_transformation_common_api + * @brief Converts AvgPool v14 to AvgPool v1 + */ +class TRANSFORMATIONS_API ConvertAvgPool14ToAvgPool1 : public MatcherPass { +public: + OPENVINO_RTTI("ConvertAvgPool14ToAvgPool1", "0"); + ConvertAvgPool14ToAvgPool1(); +}; +} // namespace pass +} // namespace ov diff --git a/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp new file mode 100644 index 00000000000000..e10646247c7ccb --- /dev/null +++ b/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ov { +namespace pass { +/** + * @ingroup ie_transformation_common_api + * @brief Converts MaxPool v14 to MaxPool v8 + */ +class TRANSFORMATIONS_API ConvertMaxPool14ToMaxPool8 : public MatcherPass { +public: + OPENVINO_RTTI("ConvertMaxPool14ToMaxPool8", "0"); + ConvertMaxPool14ToMaxPool8(); +}; +} // namespace pass +} // namespace ov diff --git a/src/common/transformations/include/transformations/op_conversions/convert_maxpool_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp similarity index 100% rename from src/common/transformations/include/transformations/op_conversions/convert_maxpool_downgrade.hpp rename to src/common/transformations/include/transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index 30faae0cfee68d..e561bffd03f2e2 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -66,6 +66,7 @@ #include "transformations/init_node_info.hpp" #include "transformations/op_conversions/batch_norm_decomposition.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" +#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" #include "transformations/op_conversions/convert_bitwise_to_logical_bool.hpp" #include "transformations/op_conversions/convert_broadcast_to_tiles.hpp" #include "transformations/op_conversions/convert_convertlike.hpp" @@ -78,7 +79,8 @@ #include "transformations/op_conversions/convert_gelu.hpp" #include "transformations/op_conversions/convert_interpolate11_downgrade.hpp" #include "transformations/op_conversions/convert_interpolate1_to_interpolate4.hpp" -#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" +#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" +#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" #include "transformations/op_conversions/convert_maxpool_upgrade.hpp" #include "transformations/op_conversions/convert_minimum_to_power_and_max.hpp" #include "transformations/op_conversions/convert_mod.hpp" @@ -211,6 +213,7 @@ bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr(); ADD_MATCHER(fq_fusions, FakeQuantizeMulFusion) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp new file mode 100644 index 00000000000000..25fe267ecfac9a --- /dev/null +++ b/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp @@ -0,0 +1,46 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" + +#include "itt.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/op/avg_pool.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "transformations/utils/utils.hpp" + +ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { + MATCHER_SCOPE(ConvertAvgPool14ToAvgPool1); + + const auto avg_pool_v14_pattern = pattern::wrap_type(); + + const matcher_pass_callback callback = [this](pattern::Matcher& m) { + const auto avg_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); + if (!avg_pool_v14) { + return false; + } + + const auto rounding_type_v14 = avg_pool_v14->get_rounding_type(); + const auto rounding_type_v1 = + rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; + + const auto avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), + avg_pool_v14->get_strides(), + avg_pool_v14->get_pads_begin(), + avg_pool_v14->get_pads_end(), + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + rounding_type_v1, + avg_pool_v14->get_auto_pad()); + + avg_pool_v1->set_friendly_name(avg_pool_v14->get_friendly_name()); + copy_runtime_info(avg_pool_v14, avg_pool_v1); + replace_node(avg_pool_v14, avg_pool_v1); + + return true; + }; + + auto m = std::make_shared(avg_pool_v14_pattern, matcher_name); + register_matcher(m, callback); +} diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp new file mode 100644 index 00000000000000..208d7964480bb7 --- /dev/null +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp @@ -0,0 +1,47 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "itt.hpp" +#include "openvino/core/rt_info.hpp" +#include "openvino/op/max_pool.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" +#include "transformations/utils/utils.hpp" + +ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { + MATCHER_SCOPE(ConvertMaxPool14ToMaxPool8); + + const auto max_pool_v14_pattern = pattern::wrap_type(); + + const matcher_pass_callback callback = [this](pattern::Matcher& m) { + const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); + if (!max_pool_v14) { + return false; + } + + const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); + const auto rounding_type_v8 = + rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; + + const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + max_pool_v14->get_pads_begin(), + max_pool_v14->get_pads_end(), + max_pool_v14->get_kernel(), + rounding_type_v8, + max_pool_v14->get_auto_pad(), + max_pool_v14->get_index_element_type(), + max_pool_v14->get_axis()); + + max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); + copy_runtime_info(max_pool_v14, max_pool_v8); + replace_node(max_pool_v14, max_pool_v8); + + return true; + }; + + auto m = std::make_shared(max_pool_v14_pattern, matcher_name); + register_matcher(m, callback); +} diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp similarity index 96% rename from src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp rename to src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp index a6f756ac05acd5..8e48f11ce9d491 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp @@ -2,13 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" - #include "itt.hpp" #include "openvino/core/descriptor/tensor.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/max_pool.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" #include "transformations/utils/utils.hpp" using namespace std; diff --git a/src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp new file mode 100644 index 00000000000000..5591ea6fd1d319 --- /dev/null +++ b/src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp @@ -0,0 +1,84 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" + +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "openvino/op/avg_pool.hpp" +#include "openvino/opsets/opset1.hpp" +#include "openvino/opsets/opset14.hpp" +#include "openvino/pass/manager.hpp" + +namespace { + +std::shared_ptr create_v14_model(const ov::op::RoundingType rounding_type) { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}, dilations{1, 1}; + const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto avg_pool_v14 = std::make_shared(input, + strides, + pads_begin, + pads_end, + kernel, + true, + rounding_type, + ov::op::PadType::EXPLICIT); + + avg_pool_v14->set_friendly_name("avg_pool_v14"); + + return std::make_shared(avg_pool_v14->outputs(), ov::ParameterVector{input}); +} + +std::shared_ptr create_v1_model(const ov::op::RoundingType rounding_type) { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}, dilations{1, 1}; + const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto avg_pool_v1 = std::make_shared(input, + strides, + pads_begin, + pads_end, + kernel, + true, + rounding_type, + ov::op::PadType::EXPLICIT); + + avg_pool_v1->set_friendly_name("avg_pool_v1"); + + return std::make_shared(avg_pool_v1->outputs(), ov::ParameterVector{input}); +} + +} // namespace + +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_torch_to_ceil) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); + model_ref = create_v1_model(ov::op::RoundingType::CEIL); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_to_ceil) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::CEIL); + model_ref = create_v1_model(ov::op::RoundingType::CEIL); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_floor_to_floor) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::FLOOR); + model_ref = create_v1_model(ov::op::RoundingType::FLOOR); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_incorrect_version) { + manager.register_pass(); + model = create_v1_model(ov::op::RoundingType::CEIL); +} diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp new file mode 100644 index 00000000000000..aad3a52754ec50 --- /dev/null +++ b/src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp @@ -0,0 +1,71 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "common_test_utils/ov_test_utils.hpp" +#include "openvino/op/max_pool.hpp" +#include "openvino/opsets/opset14.hpp" +#include "openvino/opsets/opset8.hpp" +#include "openvino/pass/manager.hpp" +#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" + +namespace { + +std::shared_ptr create_v14_model(const ov::op::RoundingType rounding_type) { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}, dilations{1, 1}; + const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto max_pool_v14 = + std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, rounding_type); + + max_pool_v14->set_friendly_name("max_pool_v14"); + + return std::make_shared(max_pool_v14->outputs(), ov::ParameterVector{input}); +} + +std::shared_ptr create_v8_model(const ov::op::RoundingType rounding_type) { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}, dilations{1, 1}; + const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto max_pool_v8 = + std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, rounding_type); + + max_pool_v8->set_friendly_name("max_pool_v8"); + + return std::make_shared(max_pool_v8->outputs(), ov::ParameterVector{input}); +} + +} // namespace + +TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_torch_to_ceil) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); + model_ref = create_v8_model(ov::op::RoundingType::CEIL); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_to_ceil) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::CEIL); + model_ref = create_v8_model(ov::op::RoundingType::CEIL); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_floor_to_floor) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::FLOOR); + model_ref = create_v8_model(ov::op::RoundingType::FLOOR); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + +TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_incorrect_version) { + manager.register_pass(); + model = create_v8_model(ov::op::RoundingType::CEIL); +} diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp similarity index 94% rename from src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp rename to src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp index 828ccf8d240c28..ac1c142cf5d380 100644 --- a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp +++ b/src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp @@ -2,8 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" - #include #include @@ -15,6 +13,7 @@ #include "openvino/opsets/opset8.hpp" #include "openvino/pass/manager.hpp" #include "transformations/init_node_info.hpp" +#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" using namespace ov; using namespace testing; From 51ef54f405c450423b5ba1b8d4fa92917bdfb7e2 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 14 Mar 2024 13:57:18 +0100 Subject: [PATCH 02/61] Minor change --- .../op_conversions/convert_avg_pool_downgrade.cpp | 2 +- .../op_conversions/convert_maxpool14_downgrade.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp index 25fe267ecfac9a..1e3d6586387d51 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp @@ -15,7 +15,7 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const auto avg_pool_v14_pattern = pattern::wrap_type(); - const matcher_pass_callback callback = [this](pattern::Matcher& m) { + const matcher_pass_callback callback = [](pattern::Matcher& m) { const auto avg_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); if (!avg_pool_v14) { return false; diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp index 208d7964480bb7..07afd2d90d5d86 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp @@ -14,7 +14,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto max_pool_v14_pattern = pattern::wrap_type(); - const matcher_pass_callback callback = [this](pattern::Matcher& m) { + const matcher_pass_callback callback = [](pattern::Matcher& m) { const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); if (!max_pool_v14) { return false; From 95551d970e8811ca1991783b55bb206d48b33228 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 18 Mar 2024 12:18:56 +0100 Subject: [PATCH 03/61] Disable transformations for template plugin --- src/plugins/template/src/plugin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index b612e2d68d6546..958778ffe58b47 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -16,6 +16,8 @@ #include "transformations/control_flow/unroll_if.hpp" #include "transformations/fp16_compression/convert_compression_only_to_legacy.hpp" #include "transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp" +#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" +#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" #include "transformations/op_conversions/convert_reduce_to_pooling.hpp" namespace { @@ -66,6 +68,8 @@ void transform_model(const std::shared_ptr& model) { passManager.register_pass(); // Disable some transformations passManager.get_pass_config()->disable(); + passManager.get_pass_config()->disable(); + passManager.get_pass_config()->disable(); // This transformation changes output name passManager.get_pass_config()->disable(); // Register any other transformations From 40db8925217682734e647007b6eefe4cb8dd83b5 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 18 Mar 2024 15:05:32 +0100 Subject: [PATCH 04/61] Refactor into single file for NPU plugin --- ...rade.hpp => convert_avgpool_downgrade.hpp} | 0 ...onvert_maxpool14_to_maxpool8_downgrade.hpp | 22 ------- ...rade.hpp => convert_maxpool_downgrade.hpp} | 11 ++++ .../common_optimizations.cpp | 5 +- ...rade.cpp => convert_avgpool_downgrade.cpp} | 2 +- .../convert_maxpool8_downgrade.cpp | 57 ------------------- ...rade.cpp => convert_maxpool_downgrade.cpp} | 47 ++++++++++++++- ...rade.cpp => convert_avgpool_downgrade.cpp} | 2 +- .../convert_maxpool8_downgrade_test.cpp | 41 ------------- ...cpp => convert_maxpool_downgrade_test.cpp} | 27 ++++++++- src/plugins/template/src/plugin.cpp | 4 +- 11 files changed, 89 insertions(+), 129 deletions(-) rename src/common/transformations/include/transformations/op_conversions/{convert_avg_pool_downgrade.hpp => convert_avgpool_downgrade.hpp} (100%) delete mode 100644 src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp rename src/common/transformations/include/transformations/op_conversions/{convert_maxpool8_to_maxpool1_downgrade.hpp => convert_maxpool_downgrade.hpp} (63%) rename src/common/transformations/src/transformations/op_conversions/{convert_avg_pool_downgrade.cpp => convert_avgpool_downgrade.cpp} (96%) delete mode 100644 src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp rename src/common/transformations/src/transformations/op_conversions/{convert_maxpool14_downgrade.cpp => convert_maxpool_downgrade.cpp} (50%) rename src/common/transformations/tests/op_conversions/{convert_avg_pool_downgrade.cpp => convert_avgpool_downgrade.cpp} (98%) delete mode 100644 src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp rename src/common/transformations/tests/op_conversions/{convert_maxpool14_downgrade_test.cpp => convert_maxpool_downgrade_test.cpp} (70%) diff --git a/src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp similarity index 100% rename from src/common/transformations/include/transformations/op_conversions/convert_avg_pool_downgrade.hpp rename to src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp diff --git a/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp deleted file mode 100644 index e10646247c7ccb..00000000000000 --- a/src/common/transformations/include/transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -namespace ov { -namespace pass { -/** - * @ingroup ie_transformation_common_api - * @brief Converts MaxPool v14 to MaxPool v8 - */ -class TRANSFORMATIONS_API ConvertMaxPool14ToMaxPool8 : public MatcherPass { -public: - OPENVINO_RTTI("ConvertMaxPool14ToMaxPool8", "0"); - ConvertMaxPool14ToMaxPool8(); -}; -} // namespace pass -} // namespace ov diff --git a/src/common/transformations/include/transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_maxpool_downgrade.hpp similarity index 63% rename from src/common/transformations/include/transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp rename to src/common/transformations/include/transformations/op_conversions/convert_maxpool_downgrade.hpp index 84c99d0da7f875..f62300e95a9d26 100644 --- a/src/common/transformations/include/transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp +++ b/src/common/transformations/include/transformations/op_conversions/convert_maxpool_downgrade.hpp @@ -11,6 +11,7 @@ namespace ov { namespace pass { class TRANSFORMATIONS_API ConvertMaxPool8ToMaxPool1; +class TRANSFORMATIONS_API ConvertMaxPool14ToMaxPool8; } // namespace pass } // namespace ov @@ -24,3 +25,13 @@ class ov::pass::ConvertMaxPool8ToMaxPool1 : public ov::pass::MatcherPass { OPENVINO_RTTI("ConvertMaxPool8ToMaxPool1"); ConvertMaxPool8ToMaxPool1(); }; + +/** + * @ingroup ov_transformation_common_api + * @brief ConvertMaxPool14ToMaxPool8 converts v14::MaxPool into v8::MaxPool. + */ +class ov::pass::ConvertMaxPool14ToMaxPool8 : public ov::pass::MatcherPass { +public: + OPENVINO_RTTI("ConvertMaxPool14ToMaxPool8", "0"); + ConvertMaxPool14ToMaxPool8(); +}; diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index de0abcfc51927b..83a7372c197db4 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -66,7 +66,7 @@ #include "transformations/init_node_info.hpp" #include "transformations/op_conversions/batch_norm_decomposition.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" -#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" +#include "transformations/op_conversions/convert_avgpool_downgrade.hpp" #include "transformations/op_conversions/convert_bitwise_to_logical_bool.hpp" #include "transformations/op_conversions/convert_broadcast_to_tiles.hpp" #include "transformations/op_conversions/convert_convertlike.hpp" @@ -79,8 +79,7 @@ #include "transformations/op_conversions/convert_gelu.hpp" #include "transformations/op_conversions/convert_interpolate11_downgrade.hpp" #include "transformations/op_conversions/convert_interpolate1_to_interpolate4.hpp" -#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" -#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" +#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" #include "transformations/op_conversions/convert_maxpool_upgrade.hpp" #include "transformations/op_conversions/convert_minimum_to_power_and_max.hpp" #include "transformations/op_conversions/convert_mod.hpp" diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp similarity index 96% rename from src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp rename to src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 1e3d6586387d51..31cb63b0a2bd24 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avg_pool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" +#include "transformations/op_conversions/convert_avgpool_downgrade.hpp" #include "itt.hpp" #include "openvino/core/rt_info.hpp" diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp deleted file mode 100644 index 216e3ea4cc1105..00000000000000 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool8_downgrade.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "itt.hpp" -#include "openvino/core/descriptor/tensor.hpp" -#include "openvino/core/rt_info.hpp" -#include "openvino/op/max_pool.hpp" -#include "openvino/pass/pattern/op/wrap_type.hpp" -#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" -#include "transformations/utils/utils.hpp" - -using namespace std; -using namespace ov; - -pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { - MATCHER_SCOPE(ConvertMaxPool8ToMaxPool1); - - auto maxpool_v8_pattern = pattern::wrap_type(); - - matcher_pass_callback callback = [=](pattern::Matcher& m) { - auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); - - if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) - return false; - - for (auto dilation : maxpool_v8_node->get_dilations()) - if (dilation != 1) - return false; - - auto maxpool_v1_node = make_shared(maxpool_v8_node->input_value(0), - maxpool_v8_node->get_strides(), - maxpool_v8_node->get_pads_begin(), - maxpool_v8_node->get_pads_end(), - maxpool_v8_node->get_kernel(), - maxpool_v8_node->get_rounding_type(), - maxpool_v8_node->get_auto_pad()); - - OPENVINO_SUPPRESS_DEPRECATED_START - auto out_name = ov::op::util::create_ie_output_name(maxpool_v8_node->output(0)); - OPENVINO_SUPPRESS_DEPRECATED_END - - maxpool_v1_node->set_friendly_name(maxpool_v8_node->get_friendly_name()); - maxpool_v8_node->output(0).replace(maxpool_v1_node->output(0)); - ov::copy_runtime_info(maxpool_v8_node, maxpool_v1_node); - maxpool_v8_node->clear_control_dependencies(); - - OPENVINO_SUPPRESS_DEPRECATED_START - ov::descriptor::set_ov_tensor_legacy_name(maxpool_v1_node->output(0).get_tensor(), out_name); - OPENVINO_SUPPRESS_DEPRECATED_END - - return true; - }; - - auto m = make_shared(maxpool_v8_pattern, matcher_name); - register_matcher(m, callback); -} diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp similarity index 50% rename from src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp rename to src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 07afd2d90d5d86..4d72a296490903 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool14_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -2,13 +2,58 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" + #include "itt.hpp" +#include "openvino/core/descriptor/tensor.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/max_pool.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" -#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" #include "transformations/utils/utils.hpp" +ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { + MATCHER_SCOPE(ConvertMaxPool8ToMaxPool1); + + auto maxpool_v8_pattern = pattern::wrap_type(); + + matcher_pass_callback callback = [=](pattern::Matcher& m) { + auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); + + if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) + return false; + + for (auto dilation : maxpool_v8_node->get_dilations()) + if (dilation != 1) + return false; + + auto maxpool_v1_node = std::make_shared(maxpool_v8_node->input_value(0), + maxpool_v8_node->get_strides(), + maxpool_v8_node->get_pads_begin(), + maxpool_v8_node->get_pads_end(), + maxpool_v8_node->get_kernel(), + maxpool_v8_node->get_rounding_type(), + maxpool_v8_node->get_auto_pad()); + + OPENVINO_SUPPRESS_DEPRECATED_START + auto out_name = ov::op::util::create_ie_output_name(maxpool_v8_node->output(0)); + OPENVINO_SUPPRESS_DEPRECATED_END + + maxpool_v1_node->set_friendly_name(maxpool_v8_node->get_friendly_name()); + maxpool_v8_node->output(0).replace(maxpool_v1_node->output(0)); + ov::copy_runtime_info(maxpool_v8_node, maxpool_v1_node); + maxpool_v8_node->clear_control_dependencies(); + + OPENVINO_SUPPRESS_DEPRECATED_START + ov::descriptor::set_ov_tensor_legacy_name(maxpool_v1_node->output(0).get_tensor(), out_name); + OPENVINO_SUPPRESS_DEPRECATED_END + + return true; + }; + + auto m = std::make_shared(maxpool_v8_pattern, matcher_name); + register_matcher(m, callback); +} + ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { MATCHER_SCOPE(ConvertMaxPool14ToMaxPool8); diff --git a/src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp similarity index 98% rename from src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp rename to src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp index 5591ea6fd1d319..e54c9afbd84233 100644 --- a/src/common/transformations/tests/op_conversions/convert_avg_pool_downgrade.cpp +++ b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" +#include "transformations/op_conversions/convert_avgpool_downgrade.hpp" #include diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp deleted file mode 100644 index f76a84f2c11c35..00000000000000 --- a/src/common/transformations/tests/op_conversions/convert_maxpool8_downgrade_test.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include -#include - -#include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/model.hpp" -#include "openvino/opsets/opset1.hpp" -#include "openvino/opsets/opset8.hpp" -#include "openvino/pass/manager.hpp" -#include "transformations/init_node_info.hpp" -#include "transformations/op_conversions/convert_maxpool8_to_maxpool1_downgrade.hpp" -using namespace ov; -using namespace testing; - -TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { - { - auto data = std::make_shared(element::f32, Shape{1, 2, 3}); - Strides strides{1}, dilations{1}; - Shape pads_begin{0}, pads_end{0}, kernel{1}; - auto maxpool_8 = std::make_shared(data, strides, dilations, pads_begin, pads_end, kernel); - auto result = std::make_shared(maxpool_8->output(0)); - - model = std::make_shared(NodeVector{result}, ParameterVector{data}); - manager.register_pass(); - } - - { - auto data = std::make_shared(element::f32, Shape{1, 2, 3}); - Strides strides{1}; - Shape pads_begin{0}, pads_end{0}, kernel{1}; - auto maxpool_1 = std::make_shared(data, strides, pads_begin, pads_end, kernel); - auto result = std::make_shared(maxpool_1->output(0)); - - model_ref = std::make_shared(NodeVector{result}, ParameterVector{data}); - } -} diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp similarity index 70% rename from src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp rename to src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp index aad3a52754ec50..4fef1174866ed5 100644 --- a/src/common/transformations/tests/op_conversions/convert_maxpool14_downgrade_test.cpp +++ b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp @@ -2,14 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" + #include #include "common_test_utils/ov_test_utils.hpp" #include "openvino/op/max_pool.hpp" +#include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset14.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/pass/manager.hpp" -#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" namespace { @@ -41,6 +43,29 @@ std::shared_ptr create_v8_model(const ov::op::RoundingType rounding_t } // namespace +TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { + { + auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); + ov::Strides strides{1}, dilations{1}; + ov::Shape pads_begin{0}, pads_end{0}, kernel{1}; + auto maxpool_8 = std::make_shared(data, strides, dilations, pads_begin, pads_end, kernel); + auto result = std::make_shared(maxpool_8->output(0)); + + model = std::make_shared(ov::NodeVector{result}, ov::ParameterVector{data}); + manager.register_pass(); + } + + { + auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); + ov::Strides strides{1}; + ov::Shape pads_begin{0}, pads_end{0}, kernel{1}; + auto maxpool_1 = std::make_shared(data, strides, pads_begin, pads_end, kernel); + auto result = std::make_shared(maxpool_1->output(0)); + + model_ref = std::make_shared(ov::NodeVector{result}, ov::ParameterVector{data}); + } +} + TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_torch_to_ceil) { manager.register_pass(); model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp index 958778ffe58b47..e7f1556dc12c0b 100644 --- a/src/plugins/template/src/plugin.cpp +++ b/src/plugins/template/src/plugin.cpp @@ -16,8 +16,8 @@ #include "transformations/control_flow/unroll_if.hpp" #include "transformations/fp16_compression/convert_compression_only_to_legacy.hpp" #include "transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp" -#include "transformations/op_conversions/convert_avg_pool_downgrade.hpp" -#include "transformations/op_conversions/convert_maxpool14_to_maxpool8_downgrade.hpp" +#include "transformations/op_conversions/convert_avgpool_downgrade.hpp" +#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" #include "transformations/op_conversions/convert_reduce_to_pooling.hpp" namespace { From 4d691bd07dba3cbf21065ff05470d023ac113b33 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 19 Mar 2024 15:09:51 +0100 Subject: [PATCH 05/61] WIP --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 55 +++++- src/plugins/intel_cpu/src/nodes/pooling.h | 3 + .../src/shape_inference/shape_inference.cpp | 2 + .../single_layer_tests/classes/pooling.cpp | 75 +++---- .../single_layer_tests/classes/pooling.hpp | 19 +- .../instances/common/pooling.cpp | 8 +- .../instances/x64/pooling.cpp | 8 +- .../avg_pool_shape_inference_test.cpp | 183 +++++++++++++----- .../max_pool_shape_inference_test.cpp | 118 ++++++++--- 9 files changed, 331 insertions(+), 140 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index f7c7df94e62d71..21e8fe96f6bcb9 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -142,7 +142,12 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& return desc; } -} // namespace +} // namespace + +//template +//static bool Pooling::isCeilTorchSupported(const TOp& op) { +// return op.get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; +//} bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { @@ -154,6 +159,11 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st } else if (!ov::is_type(op) && !ov::is_type(op)) { errorMessage = "MaxPool and AvgPool from opset1 and MaxPool from opset8 are supported"; return false; + //} else if (!ov::is_type(op) && !ov::is_type(op)) { + // if (!Pooling::isCeilTorchSupported(op)) { + // errorMessage = "CEIL_TORCH rounding type is not supported in opsets lower than opset14"; + // return false; + // } } } catch (...) { return false; @@ -174,7 +184,20 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c } }; - if (auto maxPoolOp_v8 = ov::as_type_ptr(op)) { + if (auto maxPoolOp_v14 = ov::as_type_ptr(op)) { + algorithm = Algorithm::PoolingMax; + poolingAttrs.exclude_pad = false; + poolingAttrs.rounding = maxPoolOp_v14->get_rounding_type(); + poolingAttrs.pad_type = maxPoolOp_v14->get_auto_pad(); + + get_attributes(poolingAttrs.dilation, maxPoolOp_v14->get_dilations()); + get_attributes(poolingAttrs.stride, maxPoolOp_v14->get_strides()); + get_attributes(poolingAttrs.kernel, maxPoolOp_v14->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, maxPoolOp_v14->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, maxPoolOp_v14->get_pads_end()); + + poolingAttrs.auto_pad = (maxPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || maxPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); + } else if (auto maxPoolOp_v8 = ov::as_type_ptr(op)) { isMaxPool8 = true; algorithm = Algorithm::PoolingMax; poolingAttrs.exclude_pad = false; @@ -201,18 +224,30 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); poolingAttrs.auto_pad = (maxPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || maxPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); - } else if (auto avgPoolOp = ov::as_type_ptr(op)) { + } else if (auto avgPoolOp_v1 = ov::as_type_ptr(op)) { + algorithm = Algorithm::PoolingAvg; + poolingAttrs.exclude_pad = avgPoolOp_v1->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOp_v1->get_rounding_type(); + + get_attributes(poolingAttrs.stride, avgPoolOp_v1->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOp_v1->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v1->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v1->get_pads_end()); + poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); + + poolingAttrs.auto_pad = (avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); + } else if (auto avgPoolOp_v14 = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp->get_rounding_type(); + poolingAttrs.exclude_pad = avgPoolOp_v14->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOp_v14->get_rounding_type(); - get_attributes(poolingAttrs.stride, avgPoolOp->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp->get_pads_end()); + get_attributes(poolingAttrs.stride, avgPoolOp_v14->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOp_v14->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v14->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v14->get_pads_end()); poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - poolingAttrs.auto_pad = (avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_UPPER); + poolingAttrs.auto_pad = (avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); } poolingAttrs.algorithm = algorithm; diff --git a/src/plugins/intel_cpu/src/nodes/pooling.h b/src/plugins/intel_cpu/src/nodes/pooling.h index e526f144a5cbb1..f3af805dc3c497 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.h +++ b/src/plugins/intel_cpu/src/nodes/pooling.h @@ -34,6 +34,9 @@ class Pooling : public Node { static bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept; + template + static bool isCeilTorchSupported(const TOp&); + protected: AttrPtr initPrimitiveAttr() override; diff --git a/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp b/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp index 8f05876ce219b7..4802ea2f896212 100644 --- a/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp +++ b/src/plugins/intel_cpu/src/shape_inference/shape_inference.cpp @@ -400,6 +400,8 @@ template <> const IStaticShapeInferFactory::TRegistry IStaticShapeInferFactory::registry{ // opset14 _OV_OP_SHAPE_INFER_MASK_REG(opset14::Inverse, ShapeInferTA, util::bit::mask()), + _OV_OP_SHAPE_INFER_MASK_REG(opset14::MaxPool, ShapeInferPaddingTA, util::bit::mask()), + _OV_OP_SHAPE_INFER_MASK_REG(opset14::AvgPool, ShapeInferPaddingTA, util::bit::mask()), // opset13 _OV_OP_SHAPE_INFER_MASK_REG(opset13::Multinomial, ShapeInferTA, util::bit::mask(1)), _OV_OP_SHAPE_INFER_MASK_REG(opset13::ScaledDotProductAttention, ShapeInferTA, util::bit::mask(3, 5)), diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 83e442f170039a..7587d64bf91cb4 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,7 +11,45 @@ using namespace CPUTestUtils; namespace ov { namespace test { +namespace util { +static std::string getTestCaseNameUtil( + const testing::TestParamInfo& obj) { + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); +} +} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -113,41 +151,8 @@ void PoolingLayerCPUTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "MaxPool_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "D" << ov::test::utils::vec2str(dilation) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - - results << CPUTestsBase::getTestCaseName(cpuParams); - return results.str(); + const testing::TestParamInfo& obj) { + return util::getTestCaseNameUtil(obj); } void MaxPoolingV8LayerCPUTest::SetUp() { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 6f9303e7fa9100..a2aeb05c3b5a09 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -21,7 +21,7 @@ using poolLayerCpuTestParamsSet = std::tuple; -using maxPoolV8LayerCpuTestParamsSet = std::tuple; @@ -35,10 +35,19 @@ class PoolingLayerCPUTest : public testing::WithParamInterface, +class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + +class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CPUTestsBase { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); protected: void SetUp() override; @@ -52,8 +61,8 @@ const std::vector& paramsMax3D(); const std::vector& paramsAvg3D(); const std::vector& paramsMax4D(); -const std::vector& paramsMaxV84D(); -const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV84D(); +const std::vector& paramsMaxV85D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index cab1f0ff4dcd2b..27c25ba9716a3e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -109,14 +109,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsMaxV85D_ref = { - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, +const std::vector paramsMaxV85D_ref = { + maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, + maxPoolSpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index e11a9c0c572d34..34a98a4b5aec2e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -21,14 +21,14 @@ const auto sse42 = CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; const std::vector vecCpuConfigs = {sse42, avx, avx512}; -const std::vector paramsMaxV84D_ref = { - maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, +const std::vector paramsMaxV84D_ref = { + maxPoolSpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, + maxPoolSpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, + maxPoolSpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp index 6b145faf3b93a6..eca8ede3b3d9a0 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp @@ -12,34 +12,37 @@ using namespace ov; using namespace ov::intel_cpu; using namespace testing; -class AvgPoolV1StaticShapeInferenceTest : public OpStaticShapeInferenceTest { +template +class AvgPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest { protected: void SetUp() override { - output_shapes.resize(1); + this->output_shapes.resize(1); } }; -TEST_F(AvgPoolV1StaticShapeInferenceTest, default_ctor) { - op = make_op(); - op->set_strides({1, 1}); - op->set_pads_begin({2, 2}); - op->set_pads_end({2, 1}); - op->set_kernel({3, 2}); - op->set_rounding_type(op::RoundingType::FLOOR); - op->set_auto_pad(op::PadType::VALID); - - input_shapes = ShapeVector{{1, 3, 10, 12}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - - EXPECT_EQ(output_shapes.size(), 1); - EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 8, 11})); +TYPED_TEST_SUITE_P(AvgPoolCommonStaticShapeInferenceTest); + +TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, default_ctor) { + this->op = this->make_op(); + this->op->set_strides({1, 1}); + this->op->set_pads_begin({2, 2}); + this->op->set_pads_end({2, 1}); + this->op->set_kernel({3, 2}); + this->op->set_rounding_type(op::RoundingType::FLOOR); + this->op->set_auto_pad(op::PadType::VALID); + + this->input_shapes = ShapeVector{{1, 3, 10, 12}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 8, 11})); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({0, 0})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({0, 0})); } -TEST_F(AvgPoolV1StaticShapeInferenceTest, no_auto_pad_round_floor) { +TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, no_auto_pad_round_floor) { const auto data = std::make_shared(element::f64, PartialShape{-1, -1, -1, -1}); const Strides strides{1, 1}; @@ -49,20 +52,20 @@ TEST_F(AvgPoolV1StaticShapeInferenceTest, no_auto_pad_round_floor) { const auto rounding_mode = op::RoundingType::FLOOR; const auto pad_type = op::PadType::EXPLICIT; - op = make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); - input_shapes = ShapeVector{{1, 3, 10, 12}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{1, 3, 10, 12}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 1); - EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 12, 14})); + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 12, 14})); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({2, 2})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({2, 1})); } -TEST_F(AvgPoolV1StaticShapeInferenceTest, auto_padding_same_lower_round_ceil) { +TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_lower_round_ceil) { const auto data = std::make_shared(element::f64, PartialShape::dynamic()); const Strides strides{1, 3, 2}; @@ -72,20 +75,20 @@ TEST_F(AvgPoolV1StaticShapeInferenceTest, auto_padding_same_lower_round_ceil) { const auto rounding_mode = op::RoundingType::CEIL; const auto pad_type = op::PadType::SAME_LOWER; - op = make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); - input_shapes = ShapeVector{{1, 3, 10, 12, 20}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{1, 3, 10, 12, 20}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 1); - EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 10, 4, 10})); + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 10, 4, 10})); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({2, 1, 2})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({2, 1, 1})); } -TEST_F(AvgPoolV1StaticShapeInferenceTest, auto_padding_same_upper_round_floor_exclude_pad) { +TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_upper_round_floor_exclude_pad) { const auto data = std::make_shared(element::f64, PartialShape::dynamic()); const Strides strides{1, 3, 2}; @@ -95,20 +98,20 @@ TEST_F(AvgPoolV1StaticShapeInferenceTest, auto_padding_same_upper_round_floor_ex const auto rounding_mode = op::RoundingType::FLOOR; const auto pad_type = op::PadType::SAME_UPPER; - op = make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type); + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type); - input_shapes = ShapeVector{{1, 3, 10, 12, 20}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{1, 3, 10, 12, 20}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 1); - EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 10, 4, 10})); + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 10, 4, 10})); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({2, 1, 1})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({2, 1, 2})); } -TEST_F(AvgPoolV1StaticShapeInferenceTest, 5d_auto_padding_same_upper_round_floor) { +TYPED_TEST_P(AvgPoolCommonStaticShapeInferenceTest, auto_padding_same_upper_round_floor) { const auto data = std::make_shared(element::f64, PartialShape::dynamic()); const Strides strides{1, 1, 1}; @@ -118,15 +121,95 @@ TEST_F(AvgPoolV1StaticShapeInferenceTest, 5d_auto_padding_same_upper_round_floor const auto rounding_mode = op::RoundingType::FLOOR; const auto pad_type = op::PadType::SAME_UPPER; - op = make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type); + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type); - input_shapes = ShapeVector{{32, 32, 2, 2, 4}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{32, 32, 2, 2, 4}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 1); - EXPECT_EQ(output_shapes.front(), StaticShape({32, 32, 2, 2, 4})); + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({32, 32, 2, 2, 4})); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({0, 0, 0})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({1, 1, 1})); } + +REGISTER_TYPED_TEST_SUITE_P(AvgPoolCommonStaticShapeInferenceTest, + default_ctor, + no_auto_pad_round_floor, + auto_padding_same_lower_round_ceil, + auto_padding_same_upper_round_floor_exclude_pad, + auto_padding_same_upper_round_floor); + +using AvgPoolOpTypes = Types; +INSTANTIATE_TYPED_TEST_SUITE_P(StaticShapeInferenceTest, AvgPoolCommonStaticShapeInferenceTest, AvgPoolOpTypes); + +class AvgPoolV14StaticShapeInferenceTest : public OpStaticShapeInferenceTest { +protected: + void SetUp() override { + output_shapes.resize(1); + } +}; + +TEST_F(AvgPoolV14StaticShapeInferenceTest, explicit_padding_ceil_torch) { + const auto data = std::make_shared(element::f64, PartialShape::dynamic()); + + const Strides strides{2, 2}; + const ov::Shape pads_begin{1, 1}; + const ov::Shape pads_end{1, 1}; + const ov::Shape kernel_shape{2, 2}; + const auto rounding_mode = op::RoundingType::CEIL_TORCH; + const auto pad_type = op::PadType::EXPLICIT; + + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, true, rounding_mode, pad_type); + + this->input_shapes = ShapeVector{{1, 3, 9, 9}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 5, 5})); +} + +TEST_F(AvgPoolV14StaticShapeInferenceTest, explicit_padding_ceil_torch_no_strides) { + const auto data = std::make_shared(element::f64, PartialShape::dynamic()); + + const Strides strides{1, 1}; + const ov::Shape pads_begin{1, 1}; + const ov::Shape pads_end{1, 1}; + const ov::Shape kernel_shape{2, 2}; + const auto rounding_mode = op::RoundingType::CEIL_TORCH; + const auto pad_type = op::PadType::EXPLICIT; + + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); + + this->input_shapes = ShapeVector{{1, 3, 9, 9}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 10, 10})); +} + +TEST_F(AvgPoolV14StaticShapeInferenceTest, auto_padding_ceil_torch) { + const auto data = std::make_shared(element::f64, PartialShape::dynamic()); + + const Strides strides{1, 1}; + const ov::Shape pads_begin{1, 1}; + const ov::Shape pads_end{1, 1}; + const ov::Shape kernel_shape{2, 2}; + const auto rounding_mode = op::RoundingType::CEIL_TORCH; + const auto pad_type = op::PadType::SAME_LOWER; + + this->op = this->make_op(data, strides, pads_begin, pads_end, kernel_shape, false, rounding_mode, pad_type); + + this->input_shapes = ShapeVector{{1, 3, 9, 9}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_EQ(this->output_shapes.size(), 1); + EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 3, 9, 9})); +} diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp index e1395b529e7558..b927be1858e571 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp @@ -85,35 +85,81 @@ TEST_F(MaxPoolV1StaticShapeInferenceTest, auto_padding_same_lower_round_ceil) { EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({2, 1, 1})); } -class MaxPoolV8StaticShapeInferenceTest : public OpStaticShapeInferenceTest { +class MaxPoolV14StaticShapeInferenceTest : public OpStaticShapeInferenceTest { protected: void SetUp() override { output_shapes.resize(2); } }; -TEST_F(MaxPoolV8StaticShapeInferenceTest, default_ctor) { - op = make_op(); - op->set_strides({1, 1}); - op->set_pads_begin({2, 2}); - op->set_pads_end({2, 1}); - op->set_kernel({3, 2}); - op->set_dilations({2, 1}); - op->set_rounding_type(op::RoundingType::FLOOR); - op->set_auto_pad(op::PadType::VALID); +TEST_F(MaxPoolV14StaticShapeInferenceTest, ceil_torch_mode_1) { + const auto data = std::make_shared(element::f64, PartialShape::dynamic()); + const Strides strides{2, 2}; + const Strides dilations{1, 1}; + const Shape pads_begin{1, 1}; + const Shape pads_end{1, 1}; + const Shape kernel_shape{2, 2}; + const auto rounding_mode = op::RoundingType::CEIL_TORCH; + + op = make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape, rounding_mode); + this->input_shapes = ShapeVector{{1, 3, 5, 5}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_THAT(this->output_shapes, Each(StaticShape({1, 3, 3, 3}))); +} - input_shapes = ShapeVector{{1, 3, 10, 12}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); +TEST_F(MaxPoolV14StaticShapeInferenceTest, ceil_torch_mode_2) { + const auto data = std::make_shared(element::f64, PartialShape::dynamic()); + const Strides strides{2, 2}; + const Strides dilations{1, 1}; + const Shape pads_begin{1, 1}; + const Shape pads_end{1, 1}; + const Shape kernel_shape{2, 2}; + const auto rounding_mode = op::RoundingType::CEIL_TORCH; + + op = make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape, rounding_mode); + this->input_shapes = ShapeVector{{1, 3, 9, 9}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_THAT(this->output_shapes, Each(StaticShape({1, 3, 5, 5}))); +} + +template +class MaxPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest { +protected: + void SetUp() override { + this->output_shapes.resize(2); + } +}; - EXPECT_EQ(output_shapes.size(), 2); - EXPECT_THAT(output_shapes, Each(StaticShape({1, 3, 6, 11}))); +TYPED_TEST_SUITE_P(MaxPoolCommonStaticShapeInferenceTest); + +TYPED_TEST_P(MaxPoolCommonStaticShapeInferenceTest, default_ctor) { + this->op = this->make_op(); + this->op->set_strides({1, 1}); + this->op->set_pads_begin({2, 2}); + this->op->set_pads_end({2, 1}); + this->op->set_kernel({3, 2}); + this->op->set_dilations({2, 1}); + this->op->set_rounding_type(op::RoundingType::FLOOR); + this->op->set_auto_pad(op::PadType::VALID); + + this->input_shapes = ShapeVector{{1, 3, 10, 12}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + + EXPECT_EQ(this->output_shapes.size(), 2); + EXPECT_THAT(this->output_shapes, Each(StaticShape({1, 3, 6, 11}))); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({0, 0})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({0, 0})); } -TEST_F(MaxPoolV8StaticShapeInferenceTest, no_dilation) { +TYPED_TEST_P(MaxPoolCommonStaticShapeInferenceTest, no_dilation) { const auto data = std::make_shared(element::f64, PartialShape{-1, -1, -1, -1}); const Strides strides{1, 1}; @@ -122,20 +168,20 @@ TEST_F(MaxPoolV8StaticShapeInferenceTest, no_dilation) { const ov::Shape pads_end{0, 0}; const ov::Shape kernel_shape{2, 2}; - op = make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape); + this->op = this->make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape); - input_shapes = ShapeVector{{2, 3, 13, 13}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{2, 3, 13, 13}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 2); - EXPECT_THAT(output_shapes, Each(StaticShape({2, 3, 13, 13}))); + EXPECT_EQ(this->output_shapes.size(), 2); + EXPECT_THAT(this->output_shapes, Each(StaticShape({2, 3, 13, 13}))); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({1, 1})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({0, 0})); } -TEST_F(MaxPoolV8StaticShapeInferenceTest, with_dilations) { +TYPED_TEST_P(MaxPoolCommonStaticShapeInferenceTest, with_dilations) { const auto data = std::make_shared(element::f64, PartialShape::dynamic()); const Strides strides{1, 1}; @@ -144,15 +190,23 @@ TEST_F(MaxPoolV8StaticShapeInferenceTest, with_dilations) { const ov::Shape pads_end{1, 1}; const ov::Shape kernel_shape{2, 2}; - op = make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape); + this->op = this->make_op(data, strides, dilations, pads_begin, pads_end, kernel_shape); - input_shapes = ShapeVector{{2, 4, 13, 13}}; - auto shape_infer = make_shape_inference(op); - const auto input_shape_refs = make_static_shape_refs(input_shapes); - output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); + this->input_shapes = ShapeVector{{2, 4, 13, 13}}; + auto shape_infer = make_shape_inference(this->op); + const auto input_shape_refs = make_static_shape_refs(this->input_shapes); + this->output_shapes = *shape_infer->infer(input_shape_refs, make_tensor_accessor()); - EXPECT_EQ(output_shapes.size(), 2); - EXPECT_THAT(output_shapes, Each(StaticShape({2, 4, 12, 11}))); + EXPECT_EQ(this->output_shapes.size(), 2); + EXPECT_THAT(this->output_shapes, Each(StaticShape({2, 4, 12, 11}))); EXPECT_EQ(shape_infer->get_pads_begin(), CoordinateDiff({0, 0})); EXPECT_EQ(shape_infer->get_pads_end(), CoordinateDiff({1, 1})); } + +REGISTER_TYPED_TEST_SUITE_P(MaxPoolCommonStaticShapeInferenceTest, + default_ctor, + no_dilation, + with_dilations); + +using MaxPoolOpTypes = Types; +INSTANTIATE_TYPED_TEST_SUITE_P(StaticShapeInferenceTest, MaxPoolCommonStaticShapeInferenceTest, MaxPoolOpTypes); From bccebe734a37203f040dddca23981021ddc0782c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 19 Mar 2024 16:24:22 +0100 Subject: [PATCH 06/61] WIP --- .../single_layer_tests/classes/pooling.cpp | 75 +++++++++---------- .../single_layer_tests/classes/pooling.hpp | 14 ++-- .../instances/common/pooling.cpp | 8 +- .../instances/x64/pooling.cpp | 8 +- 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 7587d64bf91cb4..83e442f170039a 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,45 +11,7 @@ using namespace CPUTestUtils; namespace ov { namespace test { -namespace util { -static std::string getTestCaseNameUtil( - const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "MaxPool_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "D" << ov::test::utils::vec2str(dilation) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - - results << CPUTestsBase::getTestCaseName(cpuParams); - return results.str(); -} -} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -151,8 +113,41 @@ void PoolingLayerCPUTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - return util::getTestCaseNameUtil(obj); + const testing::TestParamInfo& obj) { + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); } void MaxPoolingV8LayerCPUTest::SetUp() { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index a2aeb05c3b5a09..603352db56a5f3 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -21,7 +21,7 @@ using poolLayerCpuTestParamsSet = std::tuple; -using maxPoolLayerCpuTestParamsSet = std::tuple; @@ -35,19 +35,19 @@ class PoolingLayerCPUTest : public testing::WithParamInterface, +class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); + static std::string getTestCaseName(const testing::TestParamInfo& obj); protected: void SetUp() override; }; -class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, +class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); + static std::string getTestCaseName(const testing::TestParamInfo& obj); protected: void SetUp() override; @@ -61,8 +61,8 @@ const std::vector& paramsMax3D(); const std::vector& paramsAvg3D(); const std::vector& paramsMax4D(); -const std::vector& paramsMaxV84D(); -const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV84D(); +const std::vector& paramsMaxV85D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 27c25ba9716a3e..cab1f0ff4dcd2b 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -109,14 +109,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsMaxV85D_ref = { - maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, +const std::vector paramsMaxV85D_ref = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolSpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, + maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 34a98a4b5aec2e..e11a9c0c572d34 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -21,14 +21,14 @@ const auto sse42 = CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; const std::vector vecCpuConfigs = {sse42, avx, avx512}; -const std::vector paramsMaxV84D_ref = { - maxPoolSpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, +const std::vector paramsMaxV84D_ref = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolSpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, + maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolSpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, + maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; From 5a93d14215ed5cc48723e6bddc2510ae51adea5f Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Wed, 20 Mar 2024 15:43:23 +0100 Subject: [PATCH 07/61] Update and refactor tests --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 9 - .../single_layer_tests/classes/pooling.cpp | 187 ++++++++++-------- .../single_layer_tests/classes/pooling.hpp | 31 +-- .../instances/common/pooling.cpp | 24 ++- .../instances/x64/pooling.cpp | 8 +- .../shared_test_classes/single_op/pooling.hpp | 4 +- .../src/single_op/pooling.cpp | 4 +- 7 files changed, 156 insertions(+), 111 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 21e8fe96f6bcb9..3a899e235eabfe 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -144,10 +144,6 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& } // namespace -//template -//static bool Pooling::isCeilTorchSupported(const TOp& op) { -// return op.get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; -//} bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { @@ -159,11 +155,6 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st } else if (!ov::is_type(op) && !ov::is_type(op)) { errorMessage = "MaxPool and AvgPool from opset1 and MaxPool from opset8 are supported"; return false; - //} else if (!ov::is_type(op) && !ov::is_type(op)) { - // if (!Pooling::isCeilTorchSupported(op)) { - // errorMessage = "CEIL_TORCH rounding type is not supported in opsets lower than opset14"; - // return false; - // } } } catch (...) { return false; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 83e442f170039a..1480bb7328264a 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,7 +11,93 @@ using namespace CPUTestUtils; namespace ov { namespace test { +namespace util { +static std::string getTestCaseNameUtil(const testing::TestParamInfo& obj) { + maxPoolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); +} + +template +void SetUpUtil(TTest* testInstance, + std::vector>& inFmts, + std::vector>& outFmts, + std::vector>& priority, + std::string& selectedType, + std::shared_ptr& function, + std::vector& inputDynamicShapes) { + maxPoolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = testInstance->GetParam(); + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + if (selectedType.empty()) { + auto selectedType = testInstance->getPrimitiveTypeUtil(); + } + selectedType = testInstance->makeSelectedTypeStr(selectedType, inPrc); + + testInstance->init_input_shapes_util({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + auto pooling = std::make_shared(params[0], + stride, + dilation, + padBegin, + padEnd, + kernel, + roundingType, + padType, + indexElementType, + axis); + pooling->get_rt_info() = testInstance->getCPUInfo(); + ov::ResultVector results{std::make_shared(pooling->output(0))}; + function = std::make_shared(results, params, "MaxPooling"); +} +} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -113,85 +199,23 @@ void PoolingLayerCPUTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "MaxPool_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "D" << ov::test::utils::vec2str(dilation) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - - results << CPUTestsBase::getTestCaseName(cpuParams); - return results.str(); + const testing::TestParamInfo& obj) { + return util::getTestCaseNameUtil(obj); } void MaxPoolingV8LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; + util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); +} - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - if (selectedType.empty()) { - selectedType = getPrimitiveType(); - } - selectedType = makeSelectedTypeStr(selectedType, inPrc); - - init_input_shapes({inputShapes}); +std::string MaxPoolingV14LayerCPUTest::getTestCaseName( + const testing::TestParamInfo& obj) { + return util::getTestCaseNameUtil(obj); +} - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - auto pooling = std::make_shared(params[0], - stride, - dilation, - padBegin, - padEnd, - kernel, - roundingType, - padType, - indexElementType, - axis); - pooling->get_rt_info() = getCPUInfo(); - ov::ResultVector results{std::make_shared(pooling->output(0))}; - function = std::make_shared(results, params, "MaxPooling"); +void MaxPoolingV14LayerCPUTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); } TEST_P(PoolingLayerCPUTest, CompareWithRefs) { @@ -204,6 +228,11 @@ TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Pooling"); +} + namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool @@ -258,9 +287,9 @@ const std::vector& paramsMax4D() { return paramsMax4D; } -const std::vector& paramsMaxV84D() { - static const std::vector paramsMaxV84D = { - maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, +const std::vector& paramsMaxV84D() { + static const std::vector paramsMaxV84D = { + maxPoolSpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, }; @@ -370,9 +399,9 @@ const std::vector& inputShapes5D() { return inputShapes5D; } -const std::vector& paramsMaxV85D() { - static const std::vector paramsMaxV85D = { - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, +const std::vector& paramsMaxV85D() { + static const std::vector paramsMaxV85D = { + maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 603352db56a5f3..77eb5cc843bb2c 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -13,7 +13,6 @@ using namespace CPUTestUtils; namespace ov { namespace test { - using poolLayerCpuTestParamsSet = std::tuple; -using maxPoolV8LayerCpuTestParamsSet = std::tuple; @@ -35,20 +34,30 @@ class PoolingLayerCPUTest : public testing::WithParamInterface, +class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - + static std::string getTestCaseName(const testing::TestParamInfo& obj); + std::string getPrimitiveTypeUtil() const { + return CPUTestsBase::getPrimitiveType(); + }; + void init_input_shapes_util(const std::vector &shapes) { + SubgraphBaseTest::init_input_shapes(shapes); + }; protected: void SetUp() override; }; -class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { +class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - + static std::string getTestCaseName(const testing::TestParamInfo& obj); + std::string getPrimitiveTypeUtil() const { + return CPUTestsBase::getPrimitiveType(); + }; + void init_input_shapes_util(const std::vector &shapes) { + SubgraphBaseTest::init_input_shapes(shapes); + }; protected: void SetUp() override; }; @@ -61,8 +70,8 @@ const std::vector& paramsMax3D(); const std::vector& paramsAvg3D(); const std::vector& paramsMax4D(); -const std::vector& paramsMaxV84D(); -const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV84D(); +const std::vector& paramsMaxV85D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index cab1f0ff4dcd2b..62fdcf0c2e6e65 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -109,14 +109,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsMaxV85D_ref = { - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, +const std::vector paramsMaxV85D_ref = { + maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, + maxPoolSpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; @@ -154,6 +154,22 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, ::testing::Values(expectedCpuConfig())), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV85D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(vecCpuConfigs)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV85D_ref), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(expectedCpuConfig())), + MaxPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D()), diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index e11a9c0c572d34..34a98a4b5aec2e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -21,14 +21,14 @@ const auto sse42 = CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; const std::vector vecCpuConfigs = {sse42, avx, avx512}; -const std::vector paramsMaxV84D_ref = { - maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, +const std::vector paramsMaxV84D_ref = { + maxPoolSpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, + maxPoolSpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, + maxPoolSpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp index 8cd5bd88c5d032..c564118519bc46 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp @@ -41,10 +41,10 @@ typedef std::tuple< int64_t, // Axis ov::op::RoundingType, // Rounding type ov::op::PadType // Pad type -> maxPoolV8SpecificParams; +> maxPoolSpecificParams; typedef std::tuple< - maxPoolV8SpecificParams, + maxPoolSpecificParams, ov::element::Type, // Model type std::vector, // Input shape std::string // Device name diff --git a/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp index 40dcea4a4b8668..f868c3c3272f87 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp @@ -90,7 +90,7 @@ void PoolingLayerTest::SetUp() { std::string MaxPoolingV8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams pool_params; + maxPoolSpecificParams pool_params; ov::element::Type model_type; std::vector shapes; std::string target_device; @@ -131,7 +131,7 @@ std::string MaxPoolingV8LayerTest::getTestCaseName(const testing::TestParamInfo< } void MaxPoolingV8LayerTest::SetUp() { - maxPoolV8SpecificParams pool_params; + maxPoolSpecificParams pool_params; ov::element::Type model_type; std::vector shapes; std::tie(pool_params, model_type, shapes, targetDevice) = this->GetParam(); From 5be16f6770c5104df110750dd13d789be0c0f50d Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Wed, 20 Mar 2024 15:50:24 +0100 Subject: [PATCH 08/61] Minor updates --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 3 +-- src/plugins/intel_cpu/src/nodes/pooling.h | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 3a899e235eabfe..926e04f32ecd86 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -142,8 +142,7 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& return desc; } -} // namespace - +} // namespace bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { diff --git a/src/plugins/intel_cpu/src/nodes/pooling.h b/src/plugins/intel_cpu/src/nodes/pooling.h index f3af805dc3c497..e526f144a5cbb1 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.h +++ b/src/plugins/intel_cpu/src/nodes/pooling.h @@ -34,9 +34,6 @@ class Pooling : public Node { static bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept; - template - static bool isCeilTorchSupported(const TOp&); - protected: AttrPtr initPrimitiveAttr() override; From 729bb5e6ef043db2a52aa3046be54db6921dbcd9 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 21 Mar 2024 15:38:27 +0100 Subject: [PATCH 09/61] Apply CR --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 41 +++++-------------- .../single_layer_tests/classes/pooling.hpp | 8 ++-- .../avg_pool_shape_inference_test.cpp | 14 +------ .../max_pool_shape_inference_test.cpp | 7 +--- 4 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 926e04f32ecd86..81274f7a6c14c8 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -174,46 +174,25 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c } }; - if (auto maxPoolOp_v14 = ov::as_type_ptr(op)) { + if (auto maxPoolOpBase = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingMax; poolingAttrs.exclude_pad = false; - poolingAttrs.rounding = maxPoolOp_v14->get_rounding_type(); - poolingAttrs.pad_type = maxPoolOp_v14->get_auto_pad(); + poolingAttrs.rounding = maxPoolOpBase->get_rounding_type(); + poolingAttrs.pad_type = maxPoolOpBase->get_auto_pad(); + get_attributes(poolingAttrs.stride, maxPoolOpBase->get_strides()); + get_attributes(poolingAttrs.kernel, maxPoolOpBase->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, maxPoolOpBase->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, maxPoolOpBase->get_pads_end()); + poolingAttrs.auto_pad = (poolingAttrs.pad_type == ov::op::PadType::SAME_LOWER || poolingAttrs.pad_type == ov::op::PadType::SAME_UPPER); + } + if (auto maxPoolOp_v14 = ov::as_type_ptr(op)) { get_attributes(poolingAttrs.dilation, maxPoolOp_v14->get_dilations()); - get_attributes(poolingAttrs.stride, maxPoolOp_v14->get_strides()); - get_attributes(poolingAttrs.kernel, maxPoolOp_v14->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, maxPoolOp_v14->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, maxPoolOp_v14->get_pads_end()); - - poolingAttrs.auto_pad = (maxPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || maxPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); } else if (auto maxPoolOp_v8 = ov::as_type_ptr(op)) { isMaxPool8 = true; - algorithm = Algorithm::PoolingMax; - poolingAttrs.exclude_pad = false; - poolingAttrs.rounding = maxPoolOp_v8->get_rounding_type(); - poolingAttrs.pad_type = maxPoolOp_v8->get_auto_pad(); - get_attributes(poolingAttrs.dilation, maxPoolOp_v8->get_dilations()); - get_attributes(poolingAttrs.stride, maxPoolOp_v8->get_strides()); - get_attributes(poolingAttrs.kernel, maxPoolOp_v8->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, maxPoolOp_v8->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, maxPoolOp_v8->get_pads_end()); - - poolingAttrs.auto_pad = (maxPoolOp_v8->get_auto_pad() == ov::op::PadType::SAME_LOWER || maxPoolOp_v8->get_auto_pad() == ov::op::PadType::SAME_UPPER); } else if (auto maxPoolOp_v1 = ov::as_type_ptr(op)) { - algorithm = Algorithm::PoolingMax; - poolingAttrs.exclude_pad = false; - poolingAttrs.pad_type = maxPoolOp_v1->get_auto_pad(); - poolingAttrs.rounding = maxPoolOp_v1->get_rounding_type(); - - get_attributes(poolingAttrs.stride, maxPoolOp_v1->get_strides()); - get_attributes(poolingAttrs.kernel, maxPoolOp_v1->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, maxPoolOp_v1->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, maxPoolOp_v1->get_pads_end()); poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - - poolingAttrs.auto_pad = (maxPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || maxPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); } else if (auto avgPoolOp_v1 = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingAvg; poolingAttrs.exclude_pad = avgPoolOp_v1->get_exclude_pad(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 77eb5cc843bb2c..5e314519e80add 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -40,10 +40,10 @@ class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface& obj); std::string getPrimitiveTypeUtil() const { return CPUTestsBase::getPrimitiveType(); - }; + } void init_input_shapes_util(const std::vector &shapes) { SubgraphBaseTest::init_input_shapes(shapes); - }; + } protected: void SetUp() override; }; @@ -54,10 +54,10 @@ class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface& obj); std::string getPrimitiveTypeUtil() const { return CPUTestsBase::getPrimitiveType(); - }; + } void init_input_shapes_util(const std::vector &shapes) { SubgraphBaseTest::init_input_shapes(shapes); - }; + } protected: void SetUp() override; }; diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp index eca8ede3b3d9a0..25e65d7bc680c6 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/avg_pool_shape_inference_test.cpp @@ -13,12 +13,7 @@ using namespace ov::intel_cpu; using namespace testing; template -class AvgPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest { -protected: - void SetUp() override { - this->output_shapes.resize(1); - } -}; +class AvgPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest {}; TYPED_TEST_SUITE_P(AvgPoolCommonStaticShapeInferenceTest); @@ -144,12 +139,7 @@ REGISTER_TYPED_TEST_SUITE_P(AvgPoolCommonStaticShapeInferenceTest, using AvgPoolOpTypes = Types; INSTANTIATE_TYPED_TEST_SUITE_P(StaticShapeInferenceTest, AvgPoolCommonStaticShapeInferenceTest, AvgPoolOpTypes); -class AvgPoolV14StaticShapeInferenceTest : public OpStaticShapeInferenceTest { -protected: - void SetUp() override { - output_shapes.resize(1); - } -}; +class AvgPoolV14StaticShapeInferenceTest : public OpStaticShapeInferenceTest {}; TEST_F(AvgPoolV14StaticShapeInferenceTest, explicit_padding_ceil_torch) { const auto data = std::make_shared(element::f64, PartialShape::dynamic()); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp index b927be1858e571..97beda20917414 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/max_pool_shape_inference_test.cpp @@ -129,12 +129,7 @@ TEST_F(MaxPoolV14StaticShapeInferenceTest, ceil_torch_mode_2) { } template -class MaxPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest { -protected: - void SetUp() override { - this->output_shapes.resize(2); - } -}; +class MaxPoolCommonStaticShapeInferenceTest : public OpStaticShapeInferenceTest {}; TYPED_TEST_SUITE_P(MaxPoolCommonStaticShapeInferenceTest); From 69e5577fd453f35deee57c931b7500ac7bc7ac5e Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 22 Mar 2024 15:15:10 +0100 Subject: [PATCH 10/61] Add new asserts --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 10 ++++++---- src/plugins/intel_cpu/src/nodes/pooling.h | 2 +- src/plugins/intel_gpu/thirdparty/onednn_gpu | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 81274f7a6c14c8..957d38b09a97dd 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,9 +146,10 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (ov::is_type(op)) { + // if it's not MaxPoolV1 + if (ov::is_type(op) || ov::is_type(op)) { if (!op->get_output_target_inputs(1).empty()) { - errorMessage = "MaxPool from opset8 is supported only with one output"; + errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; return false; } } else if (!ov::is_type(op) && !ov::is_type(op)) { @@ -187,9 +188,10 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c } if (auto maxPoolOp_v14 = ov::as_type_ptr(op)) { + isNotMaxPool1 = true; get_attributes(poolingAttrs.dilation, maxPoolOp_v14->get_dilations()); } else if (auto maxPoolOp_v8 = ov::as_type_ptr(op)) { - isMaxPool8 = true; + isNotMaxPool1 = true; get_attributes(poolingAttrs.dilation, maxPoolOp_v8->get_dilations()); } else if (auto maxPoolOp_v1 = ov::as_type_ptr(op)) { poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); @@ -647,7 +649,7 @@ void Pooling::initSupportedPrimitiveDescriptors() { } // CPU plugin doesn't support second output of MaxPool-8, but anyway we should have out config for second port as stub - if (isMaxPool8) { + if (isNotMaxPool1) { const auto& creatorsMap = BlockedDescCreator::getCommonCreators(); const auto outputPrecision = outConfs.front().getMemDesc()->getPrecision(); auto desc = creatorsMap.at(LayoutType::ncsp)->createSharedDesc(outputPrecision, getOutputShapeAtPort(1)); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.h b/src/plugins/intel_cpu/src/nodes/pooling.h index e526f144a5cbb1..ffd96fc320036c 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.h +++ b/src/plugins/intel_cpu/src/nodes/pooling.h @@ -57,7 +57,7 @@ class Pooling : public Node { Shape inShape; - bool isMaxPool8 = false; + bool isNotMaxPool1 = false; bool useACL = false; }; diff --git a/src/plugins/intel_gpu/thirdparty/onednn_gpu b/src/plugins/intel_gpu/thirdparty/onednn_gpu index 26c5598cccbc14..494af5f9921bda 160000 --- a/src/plugins/intel_gpu/thirdparty/onednn_gpu +++ b/src/plugins/intel_gpu/thirdparty/onednn_gpu @@ -1 +1 @@ -Subproject commit 26c5598cccbc144ff49255a0b44f00cb9b19e6f3 +Subproject commit 494af5f9921bdae98f1a0e2955fa7d76ff386c4f From 88f9d4c7b566d5488c154a7b3b99ecace323ac76 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 28 Mar 2024 10:23:51 +0100 Subject: [PATCH 11/61] debug, to be reverted --- .../common_optimizations.cpp | 2 +- .../convert_maxpool_downgrade.cpp | 40 +++++++++++++++---- .../include/openvino/reference/max_pool.hpp | 1 + src/plugins/intel_cpu/src/nodes/pooling.cpp | 13 +++++- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index 433c46a2e778a2..4d1b2830553bb3 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -208,9 +208,9 @@ bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr(); - matcher_pass_callback callback = [=](pattern::Matcher& m) { + std::cout << "\n\nLaunching 8->1 downgrade\n\n"; auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); - if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) + if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) { + std::cout << "\n\n1st false\n\n"; return false; + } + for (auto dilation : maxpool_v8_node->get_dilations()) - if (dilation != 1) + { + std::cout << "\nDilations: " << dilation << "\n"; + if (dilation != 1) { + std::cout << "\n\n2nd false\n\n"; return false; + } + + } auto maxpool_v1_node = std::make_shared(maxpool_v8_node->input_value(0), maxpool_v8_node->get_strides(), @@ -47,6 +56,7 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { ov::descriptor::set_ov_tensor_legacy_name(maxpool_v1_node->output(0).get_tensor(), out_name); OPENVINO_SUPPRESS_DEPRECATED_END + std::cout << "\n\nTransformation 8->1 complete\n\n"; return true; }; @@ -60,18 +70,31 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto max_pool_v14_pattern = pattern::wrap_type(); const matcher_pass_callback callback = [](pattern::Matcher& m) { + std::cout << "\n\nLaunching 14->8 downgrade\n\n"; const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); - if (!max_pool_v14) { + + if (!max_pool_v14 || max_pool_v14->get_output_target_inputs(1).size() != 0) { + std::cout << "\n\n1st false\n\n"; return false; } + for (auto dilation : max_pool_v14->get_dilations()) + { + std::cout << "\nDilations: " << dilation << "\n"; + if (dilation != 1) + std::cout << "\n\n2nd false\n\n"; + return false; + } + const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); const auto rounding_type_v8 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; - + std::cout << "\n\nDUPA1\n\n"; + const auto dilations_v8 = max_pool_v14->get_dilations().size() > 1 ? ov::Strides(2, 1) : ov::Strides(1, 1); + std::cout << "\n\nDUPA2\n\n"; const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), max_pool_v14->get_strides(), - max_pool_v14->get_dilations(), + dilations_v8, max_pool_v14->get_pads_begin(), max_pool_v14->get_pads_end(), max_pool_v14->get_kernel(), @@ -79,11 +102,12 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { max_pool_v14->get_auto_pad(), max_pool_v14->get_index_element_type(), max_pool_v14->get_axis()); - + std::cout << "\n\nMaxPool14 op created in transformation\n\n"; max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); copy_runtime_info(max_pool_v14, max_pool_v8); replace_node(max_pool_v14, max_pool_v8); + std::cout << "\n\nTransformation 14->8 complete\n\n"; return true; }; diff --git a/src/core/reference/include/openvino/reference/max_pool.hpp b/src/core/reference/include/openvino/reference/max_pool.hpp index ac94e194073334..3f22dca7eefc2e 100644 --- a/src/core/reference/include/openvino/reference/max_pool.hpp +++ b/src/core/reference/include/openvino/reference/max_pool.hpp @@ -235,6 +235,7 @@ void max_pool(const Values_t* data, const Shape& pads_begin, const Shape& pads_end, const int64_t axis = 0) { + std::cout << "\n\n Using reference implementation\n\n"; const auto data_batch_elems = shape_size(std::begin(data_shape) + 1, std::end(data_shape)); const auto data_channel_elems = shape_size(std::begin(data_shape) + 2, std::end(data_shape)); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 957d38b09a97dd..b1439db41afdd3 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,19 +146,30 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - // if it's not MaxPoolV1 + const bool v1op = ov::is_type(op); + const bool v8op = ov::is_type(op); + const bool v14op = ov::is_type(op); + std::cout << "\n\nThe op is v1 type: " << v1op; + std::cout << "\nThe op is v8 type: " << v8op; + std::cout << "\nThe op is v14 type: " << v14op << "\n\n"; + if (ov::is_type(op) || ov::is_type(op)) { + std::cout << "\n\nIt's v8 or v14\n\n"; if (!op->get_output_target_inputs(1).empty()) { errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; + std::cout << "\n\nOnly one input supported\n\n"; return false; } } else if (!ov::is_type(op) && !ov::is_type(op)) { errorMessage = "MaxPool and AvgPool from opset1 and MaxPool from opset8 are supported"; + std::cout << "\n\nMaxPool and AvgPool from opset1 and MaxPool from opset8 are supported\n\n"; return false; } } catch (...) { + std::cout << "\n\nRandom error\n\n"; return false; } + std::cout << "\n\nOperation is supported\n\n"; return true; } From 54f54cc4bcc4744aa0a7e6777504f0526ae3191b Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 28 Mar 2024 13:42:24 +0100 Subject: [PATCH 12/61] WIP --- .../convert_maxpool_downgrade.cpp | 25 +++---------------- .../include/openvino/reference/max_pool.hpp | 1 - src/plugins/intel_cpu/src/nodes/pooling.cpp | 6 +++-- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index ee8aa2368feae2..b6af5ad8ad1168 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -16,20 +16,16 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { auto maxpool_v8_pattern = pattern::wrap_type(); matcher_pass_callback callback = [=](pattern::Matcher& m) { - std::cout << "\n\nLaunching 8->1 downgrade\n\n"; auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) { - std::cout << "\n\n1st false\n\n"; return false; } for (auto dilation : maxpool_v8_node->get_dilations()) { - std::cout << "\nDilations: " << dilation << "\n"; if (dilation != 1) { - std::cout << "\n\n2nd false\n\n"; return false; } @@ -56,7 +52,6 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { ov::descriptor::set_ov_tensor_legacy_name(maxpool_v1_node->output(0).get_tensor(), out_name); OPENVINO_SUPPRESS_DEPRECATED_END - std::cout << "\n\nTransformation 8->1 complete\n\n"; return true; }; @@ -70,31 +65,18 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto max_pool_v14_pattern = pattern::wrap_type(); const matcher_pass_callback callback = [](pattern::Matcher& m) { - std::cout << "\n\nLaunching 14->8 downgrade\n\n"; const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); if (!max_pool_v14 || max_pool_v14->get_output_target_inputs(1).size() != 0) { - std::cout << "\n\n1st false\n\n"; return false; } - for (auto dilation : max_pool_v14->get_dilations()) - { - std::cout << "\nDilations: " << dilation << "\n"; - if (dilation != 1) - std::cout << "\n\n2nd false\n\n"; - return false; - } - const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); const auto rounding_type_v8 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; - std::cout << "\n\nDUPA1\n\n"; - const auto dilations_v8 = max_pool_v14->get_dilations().size() > 1 ? ov::Strides(2, 1) : ov::Strides(1, 1); - std::cout << "\n\nDUPA2\n\n"; const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), max_pool_v14->get_strides(), - dilations_v8, + max_pool_v14->get_dilations(), max_pool_v14->get_pads_begin(), max_pool_v14->get_pads_end(), max_pool_v14->get_kernel(), @@ -102,12 +84,11 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { max_pool_v14->get_auto_pad(), max_pool_v14->get_index_element_type(), max_pool_v14->get_axis()); - std::cout << "\n\nMaxPool14 op created in transformation\n\n"; max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); + max_pool_v14->output(0).replace(max_pool_v8->output(0)); copy_runtime_info(max_pool_v14, max_pool_v8); - replace_node(max_pool_v14, max_pool_v8); + max_pool_v14->clear_control_dependencies(); - std::cout << "\n\nTransformation 14->8 complete\n\n"; return true; }; diff --git a/src/core/reference/include/openvino/reference/max_pool.hpp b/src/core/reference/include/openvino/reference/max_pool.hpp index 3f22dca7eefc2e..ac94e194073334 100644 --- a/src/core/reference/include/openvino/reference/max_pool.hpp +++ b/src/core/reference/include/openvino/reference/max_pool.hpp @@ -235,7 +235,6 @@ void max_pool(const Values_t* data, const Shape& pads_begin, const Shape& pads_end, const int64_t axis = 0) { - std::cout << "\n\n Using reference implementation\n\n"; const auto data_batch_elems = shape_size(std::begin(data_shape) + 1, std::end(data_shape)); const auto data_channel_elems = shape_size(std::begin(data_shape) + 2, std::end(data_shape)); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index b1439db41afdd3..73f01ca63554bb 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -152,7 +152,9 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st std::cout << "\n\nThe op is v1 type: " << v1op; std::cout << "\nThe op is v8 type: " << v8op; std::cout << "\nThe op is v14 type: " << v14op << "\n\n"; - + if (ov::is_type(op)) { + return false; + } if (ov::is_type(op) || ov::is_type(op)) { std::cout << "\n\nIt's v8 or v14\n\n"; if (!op->get_output_target_inputs(1).empty()) { @@ -169,7 +171,7 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st std::cout << "\n\nRandom error\n\n"; return false; } - std::cout << "\n\nOperation is supported\n\n"; + std::cout << "\n\nCPU implementation used\n\n"; return true; } From 818f71074b89d959009280d5c0b4349a5bdd12da Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 29 Mar 2024 08:30:06 +0100 Subject: [PATCH 13/61] WIP --- .../convert_avgpool_downgrade.hpp | 4 +- .../convert_maxpool_downgrade.cpp | 74 ++++++++++++++----- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp b/src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp index 366c5ef2f7f3bf..1f6e09445443b4 100644 --- a/src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp +++ b/src/common/transformations/include/transformations/op_conversions/convert_avgpool_downgrade.hpp @@ -4,8 +4,8 @@ #pragma once -#include -#include +#include "openvino/pass/graph_rewrite.hpp" +#include "transformations_visibility.hpp" namespace ov { namespace pass { diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 4d72a296490903..65a56301f2615a 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -61,28 +61,68 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const matcher_pass_callback callback = [](pattern::Matcher& m) { const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); - if (!max_pool_v14) { + + if (!max_pool_v14 || max_pool_v14->get_output_target_inputs(1).size() != 0) { return false; } const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); - const auto rounding_type_v8 = + if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { + const auto zero = ov::op::v0::Constant::create(element::i32, Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(element::i32, Shape{}, {2}); + + const auto padding = max_pool_v14->get_pads_end(); + const auto pads_len = ov::op::v0::Constant::create(element::i32, Shape{}, {pads.size()}); + const auto pads_remaining = ov::op::v0::Constant::create(element::i32, Shape{2}, {0, 0}); + + // gather input spatial dims and prepare for compare as values (in_dim + pad) + const auto input_shape_rank = max_pool_v14->input_value(0).get_shape().size(); + const auto end = ov::op::v0::Constant::create(element::i32, Shape{}, {pads.size() + 2}); + const auto dim_idxs = std::make_shared(two, end, one, element::i32); + const auto gth_in_dims = + std::make_shared(std::get<0>(input_shape_rank), dim_idxs, zero); + const auto in_left_padded = std::make_shared(gth_in_dims, padding); + + // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride + const auto mp = + std::make_shared(max_pool_v14->input_value(0), strides, dilations, pads, pads, max_pool_v14->get_kernel(), ov::op::RoundingType::CEIL); + const auto shape_of_mp = std::make_shared(mp, element::i32); + const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); + const auto out_sub_one = std::make_shared(gth_out_dims, one); + const auto stride_node = max_pool_v14->get_strides(); + const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + + // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); + const auto selected_pads = std::make_shared(in_gt_out, padding, zero); + + // apply padding on input clear pads attribute + const auto pb = std::make_shared(OutputVector{pads_remaining, padding}, 0); + const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = + ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}); + minus_inf = std::make_shared(minus_inf, max_pool_v14-); + input = std::make_shared(input, pb, pe, minus_inf, op::PadMode::CONSTANT); + std::fill_n(pads.begin(), pads.size(), 0); + } else { + const auto rounding_type_v8 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; - - const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), - max_pool_v14->get_strides(), - max_pool_v14->get_dilations(), - max_pool_v14->get_pads_begin(), - max_pool_v14->get_pads_end(), - max_pool_v14->get_kernel(), - rounding_type_v8, - max_pool_v14->get_auto_pad(), - max_pool_v14->get_index_element_type(), - max_pool_v14->get_axis()); - - max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); - copy_runtime_info(max_pool_v14, max_pool_v8); - replace_node(max_pool_v14, max_pool_v8); + const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + max_pool_v14->get_pads_begin(), + max_pool_v14->get_pads_end(), + max_pool_v14->get_kernel(), + rounding_type_v8, + max_pool_v14->get_auto_pad(), + max_pool_v14->get_index_element_type(), + max_pool_v14->get_axis()); + max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); + max_pool_v14->output(0).replace(max_pool_v8->output(0)); + copy_runtime_info(max_pool_v14, max_pool_v8); + max_pool_v14->clear_control_dependencies(); + } return true; }; From 32248fe68731056b7610acb508cc9c47fbb9b95c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 2 Apr 2024 11:43:16 +0200 Subject: [PATCH 14/61] WIP --- .../convert_maxpool_downgrade.cpp | 130 ++++++++++-------- .../convert_maxpool_downgrade_test.cpp | 74 +++++++++- 2 files changed, 142 insertions(+), 62 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 65a56301f2615a..5485161e697209 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -10,6 +10,8 @@ #include "openvino/op/max_pool.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "openvino/pass/manager.hpp" +#include "openvino/pass/visualize_tree.hpp" ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { MATCHER_SCOPE(ConvertMaxPool8ToMaxPool1); @@ -62,68 +64,82 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const matcher_pass_callback callback = [](pattern::Matcher& m) { const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); - if (!max_pool_v14 || max_pool_v14->get_output_target_inputs(1).size() != 0) { - return false; - } - const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); + std::shared_ptr max_pool_v8; if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { - const auto zero = ov::op::v0::Constant::create(element::i32, Shape{}, {0}); - const auto one = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); - const auto two = ov::op::v0::Constant::create(element::i32, Shape{}, {2}); - - const auto padding = max_pool_v14->get_pads_end(); - const auto pads_len = ov::op::v0::Constant::create(element::i32, Shape{}, {pads.size()}); - const auto pads_remaining = ov::op::v0::Constant::create(element::i32, Shape{2}, {0, 0}); - - // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto input_shape_rank = max_pool_v14->input_value(0).get_shape().size(); - const auto end = ov::op::v0::Constant::create(element::i32, Shape{}, {pads.size() + 2}); - const auto dim_idxs = std::make_shared(two, end, one, element::i32); - const auto gth_in_dims = - std::make_shared(std::get<0>(input_shape_rank), dim_idxs, zero); - const auto in_left_padded = std::make_shared(gth_in_dims, padding); - - // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride - const auto mp = - std::make_shared(max_pool_v14->input_value(0), strides, dilations, pads, pads, max_pool_v14->get_kernel(), ov::op::RoundingType::CEIL); - const auto shape_of_mp = std::make_shared(mp, element::i32); - const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); - const auto out_sub_one = std::make_shared(gth_out_dims, one); - const auto stride_node = max_pool_v14->get_strides(); - const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); - - // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); - const auto selected_pads = std::make_shared(in_gt_out, padding, zero); - - // apply padding on input clear pads attribute - const auto pb = std::make_shared(OutputVector{pads_remaining, padding}, 0); - const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); - auto minus_inf = - ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}); - minus_inf = std::make_shared(minus_inf, max_pool_v14-); - input = std::make_shared(input, pb, pe, minus_inf, op::PadMode::CONSTANT); - std::fill_n(pads.begin(), pads.size(), 0); + auto input = max_pool_v14->input_value(0); + const auto padding_begin = max_pool_v14->get_pads_begin(); + const auto padding_begin_node = ov::op::v0::Constant::create(element::i32, Shape{padding_begin.size()}, padding_begin); + const auto padding_end = max_pool_v14->get_pads_end(); + const auto padding_end_node = ov::op::v0::Constant::create(element::i32, Shape{padding_end.size()}, padding_end); + const auto zero = ov::op::v0::Constant::create(element::i32, Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(element::i32, Shape{}, {2}); + + const auto pads_size = max_pool_v14->get_pads_begin().size(); + const auto pads_len = ov::op::v0::Constant::create(element::i32, Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(element::i32, Shape{2}, {0, 0}); + + // gather input spatial dims and prepare for compare as values (in_dim + pad) + const auto end = ov::op::v0::Constant::create(element::i32, Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, element::i32); + const auto shape = std::make_shared(input, element::i32); + const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); + const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); + + // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride + const auto mp = + std::make_shared(input, max_pool_v14->get_strides(), max_pool_v14->get_dilations(), max_pool_v14->get_pads_begin(), max_pool_v14->get_pads_end(), max_pool_v14->get_kernel(), ov::op::RoundingType::CEIL); + const auto shape_of_mp = std::make_shared(mp, element::i32); + const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); + const auto out_sub_one = std::make_shared(gth_out_dims, one); + const auto strides = max_pool_v14->get_strides(); + const auto stride_node = ov::op::v0::Constant::create(element::i32, Shape{strides.size()}, strides); + const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + + // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); + const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); + + // apply padding on input clear pads attribute + const auto pb = std::make_shared(OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = + ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}); + std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); + input = std::make_shared(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); + auto pads_begin = max_pool_v14->get_pads_begin(); + auto pads_end = max_pool_v14->get_pads_end(); + std::fill_n(pads_begin.begin(), pads_begin.size(), 0); + std::fill_n(pads_end.begin(), pads_end.size(), 0); + + max_pool_v8 = std::make_shared(input, + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + pads_begin, + pads_end, + max_pool_v14->get_kernel(), + ov::op::RoundingType::CEIL, + ov::op::PadType::EXPLICIT, + max_pool_v14->get_index_element_type(), + max_pool_v14->get_axis()); + copy_runtime_info(max_pool_v14, ov::NodeVector{dim_idxs, shape, gth_in_dims, in_left_padded, mp, shape_of_mp, gth_out_dims, out_sub_one, out_mul_stride, in_gt_out, selected_pads, pb, pe, convert_like_node}); } else { - const auto rounding_type_v8 = - rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; - const auto max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), - max_pool_v14->get_strides(), - max_pool_v14->get_dilations(), - max_pool_v14->get_pads_begin(), - max_pool_v14->get_pads_end(), - max_pool_v14->get_kernel(), - rounding_type_v8, - max_pool_v14->get_auto_pad(), - max_pool_v14->get_index_element_type(), - max_pool_v14->get_axis()); - max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); - max_pool_v14->output(0).replace(max_pool_v8->output(0)); + max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + max_pool_v14->get_pads_begin(), + max_pool_v14->get_pads_end(), + max_pool_v14->get_kernel(), + rounding_type_v14, + max_pool_v14->get_auto_pad(), + max_pool_v14->get_index_element_type(), + max_pool_v14->get_axis()); copy_runtime_info(max_pool_v14, max_pool_v8); - max_pool_v14->clear_control_dependencies(); } - + max_pool_v8->set_friendly_name(max_pool_v14->get_friendly_name()); + replace_node(max_pool_v14, max_pool_v8); + max_pool_v14->clear_control_dependencies(); return true; }; diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp index 4fef1174866ed5..4a8a6f31ab9f41 100644 --- a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp +++ b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp @@ -12,6 +12,7 @@ #include "openvino/opsets/opset14.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/pass/manager.hpp" +#include "openvino/pass/visualize_tree.hpp" namespace { @@ -41,6 +42,66 @@ std::shared_ptr create_v8_model(const ov::op::RoundingType rounding_t return std::make_shared(max_pool_v8->outputs(), ov::ParameterVector{input}); } +std::shared_ptr create_ceil_torch_workaround_model(const ov::op::RoundingType rounding_type) { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}, dilations{1, 1}; + ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto padding_begin_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pads_begin.size()}, pads_begin); + const auto padding_end_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pads_end.size()}, pads_end); + const auto zero = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {2}); + + const auto pads_size = pads_begin.size(); + const auto pads_len = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{2}, {0, 0}); + + // gather input spatial dims and prepare for compare as values (in_dim + pad) + const auto end = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, ov::element::i32); + const auto shape = std::make_shared(input, ov::element::i32); + const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); + const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); + + // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride + const auto mp = + std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, ov::op::RoundingType::CEIL); + const auto shape_of_mp = std::make_shared(mp, ov::element::i32); + const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); + const auto out_sub_one = std::make_shared(gth_out_dims, one); + const auto stride_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{strides.size()}, strides); + const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + + // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); + const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); + + // apply padding on input clear pads attribute + const auto pb = std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); + std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); + const auto pad_node = std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); + std::fill_n(pads_begin.begin(), pads_begin.size(), 0); + std::fill_n(pads_end.begin(), pads_end.size(), 0); + + const auto max_pool_v8 = std::make_shared(pad_node, + strides, + dilations, + pads_begin, + pads_end, + kernel, + ov::op::RoundingType::CEIL, + ov::op::PadType::EXPLICIT, + ov::element::i32, + 2); + + max_pool_v8->set_friendly_name("max_pool_v14"); + + return std::make_shared(max_pool_v8->outputs(), ov::ParameterVector{input}); +} + } // namespace TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { @@ -67,11 +128,14 @@ TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { } TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_torch_to_ceil) { - manager.register_pass(); model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); - model_ref = create_v8_model(ov::op::RoundingType::CEIL); - comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); - comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); + model_ref = create_ceil_torch_workaround_model(ov::op::RoundingType::CEIL); + //auto tree_vis = ov::pass::VisualizeTree("/home/pwysocki/model_ref.svg"); + //tree_vis.run_on_model(model_ref); + manager.register_pass("/home/pwysocki/model_before.svg"); + manager.register_pass(); + manager.register_pass("/home/pwysocki/model_after.svg"); + comparator.enable(FunctionsComparator::CmpValues::ACCURACY); } TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_to_ceil) { @@ -83,8 +147,8 @@ TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_to_ceil) { } TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_floor_to_floor) { - manager.register_pass(); model = create_v14_model(ov::op::RoundingType::FLOOR); + manager.register_pass(); model_ref = create_v8_model(ov::op::RoundingType::FLOOR); comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); From 367d6d144e566aa6123dd01ba544fa335e9bbc6c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Apr 2024 15:08:26 +0200 Subject: [PATCH 15/61] Added workaround subgraph --- .../convert_avgpool_downgrade.cpp | 109 +++++++++++++++--- .../convert_maxpool_downgrade.cpp | 77 +++++++++---- .../convert_avgpool_downgrade.cpp | 76 +++++++++++- .../convert_maxpool_downgrade_test.cpp | 101 +++++++++------- 4 files changed, 283 insertions(+), 80 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 31cb63b0a2bd24..70185d82fc6be2 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -21,23 +21,106 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { return false; } - const auto rounding_type_v14 = avg_pool_v14->get_rounding_type(); - const auto rounding_type_v1 = - rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; - - const auto avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), - avg_pool_v14->get_strides(), - avg_pool_v14->get_pads_begin(), - avg_pool_v14->get_pads_end(), - avg_pool_v14->get_kernel(), - avg_pool_v14->get_exclude_pad(), - rounding_type_v1, - avg_pool_v14->get_auto_pad()); + std::shared_ptr avg_pool_v1; + if (avg_pool_v14->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { + if (avg_pool_v14->is_dynamic()) { + return false; + } + auto input = avg_pool_v14->input_value(0); + const auto strides = avg_pool_v14->get_strides(); + const auto padding_begin = avg_pool_v14->get_pads_begin(); + const auto padding_begin_node = + ov::op::v0::Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); + const auto padding_end = avg_pool_v14->get_pads_end(); + const auto padding_end_node = + ov::op::v0::Constant::create(element::i64, Shape{padding_end.size()}, padding_end); + const auto zero = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(element::i64, Shape{}, {2}); + const auto pads_size = avg_pool_v14->get_pads_begin().size(); + const auto pads_len = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(element::i64, Shape{2}, {0, 0}); + + // gather input spatial dims and prepare for compare as values (in_dim + pad) + const auto end = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, element::i64); + const auto shape = std::make_shared(input, element::i64); + const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); + const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); + + // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride + const auto ap = std::make_shared(input, + avg_pool_v14->get_strides(), + avg_pool_v14->get_pads_begin(), + avg_pool_v14->get_pads_end(), + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + ov::op::RoundingType::CEIL); + const auto shape_of_ap = std::make_shared(ap, element::i64); + const auto gth_out_dims = std::make_shared(shape_of_ap, dim_idxs, zero); + const auto out_sub_one = std::make_shared(gth_out_dims, one); + const auto stride_node = ov::op::v0::Constant::create(element::i64, Shape{strides.size()}, strides); + const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + + // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); + const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); + + // apply padding on input clear pads attribute + const auto pb = + std::make_shared(OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = + ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}) + ->output(0); + std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); + const auto pad_node = + std::make_shared(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); + auto pads_begin = avg_pool_v14->get_pads_begin(); + auto pads_end = avg_pool_v14->get_pads_end(); + std::fill_n(pads_begin.begin(), pads_begin.size(), 0); + std::fill_n(pads_end.begin(), pads_end.size(), 0); + + avg_pool_v1 = std::make_shared(pad_node, + avg_pool_v14->get_strides(), + pads_begin, + pads_end, + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + ov::op::RoundingType::CEIL, + ov::op::PadType::EXPLICIT); + copy_runtime_info(avg_pool_v14, + ov::NodeVector{dim_idxs, + shape, + gth_in_dims, + in_left_padded, + ap, + shape_of_ap, + gth_out_dims, + out_sub_one, + out_mul_stride, + in_gt_out, + selected_pads, + pb, + pe, + convert_like_node, + pad_node, + avg_pool_v1}); + } else { + const auto avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), + avg_pool_v14->get_strides(), + avg_pool_v14->get_pads_begin(), + avg_pool_v14->get_pads_end(), + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + avg_pool_v14->get_rounding_type(), + avg_pool_v14->get_auto_pad()); + copy_runtime_info(avg_pool_v14, avg_pool_v1); + } avg_pool_v1->set_friendly_name(avg_pool_v14->get_friendly_name()); copy_runtime_info(avg_pool_v14, avg_pool_v1); replace_node(avg_pool_v14, avg_pool_v1); - return true; }; diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 5485161e697209..ab42e5833195c8 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -8,10 +8,10 @@ #include "openvino/core/descriptor/tensor.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/max_pool.hpp" -#include "openvino/pass/pattern/op/wrap_type.hpp" -#include "transformations/utils/utils.hpp" #include "openvino/pass/manager.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/pass/visualize_tree.hpp" +#include "transformations/utils/utils.hpp" ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { MATCHER_SCOPE(ConvertMaxPool8ToMaxPool1); @@ -67,53 +67,66 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); std::shared_ptr max_pool_v8; if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { + if (max_pool_v14->is_dynamic()) { + return false; + } auto input = max_pool_v14->input_value(0); + const auto strides = max_pool_v14->get_strides(); const auto padding_begin = max_pool_v14->get_pads_begin(); - const auto padding_begin_node = ov::op::v0::Constant::create(element::i32, Shape{padding_begin.size()}, padding_begin); + const auto padding_begin_node = + ov::op::v0::Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); const auto padding_end = max_pool_v14->get_pads_end(); - const auto padding_end_node = ov::op::v0::Constant::create(element::i32, Shape{padding_end.size()}, padding_end); - const auto zero = ov::op::v0::Constant::create(element::i32, Shape{}, {0}); - const auto one = ov::op::v0::Constant::create(element::i32, Shape{}, {1}); - const auto two = ov::op::v0::Constant::create(element::i32, Shape{}, {2}); + const auto padding_end_node = + ov::op::v0::Constant::create(element::i64, Shape{padding_end.size()}, padding_end); + const auto zero = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(element::i64, Shape{}, {2}); const auto pads_size = max_pool_v14->get_pads_begin().size(); - const auto pads_len = ov::op::v0::Constant::create(element::i32, Shape{}, {pads_size}); - const auto pads_remaining = ov::op::v0::Constant::create(element::i32, Shape{2}, {0, 0}); + const auto pads_len = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(element::i64, Shape{2}, {0, 0}); // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto end = ov::op::v0::Constant::create(element::i32, Shape{}, {pads_size + 2}); - const auto dim_idxs = std::make_shared(two, end, one, element::i32); - const auto shape = std::make_shared(input, element::i32); + const auto end = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, element::i64); + const auto shape = std::make_shared(input, element::i64); const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride - const auto mp = - std::make_shared(input, max_pool_v14->get_strides(), max_pool_v14->get_dilations(), max_pool_v14->get_pads_begin(), max_pool_v14->get_pads_end(), max_pool_v14->get_kernel(), ov::op::RoundingType::CEIL); - const auto shape_of_mp = std::make_shared(mp, element::i32); + const auto mp = std::make_shared(input, + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + max_pool_v14->get_pads_begin(), + max_pool_v14->get_pads_end(), + max_pool_v14->get_kernel(), + ov::op::RoundingType::CEIL); + const auto shape_of_mp = std::make_shared(mp, element::i64); const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); const auto out_sub_one = std::make_shared(gth_out_dims, one); - const auto strides = max_pool_v14->get_strides(); - const auto stride_node = ov::op::v0::Constant::create(element::i32, Shape{strides.size()}, strides); + const auto stride_node = ov::op::v0::Constant::create(element::i64, Shape{strides.size()}, strides); const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); - // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); + // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); // apply padding on input clear pads attribute - const auto pb = std::make_shared(OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pb = + std::make_shared(OutputVector{pads_remaining->output(0), padding_end_node}, 0); const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); auto minus_inf = - ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}); + ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}) + ->output(0); std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); - input = std::make_shared(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); + const auto pad_node = + std::make_shared(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); auto pads_begin = max_pool_v14->get_pads_begin(); auto pads_end = max_pool_v14->get_pads_end(); std::fill_n(pads_begin.begin(), pads_begin.size(), 0); std::fill_n(pads_end.begin(), pads_end.size(), 0); - max_pool_v8 = std::make_shared(input, + max_pool_v8 = std::make_shared(pad_node, max_pool_v14->get_strides(), max_pool_v14->get_dilations(), pads_begin, @@ -123,7 +136,23 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { ov::op::PadType::EXPLICIT, max_pool_v14->get_index_element_type(), max_pool_v14->get_axis()); - copy_runtime_info(max_pool_v14, ov::NodeVector{dim_idxs, shape, gth_in_dims, in_left_padded, mp, shape_of_mp, gth_out_dims, out_sub_one, out_mul_stride, in_gt_out, selected_pads, pb, pe, convert_like_node}); + copy_runtime_info(max_pool_v14, + ov::NodeVector{dim_idxs, + shape, + gth_in_dims, + in_left_padded, + mp, + shape_of_mp, + gth_out_dims, + out_sub_one, + out_mul_stride, + in_gt_out, + selected_pads, + pb, + pe, + convert_like_node, + pad_node, + max_pool_v8}); } else { max_pool_v8 = std::make_shared(max_pool_v14->input_value(0), max_pool_v14->get_strides(), diff --git a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp index e54c9afbd84233..5c5ff215bc24cc 100644 --- a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp @@ -11,6 +11,7 @@ #include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset14.hpp" #include "openvino/pass/manager.hpp" +#include "openvino/pass/visualize_tree.hpp" namespace { @@ -52,13 +53,82 @@ std::shared_ptr create_v1_model(const ov::op::RoundingType rounding_t return std::make_shared(avg_pool_v1->outputs(), ov::ParameterVector{input}); } +std::shared_ptr create_ceil_torch_workaround_model() { + const auto input = std::make_shared(ov::element::f32, ov::Shape{1, 3, 64, 64}); + const ov::Strides strides{1, 1}; + ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; + + const auto padding_begin_node = + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{pads_begin.size()}, pads_begin); + const auto padding_end_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{pads_end.size()}, pads_end); + const auto zero = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {2}); + + const auto pads_size = pads_begin.size(); + const auto pads_len = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {0, 0}); + + // gather input spatial dims and prepare for compare as values (in_dim + pad) + const auto end = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, ov::element::i64); + const auto shape = std::make_shared(input, ov::element::i64); + const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); + const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); + + // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride + const auto ap = std::make_shared(input, + strides, + pads_begin, + pads_end, + kernel, + true, + ov::op::RoundingType::CEIL); + const auto shape_of_ap = std::make_shared(ap, ov::element::i64); + const auto gth_out_dims = std::make_shared(shape_of_ap, dim_idxs, zero); + const auto out_sub_one = std::make_shared(gth_out_dims, one); + const auto stride_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{strides.size()}, strides); + const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + + // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); + const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); + + // apply padding on input clear pads attribute + const auto pb = + std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = + ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); + std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); + const auto pad_node = + std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); + std::fill_n(pads_begin.begin(), pads_begin.size(), 0); + std::fill_n(pads_end.begin(), pads_end.size(), 0); + + const auto avg_pool_v1 = std::make_shared(pad_node, + strides, + pads_begin, + pads_end, + kernel, + true, + ov::op::RoundingType::CEIL, + ov::op::PadType::EXPLICIT); + + avg_pool_v1->set_friendly_name("avg_pool_v1_ceil_torch_workaround"); + + return std::make_shared(avg_pool_v1->outputs(), ov::ParameterVector{input}); +} + } // namespace TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_torch_to_ceil) { - manager.register_pass(); model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); - model_ref = create_v1_model(ov::op::RoundingType::CEIL); - comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + model_ref = create_ceil_torch_workaround_model(); + manager.register_pass("/home/pwysocki/model_before.svg"); + manager.register_pass(); + manager.register_pass("/home/pwysocki/model_after.svg"); + comparator.disable(FunctionsComparator::CmpValues::ACCURACY); comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); } diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp index 4a8a6f31ab9f41..4d7d920630ba34 100644 --- a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp +++ b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp @@ -12,7 +12,6 @@ #include "openvino/opsets/opset14.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/pass/manager.hpp" -#include "openvino/pass/visualize_tree.hpp" namespace { @@ -21,8 +20,16 @@ std::shared_ptr create_v14_model(const ov::op::RoundingType rounding_ const ov::Strides strides{1, 1}, dilations{1, 1}; const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; - const auto max_pool_v14 = - std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, rounding_type); + const auto max_pool_v14 = std::make_shared(input, + strides, + dilations, + pads_begin, + pads_end, + kernel, + rounding_type, + ov::op::PadType::EXPLICIT, + ov::element::i64, + 2); max_pool_v14->set_friendly_name("max_pool_v14"); @@ -34,8 +41,16 @@ std::shared_ptr create_v8_model(const ov::op::RoundingType rounding_t const ov::Strides strides{1, 1}, dilations{1, 1}; const ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; - const auto max_pool_v8 = - std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, rounding_type); + const auto max_pool_v8 = std::make_shared(input, + strides, + dilations, + pads_begin, + pads_end, + kernel, + rounding_type, + ov::op::PadType::EXPLICIT, + ov::element::i64, + 2); max_pool_v8->set_friendly_name("max_pool_v8"); @@ -47,57 +62,66 @@ std::shared_ptr create_ceil_torch_workaround_model(const ov::op::Roun const ov::Strides strides{1, 1}, dilations{1, 1}; ov::Shape pads_begin{1, 1}, pads_end{1, 1}, kernel{2, 2}; - const auto padding_begin_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pads_begin.size()}, pads_begin); - const auto padding_end_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{pads_end.size()}, pads_end); - const auto zero = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0}); - const auto one = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {1}); - const auto two = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {2}); + const auto padding_begin_node = + ov::op::v0::Constant::create(ov::element::i64, ov::Shape{pads_begin.size()}, pads_begin); + const auto padding_end_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{pads_end.size()}, pads_end); + const auto zero = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {0}); + const auto one = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {1}); + const auto two = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {2}); const auto pads_size = pads_begin.size(); - const auto pads_len = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {pads_size}); - const auto pads_remaining = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{2}, {0, 0}); + const auto pads_len = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {pads_size}); + const auto pads_remaining = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{2}, {0, 0}); // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto end = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {pads_size + 2}); - const auto dim_idxs = std::make_shared(two, end, one, ov::element::i32); - const auto shape = std::make_shared(input, ov::element::i32); + const auto end = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{}, {pads_size + 2}); + const auto dim_idxs = std::make_shared(two, end, one, ov::element::i64); + const auto shape = std::make_shared(input, ov::element::i64); const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride - const auto mp = - std::make_shared(input, strides, dilations, pads_begin, pads_end, kernel, ov::op::RoundingType::CEIL); - const auto shape_of_mp = std::make_shared(mp, ov::element::i32); + const auto mp = std::make_shared(input, + strides, + dilations, + pads_begin, + pads_end, + kernel, + ov::op::RoundingType::CEIL); + const auto shape_of_mp = std::make_shared(mp, ov::element::i64); const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); const auto out_sub_one = std::make_shared(gth_out_dims, one); - const auto stride_node = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{strides.size()}, strides); + const auto stride_node = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{strides.size()}, strides); const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); - // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = std::make_shared(in_left_padded, out_mul_stride); + // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); // apply padding on input clear pads attribute - const auto pb = std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pb = + std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); - auto minus_inf = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); + auto minus_inf = + ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); - const auto pad_node = std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); + const auto pad_node = + std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); std::fill_n(pads_begin.begin(), pads_begin.size(), 0); std::fill_n(pads_end.begin(), pads_end.size(), 0); const auto max_pool_v8 = std::make_shared(pad_node, - strides, - dilations, - pads_begin, - pads_end, - kernel, - ov::op::RoundingType::CEIL, - ov::op::PadType::EXPLICIT, - ov::element::i32, - 2); - - max_pool_v8->set_friendly_name("max_pool_v14"); + strides, + dilations, + pads_begin, + pads_end, + kernel, + ov::op::RoundingType::CEIL, + ov::op::PadType::EXPLICIT, + ov::element::i64, + 2); + + max_pool_v8->set_friendly_name("max_pool_v8_ceil_torch_workaround"); return std::make_shared(max_pool_v8->outputs(), ov::ParameterVector{input}); } @@ -130,12 +154,9 @@ TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_torch_to_ceil) { model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); model_ref = create_ceil_torch_workaround_model(ov::op::RoundingType::CEIL); - //auto tree_vis = ov::pass::VisualizeTree("/home/pwysocki/model_ref.svg"); - //tree_vis.run_on_model(model_ref); - manager.register_pass("/home/pwysocki/model_before.svg"); manager.register_pass(); - manager.register_pass("/home/pwysocki/model_after.svg"); - comparator.enable(FunctionsComparator::CmpValues::ACCURACY); + comparator.disable(FunctionsComparator::CmpValues::ACCURACY); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); } TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_to_ceil) { From d9caaae817facccd0360b4ab2cf6cdd9470005ea Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Apr 2024 15:59:28 +0200 Subject: [PATCH 16/61] Fix segfault in test --- .../op_conversions/convert_avgpool_downgrade.cpp | 16 ++++++++-------- .../op_conversions/convert_avgpool_downgrade.cpp | 2 -- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 70185d82fc6be2..b5dff67487f934 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -108,14 +108,14 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { pad_node, avg_pool_v1}); } else { - const auto avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), - avg_pool_v14->get_strides(), - avg_pool_v14->get_pads_begin(), - avg_pool_v14->get_pads_end(), - avg_pool_v14->get_kernel(), - avg_pool_v14->get_exclude_pad(), - avg_pool_v14->get_rounding_type(), - avg_pool_v14->get_auto_pad()); + avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), + avg_pool_v14->get_strides(), + avg_pool_v14->get_pads_begin(), + avg_pool_v14->get_pads_end(), + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + avg_pool_v14->get_rounding_type(), + avg_pool_v14->get_auto_pad()); copy_runtime_info(avg_pool_v14, avg_pool_v1); } avg_pool_v1->set_friendly_name(avg_pool_v14->get_friendly_name()); diff --git a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp index 5c5ff215bc24cc..ffb0674edbeb05 100644 --- a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp @@ -125,9 +125,7 @@ std::shared_ptr create_ceil_torch_workaround_model() { TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_torch_to_ceil) { model = create_v14_model(ov::op::RoundingType::CEIL_TORCH); model_ref = create_ceil_torch_workaround_model(); - manager.register_pass("/home/pwysocki/model_before.svg"); manager.register_pass(); - manager.register_pass("/home/pwysocki/model_after.svg"); comparator.disable(FunctionsComparator::CmpValues::ACCURACY); comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); } From a40d21a11e7f5fb91c2916a7f8879d85b5eafbf6 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 8 Apr 2024 16:41:16 +0200 Subject: [PATCH 17/61] Multiple fixes --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 30 +--- .../single_layer_tests/classes/pooling.cpp | 153 +++++++++++------- .../single_layer_tests/classes/pooling.hpp | 31 ++++ .../instances/common/pooling.cpp | 84 +++++++++- 4 files changed, 212 insertions(+), 86 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 73f01ca63554bb..7b772c437dee7e 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -208,30 +208,16 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c get_attributes(poolingAttrs.dilation, maxPoolOp_v8->get_dilations()); } else if (auto maxPoolOp_v1 = ov::as_type_ptr(op)) { poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - } else if (auto avgPoolOp_v1 = ov::as_type_ptr(op)) { + } else if (auto avgPoolOp = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp_v1->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp_v1->get_rounding_type(); - - get_attributes(poolingAttrs.stride, avgPoolOp_v1->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp_v1->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v1->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v1->get_pads_end()); - poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - - poolingAttrs.auto_pad = (avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); - } else if (auto avgPoolOp_v14 = ov::as_type_ptr(op)) { - algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp_v14->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp_v14->get_rounding_type(); - - get_attributes(poolingAttrs.stride, avgPoolOp_v14->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp_v14->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v14->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v14->get_pads_end()); + poolingAttrs.exclude_pad = avgPoolOp->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOp->get_rounding_type(); + get_attributes(poolingAttrs.stride, avgPoolOp->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOp->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOp->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOp->get_pads_end()); poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - - poolingAttrs.auto_pad = (avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); + poolingAttrs.auto_pad = (avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_UPPER); } poolingAttrs.algorithm = algorithm; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 0748ffd4887f69..9131aed4b76ac3 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -12,7 +12,8 @@ using namespace CPUTestUtils; namespace ov { namespace test { namespace util { -static std::string getTestCaseNameUtil(const testing::TestParamInfo& obj) { +template +static std::string getTestCaseNameUtil(const TParamInfo& obj) { maxPoolSpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; @@ -50,7 +51,7 @@ static std::string getTestCaseNameUtil(const testing::TestParamInfo -void SetUpUtil(TTest* testInstance, +void MaxPoolSetUpUtil(TTest* testInstance, std::vector>& inFmts, std::vector>& outFmts, std::vector>& priority, @@ -97,7 +98,62 @@ void SetUpUtil(TTest* testInstance, ov::ResultVector results{std::make_shared(pooling->output(0))}; function = std::make_shared(results, params, "MaxPooling"); } -} // namespace util +template +void AvgPoolSetUpUtil(TTest* testInstance, + std::vector>& inFmts, + std::vector>& outFmts, + std::vector>& priority, + std::string& selectedType, + std::shared_ptr& function, + std::vector& inputDynamicShapes, + std::shared_ptr postOpMgrPtr, + testing::internal::Strings fusedOps, + double& abs_threshold) { + poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = testInstance->GetParam(); + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + std::tie(postOpMgrPtr, fusedOps) = fusingParams; + + if (selectedType.empty()) { + auto selectedType = testInstance->getPrimitiveTypeUtil(); + } + if (isInt8) + selectedType = selectedType + "_I8"; + else + selectedType = CPUTestUtils::CPUTestsBase::makeSelectedTypeStr(selectedType, inPrc); + + testInstance->init_input_shapes_util({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + + std::shared_ptr poolInput = params[0]; + if (isInt8) { + abs_threshold = 2e-2; + ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); + poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); + } + + auto pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); + function = testInstance->makeNgraphFunctionUtil(inPrc, params, pooling, "PoolingCPU"); +} +} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -147,56 +203,16 @@ std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfoGetParam(); - - utils::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; - - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - std::tie(postOpMgrPtr, fusedOps) = fusingParams; - - if (selectedType.empty()) { - selectedType = getPrimitiveType(); - } - if (isInt8) - selectedType = selectedType + "_I8"; - else - selectedType = makeSelectedTypeStr(selectedType, inPrc); - - init_input_shapes({inputShapes}); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - - std::shared_ptr poolInput = params[0]; - if (isInt8) { - abs_threshold = 2e-2; - ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); - poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); - } - - std::shared_ptr pooling; - if (ov::test::utils::PoolingTypes::MAX == poolType) { - pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, roundingType, padType); - } else { - pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); - } - - function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); + util::AvgPoolSetUpUtil(this, + inFmts, + outFmts, + priority, + selectedType, + function, + inputDynamicShapes, + postOpMgrPtr, + fusedOps, + abs_threshold); } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( @@ -206,7 +222,7 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( void MaxPoolingV8LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); + util::MaxPoolSetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); } std::string MaxPoolingV14LayerCPUTest::getTestCaseName( @@ -216,7 +232,26 @@ std::string MaxPoolingV14LayerCPUTest::getTestCaseName( void MaxPoolingV14LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); + util::MaxPoolSetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); +} + +std::string AvgPoolingV14LayerCPUTest::getTestCaseName( + const testing::TestParamInfo& obj) { + return PoolingLayerCPUTest::getTestCaseName(obj); +} + +void AvgPoolingV14LayerCPUTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + util::AvgPoolSetUpUtil(this, + inFmts, + outFmts, + priority, + selectedType, + function, + inputDynamicShapes, + postOpMgrPtr, + fusedOps, + abs_threshold); } TEST_P(PoolingLayerCPUTest, CompareWithRefs) { @@ -224,6 +259,11 @@ TEST_P(PoolingLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(AvgPoolingV14LayerCPUTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Pooling"); +} + TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -485,7 +525,6 @@ const std::vector& inputShapes4D_Large() { return inputShapes4D_Large; } - } // namespace Pooling } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 5e314519e80add..e9b67405a77b47 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -29,7 +29,38 @@ class PoolingLayerCPUTest : public testing::WithParamInterface& obj); + std::string getPrimitiveTypeUtil() const { + return CpuTestWithFusing::getPrimitiveType(); + } + void init_input_shapes_util(const std::vector &shapes) { + SubgraphBaseTest::init_input_shapes(shapes); + } + std::shared_ptr makeNgraphFunctionUtil(const ov::element::Type &ngPrc, + ov::ParameterVector ¶ms, + const std::shared_ptr &lastNode, + std::string name) { + return CPUTestUtils::CPUTestsBase::makeNgraphFunction(ngPrc, params, lastNode, name); + } +protected: + void SetUp() override; +}; +class AvgPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CpuTestWithFusing { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + std::string getPrimitiveTypeUtil() const { + return CpuTestWithFusing::getPrimitiveType(); + } + void init_input_shapes_util(const std::vector &shapes) { + SubgraphBaseTest::init_input_shapes(shapes); + } + std::shared_ptr makeNgraphFunctionUtil(const ov::element::Type &ngPrc, + ov::ParameterVector ¶ms, + const std::shared_ptr &lastNode, + std::string name) { + return CPUTestUtils::CPUTestsBase::makeNgraphFunction(ngPrc, params, lastNode, name); + } protected: void SetUp() override; }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 62fdcf0c2e6e65..f97faa2d91ae5b 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -36,7 +36,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg3D()), ::testing::ValuesIn(inputShapes3D()), @@ -46,7 +46,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg3D_RefOnly), ::testing::ValuesIn(inputShapes3D()), @@ -56,6 +56,26 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D_RefOnly), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + const std::vector paramsAvg4D_RefOnly = { poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, @@ -79,7 +99,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(vecCpuConfigs)), MaxPoolingV8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), ::testing::ValuesIn(inputShapes4D()), @@ -89,7 +109,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_RefOnly), ::testing::ValuesIn(inputShapes4D()), @@ -99,7 +119,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_Large, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_Large()), ::testing::ValuesIn(inputShapes4D_Large()), @@ -109,6 +129,36 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_RefOnly), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_Large, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_Large()), + ::testing::ValuesIn(inputShapes4D_Large()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + const std::vector paramsMaxV85D_ref = { maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, @@ -170,7 +220,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::Values(expectedCpuConfig())), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D()), ::testing::ValuesIn(inputShapes5D()), @@ -180,7 +230,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D_RefOnly), ::testing::ValuesIn(inputShapes5D()), @@ -189,6 +239,26 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(expectedCpuConfig()), ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D_RefOnly), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); #endif } // namespace Pooling } // namespace test From d9ce79d74002f6bd2eac991489de3ab2b6587f4d Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 8 Apr 2024 17:01:53 +0200 Subject: [PATCH 18/61] Minor change --- .../op_conversions/convert_maxpool_downgrade.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 490fbd4443587d..399842903b29df 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -15,7 +15,7 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { MATCHER_SCOPE(ConvertMaxPool8ToMaxPool1); - + auto maxpool_v8_pattern = pattern::wrap_type(); matcher_pass_callback callback = [=](pattern::Matcher& m) { auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); @@ -23,14 +23,11 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) { return false; } - - for (auto dilation : maxpool_v8_node->get_dilations()) - { + for (auto dilation : maxpool_v8_node->get_dilations()) { if (dilation != 1) { return false; } - } auto maxpool_v1_node = std::make_shared(maxpool_v8_node->input_value(0), From 00a0f4f48e5d28176cb44383d5be5ddcc7bfbe73 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 11 Apr 2024 17:59:37 +0200 Subject: [PATCH 19/61] Apply CR --- .../convert_avgpool_downgrade.cpp | 111 ++-------------- .../convert_maxpool_downgrade.cpp | 121 ++++++++---------- .../convert_avgpool_downgrade.cpp | 72 +---------- .../convert_maxpool_downgrade_test.cpp | 20 ++- 4 files changed, 80 insertions(+), 244 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index b5dff67487f934..9d62490712c832 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -20,104 +20,19 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { if (!avg_pool_v14) { return false; } - - std::shared_ptr avg_pool_v1; - if (avg_pool_v14->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { - if (avg_pool_v14->is_dynamic()) { - return false; - } - auto input = avg_pool_v14->input_value(0); - const auto strides = avg_pool_v14->get_strides(); - const auto padding_begin = avg_pool_v14->get_pads_begin(); - const auto padding_begin_node = - ov::op::v0::Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); - const auto padding_end = avg_pool_v14->get_pads_end(); - const auto padding_end_node = - ov::op::v0::Constant::create(element::i64, Shape{padding_end.size()}, padding_end); - const auto zero = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); - const auto one = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); - const auto two = ov::op::v0::Constant::create(element::i64, Shape{}, {2}); - - const auto pads_size = avg_pool_v14->get_pads_begin().size(); - const auto pads_len = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size}); - const auto pads_remaining = ov::op::v0::Constant::create(element::i64, Shape{2}, {0, 0}); - - // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto end = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size + 2}); - const auto dim_idxs = std::make_shared(two, end, one, element::i64); - const auto shape = std::make_shared(input, element::i64); - const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); - const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); - - // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride - const auto ap = std::make_shared(input, - avg_pool_v14->get_strides(), - avg_pool_v14->get_pads_begin(), - avg_pool_v14->get_pads_end(), - avg_pool_v14->get_kernel(), - avg_pool_v14->get_exclude_pad(), - ov::op::RoundingType::CEIL); - const auto shape_of_ap = std::make_shared(ap, element::i64); - const auto gth_out_dims = std::make_shared(shape_of_ap, dim_idxs, zero); - const auto out_sub_one = std::make_shared(gth_out_dims, one); - const auto stride_node = ov::op::v0::Constant::create(element::i64, Shape{strides.size()}, strides); - const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); - - // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); - const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); - - // apply padding on input clear pads attribute - const auto pb = - std::make_shared(OutputVector{pads_remaining->output(0), padding_end_node}, 0); - const auto pe = std::make_shared(OutputVector{pads_remaining, selected_pads}, 0); - auto minus_inf = - ov::op::v0::Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()}) - ->output(0); - std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); - const auto pad_node = - std::make_shared(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); - auto pads_begin = avg_pool_v14->get_pads_begin(); - auto pads_end = avg_pool_v14->get_pads_end(); - std::fill_n(pads_begin.begin(), pads_begin.size(), 0); - std::fill_n(pads_end.begin(), pads_end.size(), 0); - - avg_pool_v1 = std::make_shared(pad_node, - avg_pool_v14->get_strides(), - pads_begin, - pads_end, - avg_pool_v14->get_kernel(), - avg_pool_v14->get_exclude_pad(), - ov::op::RoundingType::CEIL, - ov::op::PadType::EXPLICIT); - copy_runtime_info(avg_pool_v14, - ov::NodeVector{dim_idxs, - shape, - gth_in_dims, - in_left_padded, - ap, - shape_of_ap, - gth_out_dims, - out_sub_one, - out_mul_stride, - in_gt_out, - selected_pads, - pb, - pe, - convert_like_node, - pad_node, - avg_pool_v1}); - } else { - avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), - avg_pool_v14->get_strides(), - avg_pool_v14->get_pads_begin(), - avg_pool_v14->get_pads_end(), - avg_pool_v14->get_kernel(), - avg_pool_v14->get_exclude_pad(), - avg_pool_v14->get_rounding_type(), - avg_pool_v14->get_auto_pad()); - copy_runtime_info(avg_pool_v14, avg_pool_v1); - } + const auto rounding_type_v14 = avg_pool_v14->get_rounding_type(); + const auto rounding_type_v1 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH + ? ov::op::RoundingType::CEIL + : ov::op::RoundingType::FLOOR; + + const auto avg_pool_v1 = std::make_shared(avg_pool_v14->input_value(0), + avg_pool_v14->get_strides(), + avg_pool_v14->get_pads_begin(), + avg_pool_v14->get_pads_end(), + avg_pool_v14->get_kernel(), + avg_pool_v14->get_exclude_pad(), + rounding_type_v1, + avg_pool_v14->get_auto_pad()); avg_pool_v1->set_friendly_name(avg_pool_v14->get_friendly_name()); copy_runtime_info(avg_pool_v14, avg_pool_v1); replace_node(avg_pool_v14, avg_pool_v1); diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index ab42e5833195c8..137d10ab7b90fd 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -58,14 +58,26 @@ ov::pass::ConvertMaxPool8ToMaxPool1::ConvertMaxPool8ToMaxPool1() { ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { MATCHER_SCOPE(ConvertMaxPool14ToMaxPool8); - const auto max_pool_v14_pattern = pattern::wrap_type(); const matcher_pass_callback callback = [](pattern::Matcher& m) { - const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); + using ov::op::v0::Constant; + using ov::op::v0::Concat; + using ov::op::v1::Subtract; + using ov::op::v1::Multiply; + using ov::op::v1::Greater; + using ov::op::v1::Select; + using ov::op::v1::ConvertLike; + using ov::op::v1::Add; + using ov::op::v3::ShapeOf; + using ov::op::v4::Range; + using ov::op::v8::Gather; + using ov::op::v12::Pad; + const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); std::shared_ptr max_pool_v8; + NodeRegistry node_registry; if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { if (max_pool_v14->is_dynamic()) { return false; @@ -73,86 +85,65 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { auto input = max_pool_v14->input_value(0); const auto strides = max_pool_v14->get_strides(); const auto padding_begin = max_pool_v14->get_pads_begin(); - const auto padding_begin_node = - ov::op::v0::Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); + const auto padding_begin_node = Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); const auto padding_end = max_pool_v14->get_pads_end(); - const auto padding_end_node = - ov::op::v0::Constant::create(element::i64, Shape{padding_end.size()}, padding_end); - const auto zero = ov::op::v0::Constant::create(element::i64, Shape{}, {0}); - const auto one = ov::op::v0::Constant::create(element::i64, Shape{}, {1}); - const auto two = ov::op::v0::Constant::create(element::i64, Shape{}, {2}); + const auto padding_end_node = Constant::create(element::i64, Shape{padding_end.size()}, padding_end); + const auto zero = Constant::create(element::i64, Shape{}, {0}); + const auto one = Constant::create(element::i64, Shape{}, {1}); + const auto two = Constant::create(element::i64, Shape{}, {2}); const auto pads_size = max_pool_v14->get_pads_begin().size(); - const auto pads_len = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size}); - const auto pads_remaining = ov::op::v0::Constant::create(element::i64, Shape{2}, {0, 0}); + const auto pads_len = Constant::create(element::i64, Shape{}, {pads_size}); + const auto pads_remaining = Constant::create(element::i64, Shape{2}, {0, 0}); // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto end = ov::op::v0::Constant::create(element::i64, Shape{}, {pads_size + 2}); - const auto dim_idxs = std::make_shared(two, end, one, element::i64); - const auto shape = std::make_shared(input, element::i64); - const auto gth_in_dims = std::make_shared(shape, dim_idxs, zero); - const auto in_left_padded = std::make_shared(gth_in_dims, padding_begin_node); + const auto end = Constant::create(element::i64, Shape{}, {pads_size + 2}); + const auto dim_idxs = node_registry.make(two, end, one, element::i64); + const auto shape = node_registry.make(input, element::i64); + const auto gth_in_dims = node_registry.make(shape, dim_idxs, zero); + const auto in_left_padded = node_registry.make(gth_in_dims, padding_begin_node); // gather output spatial dims and prepare it for compare as values (out_dim - 1) * stride - const auto mp = std::make_shared(input, - max_pool_v14->get_strides(), - max_pool_v14->get_dilations(), - max_pool_v14->get_pads_begin(), - max_pool_v14->get_pads_end(), - max_pool_v14->get_kernel(), - ov::op::RoundingType::CEIL); - const auto shape_of_mp = std::make_shared(mp, element::i64); - const auto gth_out_dims = std::make_shared(shape_of_mp, dim_idxs, zero); - const auto out_sub_one = std::make_shared(gth_out_dims, one); - const auto stride_node = ov::op::v0::Constant::create(element::i64, Shape{strides.size()}, strides); - const auto out_mul_stride = std::make_shared(out_sub_one, stride_node); + const auto mp = node_registry.make(input, + max_pool_v14->get_strides(), + max_pool_v14->get_dilations(), + max_pool_v14->get_pads_begin(), + max_pool_v14->get_pads_end(), + max_pool_v14->get_kernel(), + ov::op::RoundingType::CEIL); + const auto shape_of_mp = node_registry.make(mp, element::i64); + const auto gth_out_dims = node_registry.make(shape_of_mp, dim_idxs, zero); + const auto out_sub_one = node_registry.make(gth_out_dims, one); + const auto stride_node = Constant::create(element::i64, Shape{strides.size()}, strides); + const auto out_mul_stride = node_registry.make(out_sub_one, stride_node); // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = std::make_shared(out_mul_stride, in_left_padded); - const auto selected_pads = std::make_shared(in_gt_out, padding_end_node, zero); + const auto in_gt_out = node_registry.make(out_mul_stride, in_left_padded); + const auto selected_pads = node_registry.make(in_gt_out, padding_end_node, zero); // apply padding on input clear pads attribute - const auto pb = - std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); - const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); - auto minus_inf = - ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); - std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); - const auto pad_node = - std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); + const auto pb = std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); + auto minus_inf = Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); + std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); + const auto pad_node = std::make_shared(input, pb, pe, convert_like_node, ov::op::PadMode::CONSTANT); std::fill_n(pads_begin.begin(), pads_begin.size(), 0); std::fill_n(pads_end.begin(), pads_end.size(), 0); @@ -130,21 +150,21 @@ std::shared_ptr create_ceil_torch_workaround_model(const ov::op::Roun TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { { - auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); + auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); ov::Strides strides{1}, dilations{1}; ov::Shape pads_begin{0}, pads_end{0}, kernel{1}; - auto maxpool_8 = std::make_shared(data, strides, dilations, pads_begin, pads_end, kernel); - auto result = std::make_shared(maxpool_8->output(0)); + auto maxpool_8 = std::make_shared(data, strides, dilations, pads_begin, pads_end, kernel); + auto result = std::make_shared(maxpool_8->output(0)); model = std::make_shared(ov::NodeVector{result}, ov::ParameterVector{data}); manager.register_pass(); } { - auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); + auto data = std::make_shared(ov::element::f32, ov::Shape{1, 2, 3}); ov::Strides strides{1}; ov::Shape pads_begin{0}, pads_end{0}, kernel{1}; - auto maxpool_1 = std::make_shared(data, strides, pads_begin, pads_end, kernel); - auto result = std::make_shared(maxpool_1->output(0)); + auto maxpool_1 = std::make_shared(data, strides, pads_begin, pads_end, kernel); + auto result = std::make_shared(maxpool_1->output(0)); model_ref = std::make_shared(ov::NodeVector{result}, ov::ParameterVector{data}); } } From bdcf9482bb4038ea1d951bd237bac7ad6b8fe087 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 18 Apr 2024 14:58:20 +0200 Subject: [PATCH 21/61] Fix code style --- .../op_conversions/convert_avgpool_downgrade.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 0833e9b291e680..1727f5fdf8e4b0 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -22,9 +22,8 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const matcher_pass_callback callback = [](pattern::Matcher& m) { const auto avg_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); const auto rounding_type_v14 = avg_pool_v14->get_rounding_type(); - const auto rounding_type_v1 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH - ? ov::op::RoundingType::CEIL - : rounding_type_v14; + const auto rounding_type_v1 = + rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; const auto exclude_pad = avg_pool_v14->get_exclude_pad(); const auto input = avg_pool_v14->input_value(0); From 7c84245152c29587bc5713ea38620027543f628f Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 22 Apr 2024 12:16:06 +0200 Subject: [PATCH 22/61] Minor change --- .../op_conversions/convert_maxpool_downgrade.cpp | 4 ++-- .../op_conversions/convert_maxpool_downgrade_test.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 137d10ab7b90fd..5e9f96105b64a4 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -117,8 +117,8 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto stride_node = Constant::create(element::i64, Shape{strides.size()}, strides); const auto out_mul_stride = node_registry.make(out_sub_one, stride_node); - // if (in_dim + pad) < ((out_dim - 1) * stride) sliding window in bound use end padding. - const auto in_gt_out = node_registry.make(out_mul_stride, in_left_padded); + // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. + const auto in_gt_out = node_registry.make(in_left_padded, out_mul_stride); const auto selected_pads = node_registry.make(in_gt_out, padding_end_node, zero); // apply padding on input clear pads attribute - const auto pb = std::make_shared(ov::OutputVector{pads_remaining->output(0), padding_end_node}, 0); + const auto pb = std::make_shared(ov::OutputVector{pads_remaining, padding_end_node}, 0); const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); auto minus_inf = Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); @@ -140,6 +140,7 @@ std::shared_ptr create_ceil_torch_workaround_model(const ov::op::Roun ov::op::PadType::EXPLICIT, ov::element::i64, 2); + std::cout << "Workaround shape: " << max_pool_v8->get_output_partial_shape(0) << std::endl; max_pool_v8->set_friendly_name("max_pool_v8_ceil_torch_workaround"); @@ -170,7 +171,7 @@ TEST_F(TransformationTestsF, ConvertMaxPool8ToMaxPool1) { } TEST_F(TransformationTestsF, ConvertMaxPool14ToMaxPool8_ceil_torch_to_ceil) { - model = create_v14_model(ov::op::RoundingType::CEIL_TORCH, ov::Shape{1, 3, 65, 65}); + model = create_v14_model(ov::op::RoundingType::CEIL_TORCH, ov::Shape{1, 3, 64, 64}); model_ref = create_ceil_torch_workaround_model(ov::op::RoundingType::CEIL); manager.register_pass(); comparator.disable(FunctionsComparator::CmpValues::ACCURACY); From b12dce2e150516966dff0c0b38e727a8ad7a68f5 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 23 Apr 2024 16:10:50 +0200 Subject: [PATCH 23/61] Apply CR --- .../convert_avgpool_downgrade.cpp | 17 +++++++++++------ .../convert_avgpool_downgrade.cpp | 2 +- .../convert_maxpool_downgrade_test.cpp | 2 -- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 1727f5fdf8e4b0..94b4d83da11a70 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -30,6 +30,7 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { NodeRegistry node_registry; ov::Shape pads_begin; ov::Shape pads_end; + ov::Output new_input; using ov::op::v0::Constant; using ov::op::v0::Concat; @@ -40,16 +41,18 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { using ov::op::v3::ShapeOf; if (!exclude_pad) { - const auto zero = Constant::create(element::f32, Shape{}, {0}); + const auto zero = node_registry.make(element::f32, Shape{}, 0); const auto zero_node = node_registry.make(zero, input); - const auto zero_i64 = Constant::create(element::i64, Shape{}, {0}); + const auto zero_i64 = node_registry.make(element::i64, Shape{}, 0); const auto shape = node_registry.make(input, element::i64); const auto rank = node_registry.make(shape, element::i64); const auto pads_begin_v14 = avg_pool_v14->get_pads_begin(); - const auto pads_begin_node = Constant::create(element::i64, Shape{pads_begin_v14.size()}, pads_begin_v14); + const auto pads_begin_node = + node_registry.make(element::i64, Shape{pads_begin_v14.size()}, pads_begin_v14); const auto pads_end_v14 = avg_pool_v14->get_pads_end(); - const auto pads_end_node = Constant::create(element::i64, Shape{pads_end_v14.size()}, pads_end_v14); - const auto pads_len = Constant::create(element::i64, Shape{}, {pads_begin_v14.size()}); + const auto pads_end_node = + node_registry.make(element::i64, Shape{pads_end_v14.size()}, pads_end_v14); + const auto pads_len = node_registry.make(element::i64, Shape{}, pads_begin_v14.size()); const auto pads_diff = node_registry.make(rank, pads_len); const auto pads_remaining = node_registry.make(zero_i64, pads_diff); const auto pads_begin_v1 = @@ -60,11 +63,13 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { node_registry.make(input, pads_begin_v1, pads_end_v1, zero_node, ov::op::PadMode::CONSTANT); pads_begin = Shape(pads_begin_v14.size(), 0); pads_end = Shape(pads_begin_v14.size(), 0); + new_input = pad_node; } else { pads_begin = avg_pool_v14->get_pads_begin(); pads_end = avg_pool_v14->get_pads_end(); + new_input = input; } - const auto avg_pool_v1 = node_registry.make(input, + const auto avg_pool_v1 = node_registry.make(new_input, avg_pool_v14->get_strides(), pads_begin, pads_end, diff --git a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp index 548e6b5faf2777..baa1f10b28c5c1 100644 --- a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp @@ -89,7 +89,7 @@ std::shared_ptr create_exclude_pad_workaround_model() { std::make_shared(input, pads_begin_v1, pads_end_v1, zero_node, ov::op::PadMode::CONSTANT); const auto pads_begin_zeros = ov::Shape{0, 0}; const auto pads_end_zeros = ov::Shape{0, 0}; - const auto avg_pool_v1 = std::make_shared(input, + const auto avg_pool_v1 = std::make_shared(pad_node, strides, pads_begin_zeros, pads_end_zeros, diff --git a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp index 8eccae191562e7..6a437beda64ea7 100644 --- a/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp +++ b/src/common/transformations/tests/op_conversions/convert_maxpool_downgrade_test.cpp @@ -140,8 +140,6 @@ std::shared_ptr create_ceil_torch_workaround_model(const ov::op::Roun ov::op::PadType::EXPLICIT, ov::element::i64, 2); - std::cout << "Workaround shape: " << max_pool_v8->get_output_partial_shape(0) << std::endl; - max_pool_v8->set_friendly_name("max_pool_v8_ceil_torch_workaround"); return std::make_shared(max_pool_v8->outputs(), ov::ParameterVector{input}); From 32cbea83ce3397b26ac02c8eb1df45a5d008bd8a Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Wed, 24 Apr 2024 11:30:36 +0200 Subject: [PATCH 24/61] Apply CR --- .../convert_avgpool_downgrade.cpp | 2 +- .../convert_maxpool_downgrade.cpp | 20 +++++++++---------- .../convert_avgpool_downgrade.cpp | 12 +++++++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 94b4d83da11a70..35cfa1ddda0fa0 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -40,7 +40,7 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { using ov::op::v3::Broadcast; using ov::op::v3::ShapeOf; - if (!exclude_pad) { + if (!exclude_pad && rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { const auto zero = node_registry.make(element::f32, Shape{}, 0); const auto zero_node = node_registry.make(zero, input); const auto zero_i64 = node_registry.make(element::i64, Shape{}, 0); diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 5e9f96105b64a4..c75d854aabe526 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -85,19 +85,19 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { auto input = max_pool_v14->input_value(0); const auto strides = max_pool_v14->get_strides(); const auto padding_begin = max_pool_v14->get_pads_begin(); - const auto padding_begin_node = Constant::create(element::i64, Shape{padding_begin.size()}, padding_begin); + const auto padding_begin_node = node_registry.make(element::i64, Shape{padding_begin.size()}, padding_begin); const auto padding_end = max_pool_v14->get_pads_end(); - const auto padding_end_node = Constant::create(element::i64, Shape{padding_end.size()}, padding_end); - const auto zero = Constant::create(element::i64, Shape{}, {0}); - const auto one = Constant::create(element::i64, Shape{}, {1}); - const auto two = Constant::create(element::i64, Shape{}, {2}); + const auto padding_end_node = node_registry.make(element::i64, Shape{padding_end.size()}, padding_end); + const auto zero = node_registry.make(element::i64, Shape{}, 0); + const auto one = node_registry.make(element::i64, Shape{}, 1); + const auto two = node_registry.make(element::i64, Shape{}, 2); const auto pads_size = max_pool_v14->get_pads_begin().size(); - const auto pads_len = Constant::create(element::i64, Shape{}, {pads_size}); - const auto pads_remaining = Constant::create(element::i64, Shape{2}, {0, 0}); + const auto pads_len = node_registry.make(element::i64, Shape{}, pads_size); + const auto pads_remaining = node_registry.make(element::i64, Shape{2}, std::vector{0, 0}); // gather input spatial dims and prepare for compare as values (in_dim + pad) - const auto end = Constant::create(element::i64, Shape{}, {pads_size + 2}); + const auto end = node_registry.make(element::i64, Shape{}, pads_size + 2); const auto dim_idxs = node_registry.make(two, end, one, element::i64); const auto shape = node_registry.make(input, element::i64); const auto gth_in_dims = node_registry.make(shape, dim_idxs, zero); @@ -114,7 +114,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto shape_of_mp = node_registry.make(mp, element::i64); const auto gth_out_dims = node_registry.make(shape_of_mp, dim_idxs, zero); const auto out_sub_one = node_registry.make(gth_out_dims, one); - const auto stride_node = Constant::create(element::i64, Shape{strides.size()}, strides); + const auto stride_node = node_registry.make(element::i64, Shape{strides.size()}, strides); const auto out_mul_stride = node_registry.make(out_sub_one, stride_node); // if (in_dim + pad) > ((out_dim - 1) * stride) sliding window in bound use end padding. @@ -125,7 +125,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto pb = node_registry.make(OutputVector{pads_remaining->output(0), padding_end_node}, 0); const auto pe = node_registry.make(OutputVector{pads_remaining, selected_pads}, 0); auto minus_inf = - Constant::create(element::f32, Shape{}, {-std::numeric_limits::infinity()})->output(0); + node_registry.make(element::f32, Shape{}, -std::numeric_limits::infinity()); std::shared_ptr convert_like_node = node_registry.make(minus_inf, input); const auto pad_node = node_registry.make(input, pb, pe, convert_like_node, op::PadMode::CONSTANT); auto pads_begin = max_pool_v14->get_pads_begin(); diff --git a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp index baa1f10b28c5c1..444df91b5bf27b 100644 --- a/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/tests/op_conversions/convert_avgpool_downgrade.cpp @@ -128,14 +128,22 @@ TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_floor_to_floor) { comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); } -TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_to_ceil_exclude_pad) { +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_torch_to_ceil_no_exclude_pad) { manager.register_pass(); - model = create_v14_model(ov::op::RoundingType::CEIL, false); + model = create_v14_model(ov::op::RoundingType::CEIL_TORCH, false); model_ref = create_exclude_pad_workaround_model(); comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); } +TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_ceil_torch_to_ceil_exclude_pad) { + manager.register_pass(); + model = create_v14_model(ov::op::RoundingType::CEIL_TORCH, true); + model_ref = create_v1_model(ov::op::RoundingType::CEIL); + comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES); + comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES); +} + TEST_F(TransformationTestsF, ConvertAvgPool14ToAvgPool1_incorrect_version) { manager.register_pass(); model = create_v1_model(ov::op::RoundingType::CEIL); From 05f817c9269854aead1f75ccc218bd047a4d65f9 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 25 Apr 2024 08:25:07 +0200 Subject: [PATCH 25/61] Clang format --- .../op_conversions/convert_maxpool_downgrade.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index c75d854aabe526..f80e7baeb9b0ed 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -85,16 +85,19 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { auto input = max_pool_v14->input_value(0); const auto strides = max_pool_v14->get_strides(); const auto padding_begin = max_pool_v14->get_pads_begin(); - const auto padding_begin_node = node_registry.make(element::i64, Shape{padding_begin.size()}, padding_begin); + const auto padding_begin_node = + node_registry.make(element::i64, Shape{padding_begin.size()}, padding_begin); const auto padding_end = max_pool_v14->get_pads_end(); - const auto padding_end_node = node_registry.make(element::i64, Shape{padding_end.size()}, padding_end); + const auto padding_end_node = + node_registry.make(element::i64, Shape{padding_end.size()}, padding_end); const auto zero = node_registry.make(element::i64, Shape{}, 0); const auto one = node_registry.make(element::i64, Shape{}, 1); const auto two = node_registry.make(element::i64, Shape{}, 2); const auto pads_size = max_pool_v14->get_pads_begin().size(); const auto pads_len = node_registry.make(element::i64, Shape{}, pads_size); - const auto pads_remaining = node_registry.make(element::i64, Shape{2}, std::vector{0, 0}); + const auto pads_remaining = + node_registry.make(element::i64, Shape{2}, std::vector{0, 0}); // gather input spatial dims and prepare for compare as values (in_dim + pad) const auto end = node_registry.make(element::i64, Shape{}, pads_size + 2); From 3cd7778c5b50e3975957e6728b2ff2fa7e3038f8 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 26 Apr 2024 11:27:27 +0200 Subject: [PATCH 26/61] Fix include errors --- .../op_conversions/convert_avgpool_downgrade.cpp | 8 +++++++- .../op_conversions/convert_maxpool_downgrade.cpp | 14 +++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 35cfa1ddda0fa0..1e53d0cef7f3d0 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -9,8 +9,13 @@ #include "openvino/op/avg_pool.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" +#include "openvino/op/convert_like.hpp" +#include "openvino/op/gather.hpp" #include "openvino/op/pad.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/select.hpp" #include "openvino/op/shape_of.hpp" +#include "openvino/op/subtract.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" @@ -39,6 +44,7 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { using ov::op::v1::ConvertLike; using ov::op::v3::Broadcast; using ov::op::v3::ShapeOf; + using ov::op::v4::Range; if (!exclude_pad && rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { const auto zero = node_registry.make(element::f32, Shape{}, 0); @@ -56,7 +62,7 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const auto pads_diff = node_registry.make(rank, pads_len); const auto pads_remaining = node_registry.make(zero_i64, pads_diff); const auto pads_begin_v1 = - node_registry.make(OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, 0); + node_registry.make(OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, 0); const auto pads_end_v1 = node_registry.make(OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, 0); const auto pad_node = diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index f80e7baeb9b0ed..8d35bc53421c99 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -6,8 +6,20 @@ #include "itt.hpp" #include "openvino/core/descriptor/tensor.hpp" -#include "openvino/core/rt_info.hpp" +#include "openvino/op/add.hpp" +#include "openvino/op/avg_pool.hpp" +#include "openvino/op/broadcast.hpp" +#include "openvino/op/concat.hpp" +#include "openvino/op/convert_like.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/greater.hpp" #include "openvino/op/max_pool.hpp" +#include "openvino/op/multiply.hpp" +#include "openvino/op/pad.hpp" +#include "openvino/op/range.hpp" +#include "openvino/op/select.hpp" +#include "openvino/op/shape_of.hpp" +#include "openvino/op/subtract.hpp" #include "openvino/pass/manager.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/pass/visualize_tree.hpp" From 35daa3a4310abce96158e2feb60a007906012ee5 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 26 Apr 2024 11:35:37 +0200 Subject: [PATCH 27/61] Minor change --- .../op_conversions/convert_avgpool_downgrade.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 1e53d0cef7f3d0..034fd681372143 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -61,10 +61,14 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const auto pads_len = node_registry.make(element::i64, Shape{}, pads_begin_v14.size()); const auto pads_diff = node_registry.make(rank, pads_len); const auto pads_remaining = node_registry.make(zero_i64, pads_diff); - const auto pads_begin_v1 = - node_registry.make(OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, 0); - const auto pads_end_v1 = - node_registry.make(OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, 0); + const auto pads_begin_v1 = node_registry.make( + OutputVector{std::move(pads_remaining), + std::move(pads_begin_node)}, + 0); + const auto pads_end_v1 = node_registry.make( + OutputVector{std::move(pads_remaining), + std::move(pads_begin_node)}, + 0); const auto pad_node = node_registry.make(input, pads_begin_v1, pads_end_v1, zero_node, ov::op::PadMode::CONSTANT); pads_begin = Shape(pads_begin_v14.size(), 0); From 460415692076dd9507d3b6883617ec5c4d88df1b Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 26 Apr 2024 11:40:23 +0200 Subject: [PATCH 28/61] Minor change --- .../convert_avgpool_downgrade.cpp | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 034fd681372143..491fd5b19a6740 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -62,13 +62,19 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const auto pads_diff = node_registry.make(rank, pads_len); const auto pads_remaining = node_registry.make(zero_i64, pads_diff); const auto pads_begin_v1 = node_registry.make( - OutputVector{std::move(pads_remaining), - std::move(pads_begin_node)}, - 0); - const auto pads_end_v1 = node_registry.make( - OutputVector{std::move(pads_remaining), - std::move(pads_begin_node)}, - 0); + OutputVector{ + std::move(pads_remaining), + std::move(pads_begin_node) + }, + 0 + ); + const auto pads_end_v1 = node_registry.make( + OutputVector{ + std::move(pads_remaining), + std::move(pads_begin_node) + }, + 0 + ); const auto pad_node = node_registry.make(input, pads_begin_v1, pads_end_v1, zero_node, ov::op::PadMode::CONSTANT); pads_begin = Shape(pads_begin_v14.size(), 0); From 070c111f29bf64ce0ef61a4328f2fe51d6ead1ea Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 26 Apr 2024 11:57:30 +0200 Subject: [PATCH 29/61] Fix linter --- .../op_conversions/convert_avgpool_downgrade.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp index 491fd5b19a6740..3333c1d6885f08 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_avgpool_downgrade.cpp @@ -62,19 +62,11 @@ ov::pass::ConvertAvgPool14ToAvgPool1::ConvertAvgPool14ToAvgPool1() { const auto pads_diff = node_registry.make(rank, pads_len); const auto pads_remaining = node_registry.make(zero_i64, pads_diff); const auto pads_begin_v1 = node_registry.make( - OutputVector{ - std::move(pads_remaining), - std::move(pads_begin_node) - }, - 0 - ); + OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, + 0); const auto pads_end_v1 = node_registry.make( - OutputVector{ - std::move(pads_remaining), - std::move(pads_begin_node) - }, - 0 - ); + OutputVector{std::move(pads_remaining), std::move(pads_begin_node)}, + 0); const auto pad_node = node_registry.make(input, pads_begin_v1, pads_end_v1, zero_node, ov::op::PadMode::CONSTANT); pads_begin = Shape(pads_begin_v14.size(), 0); From d11bfd15ba29debc6a1ae72f899662acdadc4f13 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 6 May 2024 16:14:12 +0200 Subject: [PATCH 30/61] Fix conflict --- .../custom/single_layer_tests/classes/pooling.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index e2e98b63a94e26..9a7e68e66357b8 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -299,12 +299,12 @@ const std::vector& paramsMax3D() { return paramsMax3D; } -const std::vector& paramsMaxV83D() { - static const std::vector paramsMaxV83D = { - maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, +const std::vector& paramsMaxV83D() { + static const std::vector paramsMaxV83D = { + maxPoolSpecificParams{ {2}, {2}, {1}, {0}, {0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, + maxPoolSpecificParams{ {7}, {2}, {1}, {2}, {2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, }; @@ -349,7 +349,7 @@ const std::vector& paramsMaxV84D() { maxPoolSpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + maxPoolSpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, }; @@ -464,7 +464,7 @@ const std::vector& paramsMaxV85D() { maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, + maxPoolSpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; From bfdf86a6b115a9b4dfcb7f48589bb3e758599e69 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 6 May 2024 16:14:17 +0200 Subject: [PATCH 31/61] Revert "Multiple fixes" This reverts commit a40d21a11e7f5fb91c2916a7f8879d85b5eafbf6. --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 30 +++- .../single_layer_tests/classes/pooling.cpp | 153 +++++++----------- .../single_layer_tests/classes/pooling.hpp | 31 ---- .../instances/common/pooling.cpp | 84 +--------- 4 files changed, 86 insertions(+), 212 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 909dff16c23055..5e4326ee1b4f19 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -208,16 +208,30 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c get_attributes(poolingAttrs.dilation, maxPoolOp_v8->get_dilations()); } else if (auto maxPoolOp_v1 = ov::as_type_ptr(op)) { poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - } else if (auto avgPoolOp = ov::as_type_ptr(op)) { + } else if (auto avgPoolOp_v1 = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp->get_rounding_type(); - get_attributes(poolingAttrs.stride, avgPoolOp->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp->get_pads_end()); + poolingAttrs.exclude_pad = avgPoolOp_v1->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOp_v1->get_rounding_type(); + + get_attributes(poolingAttrs.stride, avgPoolOp_v1->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOp_v1->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v1->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v1->get_pads_end()); + poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); + + poolingAttrs.auto_pad = (avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); + } else if (auto avgPoolOp_v14 = ov::as_type_ptr(op)) { + algorithm = Algorithm::PoolingAvg; + poolingAttrs.exclude_pad = avgPoolOp_v14->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOp_v14->get_rounding_type(); + + get_attributes(poolingAttrs.stride, avgPoolOp_v14->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOp_v14->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v14->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v14->get_pads_end()); poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - poolingAttrs.auto_pad = (avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp->get_auto_pad() == ov::op::PadType::SAME_UPPER); + + poolingAttrs.auto_pad = (avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); } poolingAttrs.algorithm = algorithm; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 9a7e68e66357b8..bfe10dd5afcba8 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -12,8 +12,7 @@ using namespace CPUTestUtils; namespace ov { namespace test { namespace util { -template -static std::string getTestCaseNameUtil(const TParamInfo& obj) { +static std::string getTestCaseNameUtil(const testing::TestParamInfo& obj) { maxPoolSpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; @@ -51,7 +50,7 @@ static std::string getTestCaseNameUtil(const TParamInfo& obj) { } template -void MaxPoolSetUpUtil(TTest* testInstance, +void SetUpUtil(TTest* testInstance, std::vector>& inFmts, std::vector>& outFmts, std::vector>& priority, @@ -98,62 +97,7 @@ void MaxPoolSetUpUtil(TTest* testInstance, ov::ResultVector results{std::make_shared(pooling->output(0))}; function = std::make_shared(results, params, "MaxPooling"); } -template -void AvgPoolSetUpUtil(TTest* testInstance, - std::vector>& inFmts, - std::vector>& outFmts, - std::vector>& priority, - std::string& selectedType, - std::shared_ptr& function, - std::vector& inputDynamicShapes, - std::shared_ptr postOpMgrPtr, - testing::internal::Strings fusedOps, - double& abs_threshold) { - poolSpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - bool isInt8; - CPUSpecificParams cpuParams; - fusingSpecificParams fusingParams; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = testInstance->GetParam(); - - utils::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; - - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - std::tie(postOpMgrPtr, fusedOps) = fusingParams; - - if (selectedType.empty()) { - auto selectedType = testInstance->getPrimitiveTypeUtil(); - } - if (isInt8) - selectedType = selectedType + "_I8"; - else - selectedType = CPUTestUtils::CPUTestsBase::makeSelectedTypeStr(selectedType, inPrc); - - testInstance->init_input_shapes_util({inputShapes}); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - - std::shared_ptr poolInput = params[0]; - if (isInt8) { - abs_threshold = 2e-2; - ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); - poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); - } - - auto pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); - function = testInstance->makeNgraphFunctionUtil(inPrc, params, pooling, "PoolingCPU"); -} -} // namespace util +} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -203,16 +147,56 @@ std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo(this, - inFmts, - outFmts, - priority, - selectedType, - function, - inputDynamicShapes, - postOpMgrPtr, - fusedOps, - abs_threshold); + + poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = this->GetParam(); + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + std::tie(postOpMgrPtr, fusedOps) = fusingParams; + + if (selectedType.empty()) { + selectedType = getPrimitiveType(); + } + if (isInt8) + selectedType = selectedType + "_I8"; + else + selectedType = makeSelectedTypeStr(selectedType, inPrc); + + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + + std::shared_ptr poolInput = params[0]; + if (isInt8) { + abs_threshold = 2e-2; + ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); + poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); + } + + std::shared_ptr pooling; + if (ov::test::utils::PoolingTypes::MAX == poolType) { + pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, roundingType, padType); + } else { + pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); + } + + function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( @@ -222,7 +206,7 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( void MaxPoolingV8LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - util::MaxPoolSetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); + util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); } std::string MaxPoolingV14LayerCPUTest::getTestCaseName( @@ -232,26 +216,7 @@ std::string MaxPoolingV14LayerCPUTest::getTestCaseName( void MaxPoolingV14LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - util::MaxPoolSetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); -} - -std::string AvgPoolingV14LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - return PoolingLayerCPUTest::getTestCaseName(obj); -} - -void AvgPoolingV14LayerCPUTest::SetUp() { - targetDevice = ov::test::utils::DEVICE_CPU; - util::AvgPoolSetUpUtil(this, - inFmts, - outFmts, - priority, - selectedType, - function, - inputDynamicShapes, - postOpMgrPtr, - fusedOps, - abs_threshold); + util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); } TEST_P(PoolingLayerCPUTest, CompareWithRefs) { @@ -259,11 +224,6 @@ TEST_P(PoolingLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } -TEST_P(AvgPoolingV14LayerCPUTest, CompareWithRefs) { - run(); - CheckPluginRelatedResults(compiledModel, "Pooling"); -} - TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -547,6 +507,7 @@ const std::vector& inputShapes4D_Large() { return inputShapes4D_Large; } + } // namespace Pooling } // namespace test -} // namespace ov +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 511aa5d28b62e8..13bb8433987f67 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -29,38 +29,7 @@ class PoolingLayerCPUTest : public testing::WithParamInterface& obj); - std::string getPrimitiveTypeUtil() const { - return CpuTestWithFusing::getPrimitiveType(); - } - void init_input_shapes_util(const std::vector &shapes) { - SubgraphBaseTest::init_input_shapes(shapes); - } - std::shared_ptr makeNgraphFunctionUtil(const ov::element::Type &ngPrc, - ov::ParameterVector ¶ms, - const std::shared_ptr &lastNode, - std::string name) { - return CPUTestUtils::CPUTestsBase::makeNgraphFunction(ngPrc, params, lastNode, name); - } -protected: - void SetUp() override; -}; -class AvgPoolingV14LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CpuTestWithFusing { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - std::string getPrimitiveTypeUtil() const { - return CpuTestWithFusing::getPrimitiveType(); - } - void init_input_shapes_util(const std::vector &shapes) { - SubgraphBaseTest::init_input_shapes(shapes); - } - std::shared_ptr makeNgraphFunctionUtil(const ov::element::Type &ngPrc, - ov::ParameterVector ¶ms, - const std::shared_ptr &lastNode, - std::string name) { - return CPUTestUtils::CPUTestsBase::makeNgraphFunction(ngPrc, params, lastNode, name); - } protected: void SetUp() override; }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 2722c3ca1bc5f7..eb40d776fdab0e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -36,7 +36,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg3D()), ::testing::ValuesIn(inputShapes3D()), @@ -46,7 +46,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg3D_RefOnly), ::testing::ValuesIn(inputShapes3D()), @@ -56,26 +56,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_3D_NotOptimized, PoolingLayerCPUTes ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg3D()), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_NotOptimized, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg3D_RefOnly), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - const std::vector paramsAvg4D_RefOnly = { poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, @@ -99,7 +79,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(vecCpuConfigs)), MaxPoolingV8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), ::testing::ValuesIn(inputShapes4D()), @@ -109,7 +89,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_RefOnly), ::testing::ValuesIn(inputShapes4D()), @@ -119,7 +99,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_4D_NotOptimized, PoolingLayerCPUTes ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_Large, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_Large()), ::testing::ValuesIn(inputShapes4D_Large()), @@ -129,36 +109,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D_RefOnly), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_Large, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D_Large()), - ::testing::ValuesIn(inputShapes4D_Large()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - const std::vector paramsMaxV85D_ref = { maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, @@ -220,7 +170,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::Values(expectedCpuConfig())), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D()), ::testing::ValuesIn(inputShapes5D()), @@ -230,7 +180,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D_NotOptimized, PoolingLayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D_RefOnly), ::testing::ValuesIn(inputShapes5D()), @@ -239,26 +189,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV1_CPU_5D_NotOptimized, PoolingLayerCPUTes ::testing::Values(expectedCpuConfig()), ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg5D()), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_NotOptimized, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg5D_RefOnly), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); #endif } // namespace Pooling } // namespace test From f63c285e0390c826b0ead7c591bab1d4afec68c3 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 6 May 2024 16:23:42 +0200 Subject: [PATCH 32/61] Revert "Update and refactor tests" This reverts commit 5a93d14215ed5cc48723e6bddc2510ae51adea5f. --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 7 +- .../single_layer_tests/classes/pooling.cpp | 187 ++++++++---------- .../single_layer_tests/classes/pooling.hpp | 31 +-- .../instances/common/pooling.cpp | 24 +-- .../instances/x64/pooling.cpp | 8 +- .../shared_test_classes/single_op/pooling.hpp | 4 +- .../src/single_op/pooling.cpp | 4 +- 7 files changed, 107 insertions(+), 158 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 5e4326ee1b4f19..19603263b8badb 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -142,7 +142,7 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& return desc; } -} // namespace +} // namespace bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { @@ -166,6 +166,11 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st errorMessage = "MaxPool and AvgPool from opset1 and MaxPool from opset8 are supported"; std::cout << "\n\nMaxPool and AvgPool from opset1 and MaxPool from opset8 are supported\n\n"; return false; + //} else if (!ov::is_type(op) && !ov::is_type(op)) { + // if (!Pooling::isCeilTorchSupported(op)) { + // errorMessage = "CEIL_TORCH rounding type is not supported in opsets lower than opset14"; + // return false; + // } } } catch (...) { std::cout << "\n\nRandom error\n\n"; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index bfe10dd5afcba8..791b942440f3b3 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,93 +11,7 @@ using namespace CPUTestUtils; namespace ov { namespace test { -namespace util { -static std::string getTestCaseNameUtil(const testing::TestParamInfo& obj) { - maxPoolSpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "MaxPool_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "D" << ov::test::utils::vec2str(dilation) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - - results << CPUTestsBase::getTestCaseName(cpuParams); - return results.str(); -} - -template -void SetUpUtil(TTest* testInstance, - std::vector>& inFmts, - std::vector>& outFmts, - std::vector>& priority, - std::string& selectedType, - std::shared_ptr& function, - std::vector& inputDynamicShapes) { - maxPoolSpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = testInstance->GetParam(); - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - if (selectedType.empty()) { - auto selectedType = testInstance->getPrimitiveTypeUtil(); - } - selectedType = testInstance->makeSelectedTypeStr(selectedType, inPrc); - - testInstance->init_input_shapes_util({inputShapes}); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - auto pooling = std::make_shared(params[0], - stride, - dilation, - padBegin, - padEnd, - kernel, - roundingType, - padType, - indexElementType, - axis); - pooling->get_rt_info() = testInstance->getCPUInfo(); - ov::ResultVector results{std::make_shared(pooling->output(0))}; - function = std::make_shared(results, params, "MaxPooling"); -} -} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -200,23 +114,85 @@ void PoolingLayerCPUTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - return util::getTestCaseNameUtil(obj); + const testing::TestParamInfo& obj) { + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); } void MaxPoolingV8LayerCPUTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; - util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); -} -std::string MaxPoolingV14LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { - return util::getTestCaseNameUtil(obj); -} + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); -void MaxPoolingV14LayerCPUTest::SetUp() { - targetDevice = ov::test::utils::DEVICE_CPU; - util::SetUpUtil(this, inFmts, outFmts, priority, selectedType, function, inputDynamicShapes); + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + if (selectedType.empty()) { + selectedType = getPrimitiveType(); + } + selectedType = makeSelectedTypeStr(selectedType, inPrc); + + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + auto pooling = std::make_shared(params[0], + stride, + dilation, + padBegin, + padEnd, + kernel, + roundingType, + padType, + indexElementType, + axis); + pooling->get_rt_info() = getCPUInfo(); + ov::ResultVector results{std::make_shared(pooling->output(0))}; + function = std::make_shared(results, params, "MaxPooling"); } TEST_P(PoolingLayerCPUTest, CompareWithRefs) { @@ -229,11 +205,6 @@ TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } -TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { - run(); - CheckPluginRelatedResults(compiledModel, "Pooling"); -} - namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool @@ -304,9 +275,9 @@ const std::vector& paramsMax4D() { return paramsMax4D; } -const std::vector& paramsMaxV84D() { - static const std::vector paramsMaxV84D = { - maxPoolSpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, +const std::vector& paramsMaxV84D() { + static const std::vector paramsMaxV84D = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, maxPoolSpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, @@ -419,9 +390,9 @@ const std::vector& inputShapes5D() { return inputShapes5D; } -const std::vector& paramsMaxV85D() { - static const std::vector paramsMaxV85D = { - maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, +const std::vector& paramsMaxV85D() { + static const std::vector paramsMaxV85D = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, maxPoolSpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 13bb8433987f67..e2ff6de2a87e06 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -13,6 +13,7 @@ using namespace CPUTestUtils; namespace ov { namespace test { + using poolLayerCpuTestParamsSet = std::tuple; -using maxPoolLayerCpuTestParamsSet = std::tuple; @@ -34,30 +35,18 @@ class PoolingLayerCPUTest : public testing::WithParamInterface, +class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - std::string getPrimitiveTypeUtil() const { - return CPUTestsBase::getPrimitiveType(); - } - void init_input_shapes_util(const std::vector &shapes) { - SubgraphBaseTest::init_input_shapes(shapes); - } + static std::string getTestCaseName(const testing::TestParamInfo& obj); protected: void SetUp() override; }; -class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { +class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CPUTestsBase { public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - std::string getPrimitiveTypeUtil() const { - return CPUTestsBase::getPrimitiveType(); - } - void init_input_shapes_util(const std::vector &shapes) { - SubgraphBaseTest::init_input_shapes(shapes); - } + static std::string getTestCaseName(const testing::TestParamInfo& obj); protected: void SetUp() override; }; @@ -70,9 +59,9 @@ const std::vector& paramsMax3D(); const std::vector& paramsAvg3D(); const std::vector& paramsMax4D(); -const std::vector& paramsMaxV83D(); -const std::vector& paramsMaxV84D(); -const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV83D(); +const std::vector& paramsMaxV84D(); +const std::vector& paramsMaxV85D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index eb40d776fdab0e..6148cc6ba6fc80 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -109,14 +109,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); -const std::vector paramsMaxV85D_ref = { - maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, +const std::vector paramsMaxV85D_ref = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolSpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolSpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, + maxPoolV8SpecificParams{ {2, 3, 4}, {2, 2, 2}, {2, 1, 1}, {1, 1, 1}, {1, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; @@ -154,22 +154,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, ::testing::Values(expectedCpuConfig())), MaxPoolingV8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV85D()), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(vecCpuConfigs)), - MaxPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV85D_ref), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(expectedCpuConfig())), - MaxPoolingV14LayerCPUTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D()), diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index d218dc049ea09e..68fd3b6272fa9a 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -21,14 +21,14 @@ const auto sse42 = CPUSpecificParams{{}, {}, {"jit_sse42"}, "jit_sse42"}; const std::vector vecCpuConfigs = {sse42, avx, avx512}; -const std::vector paramsMaxV84D_ref = { - maxPoolSpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, +const std::vector paramsMaxV84D_ref = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_UPPER }, - maxPoolSpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, + maxPoolV8SpecificParams{ {4, 2}, {2, 2}, {1, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolSpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, + maxPoolV8SpecificParams{ {4, 2}, {2, 1}, {2, 2}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp index c564118519bc46..8cd5bd88c5d032 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/pooling.hpp @@ -41,10 +41,10 @@ typedef std::tuple< int64_t, // Axis ov::op::RoundingType, // Rounding type ov::op::PadType // Pad type -> maxPoolSpecificParams; +> maxPoolV8SpecificParams; typedef std::tuple< - maxPoolSpecificParams, + maxPoolV8SpecificParams, ov::element::Type, // Model type std::vector, // Input shape std::string // Device name diff --git a/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp index f868c3c3272f87..40dcea4a4b8668 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/pooling.cpp @@ -90,7 +90,7 @@ void PoolingLayerTest::SetUp() { std::string MaxPoolingV8LayerTest::getTestCaseName(const testing::TestParamInfo& obj) { - maxPoolSpecificParams pool_params; + maxPoolV8SpecificParams pool_params; ov::element::Type model_type; std::vector shapes; std::string target_device; @@ -131,7 +131,7 @@ std::string MaxPoolingV8LayerTest::getTestCaseName(const testing::TestParamInfo< } void MaxPoolingV8LayerTest::SetUp() { - maxPoolSpecificParams pool_params; + maxPoolV8SpecificParams pool_params; ov::element::Type model_type; std::vector shapes; std::tie(pool_params, model_type, shapes, targetDevice) = this->GetParam(); From 133410fa6098e355235094a07abd79305ae3c10f Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 6 May 2024 17:32:52 +0200 Subject: [PATCH 33/61] Debug --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 2 +- .../single_layer_tests/classes/pooling.cpp | 102 ++++++- .../instances/common/pooling.cpp | 248 ++++++++++-------- 3 files changed, 227 insertions(+), 125 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 19603263b8badb..d17d15630a4316 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -142,7 +142,7 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& return desc; } -} // namespace +} // namespace bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 791b942440f3b3..54228aa9c6bc2c 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -195,6 +195,88 @@ void MaxPoolingV8LayerCPUTest::SetUp() { function = std::make_shared(results, params, "MaxPooling"); } +std::string MaxPoolingV14LayerCPUTest::getTestCaseName( + const testing::TestParamInfo& obj) { + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); +} + +void MaxPoolingV14LayerCPUTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + if (selectedType.empty()) { + selectedType = getPrimitiveType(); + } + selectedType = makeSelectedTypeStr(selectedType, inPrc); + + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + auto pooling = std::make_shared(params[0], + stride, + dilation, + padBegin, + padEnd, + kernel, + roundingType, + padType, + indexElementType, + axis); + pooling->get_rt_info() = getCPUInfo(); + ov::ResultVector results{std::make_shared(pooling->output(0))}; + function = std::make_shared(results, params, "MaxPooling"); +} + TEST_P(PoolingLayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -205,6 +287,11 @@ TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Pooling"); +} + namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool @@ -230,12 +317,12 @@ const std::vector& paramsMax3D() { return paramsMax3D; } -const std::vector& paramsMaxV83D() { - static const std::vector paramsMaxV83D = { - maxPoolSpecificParams{ {2}, {2}, {1}, {0}, {0}, +const std::vector& paramsMaxV83D() { + static const std::vector paramsMaxV83D = { + maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolSpecificParams{ {7}, {2}, {1}, {2}, {2}, + maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, }; @@ -280,7 +367,7 @@ const std::vector& paramsMaxV84D() { maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolSpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, }; @@ -395,7 +482,7 @@ const std::vector& paramsMaxV85D() { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolSpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, + maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, }; @@ -478,7 +565,6 @@ const std::vector& inputShapes4D_Large() { return inputShapes4D_Large; } - } // namespace Pooling } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 6148cc6ba6fc80..0e441722f50d7e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -26,88 +26,88 @@ const std::vector paramsAvg3D_RefOnly = { expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, }; -INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMax3D()), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg3D()), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg3D_RefOnly), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -const std::vector paramsAvg4D_RefOnly = { - poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, -}; - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMax4D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV84D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(vecCpuConfigs)), - MaxPoolingV8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D_RefOnly), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg4D_Large()), - ::testing::ValuesIn(inputShapes4D_Large()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMax3D()), +// ::testing::ValuesIn(inputShapes3D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg3D()), +// ::testing::ValuesIn(inputShapes3D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg3D_RefOnly), +// ::testing::ValuesIn(inputShapes3D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::Values(expectedCpuConfig()), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//const std::vector paramsAvg4D_RefOnly = { +// poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, +// expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, +//}; +// +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMax4D()), +// ::testing::ValuesIn(inputShapes4D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMaxV84D()), +// ::testing::ValuesIn(inputShapes4D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::ValuesIn(vecCpuConfigs)), +// MaxPoolingV8LayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg4D()), +// ::testing::ValuesIn(inputShapes4D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg4D_RefOnly), +// ::testing::ValuesIn(inputShapes4D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::Values(expectedCpuConfig()), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg4D_Large()), +// ::testing::ValuesIn(inputShapes4D_Large()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); const std::vector paramsMaxV85D_ref = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, @@ -128,51 +128,67 @@ const std::vector paramsAvg5D_RefOnly = { //FIXME: 5D cases are temporarly disabled on ARM because ACL support check in Pooling::getSupportedDescriptors() can't check layout #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) -INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMax5D()), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMax5D()), +// ::testing::ValuesIn(inputShapes5D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMaxV85D()), +// ::testing::ValuesIn(inputShapes5D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::ValuesIn(vecCpuConfigs)), +// MaxPoolingV8LayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsMaxV85D_ref), +// ::testing::ValuesIn(inputShapes5D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(expectedCpuConfig())), +// MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV85D()), ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(vecCpuConfigs)), - MaxPoolingV8LayerCPUTest::getTestCaseName); + MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV85D_ref), ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(expectedCpuConfig())), - MaxPoolingV8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg5D()), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvg5D_RefOnly), - ::testing::ValuesIn(inputShapes5D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); + MaxPoolingV14LayerCPUTest::getTestCaseName); + +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg5D()), +// ::testing::ValuesIn(inputShapes5D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::ValuesIn(vecCpuConfigs), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); +// +//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, +// ::testing::Combine( +// ::testing::ValuesIn(paramsAvg5D_RefOnly), +// ::testing::ValuesIn(inputShapes5D()), +// ::testing::ValuesIn((inpOutPrecision())), +// ::testing::Values(false), +// ::testing::Values(expectedCpuConfig()), +// ::testing::Values(emptyFusingSpec)), +// PoolingLayerCPUTest::getTestCaseName); #endif } // namespace Pooling } // namespace test From 3faec3358f2425048c07644de280c277766c7946 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Wed, 22 May 2024 09:33:00 +0200 Subject: [PATCH 34/61] Progress --- .../convert_maxpool_downgrade.cpp | 9 +- .../convert_maxpool_downgrade_test.cpp | 2 +- src/plugins/intel_cpu/src/nodes/pooling.cpp | 18 +- .../single_layer_tests/classes/pooling.cpp | 124 ++++++++- .../single_layer_tests/classes/pooling.hpp | 12 +- .../instances/common/pooling.cpp | 254 +++++++++--------- .../src/base/utils/generate_inputs.cpp | 1 + 7 files changed, 269 insertions(+), 151 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 6914c28ec6027e..4ea7b15b7d673f 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -112,7 +112,12 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto pads_len = node_registry.make(element::i64, Shape{}, pads_size); const auto pads_remaining = node_registry.make(element::i64, Shape{2}, std::vector{0, 0}); - + for(int i = 0; i < padding_begin.size(); i++) { + std::cout << "\n" << padding_begin[i] << " "; + } + for(int i = 0; i < padding_end.size(); i++) { + std::cout << "\n" << padding_end[i] << " "; + } // gather input spatial dims and prepare for compare as values (in_dim + pad) const auto end = node_registry.make(element::i64, Shape{}, pads_size + 2); const auto dim_idxs = node_registry.make(two, end, one, element::i64); @@ -139,7 +144,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto selected_pads = node_registry.make(in_gt_out, padding_end_node, zero); // apply padding on input clear pads attribute - const auto pb = std::make_shared(ov::OutputVector{pads_remaining, padding_end_node}, 0); + const auto pb = std::make_shared(ov::OutputVector{pads_remaining, padding_begin_node}, 0); const auto pe = std::make_shared(ov::OutputVector{pads_remaining, selected_pads}, 0); auto minus_inf = Constant::create(ov::element::f32, ov::Shape{}, {-std::numeric_limits::infinity()}); std::shared_ptr convert_like_node = std::make_shared(minus_inf, input); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 630f4eef1fd995..90921642436a1a 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,37 +146,21 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const bool v1op = ov::is_type(op); - const bool v8op = ov::is_type(op); - const bool v14op = ov::is_type(op); - std::cout << "\n\nThe op is v1 type: " << v1op; - std::cout << "\nThe op is v8 type: " << v8op; - std::cout << "\nThe op is v14 type: " << v14op << "\n\n"; if (ov::is_type(op)) { return false; } if (ov::is_type(op) || ov::is_type(op)) { - std::cout << "\n\nIt's v8 or v14\n\n"; if (!op->get_output_target_inputs(1).empty()) { errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; - std::cout << "\n\nOnly one input supported\n\n"; return false; } } else if (!ov::is_type(op) && !ov::is_type(op)) { - errorMessage = "MaxPool and AvgPool from opset1 and MaxPool from opset8 are supported"; - std::cout << "\n\nMaxPool and AvgPool from opset1 and MaxPool from opset8 are supported\n\n"; + errorMessage = "Supported ops are MaxPool-1, MaxPool-8, MaxPool-14, AvgPool-1 and AvgPool-14"; return false; - //} else if (!ov::is_type(op) && !ov::is_type(op)) { - // if (!Pooling::isCeilTorchSupported(op)) { - // errorMessage = "CEIL_TORCH rounding type is not supported in opsets lower than opset14"; - // return false; - // } } } catch (...) { - std::cout << "\n\nRandom error\n\n"; return false; } - std::cout << "\n\nCPU implementation used\n\n"; return true; } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 54228aa9c6bc2c..fb598425962c10 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -295,11 +295,11 @@ TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool -const ov::op::RoundingType expectedAvgRoundingType() { +const ov::op::RoundingType expectedAvgRoundingType(const ov::op::RoundingType ceil_type) { #if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64) return ov::op::RoundingType::FLOOR; #else - return ov::op::RoundingType::CEIL; + return ceil_type; #endif } @@ -329,6 +329,24 @@ const std::vector& paramsMaxV83D() { return paramsMaxV83D; } +const std::vector& paramsMaxV143D() { + static const std::vector paramsMaxV143D = { + maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, + maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT}, + }; + return paramsMaxV143D; +} + const std::vector& paramsAvg3D() { static const std::vector paramsAvg3D = { poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, @@ -341,6 +359,22 @@ const std::vector& paramsAvg3D() { return paramsAvg3D; } +const std::vector& paramsAvgV143D() { + static const std::vector paramsAvgV143D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + }; + return paramsAvgV143D; +} + const std::vector& inpOutPrecision() { static const std::vector inpOutPrecision = {ElementType::f32/*, ElementType::bf16*/}; return inpOutPrecision; @@ -374,6 +408,24 @@ const std::vector& paramsMaxV84D() { return paramsMaxV84D; } +const std::vector& paramsMaxV144D() { + static const std::vector paramsMaxV144D = { + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT}, + }; + return paramsMaxV144D; +} + const std::vector& inputShapes3D() { static const std::vector inputShapes3D = { { {}, {{3, 4, 64}} }, @@ -489,6 +541,24 @@ const std::vector& paramsMaxV85D() { return paramsMaxV85D; } +const std::vector& paramsMaxV145D() { + static const std::vector paramsMaxV145D = { + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT }, + }; + return paramsMaxV145D; +} + const std::vector& paramsAvg4D() { static const std::vector paramsAvg4D = { poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, @@ -507,6 +577,30 @@ const std::vector& paramsAvg4D() { return paramsAvg4D; } +const std::vector& paramsAvgV144D() { + static const std::vector paramsAvgV144D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + }; + return paramsAvgV144D; +} + const std::vector& paramsAvg5D() { static const std::vector paramsAvg5D = { poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, @@ -527,6 +621,32 @@ const std::vector& paramsAvg5D() { return paramsAvg5D; } +const std::vector& paramsAvgV145D() { + static const std::vector paramsAvgV145D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + }; + return paramsAvgV145D; +} + const std::vector& paramsMax5D() { static const std::vector paramsMax5D = { poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index e2ff6de2a87e06..aac2cd2e15b97c 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -53,24 +53,32 @@ class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface& inpOutPrecision(); -const ov::op::RoundingType expectedAvgRoundingType(); +const ov::op::RoundingType expectedAvgRoundingType(const ov::op::RoundingType ceil_type = ov::op::RoundingType::CEIL); -const std::vector& paramsMax3D(); const std::vector& paramsAvg3D(); +const std::vector& paramsAvgV143D(); + +const std::vector& paramsMax3D(); const std::vector& paramsMax4D(); const std::vector& paramsMaxV83D(); const std::vector& paramsMaxV84D(); const std::vector& paramsMaxV85D(); +const std::vector& paramsMaxV143D(); +const std::vector& paramsMaxV144D(); +const std::vector& paramsMaxV145D(); + const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); const std::vector& paramsAvg4D(); +const std::vector& paramsAvgV144D(); const std::vector& paramsAvg4D_Large(); const std::vector& paramsAvg5D(); +const std::vector& paramsAvgV145D(); const std::vector& paramsMax5D(); } // namespace Pooling } // namespace test diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 0e441722f50d7e..c0059c4d1b85ab 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -26,88 +26,88 @@ const std::vector paramsAvg3D_RefOnly = { expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, }; -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMax3D()), -// ::testing::ValuesIn(inputShapes3D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg3D()), -// ::testing::ValuesIn(inputShapes3D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg3D_RefOnly), -// ::testing::ValuesIn(inputShapes3D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::Values(expectedCpuConfig()), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//const std::vector paramsAvg4D_RefOnly = { -// poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, -// expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, -//}; -// -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMax4D()), -// ::testing::ValuesIn(inputShapes4D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMaxV84D()), -// ::testing::ValuesIn(inputShapes4D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::ValuesIn(vecCpuConfigs)), -// MaxPoolingV8LayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg4D()), -// ::testing::ValuesIn(inputShapes4D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg4D_RefOnly), -// ::testing::ValuesIn(inputShapes4D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::Values(expectedCpuConfig()), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg4D_Large()), -// ::testing::ValuesIn(inputShapes4D_Large()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMax3D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D_RefOnly), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +const std::vector paramsAvg4D_RefOnly = { + poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, + expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, +}; + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMax4D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV84D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(vecCpuConfigs)), + MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_RefOnly), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_Large()), + ::testing::ValuesIn(inputShapes4D_Large()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); const std::vector paramsMaxV85D_ref = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, @@ -128,38 +128,38 @@ const std::vector paramsAvg5D_RefOnly = { //FIXME: 5D cases are temporarly disabled on ARM because ACL support check in Pooling::getSupportedDescriptors() can't check layout #if defined(OPENVINO_ARCH_X86) || defined(OPENVINO_ARCH_X86_64) -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMax5D()), -// ::testing::ValuesIn(inputShapes5D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMaxV85D()), -// ::testing::ValuesIn(inputShapes5D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::ValuesIn(vecCpuConfigs)), -// MaxPoolingV8LayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsMaxV85D_ref), -// ::testing::ValuesIn(inputShapes5D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(expectedCpuConfig())), -// MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMax5D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV85D()), ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(vecCpuConfigs)), + MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV85D_ref), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(expectedCpuConfig())), + MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(vecCpuConfigs)), MaxPoolingV14LayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, @@ -170,25 +170,25 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::Values(expectedCpuConfig())), MaxPoolingV14LayerCPUTest::getTestCaseName); -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg5D()), -// ::testing::ValuesIn(inputShapes5D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::ValuesIn(vecCpuConfigs), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); -// -//INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, -// ::testing::Combine( -// ::testing::ValuesIn(paramsAvg5D_RefOnly), -// ::testing::ValuesIn(inputShapes5D()), -// ::testing::ValuesIn((inpOutPrecision())), -// ::testing::Values(false), -// ::testing::Values(expectedCpuConfig()), -// ::testing::Values(emptyFusingSpec)), -// PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D_RefOnly), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); #endif } // namespace Pooling } // namespace test diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index 55259b81f8f1c5..12053d03a2ae8a 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -1124,6 +1124,7 @@ InputsMap getInputMap() { #include "openvino/opsets/opset11_tbl.hpp" #include "openvino/opsets/opset12_tbl.hpp" #include "openvino/opsets/opset13_tbl.hpp" +#include "openvino/opsets/opset14_tbl.hpp" #include "ov_ops/opset_private_tbl.hpp" #undef _OPENVINO_OP_REG From ecd96dd7ee38004dd93e241bb45eb5fc0310c114 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 14:44:28 +0200 Subject: [PATCH 35/61] Add and fix tests --- .../convert_maxpool_downgrade.cpp | 9 +- src/plugins/intel_cpu/src/nodes/pooling.cpp | 2 +- .../single_layer_tests/classes/pooling.cpp | 151 +++++++++++++++++- .../single_layer_tests/classes/pooling.hpp | 13 ++ .../instances/common/pooling.cpp | 80 +++++++++- 5 files changed, 244 insertions(+), 11 deletions(-) diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index 4ea7b15b7d673f..e32ffdb48c943f 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -93,7 +93,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { std::shared_ptr max_pool_v8; NodeRegistry node_registry; if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { - if (max_pool_v14->is_dynamic()) { + if (max_pool_v14->is_dynamic() || max_pool_v14->get_input_partial_shape(0).is_dynamic()) { return false; } auto input = max_pool_v14->input_value(0); @@ -112,12 +112,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { const auto pads_len = node_registry.make(element::i64, Shape{}, pads_size); const auto pads_remaining = node_registry.make(element::i64, Shape{2}, std::vector{0, 0}); - for(int i = 0; i < padding_begin.size(); i++) { - std::cout << "\n" << padding_begin[i] << " "; - } - for(int i = 0; i < padding_end.size(); i++) { - std::cout << "\n" << padding_end[i] << " "; - } + // gather input spatial dims and prepare for compare as values (in_dim + pad) const auto end = node_registry.make(element::i64, Shape{}, pads_size + 2); const auto dim_idxs = node_registry.make(two, end, one, element::i64); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 90921642436a1a..33c214a5832a6e 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,7 +146,7 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (ov::is_type(op)) { + if (ov::is_type(op) || ov::is_type(op)) { return false; } if (ov::is_type(op) || ov::is_type(op)) { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index fb598425962c10..07f13130dd1b56 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -113,6 +113,95 @@ void PoolingLayerCPUTest::SetUp() { function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); } +std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { + ov::test::poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = obj.param; + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "AvgPool_"; + results << "ExcludePad=" << excludePad << "_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + results << "INT8=" << isInt8 << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + results << CpuTestWithFusing::getTestCaseName(fusingParams); + return results.str(); +} + +void AvgPoolingV14LayerCPUTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + + poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = this->GetParam(); + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + std::tie(postOpMgrPtr, fusedOps) = fusingParams; + + if (selectedType.empty()) { + selectedType = getPrimitiveType(); + } + if (isInt8) + selectedType = selectedType + "_I8"; + else + selectedType = makeSelectedTypeStr(selectedType, inPrc); + + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + + std::shared_ptr poolInput = params[0]; + if (isInt8) { + abs_threshold = 2e-2; + ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); + poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); + } + + auto pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); + + function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); +} + std::string MaxPoolingV8LayerCPUTest::getTestCaseName( const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; @@ -282,6 +371,11 @@ TEST_P(PoolingLayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(AvgPoolingV14LayerCPUTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Pooling"); +} + TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -457,6 +551,37 @@ const std::vector& inputShapes3D() { return inputShapes3D; } +const std::vector& inputShapes3DCeilTorch() { + static const std::vector inputShapes3D = { + { {}, {{3, 4, 64}} }, + { {}, {{2, 8, 12}} }, + { {}, {{1, 16, 12}} }, + { {}, {{1, 21, 4}} }, + { {}, {{1, 32, 8}} }, + { + // dynamic + {-1, -1, -1}, + // target + { + {1, 32, 8}, + {1, 21, 4}, + {2, 8, 12} + } + }, + { + // dynamic + {{1, 5}, {4, 32}, {1, 64}}, + // target + { + {3, 4, 64}, + {1, 16, 12}, + {1, 32, 8} + } + } + }; + return inputShapes3D; +} + const std::vector& inputShapes4D() { static const std::vector inputShapes4D = { { {}, {{3, 4, 64, 64}} }, @@ -498,6 +623,17 @@ const std::vector& inputShapes4D() { return inputShapes4D; } +const std::vector& inputShapes4DCeilTorch() { + static const std::vector inputShapes4DCeilTorch = { + { {}, {{3, 4, 64, 64}} }, + { {}, {{2, 8, 8, 12}} }, + { {}, {{1, 16, 16, 12}} }, + { {}, {{1, 21, 8, 4}} }, + { {}, {{1, 32, 8, 8}} }, + }; + return inputShapes4DCeilTorch; +} + const std::vector& inputShapes5D() { static const std::vector inputShapes5D = { { {}, {{1, 4, 16, 16, 16}} }, @@ -529,6 +665,17 @@ const std::vector& inputShapes5D() { return inputShapes5D; } +const std::vector& inputShapes5DCeilTorch() { + static const std::vector inputShapes5D = { + { {}, {{1, 4, 16, 16, 16}} }, + { {}, {{2, 8, 8, 8, 8}} }, + { {}, {{2, 16, 12, 16, 20}} }, + { {}, {{1, 19, 16, 20, 8}} }, + { {}, {{1, 32, 16, 8, 12}} }, + }; + return inputShapes5D; +} + const std::vector& paramsMaxV85D() { static const std::vector paramsMaxV85D = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, @@ -542,7 +689,7 @@ const std::vector& paramsMaxV85D() { } const std::vector& paramsMaxV145D() { - static const std::vector paramsMaxV145D = { + static const std::vector paramsMaxV145DCeilTorch = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, @@ -556,7 +703,7 @@ const std::vector& paramsMaxV145D() { ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT }, }; - return paramsMaxV145D; + return paramsMaxV145DCeilTorch; } const std::vector& paramsAvg4D() { diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index aac2cd2e15b97c..082558e327cc72 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -35,6 +35,15 @@ class PoolingLayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CpuTestWithFusing { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: @@ -70,9 +79,12 @@ const std::vector& paramsMaxV144D(); const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); +const std::vector& inputShapes3DCeilTorch(); const std::vector& inputShapes4D(); +const std::vector& inputShapes4DCeilTorch(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); +const std::vector& inputShapes5DCeilTorch(); const std::vector& paramsAvg4D(); const std::vector& paramsAvgV144D(); @@ -80,6 +92,7 @@ const std::vector& paramsAvg4D_Large(); const std::vector& paramsAvg5D(); const std::vector& paramsAvgV145D(); const std::vector& paramsMax5D(); + } // namespace Pooling } // namespace test } // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index c0059c4d1b85ab..2b4cad746ac7dc 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -56,6 +56,26 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvgV143D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D_RefOnly), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + const std::vector paramsAvg4D_RefOnly = { poolSpecificParams{ ov::test::utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {2, 2}, {2, 2}, expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, false }, @@ -100,6 +120,36 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_NotOptimized, PoolingLayerCPUTest, PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_Large()), + ::testing::ValuesIn(inputShapes4D_Large()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvgV144D()), + ::testing::ValuesIn(inputShapes4DCeilTorch()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_RefOnly), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_Large, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_Large()), ::testing::ValuesIn(inputShapes4D_Large()), @@ -156,12 +206,20 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_ref, MaxPoolingV8LayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Combine( - ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(paramsMaxV85D()), ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(vecCpuConfigs)), MaxPoolingV14LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ceil_torch, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5DCeilTorch()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(vecCpuConfigs)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV85D_ref), @@ -180,6 +238,16 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvgV145D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(vecCpuConfigs), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D_RefOnly), @@ -189,6 +257,16 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Values(expectedCpuConfig()), ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_NotOptimized, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D_RefOnly), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(expectedCpuConfig()), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerCPUTest::getTestCaseName); #endif } // namespace Pooling } // namespace test From 0cd522c83ee5ee936e178ef3a97d43baa38a126d Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 14:52:25 +0200 Subject: [PATCH 36/61] Cleanup --- .../common_optimizations/common_optimizations.cpp | 1 - .../op_conversions/convert_maxpool_downgrade.cpp | 12 +++++------- src/plugins/intel_cpu/src/nodes/pooling.cpp | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index b6b2a179daab66..8e3ccc160d6978 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -210,7 +210,6 @@ bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr(); + matcher_pass_callback callback = [=](pattern::Matcher& m) { auto maxpool_v8_node = std::dynamic_pointer_cast(m.get_match_root()); - if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) { + if (!maxpool_v8_node || maxpool_v8_node->get_output_target_inputs(1).size() != 0) return false; - } - for (auto dilation : maxpool_v8_node->get_dilations()) { - if (dilation != 1) { + for (auto dilation : maxpool_v8_node->get_dilations()) + if (dilation != 1) return false; - } - } auto maxpool_v1_node = std::make_shared(maxpool_v8_node->input_value(0), maxpool_v8_node->get_strides(), @@ -93,7 +91,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { std::shared_ptr max_pool_v8; NodeRegistry node_registry; if (rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH) { - if (max_pool_v14->is_dynamic() || max_pool_v14->get_input_partial_shape(0).is_dynamic()) { + if (max_pool_v14->is_dynamic()) { return false; } auto input = max_pool_v14->input_value(0); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 160e0d9aee3e19..fd8f5bdfc66a96 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -147,6 +147,7 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { if (ov::is_type(op) || ov::is_type(op)) { + errorMessage = "ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes"; return false; } if (ov::is_type(op) || ov::is_type(op)) { From 1742883fcc1f677185cf3a640a7bb52ba8b9f34c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 15:02:19 +0200 Subject: [PATCH 37/61] Minor change --- .../custom/single_layer_tests/instances/common/pooling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index fce5ad5d5c67ce..9b0fe8e65d8476 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -66,7 +66,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_NotOptimized, AvgPoolingV14Laye ::testing::ValuesIn(inputShapes3D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), + ::testing::Values(expectedCpuConfigAnyLayout()), ::testing::Values(emptyFusingSpec)), AvgPoolingV14LayerCPUTest::getTestCaseName); @@ -139,7 +139,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14Laye ::testing::ValuesIn(inputShapes4D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), + ::testing::Values(expectedCpuConfigAnyLayout()), ::testing::Values(emptyFusingSpec)), AvgPoolingV14LayerCPUTest::getTestCaseName); From beb87e895b5c8b1b79a8aade9fad50bf6f670f54 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 15:22:59 +0200 Subject: [PATCH 38/61] Test fix --- .../custom/single_layer_tests/instances/common/pooling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 9b0fe8e65d8476..e11c2252c7b3fe 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -219,7 +219,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ref, MaxPoolingV14LayerCPUTest, ::testing::ValuesIn(paramsMaxV85D_ref), ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(expectedCpuConfig())), + ::testing::Values(expectedCpuConfigAnyLayout())), MaxPoolingV14LayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, @@ -258,7 +258,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_NotOptimized, AvgPoolingV14Laye ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), - ::testing::Values(expectedCpuConfig()), + ::testing::Values(expectedCpuConfigAnyLayout()), ::testing::Values(emptyFusingSpec)), AvgPoolingV14LayerCPUTest::getTestCaseName); #endif From b22988b1af029651ab0b8b2a85014793d95f0d96 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 15:43:48 +0200 Subject: [PATCH 39/61] Add x64 tests --- .../instances/x64/pooling.cpp | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 753b671dd7bace..a6f079b5b4b806 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -161,6 +161,40 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_3D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D))), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV143D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D))), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMax4D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D)), + ::testing::Values(emptyFusingSpec)), + PoolingLayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV84D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D))), + MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV144D()), + ::testing::ValuesIn(inputShapes4DCeilTorch()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D))), + MaxPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax5D()), @@ -178,6 +212,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D))), MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5DCeilTorch()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D))), + MaxPoolingV14LayerCPUTest::getTestCaseName); } // namespace } // namespace Pooling } // namespace test From 2a89ec2860c11d65cecaf0d66872ccec905bff31 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 16:00:17 +0200 Subject: [PATCH 40/61] Add version info to test name --- .../functional/custom/single_layer_tests/classes/pooling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index beae80154a39aa..c20031c1badf39 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -138,7 +138,7 @@ std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamI results << ov::test::utils::vec2str(shape) << "_"; } results << "Prc=" << inPrc << "_"; - results << "AvgPool_"; + results << "AvgPoolV14_"; results << "ExcludePad=" << excludePad << "_"; results << "K" << ov::test::utils::vec2str(kernel) << "_"; results << "S" << ov::test::utils::vec2str(stride) << "_"; From 978554363ddcc7ac9c6d0e4342b65a4d2e5bc997 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 23 May 2024 16:16:36 +0200 Subject: [PATCH 41/61] Remove x64 specific tests --- .../instances/x64/pooling.cpp | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index a6f079b5b4b806..753b671dd7bace 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -161,40 +161,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_3D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D))), MaxPoolingV8LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV143D()), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D))), - MaxPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMax4D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D)), - ::testing::Values(emptyFusingSpec)), - PoolingLayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV84D()), - ::testing::ValuesIn(inputShapes4D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D))), - MaxPoolingV8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV144D()), - ::testing::ValuesIn(inputShapes4DCeilTorch()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_4D))), - MaxPoolingV14LayerCPUTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax5D()), @@ -212,14 +178,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D))), MaxPoolingV8LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV145D()), - ::testing::ValuesIn(inputShapes5DCeilTorch()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D))), - MaxPoolingV14LayerCPUTest::getTestCaseName); } // namespace } // namespace Pooling } // namespace test From e8679a765370cbbf3e5dafaa17bf8b296867f372 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 24 May 2024 10:53:30 +0200 Subject: [PATCH 42/61] Fix duplicate tests issue --- .../single_layer_tests/classes/pooling.cpp | 39 +------------------ .../single_layer_tests/classes/pooling.hpp | 1 - 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index c20031c1badf39..10e260dac76f2f 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -455,13 +455,7 @@ const std::vector& paramsAvg3D() { const std::vector& paramsAvgV143D() { static const std::vector paramsAvgV143D = { - poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, - poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {1}, {1}, {0}, + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {2}, {0}, {0}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, @@ -551,37 +545,6 @@ const std::vector& inputShapes3D() { return inputShapes3D; } -const std::vector& inputShapes3DCeilTorch() { - static const std::vector inputShapes3D = { - { {}, {{3, 4, 64}} }, - { {}, {{2, 8, 12}} }, - { {}, {{1, 16, 12}} }, - { {}, {{1, 21, 4}} }, - { {}, {{1, 32, 8}} }, - { - // dynamic - {-1, -1, -1}, - // target - { - {1, 32, 8}, - {1, 21, 4}, - {2, 8, 12} - } - }, - { - // dynamic - {{1, 5}, {4, 32}, {1, 64}}, - // target - { - {3, 4, 64}, - {1, 16, 12}, - {1, 32, 8} - } - } - }; - return inputShapes3D; -} - const std::vector& inputShapes4D() { static const std::vector inputShapes4D = { { {}, {{3, 4, 64, 64}} }, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 3dacf611094d2d..b34ce08dd4d4c8 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -83,7 +83,6 @@ const std::vector& paramsMaxV144D(); const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); -const std::vector& inputShapes3DCeilTorch(); const std::vector& inputShapes4D(); const std::vector& inputShapes4DCeilTorch(); const std::vector& inputShapes4D_Large(); From 587f2f7526fa7ccffd31b99c4affb3386c43cc83 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 24 May 2024 13:00:34 +0200 Subject: [PATCH 43/61] Fix tests --- .../functional/custom/single_layer_tests/classes/pooling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 10e260dac76f2f..98183c68264c02 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -588,7 +588,7 @@ const std::vector& inputShapes4D() { const std::vector& inputShapes4DCeilTorch() { static const std::vector inputShapes4DCeilTorch = { - { {}, {{3, 4, 64, 64}} }, + { {}, {{3, 4, 128, 128}} }, { {}, {{2, 8, 8, 12}} }, { {}, {{1, 16, 16, 12}} }, { {}, {{1, 21, 8, 4}} }, @@ -630,7 +630,7 @@ const std::vector& inputShapes5D() { const std::vector& inputShapes5DCeilTorch() { static const std::vector inputShapes5D = { - { {}, {{1, 4, 16, 16, 16}} }, + { {}, {{1, 4, 32, 32, 32}} }, { {}, {{2, 8, 8, 8, 8}} }, { {}, {{2, 16, 12, 16, 20}} }, { {}, {{1, 19, 16, 20, 8}} }, From 0b0a56f952c36a1d38b208a5128d6d3e7a17f827 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 24 May 2024 13:30:50 +0200 Subject: [PATCH 44/61] Fixtest --- .../functional/custom/single_layer_tests/classes/pooling.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 98183c68264c02..8eee5139decd4e 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -588,7 +588,6 @@ const std::vector& inputShapes4D() { const std::vector& inputShapes4DCeilTorch() { static const std::vector inputShapes4DCeilTorch = { - { {}, {{3, 4, 128, 128}} }, { {}, {{2, 8, 8, 12}} }, { {}, {{1, 16, 16, 12}} }, { {}, {{1, 21, 8, 4}} }, From b8f8dda2d04ee7f1055d1bc7729339c914c4786c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 24 May 2024 15:13:30 +0200 Subject: [PATCH 45/61] remove duplicate tests --- .../custom/single_layer_tests/classes/pooling.cpp | 10 ---------- .../custom/single_layer_tests/classes/pooling.hpp | 1 - .../single_layer_tests/instances/common/pooling.cpp | 10 ---------- 3 files changed, 21 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 8eee5139decd4e..334ced63eacf66 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -586,16 +586,6 @@ const std::vector& inputShapes4D() { return inputShapes4D; } -const std::vector& inputShapes4DCeilTorch() { - static const std::vector inputShapes4DCeilTorch = { - { {}, {{2, 8, 8, 12}} }, - { {}, {{1, 16, 16, 12}} }, - { {}, {{1, 21, 8, 4}} }, - { {}, {{1, 32, 8, 8}} }, - }; - return inputShapes4DCeilTorch; -} - const std::vector& inputShapes5D() { static const std::vector inputShapes5D = { { {}, {{1, 4, 16, 16, 16}} }, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index b34ce08dd4d4c8..e4dca696a89fa4 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -84,7 +84,6 @@ const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); const std::vector& inputShapes4D(); -const std::vector& inputShapes4DCeilTorch(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); const std::vector& inputShapes5DCeilTorch(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index e11c2252c7b3fe..ef6f43d87572bb 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -123,16 +123,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_Large, PoolingLayerCPUTest, ::testing::Values(emptyFusingSpec)), AvgPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D, AvgPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvgV144D()), - ::testing::ValuesIn(inputShapes4DCeilTorch()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(emptyFusingSpec)), - AvgPoolingV14LayerCPUTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_RefOnly), From e88052a4d36f982da575b40d207d1e9b90007018 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 17 Jun 2024 11:42:54 +0200 Subject: [PATCH 46/61] Add evaluate to avgpool --- .../common_optimizations.cpp | 2 +- .../convert_avgpool_downgrade.cpp | 5 +- .../convert_maxpool_downgrade.cpp | 5 +- src/core/include/openvino/op/avg_pool.hpp | 3 + src/core/src/op/avg_pool.cpp | 72 +++++++++++++++++++ src/core/src/pass/serialize.cpp | 4 +- src/plugins/intel_cpu/src/extension.cpp | 1 + src/plugins/intel_cpu/src/nodes/pooling.cpp | 38 ++++------ .../x64/pass/snippets_mark_skipped.cpp | 3 +- .../transformation_pipeline.cpp | 24 +++++++ .../shared_test_classes/base/utils/ranges.hpp | 2 + 11 files changed, 128 insertions(+), 31 deletions(-) diff --git a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp index c49974bdbcff85..03a6a485b777eb 100644 --- a/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/common_optimizations.cpp @@ -213,9 +213,9 @@ bool ov::pass::CommonOptimizations::run_on_model(const std::shared_ptr(); - const matcher_pass_callback callback = [](pattern::Matcher& m) { + const matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) { const auto avg_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); + if (!avg_pool_v14 || transformation_callback(avg_pool_v14)) { + return false; + } const auto rounding_type_v14 = avg_pool_v14->get_rounding_type(); const auto rounding_type_v1 = rounding_type_v14 == ov::op::RoundingType::CEIL_TORCH ? ov::op::RoundingType::CEIL : rounding_type_v14; diff --git a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp index fbc41d72e3bc9a..9c3f1178125851 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_maxpool_downgrade.cpp @@ -72,7 +72,7 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { MATCHER_SCOPE(ConvertMaxPool14ToMaxPool8); const auto max_pool_v14_pattern = pattern::wrap_type(); - const matcher_pass_callback callback = [](pattern::Matcher& m) { + const matcher_pass_callback callback = [OV_CAPTURE_CPY_AND_THIS](pattern::Matcher& m) { using ov::op::v0::Constant; using ov::op::v0::Concat; using ov::op::v1::Subtract; @@ -87,6 +87,9 @@ ov::pass::ConvertMaxPool14ToMaxPool8::ConvertMaxPool14ToMaxPool8() { using ov::op::v12::Pad; const auto max_pool_v14 = std::dynamic_pointer_cast(m.get_match_root()); + if (!max_pool_v14 || transformation_callback(max_pool_v14)) { + return false; + } const auto rounding_type_v14 = max_pool_v14->get_rounding_type(); std::shared_ptr max_pool_v8; NodeRegistry node_registry; diff --git a/src/core/include/openvino/op/avg_pool.hpp b/src/core/include/openvino/op/avg_pool.hpp index 90b55a1f4e0af2..0d9b4cea958de7 100644 --- a/src/core/include/openvino/op/avg_pool.hpp +++ b/src/core/include/openvino/op/avg_pool.hpp @@ -84,6 +84,9 @@ class OPENVINO_API AvgPool : public util::AvgPoolBase { void validate_and_infer_types() override; + bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; + bool has_evaluate() const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace v14 diff --git a/src/core/src/op/avg_pool.cpp b/src/core/src/op/avg_pool.cpp index 31adcbf1242025..daff7e6a1db0f4 100644 --- a/src/core/src/op/avg_pool.cpp +++ b/src/core/src/op/avg_pool.cpp @@ -7,6 +7,36 @@ #include "avg_pool_shape_inference.hpp" #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" +#include "openvino/reference/avg_pool.hpp" + +namespace avgpool { +struct Evaluate : ov::element::NoAction { + using ov::element::NoAction::visit; + + template + static result_type visit(const ov::Tensor& in, + ov::Tensor& out_values, + const ov::Shape& in_shape, + const ov::Shape& out_shape, + const ov::Shape& kernel, + const ov::Strides& strides, + const ov::Shape& pads_begin, + const ov::Shape& pads_end, + const bool exclude_pad) { + using T = typename ov::element_type_traits::value_type; + ov::reference::avg_pool(in.data(), + out_values.data(), + in_shape, + out_shape, + kernel, + strides, + pads_begin, + pads_end, + !exclude_pad); + return true; + } +}; +} // namespace avgpool // ------------------------------ V1 ------------------------------ namespace ov { @@ -87,6 +117,48 @@ std::shared_ptr AvgPool::clone_with_new_inputs(const OutputVector& new_arg m_auto_pad); } +bool AvgPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const { + OV_OP_SCOPE(v14_AvgPool_evaluate); + const auto input_shapes = std::vector{inputs[0].get_shape()}; + auto pads_begin = m_pads_begin; + auto pads_end = m_pads_end; + const auto output_shapes = shape_infer(this, input_shapes, pads_begin, pads_end); + + outputs[0].set_shape(output_shapes[0].get_shape()); + using namespace ov::element; + return IF_TYPE_OF_CONVERT_TENSORS(v14_AvgPool_evaluate, + this, + outputs, + inputs, + OV_PP_ET_LIST(f32, i32, i64, u32, u64), + avgpool::Evaluate, + inputs[0].get_element_type(), + inputs[0], + outputs[0], + inputs[0].get_shape(), + outputs[0].get_shape(), + get_kernel(), + get_strides(), + get_pads_begin(), + get_pads_end(), + get_exclude_pad()); +} +bool AvgPool::has_evaluate() const { + OV_OP_SCOPE(v14_AvgPool_has_evaluate); + switch (get_input_element_type(0)) { + case element::i8: + case element::i32: + case element::i64: + case element::u8: + case element::u32: + case element::u64: + case element::f16: + case element::f32: + return true; + default: + return false; + } +} } // namespace v14 } // namespace op } // namespace ov diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index 19e2a8031b3708..506fc475b9b385 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -871,9 +871,9 @@ class PaddingsFixer { if (pad_agnostic_types.count(op->get_auto_pad())) { clone_op_and_fix_paddings(op); } - } else if (auto op = ov::as_type(node)) { + } else if (auto op = ov::as_type(node)) { if (pad_agnostic_types.count(op->get_auto_pad())) { - clone_op_and_fix_paddings(op); + clone_op_and_fix_paddings(op); } } else if (auto op = ov::as_type(node)) { if (pad_agnostic_types.count(op->get_auto_pad())) { diff --git a/src/plugins/intel_cpu/src/extension.cpp b/src/plugins/intel_cpu/src/extension.cpp index dc0ed0b983900c..61a6255d9c8a01 100644 --- a/src/plugins/intel_cpu/src/extension.cpp +++ b/src/plugins/intel_cpu/src/extension.cpp @@ -97,6 +97,7 @@ class TypeRelaxedExtension : public ov::OpExtension> { #define TYPE_RELAXED_EXTENSIONS \ TYPE_RELAXED_OP_EXTENSION(ov::op::v1::Add) \ TYPE_RELAXED_OP_EXTENSION(ov::op::v1::AvgPool) \ + TYPE_RELAXED_OP_EXTENSION(ov::op::v14::AvgPool) \ TYPE_RELAXED_OP_EXTENSION(ov::op::v0::Clamp) \ TYPE_RELAXED_OP_EXTENSION(ov::op::v0::Concat) \ TYPE_RELAXED_OP_EXTENSION(ov::op::v1::Convolution) \ diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index fd8f5bdfc66a96..e0440bf78b1efe 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,7 +146,8 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if (ov::is_type(op) || ov::is_type(op)) { + const auto is_v14 = ov::is_type(op) || ov::is_type(op); + if ((ov::is_type(op) || ov::is_type(op)) && op->is_dynamic()) { errorMessage = "ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes"; return false; } @@ -155,7 +156,9 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; return false; } - } else if (!ov::is_type(op) && !ov::is_type(op)) { + } else if (!ov::is_type(op) && !ov::is_type(op) && + !ov::is_type(op) && !ov::is_type(op) && + !ov::is_type(op)) { errorMessage = "Supported ops are MaxPool-1, MaxPool-8, MaxPool-14, AvgPool-1 and AvgPool-14"; return false; } @@ -198,32 +201,17 @@ Pooling::Pooling(const std::shared_ptr& op, const GraphContext::CPtr c get_attributes(poolingAttrs.dilation, maxPoolOp_v8->get_dilations()); } else if (auto maxPoolOp_v1 = ov::as_type_ptr(op)) { poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - } else if (auto avgPoolOp_v1 = ov::as_type_ptr(op)) { + } else if (auto avgPoolOpBase = ov::as_type_ptr(op)) { algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp_v1->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp_v1->get_rounding_type(); - - get_attributes(poolingAttrs.stride, avgPoolOp_v1->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp_v1->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v1->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v1->get_pads_end()); + poolingAttrs.exclude_pad = avgPoolOpBase->get_exclude_pad(); + poolingAttrs.rounding = avgPoolOpBase->get_rounding_type(); + get_attributes(poolingAttrs.stride, avgPoolOpBase->get_strides()); + get_attributes(poolingAttrs.kernel, avgPoolOpBase->get_kernel()); + get_attributes(poolingAttrs.data_pad_begin, avgPoolOpBase->get_pads_begin()); + get_attributes(poolingAttrs.data_pad_end, avgPoolOpBase->get_pads_end()); poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - - poolingAttrs.auto_pad = (avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v1->get_auto_pad() == ov::op::PadType::SAME_UPPER); - } else if (auto avgPoolOp_v14 = ov::as_type_ptr(op)) { - algorithm = Algorithm::PoolingAvg; - poolingAttrs.exclude_pad = avgPoolOp_v14->get_exclude_pad(); - poolingAttrs.rounding = avgPoolOp_v14->get_rounding_type(); - - get_attributes(poolingAttrs.stride, avgPoolOp_v14->get_strides()); - get_attributes(poolingAttrs.kernel, avgPoolOp_v14->get_kernel()); - get_attributes(poolingAttrs.data_pad_begin, avgPoolOp_v14->get_pads_begin()); - get_attributes(poolingAttrs.data_pad_end, avgPoolOp_v14->get_pads_end()); - poolingAttrs.dilation.resize(poolingAttrs.kernel.size(), 1); - - poolingAttrs.auto_pad = (avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOp_v14->get_auto_pad() == ov::op::PadType::SAME_UPPER); + poolingAttrs.auto_pad = (avgPoolOpBase->get_auto_pad() == ov::op::PadType::SAME_LOWER || avgPoolOpBase->get_auto_pad() == ov::op::PadType::SAME_UPPER); } - poolingAttrs.algorithm = algorithm; } diff --git a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp index 85a758ffcbcbef..b3fbf93ce07c3a 100644 --- a/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp +++ b/src/plugins/intel_cpu/src/transformations/snippets/x64/pass/snippets_mark_skipped.cpp @@ -184,7 +184,8 @@ bool isSuitableMiscParent(const std::shared_ptr &node) { ov::is_type(node) || ov::is_type(node) || ov::is_type(node) || - ov::is_type(node); + ov::is_type(node) || + ov::is_type(node); // has a single output, connected to a single child const auto out = node->outputs(); const bool has_only_child = (out.size() == 1) && (out[0].get_target_inputs().size() == 1); diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index 0da2f8fe0cb1c9..0129bd7a861b20 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -37,6 +37,7 @@ #include "transformations/common_optimizations/move_eltwise_up_data_movement.hpp" #include "transformations/control_flow/unroll_tensor_iterator.hpp" #include "transformations/fp16_compression/mark_decompression_convert_constant_folding.hpp" +#include "transformations/op_conversions/convert_avgpool_downgrade.hpp" #include "transformations/op_conversions/convert_batch_to_space.hpp" #include "transformations/op_conversions/convert_bitwise_to_logical_bool.hpp" #include "transformations/op_conversions/convert_broadcast_to_tiles.hpp" @@ -47,6 +48,7 @@ #include "transformations/op_conversions/convert_gelu.hpp" #include "transformations/op_conversions/convert_interpolate1_to_interpolate4.hpp" #include "transformations/op_conversions/convert_matrix_nms_to_matrix_nms_ie.hpp" +#include "transformations/op_conversions/convert_maxpool_downgrade.hpp" #include "transformations/op_conversions/convert_minimum_to_power_and_max.hpp" #include "transformations/op_conversions/convert_mod.hpp" #include "transformations/op_conversions/convert_multiclass_nms_to_multiclass_nms_ie.hpp" @@ -460,6 +462,28 @@ void Transformations::PreLpt(const std::vector& defaultPrecis }, ov::pass::ConvertBatchToSpace, ov::pass::ConvertSpaceToBatch); + CPU_SET_CALLBACK_COMMON( + manager, + [](const_node_ptr& node) -> bool { + const auto maxpool = std::dynamic_pointer_cast(node); + if (maxpool && maxpool->get_rounding_type() != ov::op::RoundingType::CEIL_TORCH) { + return false; + } + return true; + }, + ov::pass::ConvertMaxPool14ToMaxPool8); + + CPU_SET_CALLBACK_COMMON( + manager, + [](const_node_ptr& node) -> bool { + const auto avgpool = std::dynamic_pointer_cast(node); + if (avgpool && avgpool->get_rounding_type() != ov::op::RoundingType::CEIL_TORCH) { + return false; + } + return true; + }, + ov::pass::ConvertAvgPool14ToAvgPool1); + CPU_SET_CALLBACK_COMMON(manager, [](const_node_ptr &node) -> bool { std::string msg; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp index 5e7c51a8146666..e57803f3add6a6 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/base/utils/ranges.hpp @@ -128,9 +128,11 @@ static std::map inputRanges = { {ov::op::v5::HSigmoid::get_type_info_static(), Range({{0, 15}}, {{-1, 2, 32768}})}, {ov::op::v5::Round::get_type_info_static(), Range({{0, 15}}, {{-10, 20, 4}})}, {ov::op::v7::Gelu::get_type_info_static(), Range({{0, 15}}, {{-1, 2, 32768}})}, + {ov::op::v14::MaxPool::get_type_info_static(), Range({{0, 10, 1, 1}}, {{0, 10, 1, 1}})}, {ov::op::v8::MaxPool::get_type_info_static(), Range({{0, 10, 1, 1}}, {{0, 10, 1, 1}})}, {ov::op::v1::MaxPool::get_type_info_static(), Range({{0, 10, 1, 1}}, {{0, 10, 1, 1}})}, {ov::op::v1::AvgPool::get_type_info_static(), Range({{0, 10, 1, 1}}, {{0, 10, 1, 1}})}, + {ov::op::v14::AvgPool::get_type_info_static(), Range({{0, 10, 1, 1}}, {{0, 10, 1, 1}})}, {ov::op::v9::SoftSign::get_type_info_static(), Range({{0, 15}}, {{-100, 200, 32768}})}, // new temp {ov::op::v1::Convolution::get_type_info_static(), Range({{0, 15}}, {{0, 8, 32}})}, From 1ef42fd86e3b81c7a0101c34bd8801959f12e1b9 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 17 Jun 2024 11:46:32 +0200 Subject: [PATCH 47/61] Remove a line --- .../functional/custom/single_layer_tests/classes/pooling.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 334ced63eacf66..a9df6e0ef67f52 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -138,7 +138,6 @@ std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamI results << ov::test::utils::vec2str(shape) << "_"; } results << "Prc=" << inPrc << "_"; - results << "AvgPoolV14_"; results << "ExcludePad=" << excludePad << "_"; results << "K" << ov::test::utils::vec2str(kernel) << "_"; results << "S" << ov::test::utils::vec2str(stride) << "_"; From fd43337266ee8c51f596f96af7442116cd998b3c Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 17 Jun 2024 12:03:25 +0200 Subject: [PATCH 48/61] Minor change --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index e0440bf78b1efe..d43a653ad6dc84 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,7 +146,6 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto is_v14 = ov::is_type(op) || ov::is_type(op); if ((ov::is_type(op) || ov::is_type(op)) && op->is_dynamic()) { errorMessage = "ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes"; return false; From 9f714cfab7f2425d18d905b4c487ce3f2c16d37e Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 25 Jun 2024 15:10:30 +0200 Subject: [PATCH 49/61] Progress --- src/plugins/intel_cpu/src/nodes/pooling.cpp | 24 +- .../single_layer_tests/classes/pooling.cpp | 348 ++++++++++++++++-- .../single_layer_tests/classes/pooling.hpp | 16 + .../instances/common/pooling.cpp | 24 +- 4 files changed, 382 insertions(+), 30 deletions(-) diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index d43a653ad6dc84..204ffbbb3d4652 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,18 +146,30 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - if ((ov::is_type(op) || ov::is_type(op)) && op->is_dynamic()) { - errorMessage = "ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes"; - return false; + const auto isMaxPoolV14 = ov::is_type(op); + const auto isAvgPoolV14 = ov::is_type(op); + if ((isMaxPoolV14 || isAvgPoolV14) && op->is_dynamic()) { + if (isMaxPoolV14) { + if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { + errorMessage = "MaxPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; + return false; + } + } + if (isAvgPoolV14) { + if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { + errorMessage = "AvgPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; + return false; + } + } } - if (ov::is_type(op) || ov::is_type(op)) { + if (ov::is_type(op) || isMaxPoolV14) { if (!op->get_output_target_inputs(1).empty()) { errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; return false; } } else if (!ov::is_type(op) && !ov::is_type(op) && - !ov::is_type(op) && !ov::is_type(op) && - !ov::is_type(op)) { + !isMaxPoolV14 && !ov::is_type(op) && + !isAvgPoolV14) { errorMessage = "Supported ops are MaxPool-1, MaxPool-8, MaxPool-14, AvgPool-1 and AvgPool-14"; return false; } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index a9df6e0ef67f52..4672299f4f5a28 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,6 +11,46 @@ using namespace CPUTestUtils; namespace ov { namespace test { +namespace util { + static std::string AvgPoolV14GetTestCaseNameUtil(const testing::TestParamInfo& obj) { + ov::test::poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = obj.param; + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "ExcludePad=" << excludePad << "_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + results << "INT8=" << isInt8 << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + results << CpuTestWithFusing::getTestCaseName(fusingParams); + return results.str(); +} +} // namespace util std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; @@ -114,13 +154,19 @@ void PoolingLayerCPUTest::SetUp() { } std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { - ov::test::poolSpecificParams basicParamsSet; + return util::AvgPoolV14GetTestCaseNameUtil(obj); +} + +void AvgPoolingV14LayerCPUTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + + poolSpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; bool isInt8; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = obj.param; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = this->GetParam(); utils::PoolingTypes poolType; std::vector kernel, stride; @@ -130,29 +176,41 @@ std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamI bool excludePad; std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + std::tie(postOpMgrPtr, fusedOps) = fusingParams; + + if (selectedType.empty()) { + selectedType = getPrimitiveType(); } - results << "Prc=" << inPrc << "_"; - results << "ExcludePad=" << excludePad << "_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - results << "INT8=" << isInt8 << "_"; + if (isInt8) + selectedType = selectedType + "_I8"; + else + selectedType = makeSelectedTypeStr(selectedType, inPrc); - results << CPUTestsBase::getTestCaseName(cpuParams); - results << CpuTestWithFusing::getTestCaseName(fusingParams); - return results.str(); + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + + std::shared_ptr poolInput = params[0]; + if (isInt8) { + abs_threshold = 2e-2; + ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); + poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); + } + + auto pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); + + function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); } -void AvgPoolingV14LayerCPUTest::SetUp() { +std::string AvgPoolingV14LayerRefFallbackTest::getTestCaseName(const testing::TestParamInfo& obj) { + return util::AvgPoolV14GetTestCaseNameUtil(obj); +} + +void AvgPoolingV14LayerRefFallbackTest::SetUp() { targetDevice = ov::test::utils::DEVICE_CPU; poolSpecificParams basicParamsSet; @@ -202,6 +260,8 @@ void AvgPoolingV14LayerCPUTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( +<<<<<<< HEAD +======= const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; @@ -284,6 +344,7 @@ void MaxPoolingV8LayerCPUTest::SetUp() { } std::string MaxPoolingV14LayerCPUTest::getTestCaseName( +>>>>>>> 7ef152ef51... Progress const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; @@ -365,6 +426,88 @@ void MaxPoolingV14LayerCPUTest::SetUp() { function = std::make_shared(results, params, "MaxPooling"); } +std::string MaxPoolingV14LayerRefFallbackTest::getTestCaseName( + const testing::TestParamInfo& obj) { + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "MaxPool_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "D" << ov::test::utils::vec2str(dilation) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + + results << CPUTestsBase::getTestCaseName(cpuParams); + return results.str(); +} + +void MaxPoolingV14LayerRefFallbackTest::SetUp() { + targetDevice = ov::test::utils::DEVICE_CPU; + + maxPoolV8SpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + CPUSpecificParams cpuParams; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); + + std::vector kernel, stride, dilation; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + ov::element::Type indexElementType; + int64_t axis; + std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = + basicParamsSet; + std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; + if (selectedType.empty()) { + selectedType = getPrimitiveType(); + } + selectedType = makeSelectedTypeStr(selectedType, inPrc); + + init_input_shapes({inputShapes}); + + ov::ParameterVector params; + for (auto&& shape : inputDynamicShapes) { + params.push_back(std::make_shared(inPrc, shape)); + } + auto pooling = std::make_shared(params[0], + stride, + dilation, + padBegin, + padEnd, + kernel, + roundingType, + padType, + indexElementType, + axis); + pooling->get_rt_info() = getCPUInfo(); + ov::ResultVector results{std::make_shared(pooling->output(0))}; + function = std::make_shared(results, params, "MaxPooling"); +} + TEST_P(PoolingLayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -385,6 +528,11 @@ TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(MaxPoolingV14LayerRefFallbackTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Reference"); +} + namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool @@ -430,6 +578,12 @@ const std::vector& paramsMaxV143D() { maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, + maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT}, maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -503,6 +657,24 @@ const std::vector& paramsMaxV144D() { maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT}, + maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT}, + }; + return paramsMaxV144D; +} + +const std::vector& paramsMaxV144DCeilTorch() { + static const std::vector paramsMaxV144D = { maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -514,12 +686,55 @@ const std::vector& paramsMaxV144D() { } const std::vector& inputShapes3D() { +<<<<<<< HEAD static const std::vector inputShapes3D = { +======= + static std::vector inputShapes3D = { +>>>>>>> 7ef152ef51... Progress { {}, {{3, 4, 64}} }, { {}, {{2, 8, 12}} }, { {}, {{1, 16, 12}} }, { {}, {{1, 21, 4}} }, { {}, {{1, 32, 8}} }, +<<<<<<< HEAD +======= + { + // dynamic + {-1, -1, -1}, + // target + { + {1, 32, 8}, + {1, 21, 4}, + {2, 8, 12} + } + }, + { + // dynamic + {{1, 5}, {4, 32}, {1, 64}}, + // target + { + {3, 4, 64}, + {1, 16, 12}, + {1, 32, 8} + } + }}; + return inputShapes3D; +} + +const std::vector& inputShapes3DStatic() { + static const std::vector inputShapes3D = { + { {}, {{3, 4, 64}} }, + { {}, {{2, 8, 12}} }, + { {}, {{1, 16, 12}} }, + { {}, {{1, 21, 4}} }, + { {}, {{1, 32, 8}} } + }; + return inputShapes3D; +} + +const std::vector& inputShapes3DDynamic() { + static const std::vector inputShapes3D = { +>>>>>>> 7ef152ef51... Progress { // dynamic {-1, -1, -1}, @@ -585,6 +800,57 @@ const std::vector& inputShapes4D() { return inputShapes4D; } +const std::vector& inputShapes4DCeilTorch() { + static const std::vector inputShapes4D = { + { {}, {{3, 4, 64, 64}} }, + { {}, {{2, 8, 8, 12}} }, + { {}, {{1, 16, 16, 12}} }, + { {}, {{1, 21, 8, 4}} }, + { {}, {{1, 32, 8, 8}} }}; + return inputShapes4D; +} + +const std::vector& inputShapes4DDynamic() { + static const std::vector inputShapes4D = { + { {}, {{3, 4, 64, 64}} }, + { {}, {{2, 8, 8, 12}} }, + { {}, {{1, 16, 16, 12}} }, + { {}, {{1, 21, 8, 4}} }, + { {}, {{1, 32, 8, 8}} }, + { + // dynamic + {-1, -1, -1, -1}, + // target + { + {1, 32, 8, 8}, + {1, 21, 8, 4}, + {2, 8, 8, 12}, + {1, 96, 125, 125} + } + }, + { + // dynamic + {{1, 5}, {4, 32}, {1, 64}, {1, 64}}, + // target + { + {3, 4, 64, 64}, + {1, 16, 16, 12}, + {1, 32, 8, 8} + } + }, + { + // dynamic + {{1, 10}, 16, 8, 8}, + // target + { + {1, 16, 8, 8}, + {2, 16, 8, 8}, + } + } + }; + return inputShapes4D; +} + const std::vector& inputShapes5D() { static const std::vector inputShapes5D = { { {}, {{1, 4, 16, 16, 16}} }, @@ -627,6 +893,28 @@ const std::vector& inputShapes5DCeilTorch() { return inputShapes5D; } +const std::vector& inputShapes5DDynamic() { + static const std::vector inputShapes5D = { + { + {-1, -1, -1, -1, -1}, + { + {2, 8, 8, 8, 8}, + {1, 19, 16, 20, 8}, + {1, 4, 16, 16, 16} + } + }, + { + {{1, 5}, {4, 32}, {1, 64}, {1, 64}, {1, 25}}, + { + {1, 4, 16, 16, 16}, + {1, 32, 16, 8, 12}, + {3, 16, 4, 8, 3} + } + } + }; + return inputShapes5D; +} + const std::vector& paramsMaxV85D() { static const std::vector paramsMaxV85D = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, @@ -647,6 +935,12 @@ const std::vector& paramsMaxV145D() { maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, + maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, + maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, + ov::element::Type_t::i32, 0, + ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT }, maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -745,6 +1039,18 @@ const std::vector& paramsAvgV145D() { return paramsAvgV145D; } +const std::vector& paramsAvgV145DCeilTorch() { + static const std::vector paramsAvgV145D = { + poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + }; + return paramsAvgV145D; +} + const std::vector& paramsMax5D() { static const std::vector paramsMax5D = { poolSpecificParams{ utils::PoolingTypes::MAX, {2, 2, 2}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index e4dca696a89fa4..f13187f52c978b 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -60,6 +60,15 @@ class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CpuTestWithFusing { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + namespace Pooling { const std::vector& inpOutPrecision(); const ov::op::RoundingType expectedAvgRoundingType(const ov::op::RoundingType ceil_type = ov::op::RoundingType::CEIL); @@ -80,18 +89,25 @@ const std::vector& paramsMaxV85D(); const std::vector& paramsMaxV143D(); const std::vector& paramsMaxV144D(); +const std::vector& paramsMaxV144DCeilTorch(); const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); +const std::vector& inputShapes3DDynamic(); +const std::vector& inputShapes3DStatic(); const std::vector& inputShapes4D(); +const std::vector& inputShapes4DCeilTorch(); +const std::vector& inputShapes4DDynamic(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); const std::vector& inputShapes5DCeilTorch(); +const std::vector& inputShapes5DDynamic(); const std::vector& paramsAvg4D(); const std::vector& paramsAvgV144D(); const std::vector& paramsAvg4D_Large(); const std::vector& paramsAvg5D(); +const std::vector& paramsAvgV145DCeilTorch(); const std::vector& paramsAvgV145D(); const std::vector& paramsMax5D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index ef6f43d87572bb..b6c15b40661193 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -53,7 +53,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV143D()), - ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn(inputShapes3DStatic()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), ::testing::ValuesIn(vecCpuConfigs), @@ -93,6 +93,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(filterCPUInfo(vecCpuConfigsFusing_4D()))), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV144D()), + ::testing::ValuesIn(inputShapes4DCeilTorch()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfo(vecCpuConfigsFusing_4D()))), + MaxPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), @@ -199,7 +207,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ceil_torch, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV145D()), - ::testing::ValuesIn(inputShapes5DCeilTorch()), + ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(vecCpuConfigs)), MaxPoolingV14LayerCPUTest::getTestCaseName); @@ -225,13 +233,23 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV145D()), - ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn(inputShapes5DCeilTorch()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), ::testing::ValuesIn(vecCpuConfigs), ::testing::Values(emptyFusingSpec)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, AvgPoolingV14LayerRefFallbackTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvgV145DCeilTorch()), + ::testing::ValuesIn(inputShapes5DDynamic()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(false), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::Values(emptyFusingSpec)), + AvgPoolingV14LayerRefFallbackTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg5D_RefOnly), From 8c16305bb33bff3afe4068a23a5e3a28377b5592 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Tue, 25 Jun 2024 16:32:59 +0200 Subject: [PATCH 50/61] checkpoint --- .../custom/single_layer_tests/classes/pooling.cpp | 15 +++++---------- .../custom/single_layer_tests/classes/pooling.hpp | 9 +++++++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 4672299f4f5a28..672931b51e2cba 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -260,8 +260,6 @@ void AvgPoolingV14LayerRefFallbackTest::SetUp() { } std::string MaxPoolingV8LayerCPUTest::getTestCaseName( -<<<<<<< HEAD -======= const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; @@ -344,7 +342,6 @@ void MaxPoolingV8LayerCPUTest::SetUp() { } std::string MaxPoolingV14LayerCPUTest::getTestCaseName( ->>>>>>> 7ef152ef51... Progress const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; @@ -518,6 +515,11 @@ TEST_P(AvgPoolingV14LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } +TEST_P(AvgPoolingV14LayerRefFallbackTest, CompareWithRefs) { + run(); + CheckPluginRelatedResults(compiledModel, "Reference"); +} + TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -686,18 +688,12 @@ const std::vector& paramsMaxV144DCeilTorch() { } const std::vector& inputShapes3D() { -<<<<<<< HEAD static const std::vector inputShapes3D = { -======= - static std::vector inputShapes3D = { ->>>>>>> 7ef152ef51... Progress { {}, {{3, 4, 64}} }, { {}, {{2, 8, 12}} }, { {}, {{1, 16, 12}} }, { {}, {{1, 21, 4}} }, { {}, {{1, 32, 8}} }, -<<<<<<< HEAD -======= { // dynamic {-1, -1, -1}, @@ -734,7 +730,6 @@ const std::vector& inputShapes3DStatic() { const std::vector& inputShapes3DDynamic() { static const std::vector inputShapes3D = { ->>>>>>> 7ef152ef51... Progress { // dynamic {-1, -1, -1}, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index f13187f52c978b..3089971c51c26d 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -44,6 +44,15 @@ class AvgPoolingV14LayerCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, public CpuTestWithFusing { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: From 4b136b30e3676f5457be1022e89c2c18777ead36 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Sat, 29 Jun 2024 17:46:36 +0200 Subject: [PATCH 51/61] updates --- .../src/transformations/convert_precision.cpp | 12 ++++++++++-- src/core/src/op/max_pool.cpp | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/transformations/src/transformations/convert_precision.cpp b/src/common/transformations/src/transformations/convert_precision.cpp index b2e80048e66cf7..9d13c4d975fc33 100644 --- a/src/common/transformations/src/transformations/convert_precision.cpp +++ b/src/common/transformations/src/transformations/convert_precision.cpp @@ -441,6 +441,7 @@ bool ov::pass::ConvertPrecision::run_on_model(const std::shared_ptr& {ov::op::v3::TopK::get_type_info_static(), fuse_type_to_topk}, {ov::op::v11::TopK::get_type_info_static(), fuse_type_to_topk}, {ov::op::v8::MaxPool::get_type_info_static(), fuse_type_to_maxpool}, + {ov::op::v14::MaxPool::get_type_info_static(), fuse_type_to_maxpool}, {ov::op::v3::NonZero::get_type_info_static(), fuse_type_to_nonzero}, {ov::op::v3::Bucketize::get_type_info_static(), fuse_type_to_bucketize}, {ov::op::v1::Equal::get_type_info_static(), fuse_type_to_binary_comparision}, @@ -924,9 +925,16 @@ bool fuse_type_to_topk(const std::shared_ptr& node, const precisions_m } bool fuse_type_to_maxpool(const std::shared_ptr& node, const precisions_map& precisions) { - if (auto maxpool = ov::as_type_ptr(node)) { + auto maxpool_v8 = ov::as_type_ptr(node); + auto maxpool_v14 = ov::as_type_ptr(node); + if (maxpool_v14) { return update_type(1, node, precisions, [&](const element::Type& to) { - maxpool->set_index_element_type(to); + maxpool_v14->set_index_element_type(to); + }); + } + if (maxpool_v8) { + return update_type(1, node, precisions, [&](const element::Type& to) { + maxpool_v8->set_index_element_type(to); }); } return false; diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp index 741f57105efb4d..efe7f868d33ae5 100644 --- a/src/core/src/op/max_pool.cpp +++ b/src/core/src/op/max_pool.cpp @@ -422,9 +422,10 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const auto pads_begin = m_pads_begin; auto pads_end = m_pads_end; const auto output_shapes = shape_infer(this, input_shapes, pads_begin, pads_end); - outputs[0].set_shape(output_shapes[0].get_shape()); - + if (outputs.size() == 2) { + outputs[1].set_shape(output_shapes[1].get_shape()); + } return ov::op::maxpool::evaluate_util(this, outputs, inputs, get_dilations(), get_axis()); } From b4209f734b7256003130697160451b1204213ed1 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 4 Jul 2024 11:55:55 +0200 Subject: [PATCH 52/61] Modify tests --- .../single_layer_tests/classes/pooling.cpp | 275 +++++------------- .../single_layer_tests/classes/pooling.hpp | 7 +- .../instances/x64/pooling.cpp | 176 +++++++++++ .../skip_tests_config.cpp | 10 + 4 files changed, 265 insertions(+), 203 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index af0fecb2239f73..2e104e067e1c6b 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -19,7 +19,8 @@ namespace util { bool isInt8; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = obj.param; + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = obj.param; utils::PoolingTypes poolType; std::vector kernel, stride; @@ -45,6 +46,12 @@ namespace util { results << "Rounding=" << roundingType << "_"; results << "AutoPad=" << padType << "_"; results << "INT8=" << isInt8 << "_"; + if (!additionalConfig.empty()) { + results << "_PluginConf"; + for (auto& item : additionalConfig) { + results << "_" << item.first << "=" << item.second.as(); + } + } results << CPUTestsBase::getTestCaseName(cpuParams); results << CpuTestWithFusing::getTestCaseName(fusingParams); @@ -175,7 +182,9 @@ void AvgPoolingV14LayerCPUTest::SetUp() { bool isInt8; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = this->GetParam(); + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = this->GetParam(); + configuration.insert(additionalConfig.begin(), additionalConfig.end()); utils::PoolingTypes poolType; std::vector kernel, stride; @@ -228,7 +237,9 @@ void AvgPoolingV14LayerRefFallbackTest::SetUp() { bool isInt8; CPUSpecificParams cpuParams; fusingSpecificParams fusingParams; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams) = this->GetParam(); + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = this->GetParam(); + configuration.insert(additionalConfig.begin(), additionalConfig.end()); utils::PoolingTypes poolType; std::vector kernel, stride; @@ -274,7 +285,8 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = obj.param; std::vector kernel, stride, dilation; std::vector padBegin, padEnd; @@ -301,6 +313,12 @@ std::string MaxPoolingV8LayerCPUTest::getTestCaseName( results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; results << "Rounding=" << roundingType << "_"; results << "AutoPad=" << padType << "_"; + if (!additionalConfig.empty()) { + results << "_PluginConf"; + for (auto& item : additionalConfig) { + results << "_" << item.first << "=" << item.second.as(); + } + } results << CPUTestsBase::getTestCaseName(cpuParams); return results.str(); @@ -313,7 +331,9 @@ void MaxPoolingV8LayerCPUTest::SetUp() { InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = this->GetParam(); + configuration.insert(additionalConfig.begin(), additionalConfig.end()); std::vector kernel, stride, dilation; std::vector padBegin, padEnd; @@ -327,7 +347,7 @@ void MaxPoolingV8LayerCPUTest::SetUp() { if (selectedType.empty()) { selectedType = getPrimitiveType(); } - selectedType = makeSelectedTypeStr(selectedType, inPrc); + selectedType = makeSelectedTypeStr(selectedType, deduce_expected_precision(inPrc, configuration)); init_input_shapes({inputShapes}); @@ -351,12 +371,13 @@ void MaxPoolingV8LayerCPUTest::SetUp() { } std::string MaxPoolingV14LayerCPUTest::getTestCaseName( - const testing::TestParamInfo& obj) { +const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = obj.param; + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = obj.param; std::vector kernel, stride, dilation; std::vector padBegin, padEnd; @@ -383,6 +404,12 @@ std::string MaxPoolingV14LayerCPUTest::getTestCaseName( results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; results << "Rounding=" << roundingType << "_"; results << "AutoPad=" << padType << "_"; + if (!additionalConfig.empty()) { + results << "_PluginConf"; + for (auto& item : additionalConfig) { + results << "_" << item.first << "=" << item.second.as(); + } + } results << CPUTestsBase::getTestCaseName(cpuParams); return results.str(); @@ -395,7 +422,9 @@ void MaxPoolingV14LayerCPUTest::SetUp() { InputShape inputShapes; ElementType inPrc; CPUSpecificParams cpuParams; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams) = this->GetParam(); + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = this->GetParam(); + configuration.insert(additionalConfig.begin(), additionalConfig.end()); std::vector kernel, stride, dilation; std::vector padBegin, padEnd; @@ -409,7 +438,7 @@ void MaxPoolingV14LayerCPUTest::SetUp() { if (selectedType.empty()) { selectedType = getPrimitiveType(); } - selectedType = makeSelectedTypeStr(selectedType, inPrc); + selectedType = makeSelectedTypeStr(selectedType, deduce_expected_precision(inPrc, configuration)); init_input_shapes({inputShapes}); @@ -594,16 +623,7 @@ const std::vector& paramsMaxV143D() { static const std::vector paramsMaxV143D = { maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, - maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7}, {2}, {1}, {2}, {2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT}, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_UPPER }, maxPoolV8SpecificParams{ {2}, {2}, {1}, {0}, {0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -632,6 +652,10 @@ const std::vector& paramsAvgV143D() { expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {3}, {2}, {0}, {0}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_UPPER, true }, + poolSpecificParams{ utils::PoolingTypes::AVG, {4}, {4}, {2}, {2}, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_LOWER, true }, }; return paramsAvgV143D; } @@ -673,28 +697,7 @@ const std::vector& paramsMaxV144D() { static const std::vector paramsMaxV144D = { maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT}, - maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT}, - maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {11, 7}, {2, 2}, {1, 1}, {2, 2}, {2, 2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::EXPLICIT}, - }; - return paramsMaxV144D; -} - -const std::vector& paramsMaxV144DCeilTorch() { - static const std::vector paramsMaxV144D = { + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_UPPER }, maxPoolV8SpecificParams{ {2, 2}, {2, 2}, {1, 1}, {0, 0}, {0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -705,36 +708,6 @@ const std::vector& paramsMaxV144DCeilTorch() { return paramsMaxV144D; } -const std::vector& inputShapes3D() { - static const std::vector inputShapes3D = { - { {}, {{3, 4, 64}} }, - { {}, {{2, 8, 12}} }, - { {}, {{1, 16, 12}} }, - { {}, {{1, 21, 4}} }, - { {}, {{1, 32, 8}} }, - { - // dynamic - {-1, -1, -1}, - // target - { - {1, 32, 8}, - {1, 21, 4}, - {2, 8, 12} - } - }, - { - // dynamic - {{1, 5}, {4, 32}, {1, 64}}, - // target - { - {3, 4, 64}, - {1, 16, 12}, - {1, 32, 8} - } - }}; - return inputShapes3D; -} - const std::vector& inputShapes3DStatic() { static const std::vector inputShapes3D = { { {}, {{3, 4, 64}} }, @@ -772,48 +745,17 @@ const std::vector& inputShapes3DDynamic() { return inputShapes3D; } -const std::vector& inputShapes4D() { - static const std::vector inputShapes4D = { - { {}, {{3, 4, 64, 64}} }, - { {}, {{2, 8, 8, 12}} }, - { {}, {{1, 16, 16, 12}} }, - { {}, {{1, 21, 8, 4}} }, - { {}, {{1, 32, 8, 8}} }, - { - // dynamic - {-1, -1, -1, -1}, - // target - { - {1, 32, 8, 8}, - {1, 21, 8, 4}, - {2, 8, 8, 12}, - {1, 96, 125, 125} - } - }, - { - // dynamic - {{1, 5}, {4, 32}, {1, 64}, {1, 64}}, - // target - { - {3, 4, 64, 64}, - {1, 16, 16, 12}, - {1, 32, 8, 8} - } - }, - { - // dynamic - {{1, 10}, 16, 8, 8}, - // target - { - {1, 16, 8, 8}, - {2, 16, 8, 8}, - } - } - }; - return inputShapes4D; +const std::vector& inputShapes3D() { + static std::vector combinedInputShapes; + if (combinedInputShapes.empty()) { + combinedInputShapes = inputShapes3DStatic(); + const auto& dynamicShapes = inputShapes3DDynamic(); + combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); + } + return combinedInputShapes; } -const std::vector& inputShapes4DCeilTorch() { +const std::vector& inputShapes4DStatic() { static const std::vector inputShapes4D = { { {}, {{3, 4, 64, 64}} }, { {}, {{2, 8, 8, 12}} }, @@ -825,11 +767,6 @@ const std::vector& inputShapes4DCeilTorch() { const std::vector& inputShapes4DDynamic() { static const std::vector inputShapes4D = { - { {}, {{3, 4, 64, 64}} }, - { {}, {{2, 8, 8, 12}} }, - { {}, {{1, 16, 16, 12}} }, - { {}, {{1, 21, 8, 4}} }, - { {}, {{1, 32, 8, 8}} }, { // dynamic {-1, -1, -1, -1}, @@ -864,38 +801,17 @@ const std::vector& inputShapes4DDynamic() { return inputShapes4D; } -const std::vector& inputShapes5D() { - static const std::vector inputShapes5D = { - { {}, {{1, 4, 16, 16, 16}} }, - { {}, {{2, 8, 8, 8, 8}} }, - { {}, {{2, 16, 12, 16, 20}} }, - { {}, {{1, 19, 16, 20, 8}} }, - { {}, {{1, 32, 16, 8, 12}} }, - { - // dynamic - {-1, -1, -1, -1, -1}, - // target - { - {2, 8, 8, 8, 8}, - {1, 19, 16, 20, 8}, - {1, 4, 16, 16, 16} - } - }, - { - // dynamic - {{1, 5}, {4, 32}, {1, 64}, {1, 64}, {1, 25}}, - // target - { - {1, 4, 16, 16, 16}, - {1, 32, 16, 8, 12}, - {3, 16, 4, 8, 3} - } - } - }; - return inputShapes5D; +const std::vector& inputShapes4D() { + static std::vector combinedInputShapes; + if (combinedInputShapes.empty()) { + combinedInputShapes = inputShapes4DStatic(); + const auto& dynamicShapes = inputShapes4DDynamic(); + combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); + } + return combinedInputShapes; } -const std::vector& inputShapes5DCeilTorch() { +const std::vector& inputShapes5DStatic() { static const std::vector inputShapes5D = { { {}, {{1, 4, 32, 32, 32}} }, { {}, {{2, 8, 8, 8, 8}} }, @@ -928,6 +844,16 @@ const std::vector& inputShapes5DDynamic() { return inputShapes5D; } +const std::vector& inputShapes5D() { + static std::vector combinedInputShapes; + if (combinedInputShapes.empty()) { + combinedInputShapes = inputShapes5DStatic(); + const auto& dynamicShapes = inputShapes5DDynamic(); + combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); + } + return combinedInputShapes; +} + const std::vector& paramsMaxV85D() { static const std::vector paramsMaxV85D = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, @@ -944,16 +870,7 @@ const std::vector& paramsMaxV145D() { static const std::vector paramsMaxV145DCeilTorch = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::CEIL, ov::op::PadType::EXPLICIT }, - maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::SAME_LOWER }, - maxPoolV8SpecificParams{ {7, 11, 6}, {2, 2, 2}, {1, 1, 1}, {2, 2, 2}, {2, 2, 2}, - ov::element::Type_t::i32, 0, - ov::op::RoundingType::FLOOR, ov::op::PadType::EXPLICIT }, + ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_UPPER }, maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, ov::element::Type_t::i32, 0, ov::op::RoundingType::CEIL_TORCH, ov::op::PadType::SAME_LOWER }, @@ -984,22 +901,10 @@ const std::vector& paramsAvg4D() { const std::vector& paramsAvgV144D() { static const std::vector paramsAvgV144D = { - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {1, 0}, {0, 0}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_UPPER, false }, poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2}, {2, 2}, {0, 0}, {0, 0}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_LOWER, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4}, {4, 4}, {2, 2}, {2, 2}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, }; @@ -1028,36 +933,10 @@ const std::vector& paramsAvg5D() { const std::vector& paramsAvgV145D() { static const std::vector paramsAvgV145D = { - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_LOWER, false }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {1, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::SAME_UPPER, false }, poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_UPPER, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, - expectedAvgRoundingType(), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, - }; - return paramsAvgV145D; -} - -const std::vector& paramsAvgV145DCeilTorch() { - static const std::vector paramsAvgV145D = { - poolSpecificParams{ utils::PoolingTypes::AVG, {2, 2, 2}, {2, 2, 2}, {0, 0, 0}, {0, 0, 0}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, - poolSpecificParams{ utils::PoolingTypes::AVG, {3, 3, 3}, {3, 3, 3}, {1, 1, 1}, {0, 0, 0}, - expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, + expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::SAME_LOWER, true }, poolSpecificParams{ utils::PoolingTypes::AVG, {4, 4, 4}, {2, 2, 2}, {2, 2, 2}, {2, 2, 2}, expectedAvgRoundingType(ov::op::RoundingType::CEIL_TORCH), ov::op::PadType::EXPLICIT, true }, }; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 9406dce501888c..14427fba7aaea4 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -101,28 +101,25 @@ const std::vector& paramsMaxV85D(); const std::vector& paramsMaxV143D(); const std::vector& paramsMaxV144D(); -const std::vector& paramsMaxV144DCeilTorch(); const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); const std::vector& inputShapes3DDynamic(); const std::vector& inputShapes3DStatic(); const std::vector& inputShapes4D(); -const std::vector& inputShapes4DCeilTorch(); +const std::vector& inputShapes4DStatic(); const std::vector& inputShapes4DDynamic(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); -const std::vector& inputShapes5DCeilTorch(); +const std::vector& inputShapes5DStatic(); const std::vector& inputShapes5DDynamic(); const std::vector& paramsAvg4D(); const std::vector& paramsAvgV144D(); const std::vector& paramsAvg4D_Large(); const std::vector& paramsAvg5D(); -const std::vector& paramsAvgV145DCeilTorch(); const std::vector& paramsAvgV145D(); const std::vector& paramsMax5D(); - } // namespace Pooling } // namespace test } // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 4127d0c9deddd8..85deafd66253ab 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -168,6 +168,39 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_I8_FP16, PoolingLayerCPUTest, ::testing::Values(cpu_f16_plugin_config)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_I8, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D()), + ::testing::ValuesIn(inputShapes5D_int8), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), + ::testing::ValuesIn(fusingParamsSet), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_I8_FP16, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D()), + ::testing::ValuesIn(inputShapes4D_int8), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigsFusing_4D)), + ::testing::ValuesIn(fusingParamsSet), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D_I8_FP16, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg5D()), + ::testing::ValuesIn(inputShapes5D_int8), + ::testing::Values(ElementType::f32), + ::testing::Values(true), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigsFusing_5D)), + ::testing::ValuesIn(fusingParamsSet), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D_FP16, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax3D()), @@ -190,6 +223,28 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_FP16, PoolingLayerCPUTest, ::testing::Values(cpu_f16_plugin_config)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_FP16, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg3D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_FP16_Ceil_Torch, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvgV143D()), + ::testing::ValuesIn(inputShapes3DStatic()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D_FP16, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax4D()), @@ -210,6 +265,55 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D_FP16, MaxPoolingV8LayerCPUTest, ::testing::Values(cpu_f16_plugin_config)), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D_FP16, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV84D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D_FP16_Ceil_Torch, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV144D()), + ::testing::ValuesIn(inputShapes4DStatic()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_4D_FP16, MaxPoolingV14LayerRefFallbackTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV144D()), + ::testing::ValuesIn(inputShapes4DDynamic()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV14LayerRefFallbackTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_FP16, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_Large_FP16, AvgPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsAvg4D_Large()), + ::testing::ValuesIn(inputShapes4D_Large()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(false), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(emptyFusingSpec), + ::testing::Values(cpu_f16_plugin_config)), + AvgPoolingV14LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D_FP16, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), @@ -252,6 +356,33 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D_FP16, MaxPoolingV8LayerCPUTest, ::testing::Values(cpu_f16_plugin_config)), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_FP16, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV85D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_FP16_Ceil_Torch, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D_FP16, MaxPoolingV14LayerRefFallbackTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5DDynamic()), + ::testing::ValuesIn(inpOutPrecision()), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::Values(cpu_f16_plugin_config)), + MaxPoolingV14LayerRefFallbackTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax3D()), @@ -272,6 +403,33 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_3D, MaxPoolingV8LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV8LayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV83D()), + ::testing::ValuesIn(inputShapes3D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D)), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D_Ceil_Torch, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV143D()), + ::testing::ValuesIn(inputShapes3DStatic()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "jit_avx512"}), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_3D, MaxPoolingV14LayerRefFallbackTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV143D()), + ::testing::ValuesIn(inputShapes3DDynamic()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV14LayerRefFallbackTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax5D()), @@ -291,6 +449,24 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_5D, MaxPoolingV8LayerCPUTest, ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV8LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV85D()), + ::testing::ValuesIn(inputShapes5D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV14LayerCPUTest::getTestCaseName); + +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D, MaxPoolingV14LayerRefFallbackTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV145D()), + ::testing::ValuesIn(inputShapes5DDynamic()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV14LayerRefFallbackTest::getTestCaseName); } // namespace } // namespace Pooling } // namespace test diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 70dd06ecfb44d9..045c4ed7599dcd 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -314,6 +314,16 @@ std::vector disabledTestPatterns() { R"(.*smoke_LoopForCommon/LoopLayerCPUTest.CompareWithRefs/Input0_IS=\[1..10.1.1..10\]_.*_Input1_IS=\[1..8.1.1..8\]_.*_Input2_IS=\[1..10.\?.1..10\]_TS=.*_types=0_0_1_trip_count_type=.*_trip_count=(1|5)_exec_cond=1_netType=i8.*)", // Issue: 142997 R"(.*smoke_TestsROIAlign.*)", + // Issue: TODO + R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", + R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", + R"(.*smoke_MaxPoolV14_Ref_Fallback_4D_ceil_torch/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_MaxPool_K\(2.2\)_S\(2.2\)_D\(1.1\)_PB\(0.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", + R"(.*smoke_MaxPoolV14_Ref_Fallback_5D/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", + R"(.*smoke_MaxPoolV14_Ref_Fallback_5D/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", + R"(.*smoke_AvgPoolV14_Ref_Fallback_4D_Ceil_torch/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_ExcludePad=1_K\(2.2\)_S\(2.2\)_PB\(0.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)", + R"(.*smoke_AvgPoolV14_Ref_Fallback_4D_Ceil_torch/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_ExcludePad=0_K\(2.2\)_S\(2.2\)_PB\(1.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_upper_INT8=0__primitive=ref.*)", + R"(.*smoke_AvgPoolV14_Ref_Fallback_5D/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_ExcludePad=1_K\(3.3.3\)_S\(3.3.3\)_PB\(1.1.1\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)", + R"(.*smoke_AvgPoolV14_Ref_Fallback_5D/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_ExcludePad=1_K\(3.3.3\)_S\(3.3.3\)_PB\(1.1.1\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)" }; // fp32 floor for bf16 models: conversion issue From 2193a3e42fa7f7252ddbddfd85372cde2ee55b93 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 4 Jul 2024 13:06:24 +0200 Subject: [PATCH 53/61] Add ticket id --- .../functional/shared_tests_instances/skip_tests_config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 045c4ed7599dcd..e8cce0eb491051 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -314,7 +314,7 @@ std::vector disabledTestPatterns() { R"(.*smoke_LoopForCommon/LoopLayerCPUTest.CompareWithRefs/Input0_IS=\[1..10.1.1..10\]_.*_Input1_IS=\[1..8.1.1..8\]_.*_Input2_IS=\[1..10.\?.1..10\]_TS=.*_types=0_0_1_trip_count_type=.*_trip_count=(1|5)_exec_cond=1_netType=i8.*)", // Issue: 142997 R"(.*smoke_TestsROIAlign.*)", - // Issue: TODO + // Issue: 146063 R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", R"(.*smoke_MaxPoolV14_Ref_Fallback_4D_ceil_torch/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_MaxPool_K\(2.2\)_S\(2.2\)_D\(1.1\)_PB\(0.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", From 634bf8cf3a946ed992aee1c6de7622fab9554e0f Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 4 Jul 2024 14:08:42 +0200 Subject: [PATCH 54/61] Hopefully fix a test on CI --- .../custom/single_layer_tests/instances/common/pooling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 898499737c6e79..46ae130a32bc14 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -116,7 +116,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D, MaxPoolingV14LayerCPUTest, ::testing::ValuesIn(paramsMaxV144D()), ::testing::ValuesIn(inputShapes4DStatic()), ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(filterCPUInfo(vecCpuConfigsFusing_4D())), + ::testing::ValuesIn(vecCpuConfigs), ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); From 4cbc7a31ef5b5a82d9e11d1851e064bba0de89c1 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 4 Jul 2024 16:12:41 +0200 Subject: [PATCH 55/61] Align MaxPool v8 and v14 tests --- .../instances/common/pooling.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 46ae130a32bc14..8150e6d3f02e92 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -102,24 +102,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV143D()), - ::testing::ValuesIn(inputShapes3D()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(CPUTestUtils::empty_plugin_config)), - MaxPoolingV14LayerCPUTest::getTestCaseName); - -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D, MaxPoolingV14LayerCPUTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV144D()), - ::testing::ValuesIn(inputShapes4DStatic()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::ValuesIn(vecCpuConfigs), - ::testing::Values(CPUTestUtils::empty_plugin_config)), - MaxPoolingV14LayerCPUTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_4D_ceil_torch, MaxPoolingV14LayerRefFallbackTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV144D()), From 72678d6d53e78716028a73e1bc95319609f9110b Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Thu, 4 Jul 2024 17:33:15 +0200 Subject: [PATCH 56/61] Minor change --- .../custom/single_layer_tests/instances/x64/pooling.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 85deafd66253ab..d4d1db7c577c39 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -417,7 +417,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D_Ceil_Torch, MaxPoolingV14LayerC ::testing::ValuesIn(paramsMaxV143D()), ::testing::ValuesIn(inputShapes3DStatic()), ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "jit_avx512"}), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D)), ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); @@ -459,7 +459,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D, MaxPoolingV14LayerRefFallbackTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_RefFallback_5D, MaxPoolingV14LayerRefFallbackTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV145D()), ::testing::ValuesIn(inputShapes5DDynamic()), From 67705580e2d1f04cbfe1fe1a32cadc1a45c92cfc Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Jul 2024 10:37:55 +0200 Subject: [PATCH 57/61] Correct test name for skipping --- .../custom/single_layer_tests/instances/x64/pooling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index d4d1db7c577c39..06629bce45f414 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -459,7 +459,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_RefFallback_5D, MaxPoolingV14LayerRefFallbackTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D, MaxPoolingV14LayerRefFallbackTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV145D()), ::testing::ValuesIn(inputShapes5DDynamic()), From ad0f99289576fdacfffcab52098b7d6bf92f69ec Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Jul 2024 13:25:54 +0200 Subject: [PATCH 58/61] Remove evaluate --- src/core/include/openvino/op/avg_pool.hpp | 3 - src/core/src/op/avg_pool.cpp | 72 ----- src/plugins/intel_cpu/src/nodes/pooling.cpp | 28 +- .../single_layer_tests/classes/pooling.cpp | 245 ++---------------- .../single_layer_tests/classes/pooling.hpp | 24 -- .../instances/common/pooling.cpp | 52 ++-- .../instances/x64/pooling.cpp | 41 +-- .../skip_tests_config.cpp | 10 - 8 files changed, 58 insertions(+), 417 deletions(-) diff --git a/src/core/include/openvino/op/avg_pool.hpp b/src/core/include/openvino/op/avg_pool.hpp index 0d9b4cea958de7..90b55a1f4e0af2 100644 --- a/src/core/include/openvino/op/avg_pool.hpp +++ b/src/core/include/openvino/op/avg_pool.hpp @@ -84,9 +84,6 @@ class OPENVINO_API AvgPool : public util::AvgPoolBase { void validate_and_infer_types() override; - bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; - bool has_evaluate() const override; - std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace v14 diff --git a/src/core/src/op/avg_pool.cpp b/src/core/src/op/avg_pool.cpp index daff7e6a1db0f4..31adcbf1242025 100644 --- a/src/core/src/op/avg_pool.cpp +++ b/src/core/src/op/avg_pool.cpp @@ -7,36 +7,6 @@ #include "avg_pool_shape_inference.hpp" #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/reference/avg_pool.hpp" - -namespace avgpool { -struct Evaluate : ov::element::NoAction { - using ov::element::NoAction::visit; - - template - static result_type visit(const ov::Tensor& in, - ov::Tensor& out_values, - const ov::Shape& in_shape, - const ov::Shape& out_shape, - const ov::Shape& kernel, - const ov::Strides& strides, - const ov::Shape& pads_begin, - const ov::Shape& pads_end, - const bool exclude_pad) { - using T = typename ov::element_type_traits::value_type; - ov::reference::avg_pool(in.data(), - out_values.data(), - in_shape, - out_shape, - kernel, - strides, - pads_begin, - pads_end, - !exclude_pad); - return true; - } -}; -} // namespace avgpool // ------------------------------ V1 ------------------------------ namespace ov { @@ -117,48 +87,6 @@ std::shared_ptr AvgPool::clone_with_new_inputs(const OutputVector& new_arg m_auto_pad); } -bool AvgPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const { - OV_OP_SCOPE(v14_AvgPool_evaluate); - const auto input_shapes = std::vector{inputs[0].get_shape()}; - auto pads_begin = m_pads_begin; - auto pads_end = m_pads_end; - const auto output_shapes = shape_infer(this, input_shapes, pads_begin, pads_end); - - outputs[0].set_shape(output_shapes[0].get_shape()); - using namespace ov::element; - return IF_TYPE_OF_CONVERT_TENSORS(v14_AvgPool_evaluate, - this, - outputs, - inputs, - OV_PP_ET_LIST(f32, i32, i64, u32, u64), - avgpool::Evaluate, - inputs[0].get_element_type(), - inputs[0], - outputs[0], - inputs[0].get_shape(), - outputs[0].get_shape(), - get_kernel(), - get_strides(), - get_pads_begin(), - get_pads_end(), - get_exclude_pad()); -} -bool AvgPool::has_evaluate() const { - OV_OP_SCOPE(v14_AvgPool_has_evaluate); - switch (get_input_element_type(0)) { - case element::i8: - case element::i32: - case element::i64: - case element::u8: - case element::u32: - case element::u64: - case element::f16: - case element::f32: - return true; - default: - return false; - } -} } // namespace v14 } // namespace op } // namespace ov diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 204ffbbb3d4652..4825fdc98006bc 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -148,20 +148,20 @@ bool Pooling::isSupportedOperation(const std::shared_ptr& op, st try { const auto isMaxPoolV14 = ov::is_type(op); const auto isAvgPoolV14 = ov::is_type(op); - if ((isMaxPoolV14 || isAvgPoolV14) && op->is_dynamic()) { - if (isMaxPoolV14) { - if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { - errorMessage = "MaxPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; - return false; - } - } - if (isAvgPoolV14) { - if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { - errorMessage = "AvgPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; - return false; - } - } - } + //if ((isMaxPoolV14 || isAvgPoolV14) && op->is_dynamic()) { + // if (isMaxPoolV14) { + // if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { + // errorMessage = "MaxPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; + // return false; + // } + // } + // if (isAvgPoolV14) { + // if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { + // errorMessage = "AvgPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; + // return false; + // } + // } + //} if (ov::is_type(op) || isMaxPoolV14) { if (!op->get_output_target_inputs(1).empty()) { errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 2e104e067e1c6b..e2072e5c1bced2 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -224,61 +224,6 @@ void AvgPoolingV14LayerCPUTest::SetUp() { function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); } -std::string AvgPoolingV14LayerRefFallbackTest::getTestCaseName(const testing::TestParamInfo& obj) { - return util::AvgPoolV14GetTestCaseNameUtil(obj); -} - -void AvgPoolingV14LayerRefFallbackTest::SetUp() { - targetDevice = ov::test::utils::DEVICE_CPU; - - poolSpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - bool isInt8; - CPUSpecificParams cpuParams; - fusingSpecificParams fusingParams; - ov::AnyMap additionalConfig; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = this->GetParam(); - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - utils::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; - - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - std::tie(postOpMgrPtr, fusedOps) = fusingParams; - - if (selectedType.empty()) { - selectedType = getPrimitiveType(); - } - if (isInt8) - selectedType = selectedType + "_I8"; - else - selectedType = makeSelectedTypeStr(selectedType, inPrc); - - init_input_shapes({inputShapes}); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - - std::shared_ptr poolInput = params[0]; - if (isInt8) { - abs_threshold = 2e-2; - ov::Shape newShape(poolInput->get_output_partial_shape(0).size(), 1); - poolInput = ov::test::utils::make_fake_quantize(poolInput, inPrc, 256, newShape); - } - - auto pooling = std::make_shared(poolInput, stride, padBegin, padEnd, kernel, excludePad, roundingType, padType); - - function = makeNgraphFunction(inPrc, params, pooling, "PoolingCPU"); -} - std::string MaxPoolingV8LayerCPUTest::getTestCaseName( const testing::TestParamInfo& obj) { maxPoolV8SpecificParams basicParamsSet; @@ -461,97 +406,6 @@ void MaxPoolingV14LayerCPUTest::SetUp() { function = std::make_shared(results, params, "MaxPooling"); } -std::string MaxPoolingV14LayerRefFallbackTest::getTestCaseName( - const testing::TestParamInfo& obj) { - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - ov::AnyMap additionalConfig; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = obj.param; - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "MaxPool_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "D" << ov::test::utils::vec2str(dilation) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - if (!additionalConfig.empty()) { - results << "_PluginConf"; - for (auto& item : additionalConfig) { - results << "_" << item.first << "=" << item.second.as(); - } - } - - results << CPUTestsBase::getTestCaseName(cpuParams); - return results.str(); -} - -void MaxPoolingV14LayerRefFallbackTest::SetUp() { - targetDevice = ov::test::utils::DEVICE_CPU; - - maxPoolV8SpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - CPUSpecificParams cpuParams; - ov::AnyMap additionalConfig; - std::tie(basicParamsSet, inputShapes, inPrc, cpuParams, additionalConfig) = this->GetParam(); - configuration.insert(additionalConfig.begin(), additionalConfig.end()); - - std::vector kernel, stride, dilation; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - ov::element::Type indexElementType; - int64_t axis; - std::tie(kernel, stride, dilation, padBegin, padEnd, indexElementType, axis, roundingType, padType) = - basicParamsSet; - std::tie(inFmts, outFmts, priority, selectedType) = cpuParams; - if (selectedType.empty()) { - selectedType = getPrimitiveType(); - } - selectedType = makeSelectedTypeStr(selectedType, deduce_expected_precision(inPrc, configuration)); - - init_input_shapes({inputShapes}); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(inPrc, shape)); - } - auto pooling = std::make_shared(params[0], - stride, - dilation, - padBegin, - padEnd, - kernel, - roundingType, - padType, - indexElementType, - axis); - pooling->get_rt_info() = getCPUInfo(); - ov::ResultVector results{std::make_shared(pooling->output(0))}; - function = std::make_shared(results, params, "MaxPooling"); -} - TEST_P(PoolingLayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -562,11 +416,6 @@ TEST_P(AvgPoolingV14LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } -TEST_P(AvgPoolingV14LayerRefFallbackTest, CompareWithRefs) { - run(); - CheckPluginRelatedResults(compiledModel, "Reference"); -} - TEST_P(MaxPoolingV8LayerCPUTest, CompareWithRefs) { run(); CheckPluginRelatedResults(compiledModel, "Pooling"); @@ -577,11 +426,6 @@ TEST_P(MaxPoolingV14LayerCPUTest, CompareWithRefs) { CheckPluginRelatedResults(compiledModel, "Pooling"); } -TEST_P(MaxPoolingV14LayerRefFallbackTest, CompareWithRefs) { - run(); - CheckPluginRelatedResults(compiledModel, "Reference"); -} - namespace Pooling { // The combination of parameters: NCHW + CEIL gives an accuracy problem in ACL AvgPool @@ -708,18 +552,7 @@ const std::vector& paramsMaxV144D() { return paramsMaxV144D; } -const std::vector& inputShapes3DStatic() { - static const std::vector inputShapes3D = { - { {}, {{3, 4, 64}} }, - { {}, {{2, 8, 12}} }, - { {}, {{1, 16, 12}} }, - { {}, {{1, 21, 4}} }, - { {}, {{1, 32, 8}} } - }; - return inputShapes3D; -} - -const std::vector& inputShapes3DDynamic() { +const std::vector& inputShapes3D() { static const std::vector inputShapes3D = { { // dynamic @@ -740,32 +573,17 @@ const std::vector& inputShapes3DDynamic() { {1, 16, 12}, {1, 32, 8} } - } + }, + { {}, {{3, 4, 64}} }, + { {}, {{2, 8, 12}} }, + { {}, {{1, 16, 12}} }, + { {}, {{1, 21, 4}} }, + { {}, {{1, 32, 8}} } }; return inputShapes3D; } -const std::vector& inputShapes3D() { - static std::vector combinedInputShapes; - if (combinedInputShapes.empty()) { - combinedInputShapes = inputShapes3DStatic(); - const auto& dynamicShapes = inputShapes3DDynamic(); - combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); - } - return combinedInputShapes; -} - -const std::vector& inputShapes4DStatic() { - static const std::vector inputShapes4D = { - { {}, {{3, 4, 64, 64}} }, - { {}, {{2, 8, 8, 12}} }, - { {}, {{1, 16, 16, 12}} }, - { {}, {{1, 21, 8, 4}} }, - { {}, {{1, 32, 8, 8}} }}; - return inputShapes4D; -} - -const std::vector& inputShapes4DDynamic() { +const std::vector& inputShapes4D() { static const std::vector inputShapes4D = { { // dynamic @@ -796,33 +614,17 @@ const std::vector& inputShapes4DDynamic() { {1, 16, 8, 8}, {2, 16, 8, 8}, } - } + }, + { {}, {{3, 4, 64, 64}} }, + { {}, {{2, 8, 8, 12}} }, + { {}, {{1, 16, 16, 12}} }, + { {}, {{1, 21, 8, 4}} }, + { {}, {{1, 32, 8, 8}} } }; return inputShapes4D; } -const std::vector& inputShapes4D() { - static std::vector combinedInputShapes; - if (combinedInputShapes.empty()) { - combinedInputShapes = inputShapes4DStatic(); - const auto& dynamicShapes = inputShapes4DDynamic(); - combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); - } - return combinedInputShapes; -} - -const std::vector& inputShapes5DStatic() { - static const std::vector inputShapes5D = { - { {}, {{1, 4, 32, 32, 32}} }, - { {}, {{2, 8, 8, 8, 8}} }, - { {}, {{2, 16, 12, 16, 20}} }, - { {}, {{1, 19, 16, 20, 8}} }, - { {}, {{1, 32, 16, 8, 12}} }, - }; - return inputShapes5D; -} - -const std::vector& inputShapes5DDynamic() { +const std::vector& inputShapes5D() { static const std::vector inputShapes5D = { { {-1, -1, -1, -1, -1}, @@ -839,21 +641,16 @@ const std::vector& inputShapes5DDynamic() { {1, 32, 16, 8, 12}, {3, 16, 4, 8, 3} } - } + }, + { {}, {{1, 4, 32, 32, 32}} }, + { {}, {{2, 8, 8, 8, 8}} }, + { {}, {{2, 16, 12, 16, 20}} }, + { {}, {{1, 19, 16, 20, 8}} }, + { {}, {{1, 32, 16, 8, 12}} } }; return inputShapes5D; } -const std::vector& inputShapes5D() { - static std::vector combinedInputShapes; - if (combinedInputShapes.empty()) { - combinedInputShapes = inputShapes5DStatic(); - const auto& dynamicShapes = inputShapes5DDynamic(); - combinedInputShapes.insert(combinedInputShapes.end(), dynamicShapes.begin(), dynamicShapes.end()); - } - return combinedInputShapes; -} - const std::vector& paramsMaxV85D() { static const std::vector paramsMaxV85D = { maxPoolV8SpecificParams{ {2, 2, 2}, {1, 1, 1}, {1, 1, 1}, {0, 0, 0}, {0, 0, 0}, diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp index 14427fba7aaea4..6b77a65cd152bb 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.hpp @@ -47,15 +47,6 @@ class AvgPoolingV14LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CpuTestWithFusing { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - class MaxPoolingV8LayerCPUTest : public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { public: @@ -72,15 +63,6 @@ class MaxPoolingV14LayerCPUTest : public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CpuTestWithFusing { -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); - -protected: - void SetUp() override; -}; - namespace Pooling { const std::vector& inpOutPrecision(); const ov::op::RoundingType expectedAvgRoundingType(const ov::op::RoundingType ceil_type = ov::op::RoundingType::CEIL); @@ -104,15 +86,9 @@ const std::vector& paramsMaxV144D(); const std::vector& paramsMaxV145D(); const std::vector& inputShapes3D(); -const std::vector& inputShapes3DDynamic(); -const std::vector& inputShapes3DStatic(); const std::vector& inputShapes4D(); -const std::vector& inputShapes4DStatic(); -const std::vector& inputShapes4DDynamic(); const std::vector& inputShapes4D_Large(); const std::vector& inputShapes5D(); -const std::vector& inputShapes5DStatic(); -const std::vector& inputShapes5DDynamic(); const std::vector& paramsAvg4D(); const std::vector& paramsAvgV144D(); diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index 8150e6d3f02e92..f160731e19f410 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -55,8 +55,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_3D_NotOptimized, PoolingLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, ::testing::Combine( - ::testing::ValuesIn(paramsAvgV143D()), - ::testing::ValuesIn(inputShapes3DStatic()), + ::testing::ValuesIn(paramsAvg3D()), + ::testing::ValuesIn(inputShapes3D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), ::testing::ValuesIn(vecCpuConfigs), @@ -64,16 +64,16 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D, AvgPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), AvgPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_Ref_Fallback_3D, AvgPoolingV14LayerRefFallbackTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14CeilTorch_CPU_3D, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV143D()), - ::testing::ValuesIn(inputShapes3DDynamic()), + ::testing::ValuesIn(inputShapes3D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::ValuesIn(vecCpuConfigs), ::testing::Values(emptyFusingSpec), ::testing::Values(CPUTestUtils::empty_plugin_config)), - AvgPoolingV14LayerRefFallbackTest::getTestCaseName); + AvgPoolingV14LayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_NotOptimized, AvgPoolingV14LayerCPUTest, ::testing::Combine( @@ -102,15 +102,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), PoolingLayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_4D_ceil_torch, MaxPoolingV14LayerRefFallbackTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV144D()), - ::testing::ValuesIn(inputShapes4DDynamic()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), - ::testing::Values(CPUTestUtils::empty_plugin_config)), - MaxPoolingV14LayerRefFallbackTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), @@ -155,10 +146,10 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D, AvgPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), AvgPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_Ceil_torch, AvgPoolingV14LayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14CeilTorch_CPU_4D, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV144D()), - ::testing::ValuesIn(inputShapes4DStatic()), + ::testing::ValuesIn(inputShapes4D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), ::testing::ValuesIn(vecCpuConfigs), @@ -166,17 +157,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_Ceil_torch, AvgPoolingV14LayerC ::testing::Values(CPUTestUtils::empty_plugin_config)), AvgPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_Ref_Fallback_4D_Ceil_torch, AvgPoolingV14LayerRefFallbackTest, - ::testing::Combine( - ::testing::ValuesIn(paramsAvgV144D()), - ::testing::ValuesIn(inputShapes4DDynamic()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(false), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), - ::testing::Values(emptyFusingSpec), - ::testing::Values(CPUTestUtils::empty_plugin_config)), - AvgPoolingV14LayerRefFallbackTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_NotOptimized, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D_RefOnly), @@ -256,7 +236,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch, MaxPoolingV14LayerCPUTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_ceil_torch, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV145D()), ::testing::ValuesIn(inputShapes5D()), @@ -287,25 +267,25 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D, PoolingLayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_5D, AvgPoolingV14LayerCPUTest, ::testing::Combine( - ::testing::ValuesIn(paramsAvgV145D()), - ::testing::ValuesIn(inputShapes5DStatic()), + ::testing::ValuesIn(paramsAvg5D()), + ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), ::testing::ValuesIn(vecCpuConfigs), ::testing::Values(emptyFusingSpec), ::testing::Values(CPUTestUtils::empty_plugin_config)), - PoolingLayerCPUTest::getTestCaseName); + AvgPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_Ref_Fallback_5D, AvgPoolingV14LayerRefFallbackTest, +INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14CeilTorch_CPU_5D, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV145D()), - ::testing::ValuesIn(inputShapes5DDynamic()), + ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::Values(false), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::ValuesIn(vecCpuConfigs), ::testing::Values(emptyFusingSpec), ::testing::Values(CPUTestUtils::empty_plugin_config)), - AvgPoolingV14LayerRefFallbackTest::getTestCaseName); + PoolingLayerCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_5D_NotOptimized, PoolingLayerCPUTest, ::testing::Combine( diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp index 06629bce45f414..cfe29692f8414c 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/x64/pooling.cpp @@ -237,7 +237,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_FP16, AvgPoolingV14LayerCPUTest INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_3D_FP16_Ceil_Torch, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvgV143D()), - ::testing::ValuesIn(inputShapes3DStatic()), + ::testing::ValuesIn(inputShapes3D()), ::testing::ValuesIn(inpOutPrecision()), ::testing::Values(false), ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), @@ -277,21 +277,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D_FP16, MaxPoolingV14LayerCPUTest INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_4D_FP16_Ceil_Torch, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV144D()), - ::testing::ValuesIn(inputShapes4DStatic()), + ::testing::ValuesIn(inputShapes4D()), ::testing::ValuesIn(inpOutPrecision()), ::testing::ValuesIn(filterCPUInfoForDeviceWithFP16(vecCpuConfigs)), ::testing::Values(cpu_f16_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_4D_FP16, MaxPoolingV14LayerRefFallbackTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV144D()), - ::testing::ValuesIn(inputShapes4DDynamic()), - ::testing::ValuesIn(inpOutPrecision()), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), - ::testing::Values(cpu_f16_plugin_config)), - MaxPoolingV14LayerRefFallbackTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_AvgPoolV14_CPU_4D_FP16, AvgPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), @@ -374,15 +365,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D_FP16_Ceil_Torch, MaxPoolingV14L ::testing::Values(cpu_f16_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D_FP16, MaxPoolingV14LayerRefFallbackTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV145D()), - ::testing::ValuesIn(inputShapes5DDynamic()), - ::testing::ValuesIn(inpOutPrecision()), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), - ::testing::Values(cpu_f16_plugin_config)), - MaxPoolingV14LayerRefFallbackTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_3D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax3D()), @@ -415,21 +397,12 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D, MaxPoolingV14LayerCPUTest, INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_3D_Ceil_Torch, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV143D()), - ::testing::ValuesIn(inputShapes3DStatic()), + ::testing::ValuesIn(inputShapes3D()), ::testing::ValuesIn((inpOutPrecision())), ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_3D)), ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_3D, MaxPoolingV14LayerRefFallbackTest, - ::testing::Combine( - ::testing::ValuesIn(paramsMaxV143D()), - ::testing::ValuesIn(inputShapes3DDynamic()), - ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), - ::testing::Values(CPUTestUtils::empty_plugin_config)), - MaxPoolingV14LayerRefFallbackTest::getTestCaseName); - INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_5D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMax5D()), @@ -459,14 +432,14 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), MaxPoolingV14LayerCPUTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14_Ref_Fallback_5D, MaxPoolingV14LayerRefFallbackTest, +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV14CeilTorch_CPU_5D, MaxPoolingV14LayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsMaxV145D()), - ::testing::ValuesIn(inputShapes5DDynamic()), + ::testing::ValuesIn(inputShapes5D()), ::testing::ValuesIn((inpOutPrecision())), - ::testing::Values(CPUSpecificParams{{}, {}, {}, "ref"}), + ::testing::ValuesIn(filterCPUInfoForDevice(vecCpuConfigsFusing_5D)), ::testing::Values(CPUTestUtils::empty_plugin_config)), - MaxPoolingV14LayerRefFallbackTest::getTestCaseName); + MaxPoolingV14LayerCPUTest::getTestCaseName); } // namespace } // namespace Pooling } // namespace test diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index e8cce0eb491051..70dd06ecfb44d9 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -314,16 +314,6 @@ std::vector disabledTestPatterns() { R"(.*smoke_LoopForCommon/LoopLayerCPUTest.CompareWithRefs/Input0_IS=\[1..10.1.1..10\]_.*_Input1_IS=\[1..8.1.1..8\]_.*_Input2_IS=\[1..10.\?.1..10\]_TS=.*_types=0_0_1_trip_count_type=.*_trip_count=(1|5)_exec_cond=1_netType=i8.*)", // Issue: 142997 R"(.*smoke_TestsROIAlign.*)", - // Issue: 146063 - R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", - R"(.*smoke_MaxPoolV14_Ref_Fallback_5D_ceil_torch/MaxPoolingV14LayerCPUTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref_any.*)", - R"(.*smoke_MaxPoolV14_Ref_Fallback_4D_ceil_torch/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_MaxPool_K\(2.2\)_S\(2.2\)_D\(1.1\)_PB\(0.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", - R"(.*smoke_MaxPoolV14_Ref_Fallback_5D/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", - R"(.*smoke_MaxPoolV14_Ref_Fallback_5D/MaxPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_MaxPool_K\(2.2.2\)_S\(1.1.1\)_D\(1.1.1\)_PB\(0.0.0\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower__primitive=ref.*)", - R"(.*smoke_AvgPoolV14_Ref_Fallback_4D_Ceil_torch/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_ExcludePad=1_K\(2.2\)_S\(2.2\)_PB\(0.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)", - R"(.*smoke_AvgPoolV14_Ref_Fallback_4D_Ceil_torch/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?\]\)_TS=\(1.32.8.8\)_\(1.21.8.4\)_\(2.8.8.12\)_\(1.96.125.125\)_Prc=f32_ExcludePad=0_K\(2.2\)_S\(2.2\)_PB\(1.0\)_PE\(0.0\)_Rounding=ceil_torch_AutoPad=same_upper_INT8=0__primitive=ref.*)", - R"(.*smoke_AvgPoolV14_Ref_Fallback_5D/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[\?.\?.\?.\?.\?\]\)_TS=\(2.8.8.8.8\)_\(1.19.16.20.8\)_\(1.4.16.16.16\)_Prc=f32_ExcludePad=1_K\(3.3.3\)_S\(3.3.3\)_PB\(1.1.1\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)", - R"(.*smoke_AvgPoolV14_Ref_Fallback_5D/AvgPoolingV14LayerRefFallbackTest.CompareWithRefs/IS=\(\[1..5.4..32.1..64.1..64.1..25\]\)_TS=\(1.4.16.16.16\)_\(1.32.16.8.12\)_\(3.16.4.8.3\)_Prc=f32_ExcludePad=1_K\(3.3.3\)_S\(3.3.3\)_PB\(1.1.1\)_PE\(0.0.0\)_Rounding=ceil_torch_AutoPad=same_lower_INT8=0__primitive=ref.*)" }; // fp32 floor for bf16 models: conversion issue From c1b12167bc4ce42cf5ecc6213b43adc4906d69a7 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Jul 2024 13:45:28 +0200 Subject: [PATCH 59/61] Cleanup --- .../src/transformations/convert_precision.cpp | 3 +- src/plugins/intel_cpu/src/nodes/pooling.cpp | 22 +-- .../single_layer_tests/classes/pooling.cpp | 132 +++++++++--------- .../instances/common/pooling.cpp | 9 ++ 4 files changed, 78 insertions(+), 88 deletions(-) diff --git a/src/common/transformations/src/transformations/convert_precision.cpp b/src/common/transformations/src/transformations/convert_precision.cpp index 9d13c4d975fc33..f6cd1ab20012f7 100644 --- a/src/common/transformations/src/transformations/convert_precision.cpp +++ b/src/common/transformations/src/transformations/convert_precision.cpp @@ -931,8 +931,7 @@ bool fuse_type_to_maxpool(const std::shared_ptr& node, const precision return update_type(1, node, precisions, [&](const element::Type& to) { maxpool_v14->set_index_element_type(to); }); - } - if (maxpool_v8) { + } else if (maxpool_v8) { return update_type(1, node, precisions, [&](const element::Type& to) { maxpool_v8->set_index_element_type(to); }); diff --git a/src/plugins/intel_cpu/src/nodes/pooling.cpp b/src/plugins/intel_cpu/src/nodes/pooling.cpp index 4825fdc98006bc..d412cdaecda192 100644 --- a/src/plugins/intel_cpu/src/nodes/pooling.cpp +++ b/src/plugins/intel_cpu/src/nodes/pooling.cpp @@ -146,30 +146,14 @@ dnnl::pooling_forward::primitive_desc createDescriptorHelper(const dnnl::engine& bool Pooling::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - const auto isMaxPoolV14 = ov::is_type(op); - const auto isAvgPoolV14 = ov::is_type(op); - //if ((isMaxPoolV14 || isAvgPoolV14) && op->is_dynamic()) { - // if (isMaxPoolV14) { - // if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { - // errorMessage = "MaxPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; - // return false; - // } - // } - // if (isAvgPoolV14) { - // if (ov::as_type_ptr(op)->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH) { - // errorMessage = "AvgPool-14 with ov::op::RoundingType::CEIL_TORCH is not supported with dynamic shapes."; - // return false; - // } - // } - //} - if (ov::is_type(op) || isMaxPoolV14) { + if (ov::is_type(op) || ov::is_type(op)) { if (!op->get_output_target_inputs(1).empty()) { errorMessage = "MaxPool from opset8 and opset14 is supported only with one output"; return false; } } else if (!ov::is_type(op) && !ov::is_type(op) && - !isMaxPoolV14 && !ov::is_type(op) && - !isAvgPoolV14) { + !ov::is_type(op) && !ov::is_type(op) && + !ov::is_type(op)) { errorMessage = "Supported ops are MaxPool-1, MaxPool-8, MaxPool-14, AvgPool-1 and AvgPool-14"; return false; } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index e2072e5c1bced2..090442bc549b00 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -11,54 +11,6 @@ using namespace CPUTestUtils; namespace ov { namespace test { -namespace util { - static std::string AvgPoolV14GetTestCaseNameUtil(const testing::TestParamInfo& obj) { - ov::test::poolSpecificParams basicParamsSet; - InputShape inputShapes; - ElementType inPrc; - bool isInt8; - CPUSpecificParams cpuParams; - fusingSpecificParams fusingParams; - ov::AnyMap additionalConfig; - std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = obj.param; - - utils::PoolingTypes poolType; - std::vector kernel, stride; - std::vector padBegin, padEnd; - ov::op::PadType padType; - ov::op::RoundingType roundingType; - bool excludePad; - std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; - - std::ostringstream results; - results << "IS=("; - results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; - results << "TS="; - for (const auto& shape : inputShapes.second) { - results << ov::test::utils::vec2str(shape) << "_"; - } - results << "Prc=" << inPrc << "_"; - results << "ExcludePad=" << excludePad << "_"; - results << "K" << ov::test::utils::vec2str(kernel) << "_"; - results << "S" << ov::test::utils::vec2str(stride) << "_"; - results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; - results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; - results << "Rounding=" << roundingType << "_"; - results << "AutoPad=" << padType << "_"; - results << "INT8=" << isInt8 << "_"; - if (!additionalConfig.empty()) { - results << "_PluginConf"; - for (auto& item : additionalConfig) { - results << "_" << item.first << "=" << item.second.as(); - } - } - - results << CPUTestsBase::getTestCaseName(cpuParams); - results << CpuTestWithFusing::getTestCaseName(fusingParams); - return results.str(); -} -} // namespace util - std::string PoolingLayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { ov::test::poolSpecificParams basicParamsSet; InputShape inputShapes; @@ -170,7 +122,49 @@ void PoolingLayerCPUTest::SetUp() { } std::string AvgPoolingV14LayerCPUTest::getTestCaseName(const testing::TestParamInfo& obj) { - return util::AvgPoolV14GetTestCaseNameUtil(obj); + ov::test::poolSpecificParams basicParamsSet; + InputShape inputShapes; + ElementType inPrc; + bool isInt8; + CPUSpecificParams cpuParams; + fusingSpecificParams fusingParams; + ov::AnyMap additionalConfig; + std::tie(basicParamsSet, inputShapes, inPrc, isInt8, cpuParams, fusingParams, additionalConfig) = obj.param; + + utils::PoolingTypes poolType; + std::vector kernel, stride; + std::vector padBegin, padEnd; + ov::op::PadType padType; + ov::op::RoundingType roundingType; + bool excludePad; + std::tie(poolType, kernel, stride, padBegin, padEnd, roundingType, padType, excludePad) = basicParamsSet; + + std::ostringstream results; + results << "IS=("; + results << ov::test::utils::partialShape2str({inputShapes.first}) << ")_"; + results << "TS="; + for (const auto& shape : inputShapes.second) { + results << ov::test::utils::vec2str(shape) << "_"; + } + results << "Prc=" << inPrc << "_"; + results << "ExcludePad=" << excludePad << "_"; + results << "K" << ov::test::utils::vec2str(kernel) << "_"; + results << "S" << ov::test::utils::vec2str(stride) << "_"; + results << "PB" << ov::test::utils::vec2str(padBegin) << "_"; + results << "PE" << ov::test::utils::vec2str(padEnd) << "_"; + results << "Rounding=" << roundingType << "_"; + results << "AutoPad=" << padType << "_"; + results << "INT8=" << isInt8 << "_"; + if (!additionalConfig.empty()) { + results << "_PluginConf"; + for (auto& item : additionalConfig) { + results << "_" << item.first << "=" << item.second.as(); + } + } + + results << CPUTestsBase::getTestCaseName(cpuParams); + results << CpuTestWithFusing::getTestCaseName(fusingParams); + return results.str(); } void AvgPoolingV14LayerCPUTest::SetUp() { @@ -554,6 +548,11 @@ const std::vector& paramsMaxV144D() { const std::vector& inputShapes3D() { static const std::vector inputShapes3D = { + { {}, {{3, 4, 64}} }, + { {}, {{2, 8, 12}} }, + { {}, {{1, 16, 12}} }, + { {}, {{1, 21, 4}} }, + { {}, {{1, 32, 8}} }, { // dynamic {-1, -1, -1}, @@ -573,18 +572,18 @@ const std::vector& inputShapes3D() { {1, 16, 12}, {1, 32, 8} } - }, - { {}, {{3, 4, 64}} }, - { {}, {{2, 8, 12}} }, - { {}, {{1, 16, 12}} }, - { {}, {{1, 21, 4}} }, - { {}, {{1, 32, 8}} } + } }; return inputShapes3D; } const std::vector& inputShapes4D() { static const std::vector inputShapes4D = { + { {}, {{3, 4, 64, 64}} }, + { {}, {{2, 8, 8, 12}} }, + { {}, {{1, 16, 16, 12}} }, + { {}, {{1, 21, 8, 4}} }, + { {}, {{1, 32, 8, 8}} }, { // dynamic {-1, -1, -1, -1}, @@ -614,20 +613,22 @@ const std::vector& inputShapes4D() { {1, 16, 8, 8}, {2, 16, 8, 8}, } - }, - { {}, {{3, 4, 64, 64}} }, - { {}, {{2, 8, 8, 12}} }, - { {}, {{1, 16, 16, 12}} }, - { {}, {{1, 21, 8, 4}} }, - { {}, {{1, 32, 8, 8}} } + } }; return inputShapes4D; } const std::vector& inputShapes5D() { static const std::vector inputShapes5D = { + { {}, {{1, 4, 16, 16, 16}} }, + { {}, {{2, 8, 8, 8, 8}} }, + { {}, {{2, 16, 12, 16, 20}} }, + { {}, {{1, 19, 16, 20, 8}} }, + { {}, {{1, 32, 16, 8, 12}} }, { + // dynamic {-1, -1, -1, -1, -1}, + // target { {2, 8, 8, 8, 8}, {1, 19, 16, 20, 8}, @@ -635,18 +636,15 @@ const std::vector& inputShapes5D() { } }, { + // dynamic {{1, 5}, {4, 32}, {1, 64}, {1, 64}, {1, 25}}, + // target { {1, 4, 16, 16, 16}, {1, 32, 16, 8, 12}, {3, 16, 4, 8, 3} } - }, - { {}, {{1, 4, 32, 32, 32}} }, - { {}, {{2, 8, 8, 8, 8}} }, - { {}, {{2, 16, 12, 16, 20}} }, - { {}, {{1, 19, 16, 20, 8}} }, - { {}, {{1, 32, 16, 8, 12}} } + } }; return inputShapes5D; } diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp index f160731e19f410..87f86d78197871 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/instances/common/pooling.cpp @@ -102,6 +102,15 @@ INSTANTIATE_TEST_SUITE_P(smoke_MaxPool_CPU_4D, PoolingLayerCPUTest, ::testing::Values(CPUTestUtils::empty_plugin_config)), PoolingLayerCPUTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_MaxPoolV8_CPU_4D, MaxPoolingV8LayerCPUTest, + ::testing::Combine( + ::testing::ValuesIn(paramsMaxV84D()), + ::testing::ValuesIn(inputShapes4D()), + ::testing::ValuesIn((inpOutPrecision())), + ::testing::ValuesIn(filterCPUInfo(vecCpuConfigsFusing_4D())), + ::testing::Values(CPUTestUtils::empty_plugin_config)), + MaxPoolingV8LayerCPUTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_AvgPool_CPU_4D, PoolingLayerCPUTest, ::testing::Combine( ::testing::ValuesIn(paramsAvg4D()), From c9615d544658c06b76e2fd79c7db4ea34c3d7012 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Fri, 5 Jul 2024 21:26:39 +0200 Subject: [PATCH 60/61] Fix for f16 tests --- .../functional/custom/single_layer_tests/classes/pooling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp index 090442bc549b00..7c4854dd334bcf 100644 --- a/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/custom/single_layer_tests/classes/pooling.cpp @@ -197,7 +197,7 @@ void AvgPoolingV14LayerCPUTest::SetUp() { if (isInt8) selectedType = selectedType + "_I8"; else - selectedType = makeSelectedTypeStr(selectedType, inPrc); + selectedType = makeSelectedTypeStr(selectedType, deduce_expected_precision(inPrc, configuration)); init_input_shapes({inputShapes}); From c0c93e462e0fda9948c69dce56038fbfa504ef73 Mon Sep 17 00:00:00 2001 From: p-wysocki Date: Mon, 8 Jul 2024 09:45:42 +0200 Subject: [PATCH 61/61] CR --- src/core/src/op/max_pool.cpp | 5 ++--- .../src/transformations/transformation_pipeline.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp index efe7f868d33ae5..741f57105efb4d 100644 --- a/src/core/src/op/max_pool.cpp +++ b/src/core/src/op/max_pool.cpp @@ -422,10 +422,9 @@ bool MaxPool::evaluate(TensorVector& outputs, const TensorVector& inputs) const auto pads_begin = m_pads_begin; auto pads_end = m_pads_end; const auto output_shapes = shape_infer(this, input_shapes, pads_begin, pads_end); + outputs[0].set_shape(output_shapes[0].get_shape()); - if (outputs.size() == 2) { - outputs[1].set_shape(output_shapes[1].get_shape()); - } + return ov::op::maxpool::evaluate_util(this, outputs, inputs, get_dilations(), get_axis()); } diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index 6e421e90bc19f6..b755062c7361f1 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -469,10 +469,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis manager, [](const_node_ptr& node) -> bool { const auto maxpool = std::dynamic_pointer_cast(node); - if (maxpool && maxpool->get_rounding_type() != ov::op::RoundingType::CEIL_TORCH) { - return false; - } - return true; + return !maxpool || maxpool->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; }, ov::pass::ConvertMaxPool14ToMaxPool8); @@ -480,10 +477,7 @@ void Transformations::PreLpt(const std::vector& defaultPrecis manager, [](const_node_ptr& node) -> bool { const auto avgpool = std::dynamic_pointer_cast(node); - if (avgpool && avgpool->get_rounding_type() != ov::op::RoundingType::CEIL_TORCH) { - return false; - } - return true; + return !avgpool || avgpool->get_rounding_type() == ov::op::RoundingType::CEIL_TORCH; }, ov::pass::ConvertAvgPool14ToAvgPool1);