diff --git a/src/common/low_precision_transformations/include/low_precision/common/fake_quantize_dequantization.hpp b/src/common/low_precision_transformations/include/low_precision/common/fake_quantize_dequantization.hpp index 48ec252ece3729..29e3805f8b5b94 100644 --- a/src/common/low_precision_transformations/include/low_precision/common/fake_quantize_dequantization.hpp +++ b/src/common/low_precision_transformations/include/low_precision/common/fake_quantize_dequantization.hpp @@ -37,16 +37,16 @@ class LP_TRANSFORMATIONS_API FakeQuantizeDequantization { static bool checkElementwise(const std::shared_ptr& elementwise); - static bool checkShape(const std::shared_ptr& elementwise) noexcept; + static bool checkShape(const std::shared_ptr& elementwise); static int fillDequantizationParams( const std::shared_ptr& elementwise, std::shared_ptr& convert, - std::shared_ptr& constant) noexcept; + std::shared_ptr& constant); static int fillDequantizationParams( const std::shared_ptr& elementwise, - std::shared_ptr& constant) noexcept; + std::shared_ptr& constant); Output data; std::shared_ptr convert; 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 3ef2c466a81928..724389b8a266a0 100644 --- a/src/common/low_precision_transformations/include/low_precision/concat.hpp +++ b/src/common/low_precision_transformations/include/low_precision/concat.hpp @@ -34,7 +34,7 @@ class LP_TRANSFORMATIONS_API ConcatTransformation : public LayerTransformation { bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override; 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) noexcept; + static bool isQuantizedStatic(const std::shared_ptr& layer); protected: static bool isHandled( diff --git a/src/common/low_precision_transformations/include/low_precision/eltwise_base_transformation.hpp b/src/common/low_precision_transformations/include/low_precision/eltwise_base_transformation.hpp index 189a24f704a7e0..80edca090e8256 100644 --- a/src/common/low_precision_transformations/include/low_precision/eltwise_base_transformation.hpp +++ b/src/common/low_precision_transformations/include/low_precision/eltwise_base_transformation.hpp @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API EltwiseBaseTransformation : public LayerTransformat bool canBeTransformed(const TransformationContext& context, std::shared_ptr layer) const override; bool isPrecisionPreserved(std::shared_ptr layer) const noexcept override; - static bool isBroadcasted(const PartialShape& shape) noexcept; + static bool isBroadcasted(const PartialShape& shape); protected: int getNotEmpty(const std::shared_ptr& eltwise) const; // Return indexes: diff --git a/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp b/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp index f31c26e424b1b2..9df09d0fccf1ed 100644 --- a/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp +++ b/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp @@ -31,8 +31,8 @@ class LP_TRANSFORMATIONS_API MultiplyToGroupConvolutionTransformation : public L bool transform(TransformationContext& context, ngraph::pattern::Matcher &m) override; bool canBeTransformed(const TransformationContext& context, std::shared_ptr layer) const override; bool isPrecisionPreserved(std::shared_ptr layer) const noexcept override; - bool isQuantized(const std::shared_ptr& layer) const noexcept override; - static bool canBeTransformedToGroupConvolution(const std::shared_ptr& layer) noexcept; + bool isQuantized(const std::shared_ptr& layer) const override; + static bool canBeTransformedToGroupConvolution(const std::shared_ptr& layer); static bool isDynamicOrScalar(const std::shared_ptr& node); void setGroupSize(const size_t groupSize); diff --git a/src/common/low_precision_transformations/src/concat.cpp b/src/common/low_precision_transformations/src/concat.cpp index cdaf1ea3d34fed..498bf65bfec794 100644 --- a/src/common/low_precision_transformations/src/concat.cpp +++ b/src/common/low_precision_transformations/src/concat.cpp @@ -331,7 +331,7 @@ bool ConcatTransformation::isHandled(const TransformationContext& context, const return false; } -bool ConcatTransformation::isQuantizedStatic(const std::shared_ptr& layer) noexcept { +bool ConcatTransformation::isQuantizedStatic(const std::shared_ptr& layer) { const auto concat = as_type_ptr(layer); if (concat == nullptr) { return false; @@ -342,8 +342,8 @@ bool ConcatTransformation::isQuantizedStatic(const std::shared_ptr& return false; } - const size_t normalizedAxis = ngraph::normalize_axis(concat->get_friendly_name(), concat->get_axis(), outputRank); - return normalizedAxis == 1ul; + const auto normalizedAxis = ngraph::normalize_axis(concat->get_friendly_name(), concat->get_axis(), outputRank); + return normalizedAxis == 1; } } // namespace low_precision diff --git a/src/common/low_precision_transformations/src/eltwise_base_transformation.cpp b/src/common/low_precision_transformations/src/eltwise_base_transformation.cpp index 8b7140ce666b73..327075ba5fedab 100644 --- a/src/common/low_precision_transformations/src/eltwise_base_transformation.cpp +++ b/src/common/low_precision_transformations/src/eltwise_base_transformation.cpp @@ -15,7 +15,7 @@ using namespace ngraph; using namespace ngraph::pass; using namespace ngraph::pass::low_precision; -bool EltwiseBaseTransformation::isBroadcasted(const PartialShape& shape) noexcept { +bool EltwiseBaseTransformation::isBroadcasted(const PartialShape& shape) { const auto rank = shape.rank(); if (rank.is_dynamic()) { return false; diff --git a/src/common/low_precision_transformations/src/fake_quantize_dequantization.cpp b/src/common/low_precision_transformations/src/fake_quantize_dequantization.cpp index 5bdec2f9e006b8..f1fff57fcf4ec0 100644 --- a/src/common/low_precision_transformations/src/fake_quantize_dequantization.cpp +++ b/src/common/low_precision_transformations/src/fake_quantize_dequantization.cpp @@ -75,7 +75,7 @@ bool FakeQuantizeDequantization::isLowPrecision() const { return DataPrecision::isSupported(data.get_element_type()); } -bool FakeQuantizeDequantization::checkShape(const std::shared_ptr& elementwise) noexcept { +bool FakeQuantizeDequantization::checkShape(const std::shared_ptr& elementwise) { std::shared_ptr convert; std::shared_ptr constant; const int branchIndex = FakeQuantizeDequantization::fillDequantizationParams(elementwise, convert, constant); @@ -90,7 +90,7 @@ bool FakeQuantizeDequantization::checkShape(const std::shared_ptr& } if (!inPShape.rank().is_dynamic()) { - for (int i = 0; i < inPShape.rank().get_length(); ++i) { + for (int i = 0; i < inPShape.size(); ++i) { if (inPShape[i] != outPShape[i] && !inPShape[i].is_dynamic()) { return false; } @@ -178,7 +178,7 @@ std::shared_ptr FakeQuantizeDequantization::copyWithNewInput(const std::sh int FakeQuantizeDequantization::fillDequantizationParams( const std::shared_ptr& elementwise, std::shared_ptr& convert, - std::shared_ptr& constant) noexcept { + std::shared_ptr& constant) { auto fill = []( const std::shared_ptr& elementwise, const size_t branchIndex, @@ -211,7 +211,7 @@ int FakeQuantizeDequantization::fillDequantizationParams( int FakeQuantizeDequantization::fillDequantizationParams( const std::shared_ptr& elementwise, - std::shared_ptr& constant) noexcept { + std::shared_ptr& constant) { constant = elementwise->get_input_element_type(1ul).is_real() ? ov::as_type_ptr(elementwise->get_input_node_shared_ptr(1ul)) : nullptr; diff --git a/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp b/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp index 8868c45f59a0cc..56acf72f21642e 100644 --- a/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp +++ b/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp @@ -201,11 +201,11 @@ bool MultiplyToGroupConvolutionTransformation::canBeTransformed(const Transforma return true; } -bool MultiplyToGroupConvolutionTransformation::isQuantized(const std::shared_ptr& layer) const noexcept { +bool MultiplyToGroupConvolutionTransformation::isQuantized(const std::shared_ptr& layer) const { return MultiplyToGroupConvolutionTransformation::canBeTransformedToGroupConvolution(layer); } -bool MultiplyToGroupConvolutionTransformation::canBeTransformedToGroupConvolution(const std::shared_ptr& layer) noexcept { +bool MultiplyToGroupConvolutionTransformation::canBeTransformedToGroupConvolution(const std::shared_ptr& layer) { const auto parent0 = layer->get_input_node_shared_ptr(0); const auto parent1 = layer->get_input_node_shared_ptr(1); @@ -219,7 +219,7 @@ bool MultiplyToGroupConvolutionTransformation::canBeTransformedToGroupConvolutio return false; } - return (pShape.rank().get_length() == 4ul) || (pShape.rank().get_length() == 5ul); + return (pShape.size() == 4ul) || (pShape.size() == 5ul); } bool MultiplyToGroupConvolutionTransformation::isDynamicOrScalar(const std::shared_ptr& node) { diff --git a/src/common/low_precision_transformations/src/shuffle_channels.cpp b/src/common/low_precision_transformations/src/shuffle_channels.cpp index f088be178e1529..0a46f013c9cf6c 100644 --- a/src/common/low_precision_transformations/src/shuffle_channels.cpp +++ b/src/common/low_precision_transformations/src/shuffle_channels.cpp @@ -92,6 +92,20 @@ bool ShuffleChannelsTransformation::canBeTransformed(const TransformationContext return false; } + // It's impossible to normalize a negative axis in case of dynamic rank + // but it's necessary when dequantization operations are per channel + if (shuffleChannels->get_input_partial_shape(0).rank().is_dynamic() && shuffleChannels->get_axis() < 0) { + const bool perChannelSub = dequantization.subtractConstant ? + ov::shape_size(dequantization.subtractConstant->get_shape()) > 0 : + false; + const bool perChannelMul = dequantization.multiplyConstant ? + ov::shape_size(dequantization.multiplyConstant->get_shape()) > 0 : + false; + if (perChannelMul || perChannelSub) { + return false; + } + } + return true; }