OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Disable fuseElementWise for FQ with mult-power (div conversion to mult-power) (#33159)
Nazanin Beheshti2c98c292d493
diff --git a/src/common/low_precision_transformations/src/fake_quantize.cpp b/src/common/low_precision_transformations/src/fake_quantize.cppindex d0018d89424..76f72cb572a 100644--- a/src/common/low_precision_transformations/src/fake_quantize.cpp+++ b/src/common/low_precision_transformations/src/fake_quantize.cpp@@ -69,16 +69,21 @@ std::shared_ptr<Node> updateShape(std::shared_ptr<Node> constantOp, const Partiareturn constantOp;}-std::shared_ptr<Node> getDataNode(const std::shared_ptr<Node>& eltwise) {+ov::Output<ov::Node> getDataInput(const std::shared_ptr<Node>& eltwise) {if (!ov::is_type<opset1::Constant>(eltwise->get_input_node_shared_ptr(0))) {- return eltwise->get_input_node_shared_ptr(0);+ return eltwise->get_input_source_output(0);}if (!ov::is_type<opset1::Constant>(eltwise->get_input_node_shared_ptr(1))) {- return eltwise->get_input_node_shared_ptr(1);+ return eltwise->get_input_source_output(1);}- return nullptr;+ return ov::Output<ov::Node>();+}++std::shared_ptr<Node> getDataNode(const std::shared_ptr<Node>& eltwise) {+ return getDataInput(eltwise).get_node_shared_ptr();+}std::shared_ptr<opset1::Constant> getConstant(const std::shared_ptr<Node>& eltwise) {@@ -133,6 +138,10 @@ bool all_precisions_equal(const std::shared_ptr<Node>& node) {} // namespace fqbool FakeQuantizeTransformation::checkElementwise(const std::shared_ptr<Node>& eltwise) {+ if (eltwise->get_input_size() > 0 && fq::getDataInput(eltwise).get_node() != nullptr && fq::getDataInput(eltwise).get_partial_shape() != eltwise->get_output_partial_shape(0)) {+ return false;+ }+const std::shared_ptr<opset1::Constant> constant = fq::getConstant(eltwise);if (constant == nullptr) {return false;diff --git a/src/common/low_precision_transformations/tests/fuse_dequantize_to_fake_quantize_transformation.cpp b/src/common/low_precision_transformations/tests/fuse_dequantize_to_fake_quantize_transformation.cppindex 7c83f347156..ff8012f6dd2 100644--- a/src/common/low_precision_transformations/tests/fuse_dequantize_to_fake_quantize_transformation.cpp+++ b/src/common/low_precision_transformations/tests/fuse_dequantize_to_fake_quantize_transformation.cpp@@ -272,6 +272,28 @@ const std::vector<FuseDequantizeToFakeQuantizeTransformationTestValues> testValu{256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f}}}},+ // 1) Multiply with different input and output shape in fp16+ {+ {128, 1},+ LayerTransformation::createParamsU8I8(),+ {+ element::f16,+ {},+ element::f16,+ {{}, {}, {{0.01f, 0.1f, 1.f}}},+ element::f16,+ {256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f}}+ },+ {+ element::f16,+ {},+ element::f16,+ {{}, {}, {{0.01f, 0.1f, 1.f}}},+ element::f16,+ element::f16,+ {256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f}}+ }+ },// Dynamic shape{{Dimension::dynamic(), Dimension::dynamic()},