[LPT] optimizeMultiplierAfter refactorinig & Reshape fix (#7036)

* [LPT] ReshapeTransformation: 2D->2D fix

* [LPT] optimizeMultiplierAfter refactorinig & Reshape fix

Co-authored-by: Vladislav Golubev <vladislav.golubev@intel.com>
This commit is contained in:
Edward Shogulin 2021-08-17 07:04:51 +01:00 committed by GitHub
parent 563fd8fa9b
commit 4a3626997d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 118 additions and 58 deletions

View File

@ -463,7 +463,14 @@ std::shared_ptr<ngraph::opset1::Multiply> NetworkHelper::optimizeMultipliesAfter
} }
auto newInput = multiply->input_value(1 - constant1->output(0).get_target_inputs().begin()->get_index()); auto newInput = multiply->input_value(1 - constant1->output(0).get_target_inputs().begin()->get_index());
auto newConst = fold<opset1::Multiply>(constant1, constant2); auto multiplyResult = fold<opset1::Multiply>(constant1, constant2);
{
// optimize constant shape: used in rfcn-resnet101-coco
const auto multiplyResultConstant = as_type_ptr<opset1::Constant>(multiplyResult);
if ((multiplyResultConstant != nullptr) && NetworkHelper::isScalarLike(multiplyResultConstant)) {
multiplyResult = NetworkHelper::toScalar(multiplyResultConstant);
}
}
auto inputPrecision0 = nextMultiply->get_origin_input_type(0); auto inputPrecision0 = nextMultiply->get_origin_input_type(0);
auto inputPrecision1 = nextMultiply->get_origin_input_type(1); auto inputPrecision1 = nextMultiply->get_origin_input_type(1);
auto outputPrecision = nextMultiply->get_overridden_output_type(0); auto outputPrecision = nextMultiply->get_overridden_output_type(0);
@ -472,7 +479,7 @@ std::shared_ptr<ngraph::opset1::Multiply> NetworkHelper::optimizeMultipliesAfter
std::vector<element::Type>{ inputPrecision0, inputPrecision1 }, std::vector<element::Type>{ inputPrecision0, inputPrecision1 },
std::vector<element::Type>{ outputPrecision }, std::vector<element::Type>{ outputPrecision },
ngraph::op::TemporaryReplaceOutputType(newInput, inputPrecision0).get(), ngraph::op::TemporaryReplaceOutputType(newInput, inputPrecision0).get(),
ngraph::op::TemporaryReplaceOutputType(newConst, inputPrecision1).get()); ngraph::op::TemporaryReplaceOutputType(multiplyResult, inputPrecision1).get());
copy_runtime_info(multiply, newMultiply); copy_runtime_info(multiply, newMultiply);
replace_node(nextMultiply, newMultiply); replace_node(nextMultiply, newMultiply);
return newMultiply; return newMultiply;

View File

