Skip to content

Commit

Permalink
changes in tests, so not to break other plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
DariaMityagina committed May 6, 2021
1 parent f67061e commit f6a537d
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ 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 @@ -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(
Expand All @@ -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<std::vector<size_t>> targetShapesTailTest = {
Expand Down Expand Up @@ -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(
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ class InterpolateLayerCPUTest : public testing::WithParamInterface<InterpolateLa
std::vector<size_t> inputShape;
std::vector<size_t> targetShape;
Precision netPrecision;
std::map<std::string, std::string> 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;
Expand Down Expand Up @@ -268,8 +266,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -286,8 +283,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -304,8 +300,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -322,8 +317,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand Down Expand Up @@ -396,8 +390,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand All @@ -414,8 +407,7 @@ 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(additional_config)),
::testing::Values(CommonTestUtils::DEVICE_CPU)),
::testing::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(filterAdditionalConfig())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ 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 @@ -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(
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ TEST_P(InterpolateLayerTest, CompareWithRefs) {
Run();
}

TEST_P(InterpolateLayerTestWithConfig, CompareWithRefs) {
Run();
}

} // namespace LayerTestsDefinitions
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ typedef std::tuple<
std::vector<float> // 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
Expand All @@ -40,7 +52,7 @@ typedef std::tuple<
InferenceEngine::SizeVector, // Target shapes
LayerTestsUtils::TargetDevice, // Device name
std::map<std::string, std::string> // Additional network configuration
> InterpolateLayerTestParams;
> InterpolateLayerTestParamsWithConfig;

class InterpolateLayerTest : public testing::WithParamInterface<InterpolateLayerTestParams>,
virtual public LayerTestsUtils::LayerTestsCommon {
Expand All @@ -51,4 +63,13 @@ class InterpolateLayerTest : public testing::WithParamInterface<InterpolateLayer
void SetUp() override;
};

class InterpolateLayerTestWithConfig : public testing::WithParamInterface<InterpolateLayerTestParamsWithConfig>,
virtual public LayerTestsUtils::LayerTestsCommon {
public:
static std::string getTestCaseName(testing::TestParamInfo<InterpolateLayerTestParamsWithConfig> obj);

protected:
void SetUp() override;
};

} // namespace LayerTestsDefinitions
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,86 @@ using ngraph::helpers::operator<<;
namespace LayerTestsDefinitions {

std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo<InterpolateLayerTestParams> 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<size_t> padBegin, padEnd;
std::vector<int64_t> axes;
std::vector<float> 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<size_t> inputShape, targetShape;
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = this->GetParam();
std::vector<size_t> padBegin, padEnd;
std::vector<int64_t> axes;
std::vector<float> 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<ngraph::opset3::Constant>(sizesConst);

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 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,
padEnd, coordinateTransformMode, nearestMode, antialias, cubeCoef};
auto 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)};
function = std::make_shared<ngraph::Function>(results, params, "interpolate");
}

std::string InterpolateLayerTestWithConfig::getTestCaseName(testing::TestParamInfo<InterpolateLayerTestParamsWithConfig> obj) {
InterpolateSpecificParams interpolateParams;
InferenceEngine::Precision netPrecision;
InferenceEngine::Precision inPrc, outPrc;
Expand Down Expand Up @@ -52,7 +132,7 @@ std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo<Interpo
return result.str();
}

void InterpolateLayerTest::SetUp() {
void InterpolateLayerTestWithConfig::SetUp() {
InterpolateSpecificParams interpolateParams;
std::vector<size_t> inputShape, targetShape;
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
Expand Down Expand Up @@ -94,4 +174,5 @@ void InterpolateLayerTest::SetUp() {
const ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(interpolate)};
function = std::make_shared<ngraph::Function>(results, params, "interpolate");
}

} // namespace LayerTestsDefinitions

0 comments on commit f6a537d

Please sign in to comment.