[LPT] AddTransformation: inconsistent element types when subtract on fullPath is empty (#8277)

This commit is contained in:
Vladimir Zinoviev 2021-11-03 18:00:06 +03:00 committed by GitHub
parent 9999b786ac
commit aa00ae8b43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View File

@ -206,7 +206,9 @@ bool AddTransformation::transform(TransformationContext& context, ngraph::patter
inputs[emptyPathIndex] = dequantizationEmptyPath.data;
inputs[fullPathIndex] = std::make_shared<opset1::Multiply>(
newSubtractFullPathValues == nullptr ?
fullPathInput :
(fullPathInput.get_element_type() != newMultiplyFullPathValues->get_element_type() ?
std::make_shared<opset1::Convert>(fullPathInput, newMultiplyFullPathValues->get_element_type()) :
fullPathInput) :
std::make_shared<opset1::Subtract>(
// precision on branch with dequantization operations can be different with dequantization precision,
// for example: FP16 model with FP32 dequantization

View File

@ -11,6 +11,7 @@
#include <ngraph/opsets/opset1.hpp>
#include <ngraph/rt_info.hpp>
#include <ngraph/pattern/op/wrap_type.hpp>
#include <transformations/utils/utils.hpp>
NGRAPH_RTTI_DEFINITION(ngraph::pass::PullTransposeThroughFQUp, "PullTransposeThroughFQUp", 0);
@ -59,7 +60,7 @@ ngraph::pass::PullTransposeThroughFQUp::PullTransposeThroughFQUp() {
opset1::Constant::create(element::i64, Shape{unsqueeze_axes.size()}, unsqueeze_axes));
new_ops.push_back(fq_input.get_node_shared_ptr());
}
fq_input = transpose->clone_with_new_inputs({fq_input, transpose->input_value(1)});
fq_input = op::util::make_try_fold<opset1::Transpose>(fq_input, transpose->input_value(1));
ngraph::copy_runtime_info(transpose, fq_input.get_node_shared_ptr());
fq_inputs.push_back(fq_input);
}

View File

@ -931,6 +931,28 @@ const std::vector<AddTransformationTestValues> testValues = {
},
""
},
// float path without subtract
{
false,
-1,
LayerTransformation::createParamsU8I8(),
{
ngraph::element::f32,
{ },
ngraph::element::u8,
{ {ngraph::element::f32}, {}, { 4.f }},
{ }
},
{
ngraph::element::f32,
{ {ngraph::element::f32}, {}, { 0.25f } },
ngraph::element::u8,
{ },
{ {}, {}, { 4.f }},
{ }
},
""
},
};
INSTANTIATE_TEST_SUITE_P(