[LPT] MarkupCanBeQuantized: handled unsupported concat (#7045)
* [LPT] MarkupCanBeQuantized: added check on unsupported concat * [LPT] ConcatTransformation: added test-case with unsupported concat and convolution * [LPT] added test on rtInfo check for unsupported concat * [LPT] ConcatTransformation: added test-case with unsupported axis to plugin tests
This commit is contained in:
parent
551b17db81
commit
78dea9a7d6
@ -26,6 +26,7 @@ public:
|
||||
bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override;
|
||||
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
|
||||
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
|
||||
static bool isQuantizedStatic(const std::shared_ptr<const Node>& layer) noexcept;
|
||||
|
||||
protected:
|
||||
static bool isHandled(
|
||||
|
@ -297,6 +297,22 @@ bool ConcatTransformation::isHandled(const TransformationContext& context, const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConcatTransformation::isQuantizedStatic(const std::shared_ptr<const Node>& layer) noexcept {
|
||||
const auto concat = as_type_ptr<const opset1::Concat>(layer);
|
||||
if (concat == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto axis = concat->get_axis();
|
||||
const auto outputRank = concat->get_output_partial_shape(0).rank();
|
||||
if (axis < 0 && outputRank.is_dynamic()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t normalizedAxis = ngraph::normalize_axis(concat->get_friendly_name(), axis, outputRank);
|
||||
return normalizedAxis == 1ul;
|
||||
}
|
||||
|
||||
} // namespace low_precision
|
||||
} // namespace pass
|
||||
} // namespace ngraph
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include <ngraph/opsets/opset1.hpp>
|
||||
#include "low_precision/concat.hpp"
|
||||
#include "low_precision/convolution.hpp"
|
||||
#include "low_precision/convolution_backprop_data.hpp"
|
||||
#include "low_precision/group_convolution.hpp"
|
||||
@ -54,6 +55,12 @@ bool ngraph::pass::low_precision::MarkupCanBeQuantized::run_on_function(std::sha
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (const auto concat = std::dynamic_pointer_cast<ngraph::opset1::Concat>(node)) {
|
||||
if (!ConcatTransformation::isQuantizedStatic(concat)) {
|
||||
setEmptyPrecisions(concat);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -230,16 +230,18 @@ TEST_P(ConcatTransformation, CompareFunctions) {
|
||||
auto res = compare_functions(referenceFunction, actualFunction, true, true, false, true, false);
|
||||
ASSERT_TRUE(res.first) << res.second;
|
||||
|
||||
const auto actualFakeQuantizes = LayerTransformation::get<opset1::FakeQuantize>(actualFunction);
|
||||
ASSERT_TRUE(checkIfOutputAttributesSharedValuesAreTheSame<std::shared_ptr<PrecisionsAttribute>>(actualFakeQuantizes)) <<
|
||||
"PrecisionsAttribute are not the same";
|
||||
|
||||
ConcatTransformationTestValues testValues = std::get<2>(GetParam());
|
||||
if (testValues.checkIntervalsAlignmentAttributes) {
|
||||
auto operations = LayerTransformation::get<opset1::Concat>(actualFunction);
|
||||
operations.insert(operations.end(), actualFakeQuantizes.begin(), actualFakeQuantizes.end());
|
||||
ASSERT_TRUE(checkIfAttributesSharedValuesAreTheSame<std::shared_ptr<IntervalsAlignmentAttribute>>(operations)) <<
|
||||
"IntervalsAlignmentAttribute are not the same";
|
||||
const auto actualFakeQuantizes = LayerTransformation::get<opset1::FakeQuantize>(actualFunction);
|
||||
if (testValues.axis == 1) {
|
||||
ASSERT_TRUE(checkIfOutputAttributesSharedValuesAreTheSame<std::shared_ptr<PrecisionsAttribute>>(actualFakeQuantizes)) <<
|
||||
"PrecisionsAttribute are not the same";
|
||||
|
||||
if (testValues.checkIntervalsAlignmentAttributes) {
|
||||
auto operations = LayerTransformation::get<opset1::Concat>(actualFunction);
|
||||
operations.insert(operations.end(), actualFakeQuantizes.begin(), actualFakeQuantizes.end());
|
||||
ASSERT_TRUE(checkIfAttributesSharedValuesAreTheSame<std::shared_ptr<IntervalsAlignmentAttribute>>(operations)) <<
|
||||
"IntervalsAlignmentAttribute are not the same";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,11 +11,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <transformations/utils/utils.hpp>
|
||||
#include <transformations/init_node_info.hpp>
|
||||
#include <low_precision/concat.hpp>
|
||||
#include <low_precision/fake_quantize_decomposition.hpp>
|
||||
#include <low_precision/max_pool.hpp>
|
||||
#include <low_precision/clamp.hpp>
|
||||
|
||||
#include "common_test_utils/ngraph_test_utils.hpp"
|
||||
#include "lpt_ngraph_functions/concat_function.hpp"
|
||||
@ -45,7 +43,8 @@ public:
|
||||
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1;
|
||||
ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2;
|
||||
ngraph::element::Type precisionBeforeOp;
|
||||
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore;
|
||||
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore1;
|
||||
ngraph::builder::subgraph::DequantizationOperations dequantizationBefore2;
|
||||
ngraph::element::Type precisionAfterOperation;
|
||||
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1;
|
||||
ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2;
|
||||
@ -63,6 +62,7 @@ class ConcatTransformationTestValues {
|
||||
public:
|
||||
TestTransformationParams params;
|
||||
bool multiChannels;
|
||||
std::int64_t axis;
|
||||
ConcatTransformationActualValues actual;
|
||||
ConcatTransformationResultValues result;
|
||||
};
|
||||
@ -87,6 +87,7 @@ public:
|
||||
actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithDifferentPrecisionOnChildren(
|
||||
precision,
|
||||
inputShape,
|
||||
testValues.axis,
|
||||
testValues.actual.fakeQuantize1,
|
||||
testValues.actual.fakeQuantize2);
|
||||
|
||||
@ -100,17 +101,18 @@ public:
|
||||
transform.add<ngraph::pass::low_precision::ConcatTransformation, ngraph::opset1::Concat>(testValues.params);
|
||||
transform.add<ngraph::pass::low_precision::FakeQuantizeDecompositionTransformation, ngraph::opset1::FakeQuantize>(testValues.params);
|
||||
transform.add<ngraph::pass::low_precision::MaxPoolTransformation, ngraph::opset1::MaxPool>(testValues.params);
|
||||
transform.add<ngraph::pass::low_precision::ClampTransformation, ngraph::opset1::Clamp>(testValues.params);
|
||||
transform.transform(actualFunction);
|
||||
|
||||
referenceFunction = ngraph::builder::subgraph::ConcatFunction::getReferenceWithDifferentPrecisionOnChildren(
|
||||
precision,
|
||||
inputShape,
|
||||
testValues.multiChannels,
|
||||
testValues.axis,
|
||||
testValues.result.fakeQuantize1,
|
||||
testValues.result.fakeQuantize2,
|
||||
testValues.result.precisionBeforeOp,
|
||||
testValues.result.dequantizationBefore,
|
||||
testValues.result.dequantizationBefore1,
|
||||
testValues.result.dequantizationBefore2,
|
||||
testValues.result.precisionAfterOperation,
|
||||
testValues.result.dequantizationAfter1,
|
||||
testValues.result.dequantizationAfter2);
|
||||
@ -153,6 +155,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{
|
||||
LayerTransformation::createParamsU8I8(),
|
||||
false,
|
||||
1,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} }
|
||||
@ -162,15 +165,37 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} },
|
||||
ngraph::element::u8,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}},
|
||||
ngraph::element::u8,
|
||||
{ ngraph::element::f32, {}, { 0.01f } },
|
||||
{ ngraph::element::f32, {}, { 0.01f } }
|
||||
}
|
||||
},
|
||||
// U8 with unsupported axis
|
||||
{
|
||||
LayerTransformation::createParamsU8I8(),
|
||||
false,
|
||||
2,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} }
|
||||
},
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {255.f} },
|
||||
ngraph::element::u8,
|
||||
{{ngraph::element::f32}, {}, {0.01f}},
|
||||
{{ngraph::element::f32}, {}, {0.005f}},
|
||||
ngraph::element::f32,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}}
|
||||
}
|
||||
},
|
||||
// I8
|
||||
{
|
||||
LayerTransformation::createParamsI8I8(),
|
||||
false,
|
||||
1,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} }
|
||||
@ -180,6 +205,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f} },
|
||||
ngraph::element::i8,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}},
|
||||
ngraph::element::i8,
|
||||
{ ngraph::element::f32, {}, { 0.01f } },
|
||||
{ ngraph::element::f32, {}, { 0.01f } }
|
||||
@ -189,6 +215,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{
|
||||
LayerTransformation::createParamsU8I8(),
|
||||
true,
|
||||
1,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} }
|
||||
@ -198,6 +225,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f} },
|
||||
ngraph::element::u8,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}},
|
||||
ngraph::element::u8,
|
||||
{ ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} },
|
||||
{ ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} },
|
||||
@ -207,6 +235,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{
|
||||
LayerTransformation::createParamsI8I8(),
|
||||
true,
|
||||
1,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} }
|
||||
@ -216,6 +245,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f} },
|
||||
ngraph::element::i8,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}},
|
||||
ngraph::element::i8,
|
||||
{ ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} },
|
||||
{ ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} },
|
||||
@ -225,6 +255,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{
|
||||
LayerTransformation::createParamsU8I8().setUpdatePrecisions(false),
|
||||
false,
|
||||
1,
|
||||
{
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} }
|
||||
@ -234,6 +265,7 @@ const std::vector<ConcatTransformationTestValues> testValues = {
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} },
|
||||
ngraph::element::f32,
|
||||
{{}, {}, {}},
|
||||
{{}, {}, {}},
|
||||
ngraph::element::f32,
|
||||
{ {}, {}, { 0.01f } },
|
||||
{ {}, {}, { 0.01f } }
|
||||
|
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "layer_transformation.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "lpt_ngraph_functions/concat_function.hpp"
|
||||
#include "simple_low_precision_transformer.hpp"
|
||||
|
||||
using namespace ::testing;
|
||||
|
||||
class smoke_LPT_ConcatWithUnsupportedAxis : public Test {};
|
||||
|
||||
TEST_F(smoke_LPT_ConcatWithUnsupportedAxis, rtInfoCheck) {
|
||||
using namespace ngraph::builder::subgraph;
|
||||
|
||||
const ngraph::element::Type precision = ngraph::element::f32;
|
||||
const ngraph::PartialShape inputPShape = PartialShape{ 1, 3, 16, 16 };
|
||||
const std::int64_t unsupportedAxis = 2;
|
||||
const auto fakeQuantize = FakeQuantizeOnData{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} };
|
||||
|
||||
std::shared_ptr<ngraph::Function> function = ConcatFunction::getOriginalWithDifferentPrecisionOnChildren(
|
||||
precision,
|
||||
inputPShape,
|
||||
unsupportedAxis,
|
||||
fakeQuantize,
|
||||
fakeQuantize);
|
||||
|
||||
SimpleLowPrecisionTransformer transformer;
|
||||
transformer.transform(function);
|
||||
|
||||
const auto actualConcat = LayerTransformation::get<opset1::Concat>(function)[0];
|
||||
const auto& rtInfo = actualConcat->get_rt_info();
|
||||
ASSERT_TRUE(rtInfo.empty()) << "Unsupported concat mustn't contain LPT runtime attributes";
|
||||
}
|
@ -16,42 +16,48 @@ const std::vector<ngraph::element::Type> netPrecisions = {
|
||||
};
|
||||
|
||||
const std::vector<ngraph::pass::low_precision::LayerTransformation::Params> trasformationParamValues = {
|
||||
// LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8(),
|
||||
LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8()
|
||||
};
|
||||
|
||||
const std::vector<ConcatWithDifferentChildrenTransformationParam> testValues = {
|
||||
// U8
|
||||
{
|
||||
1,
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }
|
||||
},
|
||||
// U8 and unsupported concat axis
|
||||
{
|
||||
2,
|
||||
{ 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
|
||||
{
|
||||
1,
|
||||
{ 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
|
||||
{
|
||||
1,
|
||||
{ 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
|
||||
{
|
||||
1,
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }
|
||||
}
|
||||
};
|
||||
|
||||
const std::vector<bool> multiChannel = { true/*, false*/ };
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(ngraph::PartialShape({ 1, 6, 10, 10 })),
|
||||
::testing::Values(CommonTestUtils::DEVICE_CPU),
|
||||
::testing::ValuesIn(testValues),
|
||||
::testing::ValuesIn(trasformationParamValues),
|
||||
::testing::ValuesIn(multiChannel)),
|
||||
::testing::ValuesIn(trasformationParamValues)),
|
||||
ConcatWithDifferentChildrenTransformation::getTestCaseName);
|
||||
} // namespace
|
||||
|
@ -16,42 +16,48 @@ const std::vector<ngraph::element::Type> netPrecisions = {
|
||||
};
|
||||
|
||||
const std::vector<ngraph::pass::low_precision::LayerTransformation::Params> trasformationParamValues = {
|
||||
// LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8(),
|
||||
LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8()
|
||||
};
|
||||
|
||||
const std::vector<ConcatWithDifferentChildrenTransformationParam> testValues = {
|
||||
// U8
|
||||
{
|
||||
1,
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }
|
||||
},
|
||||
// U8 and unsupported concat axis
|
||||
{
|
||||
2,
|
||||
{ 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({}), {-128.f}, {127.f}, {-1.28f}, {1.27f} },
|
||||
{ 256ul, ngraph::Shape({}), {-128.f}, {127.f}, {-1.28f / 2}, {1.27f / 2} }
|
||||
1,
|
||||
{ 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
|
||||
{
|
||||
1,
|
||||
{ 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
|
||||
{
|
||||
1,
|
||||
{ 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} },
|
||||
{ 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }
|
||||
}
|
||||
};
|
||||
|
||||
const std::vector<bool> multiChannel = { true/*, false*/ };
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithDifferentChildrenTransformation,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(netPrecisions),
|
||||
::testing::Values(ngraph::PartialShape({ 1, 3, 10, 10 })),
|
||||
::testing::Values(CommonTestUtils::DEVICE_GPU),
|
||||
::testing::ValuesIn(testValues),
|
||||
::testing::ValuesIn(trasformationParamValues),
|
||||
::testing::ValuesIn(multiChannel)),
|
||||
::testing::ValuesIn(trasformationParamValues)),
|
||||
ConcatWithDifferentChildrenTransformation::getTestCaseName);
|
||||
} // namespace
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace LayerTestsDefinitions {
|
||||
class ConcatWithDifferentChildrenTransformationParam {
|
||||
public:
|
||||
std::int64_t axis;
|
||||
ngraph::builder::subgraph::FakeQuantizeOnData fqOnData1;
|
||||
ngraph::builder::subgraph::FakeQuantizeOnData fqOnData2;
|
||||
};
|
||||
@ -22,9 +23,8 @@ typedef std::tuple<
|
||||
ngraph::PartialShape,
|
||||
std::string, // target device: CPU, GPU
|
||||
ConcatWithDifferentChildrenTransformationParam,
|
||||
ngraph::pass::low_precision::LayerTransformation::Params, // transformation parameters
|
||||
// multichannel
|
||||
bool> ConcatWithDifferentChildrenTransformationParams;
|
||||
ngraph::pass::low_precision::LayerTransformation::Params // transformation parameters
|
||||
> ConcatWithDifferentChildrenTransformationParams;
|
||||
|
||||
class ConcatWithDifferentChildrenTransformation :
|
||||
public testing::WithParamInterface<ConcatWithDifferentChildrenTransformationParams>,
|
||||
|
@ -25,13 +25,12 @@ std::string ConcatWithDifferentChildrenTransformation::getTestCaseName(testing::
|
||||
std::string targetDevice;
|
||||
ConcatWithDifferentChildrenTransformationParam param;
|
||||
ngraph::pass::low_precision::LayerTransformation::Params params;
|
||||
bool multiChannel;
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params, multiChannel) = obj.param;
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
result <<
|
||||
getTestCaseNameByParams(netPrecision, inputShapes, targetDevice, params) <<
|
||||
(multiChannel ? "_multichannel" : "") << param.fqOnData1 << param.fqOnData2;
|
||||
"_axis_" << param.axis << "_" << param.fqOnData1 << param.fqOnData2;
|
||||
|
||||
return result.str();
|
||||
}
|
||||
@ -42,8 +41,7 @@ InferenceEngine::Blob::Ptr ConcatWithDifferentChildrenTransformation::GenerateIn
|
||||
std::string targetDevice;
|
||||
ConcatWithDifferentChildrenTransformationParam param;
|
||||
ngraph::pass::low_precision::LayerTransformation::Params params;
|
||||
bool multiChannel;
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params, multiChannel) = this->GetParam();
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params) = this->GetParam();
|
||||
|
||||
const float k = (info.name() == "input1") ? 1.f : (info.name() == "input2" ? 2.f : 3.f);
|
||||
return LayerTransformation::GenerateInput(ngraph::element::u8, info.getTensorDesc(), k);
|
||||
@ -54,11 +52,10 @@ void ConcatWithDifferentChildrenTransformation::SetUp() {
|
||||
ngraph::PartialShape inputShapes;
|
||||
ConcatWithDifferentChildrenTransformationParam param;
|
||||
ngraph::pass::low_precision::LayerTransformation::Params params;
|
||||
bool multiChannel;
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params, multiChannel) = this->GetParam();
|
||||
std::tie(netPrecision, inputShapes, targetDevice, param, params) = this->GetParam();
|
||||
|
||||
function = ngraph::builder::subgraph::ConcatFunction::getOriginalWithDifferentPrecisionOnChildren(
|
||||
netPrecision, inputShapes, param.fqOnData1, param.fqOnData2);
|
||||
netPrecision, inputShapes, param.axis, param.fqOnData1, param.fqOnData2);
|
||||
}
|
||||
|
||||
TEST_P(ConcatWithDifferentChildrenTransformation, CompareWithRefImpl) {
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
static std::shared_ptr<ngraph::Function> getOriginalWithDifferentPrecisionOnChildren(
|
||||
const ngraph::element::Type precision,
|
||||
const ngraph::PartialShape& inputShape,
|
||||
const std::int64_t axis,
|
||||
const FakeQuantizeOnData& fqOnData1,
|
||||
const FakeQuantizeOnData& fqOnData2);
|
||||
|
||||
@ -229,10 +230,12 @@ public:
|
||||
const ngraph::element::Type precision,
|
||||
const ngraph::PartialShape& inputShape,
|
||||
const bool multiChannel,
|
||||
const std::int64_t axis,
|
||||
const FakeQuantizeOnData& fqOnData1,
|
||||
const FakeQuantizeOnData& fqOnData2,
|
||||
const ngraph::element::Type precisionBeforeOp,
|
||||
const DequantizationOperations& dequantizationBefore,
|
||||
const DequantizationOperations& dequantizationBefore1,
|
||||
const DequantizationOperations& dequantizationBefore2,
|
||||
const ngraph::element::Type precisionAfterOperation,
|
||||
const DequantizationOperations& dequantizationAfter1,
|
||||
const DequantizationOperations& dequantizationAfter2);
|
||||
|
@ -600,6 +600,7 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getOriginalWithStridedSlice(
|
||||
std::shared_ptr<ngraph::Function> ConcatFunction::getOriginalWithDifferentPrecisionOnChildren(
|
||||
const ngraph::element::Type precision,
|
||||
const ngraph::PartialShape& inputShape,
|
||||
const std::int64_t axis,
|
||||
const FakeQuantizeOnData& fqOnData1,
|
||||
const FakeQuantizeOnData& fqOnData2) {
|
||||
const auto input1 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
|
||||
@ -610,11 +611,7 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getOriginalWithDifferentPrecis
|
||||
input2->set_friendly_name("input2");
|
||||
const auto fakeQuantize2 = makeFakeQuantize(input2, precision, fqOnData2);
|
||||
|
||||
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(
|
||||
ngraph::OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, 1);
|
||||
|
||||
auto& rtInfo = concat->get_rt_info();
|
||||
rtInfo["Variant::std::string"] = std::make_shared<VariantWrapper<std::string>>("concat");
|
||||
const auto concat = std::make_shared<opset1::Concat>(OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, axis);
|
||||
|
||||
const std::vector<size_t> kernel = { 3, 3 };
|
||||
const std::vector<size_t> stride = { 1, 1 };
|
||||
@ -1687,10 +1684,12 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getReferenceWithDifferentPreci
|
||||
const ngraph::element::Type precision,
|
||||
const ngraph::PartialShape& inputShape,
|
||||
const bool multiChannel,
|
||||
const std::int64_t axis,
|
||||
const FakeQuantizeOnData& fqOnData1,
|
||||
const FakeQuantizeOnData& fqOnData2,
|
||||
const ngraph::element::Type precisionBeforeOp,
|
||||
const DequantizationOperations& dequantizationBefore,
|
||||
const DequantizationOperations& dequantizationBefore1,
|
||||
const DequantizationOperations& dequantizationBefore2,
|
||||
const ngraph::element::Type precisionAfterOperation,
|
||||
const DequantizationOperations& dequantizationAfter1,
|
||||
const DequantizationOperations& dequantizationAfter2) {
|
||||
@ -1700,7 +1699,7 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getReferenceWithDifferentPreci
|
||||
const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1);
|
||||
low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp);
|
||||
fakeQuantize1->set_friendly_name("fakeQuantize1");
|
||||
const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore);
|
||||
const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore1);
|
||||
|
||||
const auto input2 = std::make_shared<ngraph::opset1::Parameter>(precision, inputShape);
|
||||
input2->set_friendly_name("input2");
|
||||
@ -1708,16 +1707,12 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getReferenceWithDifferentPreci
|
||||
const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2);
|
||||
low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp);
|
||||
fakeQuantize2->set_friendly_name("fakeQuantize2");
|
||||
const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore);
|
||||
const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore2);
|
||||
|
||||
const std::shared_ptr<ngraph::opset1::Concat> concat = std::make_shared<ngraph::opset1::Concat>(
|
||||
ngraph::OutputVector{ deqBefore1, deqBefore2 }, 1);
|
||||
const auto concat = std::make_shared<opset1::Concat>(OutputVector{ deqBefore1, deqBefore2 }, axis);
|
||||
low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation);
|
||||
concat->set_friendly_name("concat");
|
||||
|
||||
auto& rtInfo = concat->get_rt_info();
|
||||
rtInfo["Variant::std::string"] = std::make_shared<VariantWrapper<std::string>>("concat");
|
||||
|
||||
const auto lastDequantization1 = makeDequantization(concat->output(0), dequantizationAfter1);
|
||||
|
||||
const std::vector<size_t> kernel = { 3, 3 };
|
||||
@ -1741,20 +1736,18 @@ std::shared_ptr<ngraph::Function> ConcatFunction::getReferenceWithDifferentPreci
|
||||
ngraph::ResultVector results;
|
||||
results.push_back(std::make_shared<ngraph::opset1::Result>(avgPool));
|
||||
|
||||
if (!dequantizationAfter2.empty()) {
|
||||
const std::shared_ptr<ngraph::opset1::MaxPool> maxPool = std::make_shared<ngraph::opset1::MaxPool>(
|
||||
concat->output(0),
|
||||
stride,
|
||||
padBegin,
|
||||
padEnd,
|
||||
kernel,
|
||||
roundingType,
|
||||
padType);
|
||||
const std::shared_ptr<ngraph::opset1::MaxPool> maxPool = std::make_shared<ngraph::opset1::MaxPool>(
|
||||
concat->output(0),
|
||||
stride,
|
||||
padBegin,
|
||||
padEnd,
|
||||
kernel,
|
||||
roundingType,
|
||||
padType);
|
||||
|
||||
const std::shared_ptr<ngraph::Node> lastDequantization2 = makeDequantization(maxPool, dequantizationAfter2);
|
||||
lastDequantization2->set_friendly_name("MaxPool");
|
||||
results.push_back(std::make_shared<ngraph::opset1::Result>(lastDequantization2));
|
||||
}
|
||||
const std::shared_ptr<ngraph::Node> lastDequantization2 = makeDequantization(maxPool, dequantizationAfter2);
|
||||
lastDequantization2->set_friendly_name("MaxPool");
|
||||
results.push_back(std::make_shared<ngraph::opset1::Result>(lastDequantization2));
|
||||
|
||||
std::shared_ptr<ngraph::Function> function = std::make_shared<ngraph::Function>(
|
||||
results,
|
||||
|
Loading…
Reference in New Issue
Block a user