From fadf43ecb72cf2a856cf774362ec56b88d925d65 Mon Sep 17 00:00:00 2001 From: "Efode, Irina" Date: Thu, 14 Oct 2021 01:27:24 +0300 Subject: [PATCH] Eltwise --- .../single_layer_tests/eltwise.cpp | 131 ++++++++++++++++++ .../single_layer_tests/eltwise.cpp | 31 ++--- .../skip_tests_config.cpp | 4 +- .../single_layer_tests/eltwise.cpp | 45 +++--- .../skip_tests_config.cpp | 3 + .../single_layer_tests/eltwise.cpp | 42 +++--- .../shared_test_classes/base/ov_subgraph.hpp | 4 +- 7 files changed, 196 insertions(+), 64 deletions(-) create mode 100644 docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp diff --git a/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp new file mode 100644 index 00000000000..6748a8c04bf --- /dev/null +++ b/docs/template_plugin/tests/functional/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -0,0 +1,131 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include "single_layer_tests/eltwise.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace ov::test::subgraph; + +namespace { +std::vector> inShapesStatic = { + {{2}}, + {{2, 200}}, + {{10, 200}}, + {{1, 10, 100}}, + {{4, 4, 16}}, + {{1, 1, 1, 3}}, + {{2, 17, 5, 4}, {1, 17, 1, 1}}, + {{2, 17, 5, 1}, {1, 17, 1, 4}}, + {{1, 2, 4}}, + {{1, 4, 4}}, + {{1, 4, 4, 1}}, + {{1, 1, 1, 1, 1, 1, 3}}, + {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}, +}; + +std::vector inShapesDynamic = { + {{{ngraph::Dimension(1, 10), 200}, {ngraph::Dimension(1, 10), 200}}, + {{{2, 200}, {2, 200}}, {{1, 200}, {5, 200}}}}, +}; + +std::vector netPrecisions = { + ov::element::f32, + ov::element::f16, + ov::element::i32, +}; + +std::vector secondaryInputTypes = { + ngraph::helpers::InputLayerType::CONSTANT, + ngraph::helpers::InputLayerType::PARAMETER, +}; + +std::vector secondaryInputTypesDynamic = { + ngraph::helpers::InputLayerType::PARAMETER, +}; + +std::vector opTypes = { + CommonTestUtils::OpType::SCALAR, + CommonTestUtils::OpType::VECTOR, +}; + +std::vector opTypesDynamic = { + CommonTestUtils::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 eltwiseOpTypesDynamic = { + ngraph::helpers::EltwiseTypes::ADD, + ngraph::helpers::EltwiseTypes::MULTIPLY, + ngraph::helpers::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::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::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::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::testing::Values(additional_config)); + +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_static, EltwiseLayerTest, multiply_params, EltwiseLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_CompareWithRefs_dynamic, EltwiseLayerTest, multiply_params_dynamic, EltwiseLayerTest::getTestCaseName); + + +std::vector> inShapesSingleThread = { + {{1, 2, 3, 4}}, + {{2, 2, 2, 2}}, + {{2, 1, 2, 1, 2, 2}}, +}; + +std::vector eltwiseOpTypesSingleThread = { + ngraph::helpers::EltwiseTypes::ADD, + ngraph::helpers::EltwiseTypes::POWER, +}; + +std::map additional_config_single_thread = { + {"CPU_THREADS_NUM", "1"} +}; + +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::Values(ov::element::Type_t::undefined), + ::testing::Values(ov::element::Type_t::undefined), + ::testing::Values(CommonTestUtils::DEVICE_TEMPLATE), + ::testing::Values(additional_config_single_thread)); + +INSTANTIATE_TEST_SUITE_P(smoke_SingleThread, EltwiseLayerTest, single_thread_params, EltwiseLayerTest::getTestCaseName); + + +} // namespace \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp index d57ae5f505c..e065d8597f6 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -6,23 +6,23 @@ #include "single_layer_tests/eltwise.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using namespace ov::test::subgraph; namespace { -std::vector, std::vector>>> inShapes = { - {{}, {{{2}}}}, - {{}, {{{8}}}}, - {{}, {{{1, 200}}}}, - {{}, {{{1, 1, 1, 3}}}}, - {{}, {{{1, 2, 4}}}}, - {{}, {{{1, 4, 4}}}}, - {{}, {{{1, 4, 4, 1}}}} +std::vector> inShapes = { + {{2}}, + {{8}}, + {{1, 200}}, + {{1, 1, 1, 3}}, + {{1, 2, 4}}, + {{1, 4, 4}}, + {{1, 4, 4, 1}}, }; -std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, +std::vector netPrecisions = { + ov::element::f32, + ov::element::f16, }; std::vector secondaryInputTypes = { @@ -48,14 +48,13 @@ std::map additional_config = { }; const auto multiply_params = ::testing::Combine( - ::testing::ValuesIn(inShapes), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapes)), ::testing::ValuesIn(eltwiseOpTypes), ::testing::ValuesIn(secondaryInputTypes), ::testing::ValuesIn(opTypes), ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), ::testing::Values(CommonTestUtils::DEVICE_GNA), ::testing::Values(additional_config)); diff --git a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp index 802535c03e3..15380e67262 100644 --- a/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gna/shared_tests_instances/skip_tests_config.cpp @@ -54,6 +54,8 @@ std::vector disabledTestPatterns() { // TODO: Issue: 29577 R"(.*QueryNetwork.*)", // TODO: GNA plugin does not support ExecGraph - R"(.*ExecGraphTests.*)" + R"(.*ExecGraphTests.*)", + // Issue connected with OV2.0 + R"(.*EltwiseLayerTest.*NetType=f16.*)", }; } diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp index 586293131f3..df698303262 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -6,29 +6,29 @@ #include "single_layer_tests/eltwise.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using namespace ov::test::subgraph; namespace { -std::vector, std::vector>>> inShapes = { - {{}, {{{2}}}}, - {{}, {{{2, 200}}}}, - {{}, {{{10, 200}}}}, - {{}, {{{1, 10, 100}}}}, - {{}, {{{4, 4, 16}}}}, - {{}, {{{1, 1, 1, 3}}}}, - {{}, {{{2, 17, 5, 4}, {1, 17, 1, 1}}}}, - {{}, {{{2, 17, 5, 1}, {1, 17, 1, 4}}}}, - {{}, {{{1, 2, 4}}}}, - {{}, {{{1, 4, 4}}}}, - {{}, {{{1, 4, 4, 1}}}}, - {{}, {{{1, 4, 3, 2, 1, 3}}}}, - {{}, {{{1, 3, 1, 1, 1, 3}, {1, 3, 1, 1, 1, 1}}}}, +std::vector> inShapes = { + {{2}}, + {{2, 200}}, + {{10, 200}}, + {{1, 10, 100}}, + {{4, 4, 16}}, + {{1, 1, 1, 3}}, + {{2, 17, 5, 4}, {1, 17, 1, 1}}, + {{2, 17, 5, 1}, {1, 17, 1, 4}}, + {{1, 2, 4}}, + {{1, 4, 4}}, + {{1, 4, 4, 1}}, + {{1, 4, 3, 2, 1, 3}}, + {{1, 3, 1, 1, 1, 3}, {1, 3, 1, 1, 1, 1}}, }; -std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I64, +std::vector netPrecisions = { + ov::element::f32, + ov::element::f16, + ov::element::i64, }; std::vector secondaryInputTypes = { @@ -55,14 +55,13 @@ std::vector eltwiseOpTypes = { std::map additional_config = {}; const auto multiply_params = ::testing::Combine( - ::testing::ValuesIn(inShapes), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapes)), ::testing::ValuesIn(eltwiseOpTypes), ::testing::ValuesIn(secondaryInputTypes), ::testing::ValuesIn(opTypes), ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::Values(additional_config)); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 987c9344b94..80e03d37a0c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -74,5 +74,8 @@ std::vector disabledTestPatterns() { R"(.*smoke_PrePostProcess_GPU.*convert_element_type_and_mean.*)", // TODO: Issue 67408 R"(.*smoke_LSTMSequenceCommonClip.*LSTMSequenceTest.*CompareWithRefs.*)", + R"(.*EltwiseLayerTest.*OpType=FloorMod.*NetType=i64.*)", + // Issue connected with OV2.0 + R"(.*EltwiseLayerTest.*OpType=Pow.*NetType=i64.*)", }; } diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp index 1e77b6ab0e7..05b4c4cb88d 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/eltwise.cpp @@ -9,29 +9,29 @@ #include -using namespace LayerTestsDefinitions; +using namespace ov::test::subgraph; namespace { typedef std::map Config; -std::vector, std::vector>>> inShapes = { - {{}, {{{2}}}}, - {{}, {{{1, 1, 1, 3}}}}, - {{}, {{{1, 2, 4}}}}, - {{}, {{{1, 4, 4}}}}, - {{}, {{{1, 4, 4, 1}}}}, - {{}, {{{16, 16, 96}, {96}}}}, - {{}, {{{52, 1, 52, 3, 2}, {2}}}} +std::vector> inShapes = { + {{2}}, + {{1, 1, 1, 3}}, + {{1, 2, 4}}, + {{1, 4, 4}}, + {{1, 4, 4, 1}}, + {{16, 16, 96}, {96}}, + {{52, 1, 52, 3, 2}, {2}}, }; -std::vector fpTypes = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, +std::vector fpTypes = { + ov::element::f32, + ov::element::f16, }; -std::vector intTypes = { - InferenceEngine::Precision::I32, +std::vector intTypes = { + ov::element::i32, }; std::vector opTypes = { @@ -58,14 +58,13 @@ std::vector eltwiseMathTypesINT = { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseMathFP, EltwiseLayerTest, ::testing::Combine( - ::testing::ValuesIn(inShapes), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapes)), ::testing::ValuesIn(eltwiseMathTypesFP), ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes), ::testing::ValuesIn(fpTypes), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), EltwiseLayerTest::getTestCaseName); @@ -73,14 +72,13 @@ INSTANTIATE_TEST_SUITE_P(smoke_EltwiseMathFP, INSTANTIATE_TEST_SUITE_P(smoke_EltwiseMathInt, EltwiseLayerTest, ::testing::Combine( - ::testing::ValuesIn(inShapes), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inShapes)), ::testing::ValuesIn(eltwiseMathTypesINT), ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), ::testing::ValuesIn(opTypes), ::testing::ValuesIn(intTypes), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(ov::element::undefined), + ::testing::Values(ov::element::undefined), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), EltwiseLayerTest::getTestCaseName); diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp index 04852715d23..1f64666f91d 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/ov_subgraph.hpp @@ -69,7 +69,7 @@ private: std::vector get_plugin_outputs(); }; -static std::vector static_shapes_to_test_representation(const std::vector& staticShapes) { +inline std::vector static_shapes_to_test_representation(const std::vector& staticShapes) { std::vector result; for (const auto& staticShape : staticShapes) { result.push_back({{}, {staticShape}}); @@ -77,7 +77,7 @@ static std::vector static_shapes_to_test_representation(const std::v return result; } -static std::vector static_shapes_to_test_representation(const std::vector>& staticShapes) { +inline std::vector static_shapes_to_test_representation(const std::vector>& staticShapes) { std::vector result; for (const auto& staticShape : staticShapes) { result.push_back({{}, {staticShape}});