[VPU] Batch support for interpolate (#5520)

* 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 67e5c1e4ddba4f0cc858eb1293e50ce9d9ae0227.

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

This reverts commit f6a537d2236f0b64f0ff028627af9e0e388a2d23.

* review corrections

* Firmware update
This commit is contained in:
Daria Mityagina 2021-05-21 12:54:58 +03:00 committed by GitHub
parent de58c8d008
commit 5ea8437c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 60 deletions

View File

@ -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")
#

View File

@ -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 ic = input->desc().dim(Dim::C);
const auto in = (input->desc().numDims() == 3) ? 1 : input->desc().dim(Dim::N);
const auto oc = output->desc().dim(Dim::C);
const auto on = (output->desc().numDims() == 3) ? 1 : output->desc().dim(Dim::N);
const auto on = output->desc().dim(Dim::N, 1);
const auto ic = input->desc().dim(Dim::C);
const auto in = input->desc().dim(Dim::N, 1);
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, {});
@ -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);
@ -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:

View File

@ -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),
@ -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(
@ -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 = {
@ -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(
@ -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

View File

@ -60,7 +60,9 @@ protected:
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;
@ -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 {
@ -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())),
@ -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())),
@ -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())),
@ -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())),
@ -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())),
@ -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())),

View File

@ -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),
@ -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(
@ -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

View File

@ -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},
{3, 8, 38 * 2, 38 * 2},
{3, 8, 70, 70}, // * 1.94
{3, 8, 46, 46}, // * 1.3
{3, 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, 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,
@ -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(
@ -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(
@ -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(
@ -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

View File

@ -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>,

View File

@ -18,7 +18,8 @@ std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo<Interpo
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::map<std::string, std::string> additional_config;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShapes, targetShapes, targetDevice, additional_config) = obj.param;
std::vector<size_t> padBegin, padEnd;
std::vector<int64_t> axes;
std::vector<float> scales;
@ -55,8 +56,8 @@ void InterpolateLayerTest::SetUp() {
InterpolateSpecificParams interpolateParams;
std::vector<size_t> inputShape, targetShape;
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = this->GetParam();
std::map<std::string, std::string> additional_config;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice, additional_config) = this->GetParam();
std::vector<size_t> padBegin, padEnd;
std::vector<int64_t> axes;
std::vector<float> scales;
@ -66,6 +67,8 @@ void InterpolateLayerTest::SetUp() {
ngraph::op::v4::Interpolate::CoordinateTransformMode coordinateTransformMode;
ngraph::op::v4::Interpolate::NearestMode nearestMode;
configuration.insert(additional_config.begin(), additional_config.end());
double cubeCoef;
std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams;