[LPT] checkElementwise extending for 1D tensor (#10498)

This commit is contained in:
Edward Shogulin authored and GitHub committed 2022-02-18 09:41:17 +03:00
1 parent b8ac041da9
commit 17311c46b3
4 files changed
+78 -16

No files matched your search

@@ -123,12 +123,16 @@ bool FakeQuantizeDequantization::checkElementwise(const std::shared_ptr<ngraph::
return false;
}
const auto channelsDimension = partialShape[1];
const auto channelsDimension = partialShape[partialShape.size() > 1ul ? 1ul : 0ul];
if (channelsDimension.is_dynamic()) {
return false;
}
const size_t channelsShapeVal = channelsDimension.get_length();
if (constShape.size() == 1ul) {
return constShape[0] == channelsShapeVal;
}
const size_t rank = partialShape.rank().get_length();
if (constShape.size() == rank) {
if ((constShape[0] != 1ul) || (constShape[1] != channelsShapeVal)) {
@@ -1424,6 +1424,8 @@ FakeQuantizeDequantization NetworkHelper::normalizeDequantization(FakeQuantizeDe
if (dequantization.empty()) {
return dequantization;
}
// task: 79740
if (dequantization.multiply != nullptr && ov::as_type_ptr<ngraph::opset1::Constant>(dequantization.multiply->get_input_node_shared_ptr(0))) {
const auto leftParent = dequantization.multiply->input_value(0);
const auto rightParent = dequantization.multiply->input_value(1);
@@ -697,7 +697,7 @@ const std::vector<MultiplyTransformationTestValues> multiplyTransformationTestVa
}
},
// Constant as input
// Constant as input with empty shape
{
LayerTransformation::createParamsU8I8(),
{
@@ -732,6 +732,76 @@ const std::vector<MultiplyTransformationTestValues> multiplyTransformationTestVa
}
},
// Constant as input with 1 dimension shape
{
LayerTransformation::createParamsU8I8(),
{
{
{},
{{ 7.f, 8.f, 9.f }, ngraph::element::i8, ngraph::Shape{3}}, // Constant as input
ngraph::element::i8,
{ngraph::element::f32, { }, { {0.1f, 0.2f, 0.3f}, element::f32, ngraph::Shape{3} }},
},
{
{ 1, 2, 3 },
{},
ngraph::element::f32,
{{}, {}, {{0.2f, 0.3f, 0.4f}, element::f32, ngraph::Shape{3}}},
},
false
},
{
{
{ 1, 2, 3 },
{},
ngraph::element::f32,
{},
},
{
{},
{ {0.14f, 0.48f, 1.08f}, ngraph::element::f32, ngraph::Shape{3}}, // Constant as input
{},
{},
},
true
}
},
// Parameter as input with, Constant with 1 dimension shape
{
LayerTransformation::createParamsU8I8(),
{
{
{ 1, 2, 3 },
{},
ngraph::element::f32,
{{}, {}, {{0.2f, 0.3f, 0.4f}, element::f32, ngraph::Shape{3}}},
},
{
{},
{{ 7.f, 8.f, 9.f }, ngraph::element::i8, ngraph::Shape{3}}, // Constant as input
ngraph::element::i8,
{ngraph::element::f32, { }, { {0.1f, 0.2f, 0.3f}, element::f32, ngraph::Shape{3} }},
},
false
},
{
{
{ 1, 2, 3 },
{},
ngraph::element::f32,
{},
},
{
{},
{ {0.14f, 0.48f, 1.08f}, ngraph::element::f32, ngraph::Shape{3}}, // Constant as input
{},
{},
},
true
}
},
// Actual:
//
// Parameter Constant Constant Constant
@@ -24,20 +24,6 @@ struct BranchNodes {
};
BranchNodes getBranch(const MultiplyBranch& branch) {
if (!branch.constant.empty()) {
if (branch.inputShape != branch.constant.shape) {
std::ostringstream message;
message << "shapes are not equals: " << branch.inputShape << " & " << branch.constant.shape;
throw std::runtime_error(message.str());
}
if (branch.precisionBeforeDequantization != branch.constant.outPrecision) {
std::ostringstream message;
message << "precisions are not equals: " << branch.precisionBeforeDequantization << " & " << branch.constant.outPrecision;
throw std::runtime_error(message.str());
}
}
const std::shared_ptr<Node> parent = branch.constant.empty() ?
std::make_shared<ngraph::opset1::Parameter>(branch.precisionBeforeDequantization, branch.inputShape) :
std::dynamic_pointer_cast<Node>(std::make_shared<ngraph::opset1::Constant>(