ConcatTransformation naming fix (#3965)

* concat naming fix

* [LPT] concat with child and output plugin tests
This commit is contained in:
Vladislav Golubev 2021-01-22 23:02:16 +03:00 committed by GitHub
parent c3347e1788
commit 2d39555191
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 249 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -376,7 +376,7 @@ void ConcatTransformation::addDequantizationLayers(
layer->set_output_type(0, precision, layer->get_output_partial_shape(0));
const auto it = outputs.find(layer->get_friendly_name());
if (it != outputs.end()) {
if (it != outputs.end() && is_type<ngraph::opset1::Result>(child.shared_from_this())) {
const std::string originalName = layer->get_friendly_name();
const std::string newName = layer->get_friendly_name() + LayerTransformation::originalLayerPostfix;
layer->set_friendly_name(newName);

View File

@ -0,0 +1,53 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "low_precision_transformations/concat_with_child_and_output.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<ngraph::element::Type> netPrecisions = {
ngraph::element::f32,
// ngraph::element::f16
};
const std::vector<ngraph::pass::low_precision::LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams()
};
const std::vector<ConcatWithChildAndOutputTransformationParam> testValues = {
// U8
{
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }
},
// I8
{
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f / 2.f}, {1.27f / 2.f} }
},
// mixed: U8 + I8
{
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }
},
// mixed: I8 + U8
{
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }
}
};
INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithChildAndOutputTransformation,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })),
::testing::Values(CommonTestUtils::DEVICE_CPU),
::testing::ValuesIn(testValues),
::testing::ValuesIn(trasformationParamValues)),
ConcatWithChildAndOutputTransformation::getTestCaseName);
} // namespace

View File

@ -0,0 +1,53 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <vector>
#include "low_precision_transformations/concat_with_child_and_output.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
const std::vector<ngraph::element::Type> netPrecisions = {
ngraph::element::f32,
// ngraph::element::f16
};
const std::vector<ngraph::pass::low_precision::LayerTransformation::Params> trasformationParamValues = {
LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams()
};
const std::vector<ConcatWithChildAndOutputTransformationParam> testValues = {
// U8
{
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }
},
// I8
{
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f / 2.f}, {1.27f / 2.f} }
},
// mixed: U8 + I8
{
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }
},
// mixed: I8 + U8
{
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }
}
};
INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithChildAndOutputTransformation,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })),
::testing::Values(CommonTestUtils::DEVICE_GPU),
::testing::ValuesIn(testValues),
::testing::ValuesIn(trasformationParamValues)),
ConcatWithChildAndOutputTransformation::getTestCaseName);
} // namespace

View File

@ -0,0 +1,38 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <string>
#include <memory>
#include "shared_test_classes/base/low_precision_transformations/layer_transformation.hpp"
#include "lpt_ngraph_functions/common/fake_quantize_on_data.hpp"
namespace LayerTestsDefinitions {
class ConcatWithChildAndOutputTransformationParam {
public:
ngraph::builder::subgraph::FakeQuantizeOnData fqOnData1;
ngraph::builder::subgraph::FakeQuantizeOnData fqOnData2;
};
typedef std::tuple<
ngraph::element::Type,
ngraph::Shape,
std::string, // target device: CPU, GPU
ConcatWithChildAndOutputTransformationParam,
ngraph::pass::low_precision::LayerTransformation::Params // transformation parameters
> ConcatWithChildAndOutputTransformationParams;
class ConcatWithChildAndOutputTransformation :
public testing::WithParamInterface<ConcatWithChildAndOutputTransformationParams>,
public LayerTestsUtils::LayerTransformation {
public:
static std::string getTestCaseName(testing::TestParamInfo<ConcatWithChildAndOutputTransformationParams> obj);
protected:
void SetUp() override;
};
} // namespace LayerTestsDefinitions

View File

