From 3d33cb2b43c3619f8c0d8d885adafdd824ec3486 Mon Sep 17 00:00:00 2001 From: Nesterov Alexander Date: Wed, 19 Apr 2023 16:52:09 +0200 Subject: [PATCH] [ARM CPU] Fix eltwise op tests (Divide) (#17029) * update skip list * skip change * fix divide * review fixes * review fixes #2 --- .../arm/pass/decompose_integer_divide.cpp | 32 +++++++++++++++++++ .../arm/pass/decompose_integer_divide.hpp | 19 +++++++++++ .../transformation_pipeline.cpp | 4 +++ .../skip_tests_config.cpp | 9 ------ 4 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.cpp create mode 100644 src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.hpp diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.cpp new file mode 100644 index 00000000000000..e36947cb5cb88c --- /dev/null +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.cpp @@ -0,0 +1,32 @@ +// Copyright (C) 2020-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#include "decompose_integer_divide.hpp" +#include +#include + +namespace ov { +namespace intel_cpu { + +DecomposeIntegerDivide::DecomposeIntegerDivide() { + register_matcher(std::make_shared(ngraph::pattern::wrap_type(), "DecomposeIntegerDivide"), + [](ngraph::pattern::Matcher& m) { + auto divide = std::dynamic_pointer_cast(m.get_match_root()); + if (!divide) { + return false; + } + if (!divide->get_element_type().is_integral_number()) { + return false; + } + + auto new_divide = std::make_shared(divide->input_value(0), divide->input_value(1)); + auto new_floor = std::make_shared(new_divide); + new_floor->set_friendly_name(divide->get_friendly_name()); + ngraph::copy_runtime_info(divide, new_floor); + ngraph::replace_node(divide, new_floor); + return true; + }); +} + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.hpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.hpp new file mode 100644 index 00000000000000..c9d23bee89d6fb --- /dev/null +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/arm/pass/decompose_integer_divide.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2020-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include +#include + +namespace ov { +namespace intel_cpu { + +class DecomposeIntegerDivide: public ngraph::pass::MatcherPass { +public: + OPENVINO_RTTI("DecomposeIntegerDivide", "0"); + DecomposeIntegerDivide(); +}; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp index 6f7bfd7d7a517b..36dcdd1f456076 100644 --- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp @@ -99,6 +99,7 @@ #include "transformations/cpu_opset/arm/pass/convert_group_conv1d.hpp" #include "transformations/cpu_opset/arm/pass/convert_reduce_multi_axis.hpp" #include "transformations/cpu_opset/arm/pass/mish_decomposition.hpp" +#include "transformations/cpu_opset/arm/pass/decompose_integer_divide.hpp" #include "transformations/cpu_opset/common/pass/convert_fq_rnn_to_quantized_rnn.hpp" #include "transformations/cpu_opset/common/pass/move_eltwise_up_data_movement.hpp" #include "transformations/cpu_opset/common/pass/ref_convert_i64_i32.hpp" @@ -262,6 +263,9 @@ void Transformations::PreLpt(const std::vector& defaultPrecis CPU_REGISTER_PASS_ARM(manager, ConvertConv1D); CPU_REGISTER_PASS_ARM(manager, ConvertGroupConv1D); CPU_REGISTER_PASS_ARM(manager, ConvertGroupConvolution); + // The plugin computes Divide in floating point precision. + // To preserve correct math for integer division we need to insert explicit Floor operation. + CPU_REGISTER_PASS_ARM(manager, DecomposeIntegerDivide); // SpaceToDepth/ DepthToSpace node implementation supports only equal input/output tensors with rank <= 5 CPU_SET_CALLBACK_COMMON(manager, 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 3c695b3c2b700e..bc843d9b2e6860 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 @@ -201,14 +201,6 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckWithSecondaryPropertiesDoubleTest.*)"); } retVector.emplace_back(R"(smoke_LPT.*)"); - retVector.emplace_back(R"(smoke_Activation_Basic/ActivationLayerTest.CompareWithRefs.*)"); - retVector.emplace_back(R"(smoke_Integer_Activation_Basic/ActivationLayerTest.CompareWithRefs/(Tanh|Negative|Sqrt).*)"); - retVector.emplace_back(R"(smoke_Activation_Basic_Prelu_Const/ActivationLayerTest.CompareWithRefs/(LeakyRelu|PReLu).*)"); - retVector.emplace_back(R"(smoke_Activation_Basic_Prelu_Param/ActivationParamLayerTest.CompareWithRefs/(LeakyRelu|PReLu).*)"); - retVector.emplace_back(R"(smoke_CompareWithRefs/ComparisonLayerTest.ComparisonTests.*)"); - retVector.emplace_back(R"(smoke_CompareWithRefs_static/EltwiseLayerTest.EltwiseTests.*)"); - retVector.emplace_back(R"(smoke_CompareWithRefs_static_check_collapsing/EltwiseLayerTest.EltwiseTests.*)"); - retVector.emplace_back(R"(smoke_SingleThread/EltwiseLayerTest.EltwiseTests.*)"); retVector.emplace_back(R"(smoke_Decomposition_(3|4)D/Mvn6LayerTest.CompareWithRefs.*)"); retVector.emplace_back(R"(smoke_AvgPool_ExplicitPad_CeilRounding/PoolingLayerTest.CompareWithRefs.*)"); retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.CompareWithRefs.*)"); @@ -217,7 +209,6 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(smoke_Quantized.*)"); retVector.emplace_back(R"(smoke_NegativeQuantizedMatMulMultiplyFusion.*)"); retVector.emplace_back(R"(MultipleLSTMCellTest/MultipleLSTMCellTest.CompareWithRefs.*)"); - retVector.emplace_back(R"(smoke_MultipleAdd_Nd/MultiplyAddLayerTest.CompareWithRefs.*)"); retVector.emplace_back(R"(smoke_If/SimpleIfTest.CompareWithRefs.*)"); retVector.emplace_back(R"(smoke_If/SimpleIfNotConstConditionTest.CompareWithRefs.*)"); #endif