@ -47,7 +47,7 @@ void reshapeDequantizationConstant(const std::shared_ptr<opset1::Reshape>& resha
auto replaceConstant = [](const std::shared_ptr<opset1::Reshape>& reshape, const std::shared_ptr<opset1::Constant>& originalConstant) { auto replaceConstant = [](const std::shared_ptr<opset1::Reshape>& reshape, const std::shared_ptr<opset1::Constant>& originalConstant) {
// reshape for element-wise constant is not required // reshape for element-wise constant is not required
auto constantShape = originalConstant->get_shape(); auto constantShape = originalConstant->get_shape();
if (shape_size(constantShape) == 1ul) { if (NetworkHelper::isScalarLike(originalConstant)) {
if (!constantShape.empty()) { if (!constantShape.empty()) {
const auto newConstant = NetworkHelper::toScalar(originalConstant); const auto newConstant = NetworkHelper::toScalar(originalConstant);
replace_node(originalConstant, newConstant); replace_node(originalConstant, newConstant);
@ -75,19 +75,28 @@ void reshapeDequantizationConstant(const std::shared_ptr<opset1::Reshape>& resha
return; return;
} }
Shape newOperationConstantBroadcastedShape = originalConstant->output(0).get_shape(); auto getBCastedConst = [](const std::shared_ptr<opset1::Constant>& constant, size_t dimensionsToBroadcast) -> std::shared_ptr<Node> {
// add dimensions to broadcast values if (dimensionsToBroadcast == 1ul) {
if (newOperationConstantBroadcastedShape.size() == 2ul) { return constant;
newOperationConstantBroadcastedShape.push_back(dimensionsToBroadcast); }
} else {
newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast; Shape newOperationConstantBroadcastedShape = constant->get_shape();
} // add dimensions to broadcast values
const std::shared_ptr<Node> broadcastedConstant = fold<opset1::Broadcast>( if (newOperationConstantBroadcastedShape.size() == 2ul) {
originalConstant, newOperationConstantBroadcastedShape.push_back(dimensionsToBroadcast);
std::make_shared<opset1::Constant>( } else {
newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast;
}
const auto targetShapeConstant = opset1::Constant::create(
element::i32, element::i32,
Shape({ newOperationConstantBroadcastedShape.size() }), Shape{ newOperationConstantBroadcastedShape.size() },
newOperationConstantBroadcastedShape)); newOperationConstantBroadcastedShape);
return fold<opset1::Broadcast>(constant, targetShapeConstant);
};
const std::shared_ptr<Node> broadcastedConstant = getBCastedConst(originalConstant, dimensionsToBroadcast);
std::vector<int> newReshapeConstValues(reshapeOutputRank.get_length(), 1ul); std::vector<int> newReshapeConstValues(reshapeOutputRank.get_length(), 1ul);
newReshapeConstValues[1] = reshapeOutputPShape[1].get_length(); newReshapeConstValues[1] = reshapeOutputPShape[1].get_length();
@ -190,7 +199,7 @@ bool ReshapeTransformation::canBeTransformed(const TransformationContext& contex
subtractShapeWithBatch.insert(subtractShapeWithBatch.begin(), 1ul); subtractShapeWithBatch.insert(subtractShapeWithBatch.begin(), 1ul);
} }
const Shape multiplyShape = dequantization.multiply == nullptr ? Shape{} : dequantization.multiply->input(1).get_shape(); const Shape multiplyShape = dequantization.multiply == nullptr ? Shape{} : dequantization.multiplyConstant->get_shape();
Shape multiplyShapeWithBatch = multiplyShape; Shape multiplyShapeWithBatch = multiplyShape;
if ((dequantization.multiply != nullptr) && if ((dequantization.multiply != nullptr) &&
(multiplyShapeWithBatch.size() > 1ul) && (multiplyShapeWithBatch.size() > 1ul) &&

View File

@ -162,7 +162,7 @@ const std::vector<AlignConcatQuantizationParametersTransformationTestValues> tes
ngraph::element::f32, ngraph::element::f32,
{{}, {std::vector<float>(6, 128.f), element::f32, {1, 6, 1, 1}}, {}}, {{}, {std::vector<float>(6, 128.f), element::f32, {1, 6, 1, 1}}, {}},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {std::vector<float>(9, 0.0001f), element::f32, {1, 9, 1, 1}}} {{}, {}, {{0.0001f}, element::f32, {}}}
} }
} }
}; };

View File

@ -137,7 +137,7 @@ const std::vector<AvgPoolWithChildTransformationTestValues> testValues = {
{}, {},
ngraph::element::u8, ngraph::element::u8,
{}, {},
{{}, {}, {std::vector<float>{0.0002f}, element::f32, {1, 6, 1, 1}}} {{}, {}, {std::vector<float>{0.0002f}, element::f32, {}}}
} }
}, },
// U8 per tensor quantization // U8 per tensor quantization

View File

@ -343,11 +343,11 @@ const std::vector<ConcatTransformationTestValues> testValues = {
{ {
{}, {},
{{ 128.f, 128.f, 128.f, 128.f, 128.f, 128.f }, ngraph::element::f32, { 1, 6, 1, 1 }, false}, {{ 128.f, 128.f, 128.f, 128.f, 128.f, 128.f }, ngraph::element::f32, { 1, 6, 1, 1 }, false},
{{0.1f}, ngraph::element::f32, { 1, 1, 1, 1 } } }, {{0.1f}, ngraph::element::f32, {} } },
{ {
{}, {},
{{128.f, 128.f, 128.f}, ngraph::element::f32, { 1, 3, 1, 1 }, false}, {{128.f, 128.f, 128.f}, ngraph::element::f32, { 1, 3, 1, 1 }, false},
{{0.1f}, ngraph::element::f32, { 1, 1, 1, 1 } } } {{0.1f}, ngraph::element::f32, {} } }
}, },
"convolution", "convolution",
"convolution" "convolution"

