diff --git a/src/common/low_precision_transformations/include/low_precision/concat.hpp b/src/common/low_precision_transformations/include/low_precision/concat.hpp index 14a818c5167..14a1ab4e00c 100644 --- a/src/common/low_precision_transformations/include/low_precision/concat.hpp +++ b/src/common/low_precision_transformations/include/low_precision/concat.hpp @@ -35,18 +35,6 @@ public: bool isPrecisionPreserved(std::shared_ptr layer) const noexcept override; bool canBeTransformed(const TransformationContext& context, std::shared_ptr layer) const override; static bool isQuantizedStatic(const std::shared_ptr& layer); - -protected: - static bool isHandled( - const TransformationContext& context, - const std::vector>& quantizationOperations); - - void fillDequantizationNodes( - const std::vector& layerDequantizations, - const std::shared_ptr layer, - NodeVector& convertNodes, - NodeVector& subtractNodes, - NodeVector& multiplyNodes) const; }; } // namespace low_precision diff --git a/src/common/low_precision_transformations/src/concat.cpp b/src/common/low_precision_transformations/src/concat.cpp index e528a0796d4..48e64a7772c 100644 --- a/src/common/low_precision_transformations/src/concat.cpp +++ b/src/common/low_precision_transformations/src/concat.cpp @@ -253,81 +253,6 @@ bool ConcatTransformation::canBeTransformed(const TransformationContext& context return true; } -void ConcatTransformation::fillDequantizationNodes( - const std::vector& layerDequantizations, - const std::shared_ptr layer, - NodeVector& convertNodes, - NodeVector& subtractNodes, - NodeVector& multiplyNodes) const { - if (layerDequantizations.size() > 1ul) { - auto broadcastElementWiseConst = []( - // FakeQuantize constant shape must be broadcastable to the shape on data. - std::shared_ptr operation, - const ngraph::Shape targetShape) -> std::shared_ptr { - auto targetShapeConst = opset1::Constant::create(element::i64, ngraph::Shape{ targetShape.size() }, targetShape); - auto broadcast = fold(operation, targetShapeConst); - return broadcast; - }; - - bool allDequantizationShiftAreZero = true; - bool allDequantizationMultiplyAreZero = true; - for (const auto& dequantization : layerDequantizations) { - if (dequantization.subtract != nullptr) { - allDequantizationShiftAreZero = false; - } - if (dequantization.multiply != nullptr) { - allDequantizationMultiplyAreZero = false; - } - } - - for (size_t i = 0; i < layerDequantizations.size(); ++i) { - const auto& dequantization = layerDequantizations[i]; - const ngraph::element::Type precision = deqPrecision; - ngraph::Shape targetShape(layer->get_input_partial_shape(i).rank().get_length(), 1ul); - targetShape[1] = layer->get_input_partial_shape(i)[1].get_length(); - - if (dequantization.convert != nullptr) { - convertNodes.push_back(dequantization.convert); - } - - if (!allDequantizationShiftAreZero) { - subtractNodes.push_back(dequantization.subtract == nullptr ? - std::make_shared(precision, targetShape, std::vector({ 0.f })) : - broadcastElementWiseConst(dequantization.subtractConstant, targetShape)); - } - - if (!allDequantizationMultiplyAreZero) { - multiplyNodes.push_back(dequantization.multiply == nullptr ? - std::make_shared(precision, targetShape, std::vector({ 1.0f })) : - broadcastElementWiseConst(dequantization.multiplyConstant, targetShape)); - } - } - } else { - // TODO: check constant shapes here - has to be scalar - if (layerDequantizations[0].convert != nullptr) { - convertNodes.push_back(layerDequantizations[0].convert); - } - - if (layerDequantizations[0].subtract != nullptr) { - subtractNodes.push_back(layerDequantizations[0].subtract->input_value(1).get_node_shared_ptr()); - } - - if (layerDequantizations[0].multiply != nullptr) { - multiplyNodes.push_back(layerDequantizations[0].multiply->input_value(1).get_node_shared_ptr()); - } - } -} - -bool ConcatTransformation::isHandled(const TransformationContext& context, const std::vector>& quantizationOperations) { - for (const std::shared_ptr& quantizationLayer : quantizationOperations) { - if (context.quantizedFakeQuantizeNames.find(quantizationLayer->get_friendly_name()) != context.quantizedFakeQuantizeNames.end()) { - return true; - } - } - - return false; -} - bool ConcatTransformation::isQuantizedStatic(const std::shared_ptr& layer) { const auto concat = as_type_ptr(layer); if (concat == nullptr) diff --git a/src/common/low_precision_transformations/src/layer_transformation.cpp b/src/common/low_precision_transformations/src/layer_transformation.cpp index 624bb955781..d4db65afe89 100644 --- a/src/common/low_precision_transformations/src/layer_transformation.cpp +++ b/src/common/low_precision_transformations/src/layer_transformation.cpp @@ -53,11 +53,10 @@ bool LayerTransformation::canBeTransformed(const TransformationContext& context, bool LayerTransformation::canBeTransformedStatic(const std::shared_ptr& layer, const std::vector& defaultPrecisions) { - for (const auto& output : layer->outputs()) { - const auto rank = output.get_partial_shape().rank(); - if (rank.is_dynamic() || rank.get_length() < 2) { - return false; - } + const auto outputs = layer->outputs(); + if (std::any_of(outputs.begin(), outputs.end(), + [](const Output& out) { return out.get_partial_shape().rank().is_dynamic(); })) { + return false; } const auto dequantization = NetworkHelper::getDequantization(layer, defaultPrecisions); @@ -72,8 +71,7 @@ bool LayerTransformation::canBeTransformedStatic(const std::shared_ptr& la return false; } - const auto dataShapeSize = static_cast(rank.get_length()); - if ((dataShapeSize - constShape.size()) == 1ul) { + if ((dataPShape.size() - constShape.size()) == 1ul) { constShape.insert(constShape.begin(), 1ul); } @@ -115,18 +113,10 @@ bool LayerTransformation::canBeTransformedSpatialDimension(const TransformationC if (!isQuantized(layer, defaultPrecisions)) { return false; } - - for (const auto& output : layer->outputs()) { - const auto outPShape = output.get_partial_shape(); - const auto rank = outPShape.rank(); - if (rank.is_dynamic()) { - return false; - } - - const auto size = rank.get_length(); - if ((size < 2) || (size > 5)) { - return false; - } + const auto outputs = layer->outputs(); + if (std::any_of(outputs.begin(), outputs.end(), + [](const Output& out) { return out.get_partial_shape().rank().is_dynamic(); })) { + return false; } return true; } diff --git a/src/common/low_precision_transformations/src/normalize_l2.cpp b/src/common/low_precision_transformations/src/normalize_l2.cpp index d9b6a2d9d00..b97e7edcf87 100644 --- a/src/common/low_precision_transformations/src/normalize_l2.cpp +++ b/src/common/low_precision_transformations/src/normalize_l2.cpp @@ -81,6 +81,8 @@ bool NormalizeL2Transformation::canBeTransformed(const TransformationContext& co const Shape outputShape = scalesConst->get_shape(); const size_t size = shape_size(outputShape); if (size != 1ul) { + if (operation->get_output_partial_shape(0).size() < 2) + return false; const auto channelsInterval = operation->get_output_partial_shape(0)[1]; if (channelsInterval.is_dynamic() || static_cast(channelsInterval.get_length()) != size) { return false; diff --git a/src/common/low_precision_transformations/src/reshape.cpp b/src/common/low_precision_transformations/src/reshape.cpp index 7d207d84fa2..c1fdf59e97f 100644 --- a/src/common/low_precision_transformations/src/reshape.cpp +++ b/src/common/low_precision_transformations/src/reshape.cpp @@ -211,7 +211,7 @@ bool ReshapeTransformation::canBeTransformed(const TransformationContext& contex } const PartialShape outputPShape = op->get_output_partial_shape(0); - if (outputPShape[1].is_dynamic()) { + if (outputPShape.size() < 2 || outputPShape[1].is_dynamic()) { return false; } diff --git a/src/common/low_precision_transformations/tests/mat_mul_transformation.cpp b/src/common/low_precision_transformations/tests/mat_mul_transformation.cpp index 21bdcaff72c..9511d8e5537 100644 --- a/src/common/low_precision_transformations/tests/mat_mul_transformation.cpp +++ b/src/common/low_precision_transformations/tests/mat_mul_transformation.cpp @@ -137,7 +137,8 @@ namespace testValues1 { const std::vector> shapes = { {{-1, -1, -1, -1}, {-1, -1, -1, -1}}, {{1, 16, 384, 64}, {1, 16, 64, 384}}, - {{4, 16, 384, 64}, {4, 16, 64, 384}}}; + {{1, 1, 4, 16, 384, 64}, {1, 1, 4, 16, 64, 384}}, + {{64}, {64}}}; std::vector testValues = { // U8 + I8: Constant on dequantization operations on 0 branch diff --git a/src/common/low_precision_transformations/tests/prelu_transformation.cpp b/src/common/low_precision_transformations/tests/prelu_transformation.cpp index fcf3e2258c3..fce805128e6 100644 --- a/src/common/low_precision_transformations/tests/prelu_transformation.cpp +++ b/src/common/low_precision_transformations/tests/prelu_transformation.cpp @@ -94,10 +94,7 @@ TEST_P(PReluTransformation, CompareFunctions) { } namespace testValues1 { -const std::vector shapes = { - {1, 3, 16, 16}, - {-1, -1, -1, -1}, -}; +const std::vector shapes = {{1, 3, 16, 16}, {-1, -1, -1, -1}, {1, 1, 2, 3, 4, 16}, {5}}; const std::vector testValues = { // U8: no subtract diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 45f35083729..e55797bb579 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -39,6 +39,22 @@ std::vector testValues = { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, "matMul_original", "I8" + }, + { + { 1, 1, 1, 4, 12, 2 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + { 1, 1, 1, 4, 2, 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + "matMul_original", + "I8" + }, + { + { 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + { 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + "matMul_original/MM", + "I8" } }; diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index d11d726cf06..b2b13a3f3c1 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -12,7 +12,7 @@ using namespace LayerTestsDefinitions; namespace { const std::vector netPrecisions = { ngraph::element::f32, - ngraph::element::f16 + // ngraph::element::f16 }; const std::vector trasformationParamValues = { @@ -34,7 +34,7 @@ const std::vector params = { { -1 }, { 256ul, ngraph::Shape{}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, "Reshape", - "FP32" + "U8" }, // 4D -> 3D { diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index 768cd0adc21..6e91bbe9ab9 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -27,6 +27,18 @@ std::vector testValues = { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, { 1, 4, 2, 12 }, { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} } + }, + { + { 1, 1, 1, 4, 12, 2 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + { 1, 1, 1, 4, 2, 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + }, + { + { 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, + { 12 }, + { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, } }; diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 659ead5a3f4..9265d97517a 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -34,7 +34,7 @@ const std::vector params = { { -1 }, { 256ul, ngraph::Shape{}, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, "Reshape", - "FP32" + "U8" }, // 4D -> 3D {