[GPU] Fix Interpolate axes values alignment with scales (#12634)

This commit is contained in:
Sergey Shlyapnikov 2022-08-25 09:39:30 +04:00 committed by GitHub
parent fcf20dee86
commit 30b872150a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 9 deletions

View File

@ -43,7 +43,7 @@ static void CreateInterpolateOp(Program& p, const std::shared_ptr<ngraph::op::v4
ov::normalize_axes(op.get(), inputRank, axes); ov::normalize_axes(op.get(), inputRank, axes);
} else { } else {
for (size_t i = 0; i < inputRank; ++i) { for (size_t i = 0; i < inputRank; ++i) {
ov::normalize_axis(op.get(), i, inputRank); axes.push_back(ov::normalize_axis(op.get(), i, inputRank));
} }
} }

View File

@ -78,6 +78,8 @@ const std::vector<std::vector<int64_t>> defaultAxes = {
{0, 1, 2, 3} {0, 1, 2, 3}
}; };
const std::vector<std::vector<int64_t>> emptyAxes = {{}};
const std::vector<std::vector<float>> defaultScales = { const std::vector<std::vector<float>> defaultScales = {
{1.f, 1.f, 2.f, 2.f} {1.f, 1.f, 2.f, 2.f}
}; };
@ -96,6 +98,18 @@ const auto interpolateCasesWithoutNearest = ::testing::Combine(
::testing::ValuesIn(defaultAxes), ::testing::ValuesIn(defaultAxes),
::testing::ValuesIn(defaultScales)); ::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( const auto interpolateCasesNearesMode = ::testing::Combine(
::testing::ValuesIn(nearestMode), ::testing::ValuesIn(nearestMode),
::testing::ValuesIn(shapeCalculationMode), ::testing::ValuesIn(shapeCalculationMode),
@ -121,6 +135,19 @@ INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Basic, InterpolateLayerTest, ::testin
::testing::Values(additional_config)), ::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName); 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( INSTANTIATE_TEST_SUITE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine(
interpolateCasesNearesMode, interpolateCasesNearesMode,
::testing::ValuesIn(netPrecisions), ::testing::ValuesIn(netPrecisions),

View File

@ -81,16 +81,25 @@ void InterpolateLayerTest::SetUp() {
auto scales_const = ngraph::opset3::Constant(ngraph::element::Type_t::f32, {scales.size()}, scales); auto scales_const = ngraph::opset3::Constant(ngraph::element::Type_t::f32, {scales.size()}, scales);
auto scalesInput = std::make_shared<ngraph::opset3::Constant>(scales_const); auto scalesInput = std::make_shared<ngraph::opset3::Constant>(scales_const);
auto axesConst = ngraph::opset3::Constant(ngraph::element::Type_t::i64, {axes.size()}, axes);
auto axesInput = std::make_shared<ngraph::opset3::Constant>(axesConst);
ngraph::op::v4::Interpolate::InterpolateAttrs interpolateAttributes{mode, shapeCalcMode, padBegin, ngraph::op::v4::Interpolate::InterpolateAttrs interpolateAttributes{mode, shapeCalcMode, padBegin,
padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef}; padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef};
auto interpolate = std::make_shared<ngraph::op::v4::Interpolate>(params[0],
sizesInput, std::shared_ptr<ngraph::op::v4::Interpolate> interpolate;
scalesInput, if (axes.empty()) {
axesInput, interpolate = std::make_shared<ngraph::op::v4::Interpolate>(params[0],
interpolateAttributes); sizesInput,
scalesInput,
interpolateAttributes);
} else {
auto axesConst = ngraph::opset3::Constant(ngraph::element::Type_t::i64, {axes.size()}, axes);
auto axesInput = std::make_shared<ngraph::opset3::Constant>(axesConst);
interpolate = std::make_shared<ngraph::op::v4::Interpolate>(params[0],
sizesInput,
scalesInput,
axesInput,
interpolateAttributes);
}
const ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(interpolate)}; const ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(interpolate)};
function = std::make_shared<ngraph::Function>(results, params, "interpolate"); function = std::make_shared<ngraph::Function>(results, params, "interpolate");
} }