From 30b872150aef6806c3fed7edff7968dced57146a Mon Sep 17 00:00:00 2001 From: Sergey Shlyapnikov Date: Thu, 25 Aug 2022 09:39:30 +0400 Subject: [PATCH] [GPU] Fix Interpolate axes values alignment with scales (#12634) --- .../intel_gpu/src/plugin/ops/interpolate.cpp | 2 +- .../single_layer_tests/interpolate.cpp | 27 +++++++++++++++++++ .../src/single_layer/interpolate.cpp | 25 +++++++++++------ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp b/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp index 9ee48ed5944..1b5fde10ead 100644 --- a/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp +++ b/src/plugins/intel_gpu/src/plugin/ops/interpolate.cpp @@ -43,7 +43,7 @@ static void CreateInterpolateOp(Program& p, const std::shared_ptr> defaultAxes = { {0, 1, 2, 3} }; +const std::vector> emptyAxes = {{}}; + const std::vector> defaultScales = { {1.f, 1.f, 2.f, 2.f} }; @@ -96,6 +98,18 @@ const auto interpolateCasesWithoutNearest = ::testing::Combine( ::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultScales)); +const auto interpolateCasesWithoutNearestEmptyAxes = ::testing::Combine( + ::testing::ValuesIn(modesWithoutNearest), + ::testing::ValuesIn(shapeCalculationMode), + ::testing::ValuesIn(coordinateTransformModes), + ::testing::ValuesIn(defaultNearestMode), + ::testing::ValuesIn(antialias), + ::testing::ValuesIn(pads), + ::testing::ValuesIn(pads), + ::testing::ValuesIn(cubeCoefs), + ::testing::ValuesIn(emptyAxes), + ::testing::ValuesIn(defaultScales)); + const auto interpolateCasesNearesMode = ::testing::Combine( ::testing::ValuesIn(nearestMode), ::testing::ValuesIn(shapeCalculationMode), @@ -121,6 +135,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testin ::testing::Values(additional_config)), InterpolateLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_BasicEmptyAxes, InterpolateLayerTest, ::testing::Combine( + interpolateCasesWithoutNearestEmptyAxes, + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(inShapes), + ::testing::ValuesIn(targetShapes), + ::testing::Values(CommonTestUtils::DEVICE_GPU), + ::testing::Values(additional_config)), + InterpolateLayerTest::getTestCaseName); + INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine( interpolateCasesNearesMode, ::testing::ValuesIn(netPrecisions), diff --git a/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp b/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp index 95132ad2e79..4b2a7e6a6ac 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/interpolate.cpp @@ -81,16 +81,25 @@ void InterpolateLayerTest::SetUp() { 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); + + std::shared_ptr interpolate; + if (axes.empty()) { + interpolate = std::make_shared(params[0], + sizesInput, + scalesInput, + interpolateAttributes); + } else { + auto axesConst = ngraph::opset3::Constant(ngraph::element::Type_t::i64, {axes.size()}, axes); + auto axesInput = std::make_shared(axesConst); + + 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"); }