View File

@ -223,7 +223,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -243,7 +243,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -263,7 +263,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -283,7 +283,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}},
{{}, { { 2.f }, ngraph::element::f32, {1, 2, 1, 1}, true, 1ul, element::i8, false, { "DISABLED_CONSTANT_FOLDING" } }, {}}, {{}, { { 2.f }, ngraph::element::f32, {1, 2, 1, 1}, true, 1ul, element::i8, false, { "DISABLED_CONSTANT_FOLDING" } }, {}},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }),
true true
} }
@ -303,7 +303,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -323,7 +323,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -343,7 +343,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, {1}}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }),
true true
} }
@ -363,7 +363,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -403,7 +403,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 2, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
true true
} }
@ -423,7 +423,7 @@ const std::vector<ConvolutionBackpropDataTransformationTestValues> testValues =
ngraph::element::u8, ngraph::element::u8,
{}, {},
{}, {},
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 2, 1, 1 }}}, {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}},
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ 2.f }),
true true
} }

View File

@ -178,7 +178,7 @@ const std::vector<ConvolutionQDqTransformationTestValues> testValues = {
{ std::vector<float>{ 100.f }, ngraph::element::i8}, { std::vector<float>{ 100.f }, ngraph::element::i8},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0006f }, ngraph::element::f32, {1, 1, 1, 1}}} {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}}
} }
}, },
@ -230,7 +230,7 @@ const std::vector<ConvolutionQDqTransformationTestValues> testValues = {
{ std::vector<float>{ -125.f }, ngraph::element::i8}, { std::vector<float>{ -125.f }, ngraph::element::i8},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
@ -353,7 +353,7 @@ const std::vector<ConvolutionQDqTransformationTestValues> testValues = {
{ std::vector<float>{ 2.f }, ngraph::element::i8}, { std::vector<float>{ 2.f }, ngraph::element::i8},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0006f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}}
} }
}, },
@ -421,7 +421,7 @@ const std::vector<ConvolutionQDqTransformationTestValues> testValues = {
{ std::vector<float>{ 2.f }, ngraph::element::i8}, { std::vector<float>{ 2.f }, ngraph::element::i8},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0006f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}}
} }
}, },
// incorrect zero point on activations [not transformed] // incorrect zero point on activations [not transformed]

View File

@ -153,7 +153,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// with zero point // with zero point
@ -193,7 +193,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// without zero point // without zero point
@ -213,7 +213,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// without zero point // without zero point
@ -233,7 +233,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// without zero point, not update precisions // without zero point, not update precisions
@ -253,7 +253,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// with zero point, per-channel quantization with the same values // with zero point, per-channel quantization with the same values
@ -273,7 +273,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// with zero point, per-channel quantization with different values // with zero point, per-channel quantization with different values
@ -389,7 +389,7 @@ const std::vector<ConvolutionTransformationTestValues> testValues = {
op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }), op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector<float>{ -125.f }),
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// incorrect zero point on activations [not transformed] // incorrect zero point on activations [not transformed]

View File

@ -131,7 +131,7 @@ const std::vector<ConvolutionWithIncorrectWeightsTestValues> testValues = {
{}, {},
ngraph::element::i8, ngraph::element::i8,
{-126.f}, {-126.f},
{{}, {}, {{ 0.1f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 0.1f }, ngraph::element::f32, {}}},
}, },
}, },
}; };

View File

@ -130,9 +130,9 @@ const std::vector<FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues> fak
{{}, {}, {}}, {{}, {}, {}},
ngraph::element::f32, ngraph::element::f32,
{ 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } },
{{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 1.f }, ngraph::element::f32, {}}},
{ 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } },
{{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 1.f }, ngraph::element::f32, {}}},
} }
}, },
// TODO: LPT: issue #58685 // TODO: LPT: issue #58685
@ -169,9 +169,9 @@ const std::vector<FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues> fak
{{}, {}, {}}, {{}, {}, {}},
ngraph::element::f32, ngraph::element::f32,
{ }, { },
{{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 1.f }, ngraph::element::f32, {}}},
{ }, { },
{{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, {{}, {}, {{ 1.f }, ngraph::element::f32, {}}},
} }
} }
}; };

View File

@ -204,7 +204,7 @@ const std::vector<FakeQuantizeWithNotOptimalTransformationTestValues> fakeQuanti
{ {
{ }, { },
{ }, { },
{ {0.0003f}, ngraph::element::f32, {1, 1, 1, 1}} { {0.0003f}, ngraph::element::f32, {}}
} }
}, },
} }

View File

@ -163,7 +163,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights)
} }
}, },
@ -188,7 +188,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights)
} }
}, },
@ -213,7 +213,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights)
} }
}, },
@ -262,7 +262,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights)
} }
}, },
// group convolution, per-channel quantization with different values, without zero point // group convolution, per-channel quantization with different values, without zero point
@ -335,7 +335,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{ {
{}, {},
{}, {},
{{ 0.0002f }, ngraph::element::f32, {1, 24, 1, 1}} {{ 0.0002f }, ngraph::element::f32, {}}
}, },
} }
}, },
@ -384,7 +384,7 @@ const std::vector<GroupConvolutionTestValues> testValuesGroupConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// per-channel quantization with different values, without zero point // per-channel quantization with different values, without zero point
@ -535,7 +535,7 @@ const std::vector<GroupConvolutionTestValues> testValuesForDepthWiseConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// depth-wise convolution, tensor quantization, with zero point // depth-wise convolution, tensor quantization, with zero point
@ -559,7 +559,7 @@ const std::vector<GroupConvolutionTestValues> testValuesForDepthWiseConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// depth-wise convolution, per-channel quantization with different values, without zero point // depth-wise convolution, per-channel quantization with different values, without zero point
@ -629,7 +629,7 @@ const std::vector<GroupConvolutionTestValues> testValuesForDepthWiseConv = {
{ {
{}, {},
{}, {},
{{ 0.0002f }, ngraph::element::f32, {1, 6, 1, 1}} {{ 0.0002f }, ngraph::element::f32, {}}
}, },
} }
}, },
@ -678,7 +678,7 @@ const std::vector<GroupConvolutionTestValues> testValuesForDepthWiseConv = {
{}, {},
{}, {},
ngraph::element::f32, ngraph::element::f32,
{{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}
} }
}, },
// without dequantization operations // without dequantization operations

View File

@ -332,6 +332,26 @@ const std::vector<ReshapeTransformationTestValues> testValues = {
} }
} }
}, },
// U8: no subtract 4D -> 3D: rfcn-resnet101-coco
{
{ 100, 4, 1, 1 },
{ -1, 1, 400},
LayerTransformation::createParamsU8I8(),
{
ngraph::element::u8,
{
{ngraph::element::f32}, {}, {{0.1f, 0.1f, 0.1f, 0.1f}, ngraph::element::f32, {1, 4, 1, 1}}
}
},
{
ngraph::element::u8,
{{}, {}, {}},
ngraph::element::u8,
{
{ngraph::element::f32}, {}, {{0.1f}, ngraph::element::f32, {}}
}
}
},
// U8: no subtract 4D -> 6D: channels are not affected: no subtract // U8: no subtract 4D -> 6D: channels are not affected: no subtract
{ {
{ 1, 3, 4, 5 }, { 1, 3, 4, 5 },
@ -887,6 +907,30 @@ const std::vector<ReshapeTransformationTestValues> testValues = {
{{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3, 1}} {{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3, 1}}
} }
} }
},
// U8: without subtract 2D -> 2D
{
{ 1, 3 },
{ 1, -1 },
LayerTransformation::createParamsU8I8(),
{
ngraph::element::u8,
{
{ngraph::element::f32},
{},
{{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}}
}
},
{
ngraph::element::u8,
{{}, {}, {}},
ngraph::element::u8,
{
{ngraph::element::f32},
{},
{{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}}
}
}
} }
}; };

View File

@ -149,7 +149,7 @@ std::shared_ptr<ngraph::Function> FakeQuantizePrecisionSelectionFunction::getRef
std::shared_ptr<ngraph::opset1::Multiply> branch1Multiply = std::make_shared<ngraph::opset1::Multiply>( std::shared_ptr<ngraph::opset1::Multiply> branch1Multiply = std::make_shared<ngraph::opset1::Multiply>(
convolution, convolution,
std::make_shared<ngraph::opset1::Constant>(precision, Shape({1, 1, 1, 1}), std::vector<float>({ 0.0001f }))); std::make_shared<ngraph::opset1::Constant>(precision, Shape({}), std::vector<float>({ 0.0001f })));
// just another branch // just another branch