contain only some typical fusion, reduce tensor size, not skip on traget without avx512 (#5361)

This commit is contained in:
Chenhu Wang
2021-04-23 16:29:53 +08:00
committed by GitHub
parent 6510a68b10
commit 528d4b1bac
2 changed files with 62 additions and 56 deletions

View File

@@ -17,7 +17,7 @@ const std::vector<InferenceEngine::Precision> netPrecisions = {
};
const std::vector<std::vector<size_t>> inShapes = {
{1, 4, 30, 30},
{1, 4, 6, 6},
};
const std::vector<ngraph::op::v4::Interpolate::InterpolateMode> modesWithoutNearest = {
@@ -71,15 +71,15 @@ const std::vector<double> cubeCoefs = {
};
const std::vector<std::vector<int64_t>> defaultAxes = {
{2, 3}
{0, 1, 2, 3}
};
const std::vector<std::vector<size_t>> targetShapes = {
{40, 40},
{1, 4, 8, 8},
};
const std::vector<std::vector<float>> defaultScales = {
{1.333333f, 1.333333f}
{1.f, 1.f, 1.333333f, 1.333333f}
};
const auto interpolateCasesWithoutNearest = ::testing::Combine(
@@ -131,11 +131,11 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest, InterpolateLayerTest, ::testi
InterpolateLayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> targetShapesTailTest = {
{1, 4, 10, 41}, // 10 * 41 is not multipler of 4, cover tail process code path
{1, 4, 2, 11}, // cover down sample and tails process code path
};
const std::vector<std::vector<float>> defaultScalesTailTest = {
{0.333333f, 1.366666f}
{1.f, 1.f, 0.333333f, 1.833333f}
};
const auto interpolateCasesWithoutNearestTail = ::testing::Combine(
@@ -162,7 +162,7 @@ const auto interpolateCasesTail = ::testing::Combine(
::testing::ValuesIn(defaultAxes),
::testing::ValuesIn(defaultScalesTailTest));
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_2, InterpolateLayerTest, ::testing::Combine(
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine(
interpolateCasesWithoutNearestTail,
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
@@ -174,7 +174,7 @@ INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Basic_2, InterpolateLayerTest, ::testi
::testing::Values(CommonTestUtils::DEVICE_CPU)),
InterpolateLayerTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_2, InterpolateLayerTest, ::testing::Combine(
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Nearest_Down_Sample_Tail, InterpolateLayerTest, ::testing::Combine(
interpolateCasesTail,
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),

View File

@@ -59,7 +59,7 @@ protected:
LayerTestsDefinitions::InterpolateSpecificParams interpolateParams;
std::vector<size_t> inputShape;
std::vector<size_t> targetShape;
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
Precision netPrecision;
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = basicParamsSet;
ngraph::op::v4::Interpolate::InterpolateMode mode;
@@ -101,7 +101,7 @@ protected:
selectedType = getPrimitiveType();
}
selectedType.push_back('_');
selectedType += "FP32";
selectedType += netPrecision.name();
}
};
@@ -118,17 +118,17 @@ namespace {
std::vector<CPUSpecificParams> filterCPUInfoForDevice() {
std::vector<CPUSpecificParams> resCPUParams;
if (with_cpu_x86_avx512f()) {
resCPUParams.push_back(CPUSpecificParams{{nChw16c, x, x}, {nChw16c}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{nChw16c, x, x, x}, {nChw16c}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_avx512"}, "jit_avx512"});
} else if (with_cpu_x86_avx2()) {
resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x}, {nChw8c}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x, x}, {nChw8c}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nchw, x, x, x}, {nchw}, {"jit_avx2"}, "jit_avx2"});
} else if (with_cpu_x86_sse42()) {
resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x}, {nChw8c}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x}, {nhwc}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{nChw8c, x, x, x}, {nChw8c}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{nhwc, x, x, x}, {nhwc}, {"jit_sse42"}, "jit_sse42"});
} else {
resCPUParams.push_back(CPUSpecificParams{{nchw, x, x}, {nchw}, {"ref"}, "ref"});
resCPUParams.push_back(CPUSpecificParams{{nchw, x, x, x}, {nchw}, {"ref"}, "ref"});
}
return resCPUParams;
}
@@ -177,11 +177,11 @@ const std::vector<double> cubeCoefs = {
};
const std::vector<std::vector<int64_t>> defaultAxes = {
{2, 3}
{0, 1, 2, 3}
};
const std::vector<std::vector<float>> defaultScales = {
{1.25f, 1.5f}
{1.f, 1.f, 1.25f, 1.5f}
};
const auto interpolateCasesNN = ::testing::Combine(
@@ -235,16 +235,22 @@ const auto interpolateCasesCubic = ::testing::Combine(
const std::vector<fusingSpecificParams> interpolateFusingParamsSet{
emptyFusingSpec,
fusingRelu,
fusingElu,
fusingSigmoid,
fusingClamp,
fusingSwish,
};
std::vector<std::map<std::string, std::string>> bf16EnforceFlags = {
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}},
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}
};
std::vector<std::map<std::string, std::string>> filterAdditionalConfig() {
if (with_cpu_x86_avx512f()) {
return {
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}},
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}
};
} else {
return {
// default config as an stub for target without avx512, otherwise all tests with BF16 in its name are skipped
{{PluginConfigParams::KEY_PERF_COUNT, PluginConfigParams::NO}}
};
}
}
INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest,
::testing::Combine(
@@ -255,12 +261,12 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
::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::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLayerCPUTest,
@@ -272,12 +278,12 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLaye
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
::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::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPUTest,
@@ -289,12 +295,12 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinear_Layout_Test, InterpolateLayerCPU
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
::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::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUTest,
@@ -306,30 +312,30 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUT
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
::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::ValuesIn(filterCPUInfoForDevice()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
////////////////////////5D/////////////////////////////
std::vector<CPUSpecificParams> filterCPUInfoForDevice5D() {
std::vector<CPUSpecificParams> resCPUParams;
if (with_cpu_x86_avx512f()) {
resCPUParams.push_back(CPUSpecificParams{{nCdhw16c, x, x}, {nCdhw16c}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nCdhw16c, x, x, x}, {nCdhw16c}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_avx512"}, "jit_avx512"});
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2"});
} else if (with_cpu_x86_avx2()) {
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x}, {nCdhw8c}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x, x}, {nCdhw8c}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_avx2"}, "jit_avx2"});
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x, x}, {ncdhw}, {"jit_avx2"}, "jit_avx2"});
} else if (with_cpu_x86_sse42()) {
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x}, {nCdhw8c}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x}, {ndhwc}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{nCdhw8c, x, x, x}, {nCdhw8c}, {"jit_sse42"}, "jit_sse42"});
resCPUParams.push_back(CPUSpecificParams{{ndhwc, x, x, x}, {ndhwc}, {"jit_sse42"}, "jit_sse42"});
} else {
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x}, {ncdhw}, {"ref"}, "ref"});
resCPUParams.push_back(CPUSpecificParams{{ncdhw, x, x, x}, {ncdhw}, {"ref"}, "ref"});
}
return resCPUParams;
}
@@ -339,11 +345,11 @@ const std::vector<std::vector<size_t>> pads5D = {
};
const std::vector<std::vector<int64_t>> defaultAxes5D = {
{2, 3, 4}
{0, 1, 2, 3, 4}
};
const std::vector<std::vector<float>> defaultScales5D = {
{1.25f, 1.5f, 1.5f}
{1.f, 1.f, 1.25f, 1.5f, 0.5f}
};
const auto interpolateCasesLinearOnnx5D = ::testing::Combine(
@@ -379,12 +385,12 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx5D_Layout_Test, InterpolateLa
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 10, 10})),
::testing::Values(std::vector<size_t>({1, 21, 5, 15, 15})),
::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::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTest,
@@ -396,12 +402,12 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN5D_Layout_Test, InterpolateLayerCPUTe
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t>({1, 21, 4, 10, 10})),
::testing::Values(std::vector<size_t>({1, 21, 5, 15, 15})),
::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::ValuesIn(filterCPUInfoForDevice5D()),
::testing::ValuesIn(interpolateFusingParamsSet),
::testing::ValuesIn(bf16EnforceFlags)),
::testing::ValuesIn(filterAdditionalConfig())),
InterpolateLayerCPUTest::getTestCaseName);
} // namespace