convert to bf is to be inserted only after non-const layer (#3597)
This commit is contained in:
parent
9d6bd321d8
commit
6d320d7162
@ -347,6 +347,9 @@ void BF16Transformer::addLayerToCNNNetworkAfterData(
|
||||
void BF16Transformer::insertConvertAfterInput(InferenceEngine::CNNNetwork &network) {
|
||||
auto inputLayers = InferenceEngine::CNNNetGetAllInputLayers(network);
|
||||
for (auto inputIter : inputLayers) {
|
||||
if (inputIter->type == "Const") {
|
||||
continue;
|
||||
}
|
||||
for (size_t o = 0; o < inputIter->outData.size(); o++) {
|
||||
for (auto bfInitIter : getInputTo(inputIter->outData[o])) {
|
||||
if (inputIter->outData[o]->getPrecision() == Precision::BF16) {
|
||||
|
@ -67,7 +67,7 @@ MKLDNNExecNetwork::MKLDNNExecNetwork(const InferenceEngine::ICNNNetwork &network
|
||||
BF16Transformer bf16Transformer;
|
||||
CNNNetwork cnnetwork(_clonedNetwork);
|
||||
// If enforceBF16 flag was set, BF16 transformation applies for all layers supported by CPU plugin.
|
||||
// Overwise, only layers marked as BF16 in 'cnnetwork' will be performed in bfloat16 mode.
|
||||
// Otherwise, only layers marked as BF16 in 'cnnetwork' will be performed in bfloat16 mode.
|
||||
// CPU plugin throws an exception, if marked as BF16 layers have not supported by CPU plugin.
|
||||
if (cfg.enforceBF16 == true)
|
||||
bf16Transformer.convertToBFloat16(cnnetwork);
|
||||
|
@ -12,6 +12,7 @@ namespace CPULayerTestsDefinitions {
|
||||
|
||||
typedef std::tuple<
|
||||
LayerTestsDefinitions::InterpolateLayerTestParams,
|
||||
std::map<std::string, std::string>, // Bf16 config
|
||||
CPUSpecificParams> InterpolateLayerCPUTestParamsSet;
|
||||
|
||||
class InterpolateLayerCPUTest : public testing::WithParamInterface<InterpolateLayerCPUTestParamsSet>,
|
||||
@ -20,12 +21,16 @@ public:
|
||||
static std::string getTestCaseName(testing::TestParamInfo<InterpolateLayerCPUTestParamsSet> obj) {
|
||||
LayerTestsDefinitions::InterpolateLayerTestParams basicParamsSet;
|
||||
CPUSpecificParams cpuParams;
|
||||
std::tie(basicParamsSet, cpuParams) = obj.param;
|
||||
std::map<std::string, std::string> bf16config;
|
||||
std::tie(basicParamsSet, bf16config, cpuParams) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
result << LayerTestsDefinitions::InterpolateLayerTest::getTestCaseName(testing::TestParamInfo<LayerTestsDefinitions::InterpolateLayerTestParams>(
|
||||
basicParamsSet, 0));
|
||||
|
||||
result << "bf16Enforce=" << (bf16config.count(InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16) ?
|
||||
bf16config.at(InferenceEngine::PluginConfigParams::KEY_ENFORCE_BF16) : InferenceEngine::PluginConfigParams::NO);
|
||||
|
||||
result << CPUTestsBase::getTestCaseName(cpuParams);
|
||||
|
||||
return result.str();
|
||||
@ -35,14 +40,15 @@ protected:
|
||||
void SetUp() {
|
||||
LayerTestsDefinitions::InterpolateLayerTestParams basicParamsSet;
|
||||
CPUSpecificParams cpuParams;
|
||||
std::tie(basicParamsSet, cpuParams) = this->GetParam();
|
||||
std::map<std::string, std::string> bf16config;
|
||||
std::tie(basicParamsSet, bf16config, cpuParams) = this->GetParam();
|
||||
|
||||
std::tie(inFmts, outFmts, priority, selectedType) = cpuParams;
|
||||
|
||||
LayerTestsDefinitions::InterpolateSpecificParams interpolateParams;
|
||||
std::vector<size_t> inputShape;
|
||||
std::vector<size_t> targetShape;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
auto netPrecision = InferenceEngine::Precision::UNSPECIFIED;
|
||||
std::tie(interpolateParams, netPrecision, inPrc, outPrc, inLayout, outLayout, inputShape, targetShape, targetDevice) = basicParamsSet;
|
||||
|
||||
ngraph::op::v4::Interpolate::InterpolateMode mode;
|
||||
@ -54,9 +60,9 @@ protected:
|
||||
double cubeCoef;
|
||||
std::vector<int64_t> axes;
|
||||
std::vector<float> scales;
|
||||
std:tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams;
|
||||
std::tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams;
|
||||
inPrc = outPrc = netPrecision;
|
||||
|
||||
configuration.insert(bf16config.begin(), bf16config.end());
|
||||
using ShapeCalcMode = ngraph::op::v4::Interpolate::ShapeCalcMode;
|
||||
|
||||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision);
|
||||
@ -82,7 +88,6 @@ protected:
|
||||
interpolate->get_rt_info() = getCPUInfo();
|
||||
const ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(interpolate)};
|
||||
function = std::make_shared<ngraph::Function>(results, params, "interpolate");
|
||||
|
||||
selectedType = getPrimitiveType() + "_" + inPrc.name();
|
||||
}
|
||||
};
|
||||
@ -203,6 +208,23 @@ const auto interpolateCasesCubic = ::testing::Combine(
|
||||
::testing::ValuesIn(defaultAxes),
|
||||
::testing::ValuesIn(defaultScales));
|
||||
|
||||
const auto interpolateCasesBf16Enforced = ::testing::Combine(
|
||||
::testing::Values(ngraph::op::v4::Interpolate::InterpolateMode::nearest),
|
||||
::testing::Values(ngraph::op::v4::Interpolate::ShapeCalcMode::scales),
|
||||
::testing::Values(ngraph::op::v4::Interpolate::CoordinateTransformMode::tf_half_pixel_for_nn),
|
||||
::testing::Values(ngraph::op::v4::Interpolate::NearestMode::simple),
|
||||
::testing::ValuesIn(antialias),
|
||||
::testing::ValuesIn(pads),
|
||||
::testing::ValuesIn(pads),
|
||||
::testing::ValuesIn(cubeCoefs),
|
||||
::testing::ValuesIn(defaultAxes),
|
||||
::testing::ValuesIn(defaultScales));
|
||||
|
||||
std::vector<std::map<std::string, std::string>> bf16EnforceFlags = {
|
||||
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::NO}},
|
||||
{{PluginConfigParams::KEY_ENFORCE_BF16, PluginConfigParams::YES}}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest,
|
||||
::testing::Combine(
|
||||
::testing::Combine(
|
||||
@ -215,6 +237,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateNN_Layout_Test, InterpolateLayerCPUTest
|
||||
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
|
||||
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
::testing::Values(std::map<std::string, std::string> {}),
|
||||
::testing::ValuesIn(filterCPUInfoForDevice())),
|
||||
InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
@ -230,6 +253,7 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateLinearOnnx_Layout_Test, InterpolateLaye
|
||||
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
|
||||
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
::testing::Values(std::map<std::string, std::string> {}),
|
||||
::testing::ValuesIn(filterCPUInfoForDevice())),
|
||||
InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
@ -245,9 +269,26 @@ INSTANTIATE_TEST_CASE_P(smoke_InterpolateCubic_Layout_Test, InterpolateLayerCPUT
|
||||
::testing::Values(std::vector<size_t>({1, 21, 40, 40})),
|
||||
::testing::Values(std::vector<size_t>({1, 21, 50, 60})),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU)),
|
||||
::testing::Values(std::map<std::string, std::string> {}),
|
||||
::testing::ValuesIn(filterCPUInfoForDevice())),
|
||||
InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(smoke_Interpolate_Enforced_Bf16_Layout_Test, InterpolateLayerCPUTest,
|
||||
::testing::Combine(
|
||||
::testing::Combine(
|
||||
interpolateCasesBf16Enforced,
|
||||
::testing::Values(InferenceEngine::Precision::BF16),
|
||||
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
|
||||
::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(CommonTestUtils::DEVICE_CPU)),
|
||||
::testing::ValuesIn(bf16EnforceFlags),
|
||||
::testing::ValuesIn(filterCPUInfoForDevice())),
|
||||
InterpolateLayerCPUTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
|
||||
} // namespace CPULayerTestsDefinitions
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <ie_plugin_config.hpp>
|
||||
#include "shared_test_classes/single_layer/interpolate.hpp"
|
||||
#include "ngraph_functions/builders.hpp"
|
||||
#include "ngraph_functions/utils/ngraph_helpers.hpp"
|
||||
@ -27,7 +28,7 @@ std::string InterpolateLayerTest::getTestCaseName(testing::TestParamInfo<Interpo
|
||||
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::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) << "_";
|
||||
@ -66,7 +67,7 @@ void InterpolateLayerTest::SetUp() {
|
||||
ngraph::op::v4::Interpolate::NearestMode nearestMode;
|
||||
|
||||
double cubeCoef;
|
||||
std:tie(mode, shapeCalcMode, coordinateTransformMode, nearestMode, antialias, padBegin, padEnd, cubeCoef, axes, scales) = interpolateParams;
|
||||
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});
|
||||
|
Loading…
Reference in New Issue
Block a user