Skip to content

Commit

Permalink
[VPU] Batch support for interpolate (openvinotoolkit#5520)
Browse files Browse the repository at this point in the history
* batch support for interpolate

* hash update

* compilation errors solved

* changes in tests, so not to break other plugins

* changes in tests, so not to break other plugins

* Revert "changes in tests, so not to break other plugins"

This reverts commit 67e5c1e.

* Revert "changes in tests, so not to break other plugins"

This reverts commit f6a537d.

* review corrections

* Firmware update
  • Loading branch information
DariaMityagina authored and yekruglov committed Jun 7, 2021
1 parent 06009bf commit 0ebbf41
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 60 deletions.
6 changes: 3 additions & 3 deletions inference-engine/cmake/vpu_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ include_guard(GLOBAL)

set(VPU_SUPPORTED_FIRMWARES usb-ma2x8x pcie-ma2x8x)
set(VPU_SUPPORTED_FIRMWARES_HASH
"11a6db07d3a17c9c0fc4247fce47c942e0dcd59f8d70665a96bae0d7b7121fe9"
"43f3dc0f0a8114ca34226167970aafdc869600929d6e3761c1eaa6eec71f2237")
"dc93ba50e2096759aa3aeae67a85be1d49d2ba0ca84f319ca5ff911b13788f2c"
"c50db9859c4851fd4a3a5822ff05fc0af3d16a972625f965527a450aa4bb4624")

#
# Default packages
#

