From f6a537d2236f0b64f0ff028627af9e0e388a2d23 Mon Sep 17 00:00:00 2001 From: DariaMityagina Date: Thu, 6 May 2021 11:58:10 +0300 Subject: [PATCH] changes in tests, so not to break other plugins --- .../single_layer_tests/interpolate.cpp | 14 +--- .../cpu/single_layer_tests/interpolate.cpp | 22 ++--- .../single_layer_tests/interpolate.cpp | 8 +- .../single_layer_tests/interpolate.cpp | 16 ++-- .../single_layer_tests/interpolate.hpp | 4 + .../single_layer/interpolate.hpp | 23 ++++- .../src/single_layer/interpolate.cpp | 83 ++++++++++++++++++- 7 files changed, 129 insertions(+), 41 deletions(-) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp index 08c529379767a7..d5a9c8364e7cd2 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -82,8 +82,6 @@ const std::vector> defaultScales = { {1.f, 1.f, 1.333333f, 1.333333f} }; -std::map additional_config = {}; - const auto interpolateCasesWithoutNearest = ::testing::Combine( ::testing::ValuesIn(modesWithoutNearest), ::testing::ValuesIn(shapeCalculationMode), @@ -117,8 +115,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapes), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), InterpolateLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( @@ -130,8 +127,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testi ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapes), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), InterpolateLayerTest::getTestCaseName); const std::vector> targetShapesTailTest = { @@ -175,8 +171,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_Down_Sample_Tail, InterpolateLay ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapesTailTest), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), InterpolateLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine( @@ -188,8 +183,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateL ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapesTailTest), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), InterpolateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp index 86886b30628bd4..92976d7e6a53d1 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/interpolate.cpp @@ -60,9 +60,7 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface inputShape; std::vector targetShape; Precision netPrecision; - std::map additional_config; - std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, - targetShape, targetDevice, additional_config) = basicParamsSet; + std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = basicParamsSet; ngraph::op::v4::Interpolate::InterpolateMode mode; ngraph::op::v4::Interpolate::ShapeCalcMode shapeCalcMode; @@ -268,8 +266,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), @@ -286,8 +283,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLaye ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), @@ -304,8 +300,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPU ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), @@ -322,8 +317,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUT ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), @@ -396,8 +390,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLa ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6, 2})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice5D()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), @@ -414,8 +407,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTe ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(std::vector({1, 21, 4, 4, 4})), ::testing::Values(std::vector({1, 21, 5, 6, 2})), - ::testing::Values(CommonTestUtils::DEVICE_CPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_CPU)), ::testing::ValuesIn(filterCPUInfoForDevice5D()), ::testing::ValuesIn(interpolateFusingParamsSet), ::testing::ValuesIn(filterAdditionalConfig())), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp index 0b210ebef2e4db..fbbb30c1e2c6fe 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -82,8 +82,6 @@ const std::vector> defaultScales = { {1.f, 1.f, 2.f, 2.f} }; -std::map additional_config = {}; - const auto interpolateCasesWithoutNearest = ::testing::Combine( ::testing::ValuesIn(modesWithoutNearest), ::testing::ValuesIn(shapeCalculationMode), @@ -117,8 +115,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testing ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapes), - ::testing::Values(CommonTestUtils::DEVICE_GPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), InterpolateLayerTest::getTestCaseName); INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( @@ -130,8 +127,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testi ::testing::Values(InferenceEngine::Layout::ANY), ::testing::ValuesIn(inShapes), ::testing::ValuesIn(targetShapes), - ::testing::Values(CommonTestUtils::DEVICE_GPU), - ::testing::Values(additional_config)), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), InterpolateLayerTest::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp index b7234a93c4c76a..868c17a533e3f4 100644 --- a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/single_layer_tests/interpolate.cpp @@ -172,7 +172,7 @@ const auto interpolateCasesWithoutNearestMode = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScales)); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_2x, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_2x, InterpolateLayerTestWithConfig, ::testing::Combine( interpolateCasesNearestMode2x, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -183,9 +183,9 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_2x, InterpolateLayerTest, ::testing::ValuesIn(targetShapes2x), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), - InterpolateLayerTest::getTestCaseName); + InterpolateLayerTestWithConfig::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTestWithConfig, ::testing::Combine( interpolateCasesNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -196,9 +196,9 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, :: ::testing::ValuesIn(targetShapes), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), - InterpolateLayerTest::getTestCaseName); + InterpolateLayerTestWithConfig::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTestWithConfig, ::testing::Combine( interpolateCasesNearestModeMore, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -209,9 +209,9 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTes ::testing::ValuesIn(targetShapes), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), - InterpolateLayerTest::getTestCaseName); + InterpolateLayerTestWithConfig::getTestCaseName); -INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine( +INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTestWithConfig, ::testing::Combine( interpolateCasesWithoutNearestMode, ::testing::ValuesIn(netPrecisions), ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), @@ -222,6 +222,6 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::ValuesIn(targetShapes), ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), ::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})), - InterpolateLayerTest::getTestCaseName); + InterpolateLayerTestWithConfig::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp index 476bd2a8ae2d0c..588d2143375bd3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/interpolate.hpp @@ -12,4 +12,8 @@ TEST_P(InterpolateLayerTest, CompareWithRefs) { Run(); } +TEST_P(InterpolateLayerTestWithConfig, CompareWithRefs) { + Run(); +} + } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp index 07e86512ee0ea9..2855c213a7bd3a 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/interpolate.hpp @@ -29,6 +29,18 @@ typedef std::tuple< std::vector // Scales > InterpolateSpecificParams; +typedef std::tuple< + InterpolateSpecificParams, + InferenceEngine::Precision, // Net precision + InferenceEngine::Precision, // Input precision + InferenceEngine::Precision, // Output precision + InferenceEngine::Layout, // Input layout + InferenceEngine::Layout, // Output layout + InferenceEngine::SizeVector, // Input shapes + InferenceEngine::SizeVector, // Target shapes + LayerTestsUtils::TargetDevice // Device name +> InterpolateLayerTestParams; + typedef std::tuple< InterpolateSpecificParams, InferenceEngine::Precision, // Net precision @@ -40,7 +52,7 @@ typedef std::tuple< InferenceEngine::SizeVector, // Target shapes LayerTestsUtils::TargetDevice, // Device name std::map // Additional network configuration -> InterpolateLayerTestParams; +> InterpolateLayerTestParamsWithConfig; class InterpolateLayerTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { @@ -51,4 +63,13 @@ class InterpolateLayerTest : public testing::WithParamInterface, + virtual public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(testing::TestParamInfo obj); + +protected: + void SetUp() override; +}; + } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp index 37db7bdeeab173..4e3b901341f465 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp @@ -12,6 +12,86 @@ using ngraph::helpers::operator<<; namespace LayerTestsDefinitions { std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo obj) { + InterpolateSpecificParams interpolateParams; + InferenceEngine::Precision netPrecision; + InferenceEngine::Precision inPrc, outPrc; + InferenceEngine::Layout inLayout, outLayout; + InferenceEngine::SizeVector inputShapes, targetShapes; + std::string targetDevice; + std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetShapes, targetDevice) = obj.param; + std::vector padBegin, padEnd; + std::vector axes; + std::vector scales; + bool antialias; + ngraph::op::v4::Interpolate::InterpolateMode mode; + ngraph::op::v4::Interpolate::ShapeCalcMode shapeCalcMode; + ngraph::op::v4::Interpolate::CoordinateTransformMode coordinateTransformMode; + ngraph::op::v4::Interpolate::NearestMode nearestMode; + double cubeCoef; + std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; + std::ostringstream result; + result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; + result << "TS=" << CommonTestUtils::vec2str(targetShapes) << "_"; + result << "InterpolateMode=" << mode << "_"; + result << "ShapeCalcMode=" << shapeCalcMode << "_"; + result << "CoordinateTransformMode=" << coordinateTransformMode << "_"; + result << "NearestMode=" << nearestMode << "_"; + result << "CubeCoef=" << cubeCoef << "_"; + result << "Antialias=" << antialias << "_"; + result << "PB=" << CommonTestUtils::vec2str(padBegin) << "_"; + result << "PE=" << CommonTestUtils::vec2str(padEnd) << "_"; + result << "Axes=" << CommonTestUtils::vec2str(axes) << "_"; + result << "Scales=" << CommonTestUtils::vec2str(scales) << "_"; + result << "netPRC=" << netPrecision.name() << "_"; + result << "inPRC=" << inPrc.name() << "_"; + result << "outPRC=" << outPrc.name() << "_"; + result << "inL=" << inLayout << "_"; + result << "outL=" << outLayout << "_"; + result << "trgDev=" << targetDevice; + return result.str(); +} + +void InterpolateLayerTest::SetUp() { + InterpolateSpecificParams interpolateParams; + std::vector inputShape, targetShape; + auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; + std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = this->GetParam(); + std::vector padBegin, padEnd; + std::vector axes; + std::vector scales; + bool antialias; + ngraph::op::v4::Interpolate::InterpolateMode mode; + ngraph::op::v4::Interpolate::ShapeCalcMode shapeCalcMode; + ngraph::op::v4::Interpolate::CoordinateTransformMode coordinateTransformMode; + ngraph::op::v4::Interpolate::NearestMode nearestMode; + + double cubeCoef; + std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams; + + auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); + + auto sizesConst = ngraph::opset3::Constant(ngraph::element::Type_t::i64, {targetShape.size()}, targetShape); + auto sizesInput = std::make_shared(sizesConst); + + auto scales_const = ngraph::opset3::Constant(ngraph::element::Type_t::f32, {scales.size()}, scales); + auto scalesInput = std::make_shared(scales_const); + + auto axesConst = ngraph::opset3::Constant(ngraph::element::Type_t::i64, {axes.size()}, axes); + auto axesInput = std::make_shared(axesConst); + + ngraph::op::v4::Interpolate::InterpolateAttrs interpolateAttributes{mode, shapeCalcMode, padBegin, + padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef}; + auto interpolate = std::make_shared(params[0], + sizesInput, + scalesInput, + axesInput, + interpolateAttributes); + const ngraph::ResultVector results{std::make_shared(interpolate)}; + function = std::make_shared(results, params, "interpolate"); +} + +std::string InterpolateLayerTestWithConfig::getTestCaseName(testing::TestParamInfo obj) { InterpolateSpecificParams interpolateParams; InferenceEngine::Precision netPrecision; InferenceEngine::Precision inPrc, outPrc; @@ -52,7 +132,7 @@ std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo inputShape, targetShape; auto netPrecision = InferenceEngine::Precision::UNSPECIFIED; @@ -94,4 +174,5 @@ void InterpolateLayerTest::SetUp() { const ngraph::ResultVector results{std::make_shared(interpolate)}; function = std::make_shared(results, params, "interpolate"); } + } // namespace LayerTestsDefinitions