From ce378739f0f8a6b7ca173e1613b2b5fcbb5bc84e Mon Sep 17 00:00:00 2001 From: Oleg Pipikin Date: Fri, 22 Sep 2023 14:35:20 +0200 Subject: [PATCH] Refactor DetectionOutputLayerTest, DFTLayerTest, EltwiseLayerTest (#19922) * Refactor DetectionOutputLayerTest * Refactor DFTLayerTest * Refactor EltwiseLayerTest * Fix * Fix * Disable tests --- .../single_layer_tests/detection_output.cpp | 6 +- .../single_layer_tests/dft.cpp | 53 +++---- .../single_layer_tests/eltwise.cpp | 117 +++++++-------- .../skip_tests_config.cpp | 3 + .../single_op_tests/detection_output.hpp | 15 ++ .../shared/include/single_op_tests/dft.hpp | 15 ++ .../include/single_op_tests/eltwise.hpp | 15 ++ .../shared_test_classes/base/utils/ranges.hpp | 5 + .../single_op/detection_output.hpp | 73 ++++++++++ .../shared_test_classes/single_op/dft.hpp | 33 +++++ .../shared_test_classes/single_op/eltwise.hpp | 38 +++++ .../src/single_op/detection_output.cpp | 116 +++++++++++++++ .../shared_test_classes/src/single_op/dft.cpp | 58 ++++++++ .../src/single_op/eltwise.cpp | 135 ++++++++++++++++++ 14 files changed, 596 insertions(+), 86 deletions(-) create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/detection_output.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/dft.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/eltwise.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/detection_output.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/dft.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/eltwise.hpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/detection_output.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/dft.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/eltwise.cpp diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/detection_output.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/detection_output.cpp index 8d44f46f6d6..2028d643d67 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/detection_output.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/detection_output.cpp @@ -2,11 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/detection_output.hpp" - -using namespace LayerTestsDefinitions; +#include "single_op_tests/detection_output.hpp" namespace { +using ov::test::DetectionOutputLayerTest; +using ov::test::ParamsWhichSizeDepends; const int numClasses = 11; const int backgroundLabelId = 0; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/dft.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/dft.cpp index 9982fa013ca..9d91f2d5ca5 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/dft.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/dft.cpp @@ -4,28 +4,30 @@ #include -#include "single_layer_tests/dft.hpp" +#include "single_op_tests/dft.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +namespace { +using ov::test::DFTLayerTest; -const std::vector opTypes = { - ngraph::helpers::DFTOpType::FORWARD, - ngraph::helpers::DFTOpType::INVERSE +const std::vector op_types = { + ov::test::utils::DFTOpType::FORWARD, + ov::test::utils::DFTOpType::INVERSE }; -const std::vector inputPrecision = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::BF16 +const std::vector input_type = { + ov::element::f32, + ov::element::bf16 }; -const std::vector> inputShapes = { - {10, 4, 20, 32, 2}, - {2, 5, 7, 8, 2}, - {1, 120, 128, 1, 2}, +const std::vector> input_shapes_static = { + {{10, 4, 20, 32, 2}}, + {{2, 5, 7, 8, 2}}, + {{1, 120, 128, 1, 2}}, }; /* 1D DFT */ + const std::vector> axes1D = { {0}, {1}, {2}, {3}, {-2} }; @@ -35,11 +37,11 @@ const std::vector> signalSizes1D = { }; const auto testCase1D = ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), + ::testing::ValuesIn(input_type), ::testing::ValuesIn(axes1D), ::testing::ValuesIn(signalSizes1D), - ::testing::ValuesIn(opTypes), + ::testing::ValuesIn(op_types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); @@ -53,15 +55,14 @@ const std::vector> signalSizes2D = { }; const auto testCase2D = ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), + ::testing::ValuesIn(input_type), ::testing::ValuesIn(axes2D), ::testing::ValuesIn(signalSizes2D), - ::testing::ValuesIn(opTypes), + ::testing::ValuesIn(op_types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); - /* 3D DFT */ const std::vector> axes3D = { @@ -73,11 +74,11 @@ const std::vector> signalSizes3D = { }; const auto testCase3D = ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), + ::testing::ValuesIn(input_type), ::testing::ValuesIn(axes3D), ::testing::ValuesIn(signalSizes3D), - ::testing::ValuesIn(opTypes), + ::testing::ValuesIn(op_types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); @@ -92,16 +93,16 @@ const std::vector> signalSizes4D = { }; const auto testCase4D = ::testing::Combine( - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), + ::testing::ValuesIn(input_type), ::testing::ValuesIn(axes4D), ::testing::ValuesIn(signalSizes4D), - ::testing::ValuesIn(opTypes), + ::testing::ValuesIn(op_types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); - INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_1d, DFTLayerTest, testCase1D, DFTLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_2d, DFTLayerTest, testCase2D, DFTLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_3d, DFTLayerTest, testCase3D, DFTLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsDFT_4d, DFTLayerTest, testCase4D, DFTLayerTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp index 49ccc2c37bc..f8a80efe1f6 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -3,13 +3,16 @@ // #include -#include "single_layer_tests/eltwise.hpp" +#include "single_op_tests/eltwise.hpp" #include "common_test_utils/test_constants.hpp" -using namespace ov::test::subgraph; - namespace { -std::vector> inShapesStatic = { +using ov::test::EltwiseLayerTest; +using ov::test::utils::InputLayerType; +using ov::test::utils::OpType; +using ov::test::utils::EltwiseTypes; + +std::vector> in_shapes_static = { {{2}}, {{2, 200}}, {{10, 200}}, @@ -29,103 +32,103 @@ std::vector> inShapesStatic = { {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}, }; -std::vector> inShapesStaticCheckCollapse = { +std::vector> in_shapes_static_check_collapse = { {{16, 16, 16, 16}, {16, 16, 16, 1}}, {{16, 16, 16, 1}, {16, 16, 16, 1}}, {{16, 16, 16, 16}, {16, 16, 1, 16}}, {{16, 16, 1, 16}, {16, 16, 1, 16}}, }; -std::vector> inShapesDynamic = { +std::vector> in_shapes_dynamic = { {{{ngraph::Dimension(1, 10), 200}, {{2, 200}, {1, 200}}}, {{ngraph::Dimension(1, 10), 200}, {{2, 200}, {5, 200}}}}, }; -std::vector> inShapesDynamicLargeUpperBound = { +std::vector> in_shapes_dynamic_large_upper_bound = { {{{ngraph::Dimension(1, 1000000000000), 200}, {{2, 200}, {5, 200}}}}, }; -std::vector netPrecisions = { +std::vector model_types = { ov::element::f32, ov::element::f16, ov::element::i32, }; -std::vector secondaryInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER, +std::vector secondary_input_types = { + InputLayerType::CONSTANT, + InputLayerType::PARAMETER, }; -std::vector secondaryInputTypesDynamic = { - ngraph::helpers::InputLayerType::PARAMETER, +std::vector secondary_input_types_dynamic = { + InputLayerType::PARAMETER, }; -std::vector opTypes = { - ov::test::utils::OpType::SCALAR, - ov::test::utils::OpType::VECTOR, +std::vector op_types = { + OpType::SCALAR, + OpType::VECTOR, }; -std::vector opTypesDynamic = { - ov::test::utils::OpType::VECTOR, +std::vector op_types_dynamic = { + OpType::VECTOR, }; -std::vector eltwiseOpTypes = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::MULTIPLY, - ngraph::helpers::EltwiseTypes::SUBTRACT, - ngraph::helpers::EltwiseTypes::DIVIDE, - ngraph::helpers::EltwiseTypes::FLOOR_MOD, - ngraph::helpers::EltwiseTypes::SQUARED_DIFF, - ngraph::helpers::EltwiseTypes::POWER, - ngraph::helpers::EltwiseTypes::MOD +std::vector eltwise_op_types = { + EltwiseTypes::ADD, + EltwiseTypes::MULTIPLY, + EltwiseTypes::SUBTRACT, + EltwiseTypes::DIVIDE, + EltwiseTypes::FLOOR_MOD, + EltwiseTypes::SQUARED_DIFF, + EltwiseTypes::POWER, + EltwiseTypes::MOD }; -std::vector eltwiseOpTypesDynamic = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::MULTIPLY, - ngraph::helpers::EltwiseTypes::SUBTRACT, +std::vector eltwise_op_types_dynamic = { + EltwiseTypes::ADD, + EltwiseTypes::MULTIPLY, + EltwiseTypes::SUBTRACT, }; ov::test::Config additional_config = {}; const auto multiply_params = ::testing::Combine( - ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesStatic)), - ::testing::ValuesIn(eltwiseOpTypes), - ::testing::ValuesIn(secondaryInputTypes), - ::testing::ValuesIn(opTypes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(in_shapes_static)), + ::testing::ValuesIn(eltwise_op_types), + ::testing::ValuesIn(secondary_input_types), + ::testing::ValuesIn(op_types), + ::testing::ValuesIn(model_types), ::testing::Values(ov::element::undefined), ::testing::Values(ov::element::undefined), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config)); const auto collapsing_params = ::testing::Combine( - ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesStaticCheckCollapse)), - ::testing::ValuesIn(eltwiseOpTypes), - ::testing::ValuesIn(secondaryInputTypes), - ::testing::Values(opTypes[1]), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(in_shapes_static_check_collapse)), + ::testing::ValuesIn(eltwise_op_types), + ::testing::ValuesIn(secondary_input_types), + ::testing::Values(op_types[1]), + ::testing::ValuesIn(model_types), ::testing::Values(ov::element::undefined), ::testing::Values(ov::element::undefined), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config)); const auto multiply_params_dynamic = ::testing::Combine( - ::testing::ValuesIn(inShapesDynamic), - ::testing::ValuesIn(eltwiseOpTypesDynamic), - ::testing::ValuesIn(secondaryInputTypesDynamic), - ::testing::ValuesIn(opTypesDynamic), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(in_shapes_dynamic), + ::testing::ValuesIn(eltwise_op_types_dynamic), + ::testing::ValuesIn(secondary_input_types_dynamic), + ::testing::ValuesIn(op_types_dynamic), + ::testing::ValuesIn(model_types), ::testing::Values(ov::element::undefined), ::testing::Values(ov::element::undefined), ::testing::Values(ov::test::utils::DEVICE_CPU), ::testing::Values(additional_config)); const auto multiply_params_dynamic_large_upper_bound = ::testing::Combine( - ::testing::ValuesIn(inShapesDynamicLargeUpperBound), - ::testing::Values(ngraph::helpers::EltwiseTypes::ADD), - ::testing::ValuesIn(secondaryInputTypesDynamic), - ::testing::ValuesIn(opTypesDynamic), + ::testing::ValuesIn(in_shapes_dynamic_large_upper_bound), + ::testing::Values(EltwiseTypes::ADD), + ::testing::ValuesIn(secondary_input_types_dynamic), + ::testing::ValuesIn(op_types_dynamic), ::testing::Values(ov::element::f32), ::testing::Values(ov::element::undefined), ::testing::Values(ov::element::undefined), @@ -147,9 +150,9 @@ std::vector> inShapesSingleThread = { {{2, 1, 2, 1, 2, 2}}, }; -std::vector eltwiseOpTypesSingleThread = { - ngraph::helpers::EltwiseTypes::ADD, - ngraph::helpers::EltwiseTypes::POWER, +std::vector eltwise_op_typesSingleThread = { + EltwiseTypes::ADD, + EltwiseTypes::POWER, }; ov::AnyMap additional_config_single_thread = { @@ -158,10 +161,10 @@ ov::AnyMap additional_config_single_thread = { const auto single_thread_params = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapesSingleThread)), - ::testing::ValuesIn(eltwiseOpTypesSingleThread), - ::testing::ValuesIn(secondaryInputTypes), - ::testing::ValuesIn(opTypes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(eltwise_op_typesSingleThread), + ::testing::ValuesIn(secondary_input_types), + ::testing::ValuesIn(op_types), + ::testing::ValuesIn(model_types), ::testing::Values(ov::element::undefined), ::testing::Values(ov::element::undefined), ::testing::Values(ov::test::utils::DEVICE_CPU), 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 9c8bfc2a7b0..0d6f932e000 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 @@ -195,6 +195,8 @@ std::vector disabledTestPatterns() { R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=7_axis=3_.*_modelType=f16_trgDev=CPU.*)", R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=18_.*_modelType=f16_trgDev=CPU.*)", R"(.*smoke_TopK/TopKLayerTest.Inference.*_k=21_.*_sort=value_modelType=f16_trgDev=CPU.*)", + // Issue: 121228 + R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.Inference.*bf16.*)", }; #if defined(__APPLE__) && defined(OPENVINO_ARCH_ARM64) // Issue: 120950 @@ -238,6 +240,7 @@ std::vector disabledTestPatterns() { retVector.emplace_back(R"(smoke_ExecGraph/ExecGraphRuntimePrecision.CheckRuntimePrecision/Function=(EltwiseWithTwoDynamicInputs|FakeQuantizeRelu).*)"); // Issue 108803: bug in CPU scalar implementation retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.CompareWithRefs.*)"); + retVector.emplace_back(R"(smoke_TestsDFT_(1|2|3|4)d/DFTLayerTest.Inference.*)"); // Issue 88764, 91647, 108802: accuracy issue retVector.emplace_back(R"(MultipleLSTMCellTest/MultipleLSTMCellTest.CompareWithRefs.*)"); // int8 / code-generation specific diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/detection_output.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/detection_output.hpp new file mode 100644 index 00000000000..0eb0ca2bd36 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/detection_output.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/detection_output.hpp" + +namespace ov { +namespace test { +TEST_P(DetectionOutputLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/dft.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/dft.hpp new file mode 100644 index 00000000000..b6b1400dc4b --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/dft.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/dft.hpp" + +namespace ov { +namespace test { +TEST_P(DFTLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/eltwise.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/eltwise.hpp new file mode 100644 index 00000000000..1add45da7fb --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/eltwise.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/eltwise.hpp" + +namespace ov { +namespace test { +TEST_P(EltwiseLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov 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 32d585c449b..17121e8a57a 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 @@ -20,6 +20,9 @@ #include "ngraph/op/max.hpp" #include "ngraph/op/min.hpp" +#include "openvino/op/dft.hpp" +#include "openvino/op/idft.hpp" + #include #include @@ -82,6 +85,8 @@ static std::map>> i { ov::op::v4::Proposal::get_type_info_static(), {{{0, 1, 1000, 8234231}}, {{0, 1, 1000, 8234231}}} }, { ov::op::v4::ReduceL1::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, { ov::op::v4::ReduceL2::get_type_info_static(), {{{0, 5}}, {{0, 5, 1000}}} }, + { ov::op::v7::DFT::get_type_info_static(), {{{0, 1}}, {{0, 1, 1000000}}} }, + { ov::op::v7::IDFT::get_type_info_static(), {{{0, 1}}, {{0, 1, 1000000}}} }, }; } // namespace utils diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/detection_output.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/detection_output.hpp new file mode 100644 index 00000000000..6c8da15babd --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/detection_output.hpp @@ -0,0 +1,73 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "openvino/op/detection_output.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using Attributes = ov::op::v0::DetectionOutput::Attributes; + +std::ostream& operator <<(std::ostream& os, const Attributes& inputShape); + +enum { + idxLocation, + idxConfidence, + idxPriors, + idxArmConfidence, + idxArmLocation, + numInputs +}; + +using DetectionOutputAttributes = std::tuple< + int, // numClasses + int, // backgroundLabelId + int, // topK + std::vector, // keepTopK + std::string, // codeType + float, // nmsThreshold + float, // confidenceThreshold + bool, // clip_afterNms + bool, // clip_beforeNms + bool // decreaseLabelId +>; + +using ParamsWhichSizeDepends = std::tuple< + bool, // varianceEncodedInTarget + bool, // shareLocation + bool, // normalized + size_t, // inputHeight + size_t, // inputWidth + ov::Shape, // "Location" input + ov::Shape, // "Confidence" input + ov::Shape, // "Priors" input + ov::Shape, // "ArmConfidence" input + ov::Shape // "ArmLocation" input +>; + +using DetectionOutputParams = std::tuple< + DetectionOutputAttributes, + ParamsWhichSizeDepends, + size_t, // Number of batch + float, // objectnessScore + std::string // Device name +>; + +class DetectionOutputLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { + public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/dft.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/dft.hpp new file mode 100644 index 00000000000..4160a36c2e1 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/dft.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "common_test_utils/test_enums.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +typedef std::tuple< + std::vector, // Input shapes + ov::element::Type, // Model type + std::vector, // Axes + std::vector, // Signal size + ov::test::utils::DFTOpType, + std::string> DFTParams; // Device name + +class DFTLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/eltwise.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/eltwise.hpp new file mode 100644 index 00000000000..3cd66acdb8a --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/eltwise.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// +// NOTE: WILL BE REWORKED (31905) + +#pragma once + +#include "common_test_utils/test_enums.hpp" +#include "common_test_utils/common_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +typedef std::tuple< + std::vector, // input shapes + ov::test::utils::EltwiseTypes, // eltwise op type + ov::test::utils::InputLayerType, // secondary input type + ov::test::utils::OpType, // op type + ElementType, // Model type + ElementType, // In type + ElementType, // Out type + TargetDevice, // Device name + ov::AnyMap // Additional network configuration +> EltwiseTestParams; + +class EltwiseLayerTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest { +protected: + void SetUp() override; + +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +private: + void transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/detection_output.cpp b/src/tests/functional/shared_test_classes/src/single_op/detection_output.cpp new file mode 100644 index 00000000000..ac0938643c7 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/detection_output.cpp @@ -0,0 +1,116 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/detection_output.hpp" + +namespace ov { +namespace test { +std::ostream& operator <<(std::ostream& result, const Attributes& attrs) { + result << "Classes=" << attrs.num_classes << "_"; + result << "backgrId=" << attrs.background_label_id << "_"; + result << "topK=" << attrs.top_k << "_"; + result << "varEnc=" << attrs.variance_encoded_in_target << "_"; + result << "keepTopK=" << ov::test::utils::vec2str(attrs.keep_top_k) << "_"; + result << "codeType=" << attrs.code_type << "_"; + result << "shareLoc=" << attrs.share_location << "_"; + result << "nmsThr=" << attrs.nms_threshold << "_"; + result << "confThr=" << attrs.confidence_threshold << "_"; + result << "clipAfterNms=" << attrs.clip_after_nms << "_"; + result << "clipBeforeNms=" << attrs.clip_before_nms << "_"; + result << "decrId=" << attrs.decrease_label_id << "_"; + result << "norm=" << attrs.normalized << "_"; + result << "inH=" << attrs.input_height << "_"; + result << "inW=" << attrs.input_width << "_"; + result << "OS=" << attrs.objectness_score << "_"; + return result; +} + +std::string DetectionOutputLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + DetectionOutputAttributes common_attrs; + ParamsWhichSizeDepends specific_attrs; + Attributes attrs; + size_t batch; + std::string targetDevice; + std::tie(common_attrs, specific_attrs, batch, attrs.objectness_score, targetDevice) = obj.param; + + std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold, + attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = common_attrs; + + const size_t numInputs = 5; + std::vector input_shapes(numInputs); + std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width, + input_shapes[idxLocation], input_shapes[idxConfidence], input_shapes[idxPriors], input_shapes[idxArmConfidence], + input_shapes[idxArmLocation]) = specific_attrs; + + if (input_shapes[idxArmConfidence].empty()) { + input_shapes.resize(3); + } + + for (size_t i = 0; i < input_shapes.size(); i++) { + input_shapes[i][0] = batch; + } + + std::ostringstream result; + result << "IS = { "; + result << "LOC=" << ov::test::utils::vec2str(input_shapes[0]) << "_"; + result << "CONF=" << ov::test::utils::vec2str(input_shapes[1]) << "_"; + result << "PRIOR=" << ov::test::utils::vec2str(input_shapes[2]); + std::string armConf, armLoc; + if (input_shapes.size() > 3) { + armConf = "_ARM_CONF=" + ov::test::utils::vec2str(input_shapes[3]) + "_"; + armLoc = "ARM_LOC=" + ov::test::utils::vec2str(input_shapes[4]); + } + result << armConf; + result << armLoc << " }_"; + + result << attrs; + result << "TargetDevice=" << targetDevice; + return result.str(); +} + +void DetectionOutputLayerTest::SetUp() { + DetectionOutputAttributes common_attrs; + ParamsWhichSizeDepends specific_attrs; + size_t batch; + Attributes attrs; + std::tie(common_attrs, specific_attrs, batch, attrs.objectness_score, targetDevice) = this->GetParam(); + + std::tie(attrs.num_classes, attrs.background_label_id, attrs.top_k, attrs.keep_top_k, attrs.code_type, attrs.nms_threshold, attrs.confidence_threshold, + attrs.clip_after_nms, attrs.clip_before_nms, attrs.decrease_label_id) = common_attrs; + + std::vector input_shapes; + input_shapes.resize(numInputs); + std::tie(attrs.variance_encoded_in_target, attrs.share_location, attrs.normalized, attrs.input_height, attrs.input_width, + input_shapes[idxLocation], input_shapes[idxConfidence], input_shapes[idxPriors], input_shapes[idxArmConfidence], + input_shapes[idxArmLocation]) = specific_attrs; + + if (input_shapes[idxArmConfidence].empty()) { + input_shapes.resize(3); + } + + for (size_t i = 0; i < input_shapes.size(); i++) { + input_shapes[i][0] = batch; + } + init_input_shapes(static_shapes_to_test_representation(input_shapes)); + + ov::ParameterVector params; + for (const auto& shape : inputDynamicShapes) { + params.push_back(std::make_shared(ov::element::f32, shape)); + } + + std::shared_ptr det_out; + if (params.size() == 3) + det_out = std::make_shared(params[0], params[1], params[2], attrs); + else if (params.size() == 5) + det_out = std::make_shared(params[0], + params[1], + params[2], + params[3], + params[4], + attrs); + auto result = std::make_shared(det_out); + function = std::make_shared(result, params, "DetectionOutput"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/dft.cpp b/src/tests/functional/shared_test_classes/src/single_op/dft.cpp new file mode 100644 index 00000000000..9d39ed7bea6 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/dft.cpp @@ -0,0 +1,58 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/dft.hpp" + +#include "ngraph_functions/builders.hpp" + +namespace ov { +namespace test { +std::string DFTLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + ov::element::Type model_type; + std::vector axes; + std::vector signal_size; + ov::test::utils::DFTOpType op_type; + std::string target_device; + std::tie(shapes, model_type, axes, signal_size, op_type, target_device) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (size_t i = 0lu; i < shapes.size(); i++) { + result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < shapes.size(); j++) { + result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "Precision=" << model_type.get_type_name() << "_"; + result << "Axes=" << ov::test::utils::vec2str(axes) << "_"; + result << "signal_size=" << ov::test::utils::vec2str(signal_size) << "_"; + result << "Inverse=" << (op_type == ov::test::utils::DFTOpType::INVERSE) << "_"; + result << "TargetDevice=" << target_device; + return result.str(); +} + +void DFTLayerTest::SetUp() { + std::vector shapes; + ov::element::Type model_type; + std::vector axes; + std::vector signal_size; + ov::test::utils::DFTOpType op_type; + std::tie(shapes, model_type, axes, signal_size, op_type, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + auto param = std::make_shared(model_type, inputDynamicShapes.front()); + + auto dft = ngraph::builder::makeDFT(param, axes, signal_size, op_type); + + auto result = std::make_shared(dft); + function = std::make_shared(result, ov::ParameterVector{param}, "DFT"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/eltwise.cpp b/src/tests/functional/shared_test_classes/src/single_op/eltwise.cpp new file mode 100644 index 00000000000..1297379c267 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/eltwise.cpp @@ -0,0 +1,135 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "common_test_utils/ov_tensor_utils.hpp" + +#include "shared_test_classes/single_op/eltwise.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "ngraph_functions/builders.hpp" + +namespace ov { +namespace test { +using ov::test::utils::InputLayerType; +using ov::test::utils::OpType; +using ov::test::utils::EltwiseTypes; + +std::string EltwiseLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + ElementType model_type, in_type, out_type; + InputLayerType secondary_input_type; + OpType op_type; + EltwiseTypes eltwise_op_type; + std::string device_name; + ov::AnyMap additional_config; + std::tie(shapes, eltwise_op_type, secondary_input_type, op_type, model_type, in_type, out_type, device_name, additional_config) = obj.param; + std::ostringstream results; + + results << "IS=("; + for (const auto& shape : shapes) { + results << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + results << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + results << ov::test::utils::vec2str(item) << "_"; + } + } + results << ")_eltwise_op_type=" << eltwise_op_type << "_"; + results << "secondary_input_type=" << secondary_input_type << "_"; + results << "opType=" << op_type << "_"; + results << "model_type=" << model_type << "_"; + results << "InType=" << in_type << "_"; + results << "OutType=" << out_type << "_"; + results << "trgDev=" << device_name; + for (auto const& config_item : additional_config) { + results << "_config_item=" << config_item.first << "="; + config_item.second.print(results); + } + return results.str(); +} + +void EltwiseLayerTest::transformInputShapesAccordingEltwise(const ov::PartialShape& secondInputShape) { + // propagate shapes in case 1 shape is defined + if (inputDynamicShapes.size() == 1) { + inputDynamicShapes.push_back(inputDynamicShapes.front()); + for (auto& staticShape : targetStaticShapes) { + staticShape.push_back(staticShape.front()); + } + } + ASSERT_EQ(inputDynamicShapes.size(), 2) << "Incorrect inputs number!"; + if (!secondInputShape.is_static()) { + return; + } + if (secondInputShape.get_shape() == ov::Shape{1}) { + inputDynamicShapes[1] = secondInputShape; + for (auto& staticShape : targetStaticShapes) { + staticShape[1] = secondInputShape.get_shape(); + } + } +} + +void EltwiseLayerTest::SetUp() { + std::vector shapes; + ElementType model_type; + InputLayerType secondary_input_type; + OpType op_type; + EltwiseTypes eltwise_type; + Config additional_config; + std::tie(shapes, eltwise_type, secondary_input_type, op_type, model_type, inType, outType, targetDevice, configuration) = this->GetParam(); + init_input_shapes(shapes); + + ov::ParameterVector parameters{std::make_shared(model_type, inputDynamicShapes.front())}; + + ov::PartialShape shape_input_secondary; + switch (op_type) { + case OpType::SCALAR: { + shape_input_secondary = {1}; + break; + } + case OpType::VECTOR: + shape_input_secondary = inputDynamicShapes.back(); + break; + default: + FAIL() << "Unsupported Secondary operation type"; + } + // To propagate shape_input_secondary just in static case because all shapes are defined in dynamic scenarion + if (secondary_input_type == InputLayerType::PARAMETER) { + transformInputShapesAccordingEltwise(shape_input_secondary); + } + + std::shared_ptr secondary_input; + if (secondary_input_type == InputLayerType::PARAMETER) { + auto param = std::make_shared(model_type, shape_input_secondary); + secondary_input = param; + parameters.push_back(param); + } else { + ov::Shape shape = inputDynamicShapes.back().get_max_shape(); + switch (eltwise_type) { + case EltwiseTypes::DIVIDE: + case EltwiseTypes::MOD: + case EltwiseTypes::FLOOR_MOD: { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 8, 2); + secondary_input = std::make_shared(tensor); + break; + } + case EltwiseTypes::POWER: { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 2, 1); + secondary_input = std::make_shared(tensor); + break; + } + default: { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, shape, 9, 1); + secondary_input = std::make_shared(tensor); + } + } + } + + parameters[0]->set_friendly_name("param0"); + secondary_input->set_friendly_name("param1"); + + auto eltwise = ngraph::builder::makeEltwise(parameters[0], secondary_input, eltwise_type); + function = std::make_shared(eltwise, parameters, "Eltwise"); +} +} // namespace test +} // namespace ov