set(FIRMWARE_PACKAGE_VERSION 1658)
set(FIRMWARE_PACKAGE_VERSION 1676)
set(VPU_CLC_MA2X8X_VERSION "movi-cltools-20.09.2")

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ void FrontEnd::parseInterpolate(const Model& model, const ie::CNNLayerPtr& _laye

const auto interpolateMode = _layer->GetParamAsString(g_mode, g_nearest);

const auto input = inputs[0];
const auto input = inputs[0];
const auto output = outputs[0];

// try to use existing resize layers

const auto oc = output->desc().dim(Dim::C);
const auto on = output->desc().dim(Dim::N, 1);

const auto ic = input->desc().dim(Dim::C);
const auto in = (input->desc().numDims() == 3) ? 1 : input->desc().dim(Dim::N);
const auto in = input->desc().dim(Dim::N, 1);

const auto oc = output->desc().dim(Dim::C);
const auto on = (output->desc().numDims() == 3) ? 1 : output->desc().dim(Dim::N);
VPU_THROW_UNLESS(in == on, "incompatible: input batch=%d, output batch=%d", in, on);

auto padsBegin = _layer->GetParamAsInts(g_pads_begin, {});
auto padsEnd = _layer->GetParamAsInts(g_pads_end, {});
Expand All @@ -48,7 +50,7 @@ void FrontEnd::parseInterpolate(const Model& model, const ie::CNNLayerPtr& _laye
};

const auto orderIsSupported = input->desc().dimsOrder() == DimsOrder::NCHW || input->desc().dimsOrder() == DimsOrder::NHWC
|| input->desc().dimsOrder() == DimsOrder::CHW || input->desc().dimsOrder() == DimsOrder::HWC;
|| input->desc().dimsOrder() == DimsOrder::CHW || input->desc().dimsOrder() == DimsOrder::HWC;
VPU_THROW_UNLESS(orderIsSupported, "Current Interpolate supports (N)HWC, (N)CHW data orders only, actual {}", input->desc().dimsOrder());

const auto interpolateModeIt = interpModeMap.find(interpolateMode);
Expand All @@ -59,8 +61,10 @@ void FrontEnd::parseInterpolate(const Model& model, const ie::CNNLayerPtr& _laye
interpolateModeIt->second == InterpolateMode::LinearOnnx;
VPU_THROW_UNLESS(modeIsSupported, "Current Interpolate supports 'nearest' and 'linear' modes only, actual {}", interpolateMode);

const auto paramIsSupported = ic == oc && in == 1 && on == 1 && isPadZeros(padsBegin) && isPadZeros(padsEnd);
VPU_THROW_UNLESS(paramIsSupported, "Current Interpolate does not support paddings, batches, and resize by channels");
auto paramIsSupported = ic == oc;
VPU_THROW_UNLESS(paramIsSupported, "Current Interpolate does not support resize by channels");
paramIsSupported = isPadZeros(padsBegin) && isPadZeros(padsEnd);
VPU_THROW_UNLESS(paramIsSupported, "Current Interpolate does not support paddings");

if (interpolateModeIt->second == InterpolateMode::Nearest) {
// current "Resample" supports the following "Interpolate" modes only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const std::vector<std::vector<float>> defaultScales = {
{1.f, 1.f, 1.333333f, 1.333333f}
};

std::map<std::string, std::string> additional_config = {};

const auto interpolateCasesWithoutNearest = ::testing::Combine(
::testing::ValuesIn(modesWithoutNearest),
::testing::ValuesIn(shapeCalculationMode),
Expand Down Expand Up @@ -115,7 +117,8 @@ 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(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -127,7 +130,8 @@ 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(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

const std::vector<std::vector<size_t>> targetShapesTailTest = {
Expand Down Expand Up @@ -171,7 +175,8 @@ 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(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -183,7 +188,8 @@ 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(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface<InterpolateLa
std::vector<size_t> inputShape;
std::vector<size_t> targetShape;
Precision netPrecision;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = basicParamsSet;
std::map<std::string, std::string> additional_config;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape,
targetShape, targetDevice, additional_config) = basicParamsSet;

ngraph::op::v4::Interpolate::InterpolateMode mode;
ngraph::op::v4::Interpolate::ShapeCalcMode shapeCalcMode;
Expand Down Expand Up @@ -242,6 +244,8 @@ const std::vector<fusingSpecificParams> interpolateFusingParamsSet{
fusingFakeQuantizePerChannelRelu,
};

std::map<std::string, std::string> additional_config = {};

std::vector<std::map<std::string, std::string>> filterAdditionalConfig() {
if (with_cpu_x86_avx512f()) {
return {
Expand All @@ -267,7 +271,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -284,7 +289,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLaye
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -301,7 +307,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPU
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -318,7 +325,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUT
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand Down Expand Up @@ -390,7 +398,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLa
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6, 2})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -407,7 +416,8 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTe
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 4, 4})),
::testing::Values(std::vector<size_t>({1, 21, 5, 6, 2})),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::Values(additional_config)),
::testing::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const std::vector<std::vector<float>> defaultScales = {
{1.f, 1.f, 2.f, 2.f}
};

std::map<std::string, std::string> additional_config = {};

const auto interpolateCasesWithoutNearest = ::testing::Combine(
::testing::ValuesIn(modesWithoutNearest),
::testing::ValuesIn(shapeCalculationMode),
Expand Down Expand Up @@ -115,7 +117,8 @@ 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(CommonTestUtils::DEVICE_GPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -127,7 +130,8 @@ 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(CommonTestUtils::DEVICE_GPU),
::testing::Values(additional_config)),
InterpolateLayerTest::getTestCaseName);

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,51 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP16,
};

const std::vector<std::vector<size_t>> inShapes = {
{1, 8, 38, 38},
{1, 8, 36, 36},
{1, 8, 35, 35},
{1, 8, 6, 6},
typedef std::map<std::string, std::string> Config;

{1, 8, 3, 3},
{1, 8, 4, 4},
{1, 8, 16, 16},
{1, 8, 31, 31},
{1, 8, 26, 26},
const std::vector<std::vector<size_t>> inShapes = {
{3, 8, 38, 38},
{3, 8, 36, 36},
{3, 8, 35, 35},
{3, 8, 6, 6},

{3, 8, 3, 3},
{3, 8, 4, 4},
{3, 8, 16, 16},
{3, 8, 31, 31},
{3, 8, 26, 26},
};

const std::vector<std::vector<size_t>> targetShapes = {
{1, 8, 38 * 2, 38 * 2},
{1, 8, 70, 70}, // * 1.94
{1, 8, 46, 46}, // * 1.3
{1, 8, 9, 9},

{1, 8, 6, 6},
{1, 8, 3, 3},
{1, 8, 36, 36},
{1, 8, 72, 72},
{1, 8, 30, 30},
{3, 8, 38 * 2, 38 * 2},
{3, 8, 70, 70}, // * 1.94
{3, 8, 46, 46}, // * 1.3
{3, 8, 9, 9},

{3, 8, 6, 6},
{3, 8, 3, 3},
{3, 8, 36, 36},
{3, 8, 72, 72},
{3, 8, 30, 30},
};

const std::vector<std::vector<size_t>> inShapes2x = {
{1, 19, 37, 37},
{5, 19, 37, 37},
};

const std::vector<std::vector<size_t>> targetShapes2x = {
{1, 19, 37 * 2, 37 * 2},
{5, 19, 37 * 2, 37 * 2},
};

const std::vector<std::vector<size_t>> inShapesNoBatch = {
{1, 8, 38, 38},
{1, 8, 36, 36},
};

const std::vector<std::vector<size_t>> targetShapesNoBatch = {
{1, 8, 38 * 2, 38 * 2},
{1, 8, 70, 70}, // * 1.94
};

const std::vector<ngraph::op::v4::Interpolate::InterpolateMode> modesWithoutNearest = {
ngraph::op::v4::Interpolate::InterpolateMode::linear,
Expand Down Expand Up @@ -179,7 +190,34 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_2x, InterpolateLayerTest,
::testing::Values(InferenceEngine::Layout::ANY),
::testing::ValuesIn(inShapes2x),
::testing::ValuesIn(targetShapes2x),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine(
interpolateCasesNearestMode,
::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(inShapesNoBatch),
::testing::ValuesIn(targetShapesNoBatch),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest_mode_no_batch, InterpolateLayerTest, ::testing::Combine(
interpolateCasesWithoutNearestMode,
::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(inShapesNoBatch),
::testing::ValuesIn(targetShapesNoBatch),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -191,7 +229,8 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode, InterpolateLayerTest, ::
::testing::Values(InferenceEngine::Layout::ANY),
::testing::ValuesIn(inShapes),
::testing::ValuesIn(targetShapes),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -203,7 +242,8 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_nearest_mode_more, InterpolateLayerTes
::testing::Values(InferenceEngine::Layout::ANY),
::testing::ValuesIn(inShapes),
::testing::ValuesIn(targetShapes),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest, ::testing::Combine(
Expand All @@ -215,7 +255,8 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_without_nearest, InterpolateLayerTest,
::testing::Values(InferenceEngine::Layout::ANY),
::testing::ValuesIn(inShapes),
::testing::ValuesIn(targetShapes),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD)),
::testing::Values(CommonTestUtils::DEVICE_MYRIAD),
::testing::Values(Config{{InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH, CONFIG_VALUE(NO)}})),
InterpolateLayerTest::getTestCaseName);

} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ typedef std::tuple<

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
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
std::map<std::string, std::string> // Additional network configuration
> InterpolateLayerTestParams;

class InterpolateLayerTest : public testing::WithParamInterface<InterpolateLayerTestParams>,
Expand Down
Loading

0 comments on commit 0ebbf41

Please sign in to comment.