@ -0,0 +1,63 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "low_precision_transformations/concat_with_child_and_output.hpp"
#include <memory>
#include <tuple>
#include <vector>
#include <string>
#include <ie_core.hpp>
#include <transformations/init_node_info.hpp>
#include "ngraph_functions/builders.hpp"
#include "lpt_ngraph_functions/concat_function.hpp"
using namespace InferenceEngine;
using namespace InferenceEngine::details;
namespace LayerTestsDefinitions {
std::string ConcatWithChildAndOutputTransformation::getTestCaseName(testing::TestParamInfo<ConcatWithChildAndOutputTransformationParams> obj) {
ngraph::element::Type netPrecision;
ngraph::Shape inputShapes;
std::string targetDevice;
ConcatWithChildAndOutputTransformationParam param;
ngraph::pass::low_precision::LayerTransformation::Params params;
std::tie(netPrecision, inputShapes, targetDevice, param, params) = obj.param;
std::ostringstream result;
result <<
getTestCaseNameByParams(netPrecision, inputShapes, targetDevice, params) <<
param.fqOnData1 << param.fqOnData2;
return result.str();
}
/*
* FQ FQ
* \ /
* concat
* / \
* clamp \
* / \
* output1 output2
*/
void ConcatWithChildAndOutputTransformation::SetUp() {
ngraph::element::Type netPrecision;
ngraph::Shape inputShapes;
ConcatWithChildAndOutputTransformationParam param;
ngraph::pass::low_precision::LayerTransformation::Params params;
std::tie(netPrecision, inputShapes, targetDevice, param, params) = this->GetParam();
function = ngraph::builder::subgraph::ConcatFunction::getOriginalWithChildAndOutput(
netPrecision, inputShapes, param.fqOnData1, param.fqOnData2);
}
TEST_P(ConcatWithChildAndOutputTransformation, CompareWithRefImpl) {
Run();
};
} // namespace LayerTestsDefinitions

View File

@ -29,6 +29,12 @@ public:
const FakeQuantizeOnDataWithConstant& fakeQuantize1,
const FakeQuantizeOnDataWithConstant& fakeQuantize2);
static std::shared_ptr<ngraph::Function> getOriginalWithChildAndOutput(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const FakeQuantizeOnData& fakeQuantize1,
const FakeQuantizeOnData& fakeQuantize2);
static std::shared_ptr<ngraph::Function> getOriginalWithNeighbors(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,

View File

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
@ -77,6 +77,39 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getOriginal(
return function;
}
std::shared_ptr<ngraph::Function> ConcatFunction::getOriginalWithChildAndOutput(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,
const FakeQuantizeOnData& fqOnData1,
const FakeQuantizeOnData& fqOnData2) {
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
input1->set_friendly_name("input1");
const auto fakeQuantize1 = makeFakeQuantize(input1, precision, fqOnData1);
std::shared_ptr<ngraph::opset1::Result> res1;
const std::vector<size_t> inputShape2 = inputShape;
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(precision, ngraph::Shape(inputShape2));
input2->set_friendly_name("input2");
const auto fakeQuantize2 = makeFakeQuantize(input2, precision, fqOnData2);
const auto concat = std::make_shared<ngraph::opset1::Concat>(
ngraph::OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, 1);
concat->set_friendly_name("110");
auto& rtInfo = concat->get_rt_info();
rtInfo["Variant::std::string"] = std::make_shared<VariantWrapper<std::string>>("concat");
const auto clamp = std::make_shared<ngraph::opset1::Clamp>(concat, 0.0, 6.0);
clamp->set_friendly_name("111");
ResultVector results{ std::make_shared<ngraph::opset1::Result>(clamp), std::make_shared<ngraph::opset1::Result>(concat) };
std::shared_ptr<ngraph::Function> function = std::make_shared<ngraph::Function>(
results,
ngraph::ParameterVector{ input1, input2 },
"ConcatWithChildAndOutputTransformation");
return function;
}
std::shared_ptr<ngraph::Function> ConcatFunction::getOriginalWithNeighbors(
const ngraph::element::Type precision,
const ngraph::Shape& inputShape,