From 0649865372b4f846c042341c3464d94ff63ce7a6 Mon Sep 17 00:00:00 2001 From: Tomasz Jankowski Date: Thu, 14 Dec 2023 10:10:46 +0100 Subject: [PATCH] [Core] Move validation util into dev API (#21501) * Move infer_convolution_forward to dev API * Move infer_auto_padding to dev API * Move evaluate_as_partial_shape to dev API * Move default_label_evaluator to dev API * Move generate_transpose_default_order to dev API * Move is_valid_axes_order to dev API * Move has_no_labels to dev API * Remove usage of legacy get_constant_from_source from core and transformations * Move normalize_axes to dev API * Move normalize_axis to dev API * Deprecate functions to be removed later --- .../CMakeLists.txt | 2 +- .../src/concat.cpp | 21 +- .../src/gather.cpp | 20 +- .../src/network_helper.cpp | 14 +- .../src/reduce_base_transformation.cpp | 7 +- .../src/shuffle_channels.cpp | 18 +- .../src/split.cpp | 14 +- .../src/strided_slice.cpp | 20 +- .../src/pruning/init_masks.cpp | 7 +- .../src/pruning/propagate_masks.cpp | 14 +- .../src/pruning/shrink_weights.cpp | 14 +- .../add_fake_quantize_fusion.cpp | 10 +- .../conv_to_binary_conv.cpp | 6 +- .../convert_quantize_dequantize.cpp | 10 +- .../common_optimizations/fq_mul_fusion.cpp | 10 +- .../matmul_multiply_fusion.cpp | 10 +- .../common_optimizations/mul_conv_fusion.cpp | 18 +- .../mul_fake_quantize_fusion.cpp | 10 +- .../common_optimizations/nop_elimination.cpp | 8 +- .../common_optimizations/pad_fusion.cpp | 6 +- .../pull_through_reduce.cpp | 10 +- .../pull_transpose_through_fq.cpp | 6 +- .../random_uniform_fusion.cpp | 8 +- .../common_optimizations/reduce_merge.cpp | 6 +- .../reverse_shape_and_type_infer.cpp | 6 +- .../common_optimizations/ric_fusion.cpp | 10 +- .../simplify_shape_of_sub_graph.cpp | 6 +- ...plit_concat_pair_to_interpolate_fusion.cpp | 6 +- .../strides_optimization.cpp | 10 +- .../transpose_sinking.cpp | 14 +- .../control_flow/unroll_if.cpp | 6 +- .../batch_norm_decomposition.cpp | 10 +- .../op_conversions/convert_divide.cpp | 6 +- .../convert_interpolate1_to_interpolate4.cpp | 5 +- .../convert_scatter_elements_to_scatter.cpp | 9 +- .../convert_slice_to_strided_slice.cpp | 19 +- .../convert_softmax_downgrade.cpp | 6 +- .../op_conversions/convert_subtract.cpp | 6 +- .../op_conversions/einsum_decomposition.cpp | 10 +- .../smart_reshape/shape_of_const_folding.cpp | 6 +- .../smart_reshape/strided_slice_squeeze.cpp | 24 +- .../dereshape_matmul.cpp | 6 +- .../symbolic_optimizations.cpp | 6 +- .../transpose_sinking/ts_reduction.cpp | 12 +- .../transpose_sinking/ts_squeeze.cpp | 18 +- .../transpose_sinking/ts_unsqueeze.cpp | 10 +- .../src/transformations/utils/utils.cpp | 6 +- src/core/dev_api/validation_util.hpp | 159 +++++- .../include/concat_shape_inference.hpp | 10 +- .../include/fft_common_validation.hpp | 8 +- .../gather_elements_shape_inference.hpp | 7 +- .../include/gather_shape_inference.hpp | 7 +- .../include/one_hot_shape_inference.hpp | 10 +- .../include/reduce_shape_inference.hpp | 4 +- .../include/region_yolo_shape_inference.hpp | 8 +- .../reverse_sequence_shape_inference.hpp | 9 +- .../include/roll_shape_inference.hpp | 8 +- ...catter_elements_update_shape_inference.hpp | 8 +- .../shuffle_channels_shape_inference.hpp | 9 +- .../include/slice_shape_inference.hpp | 7 +- .../include/split_shape_inference.hpp | 6 +- .../include/squeeze_shape_inference.hpp | 5 +- .../include/topk_shape_inference.hpp | 9 +- .../include/transpose_shape_inference.hpp | 9 +- .../include/unsqueeze_shape_inference.hpp | 5 +- src/core/shape_inference/include/utils.hpp | 4 +- .../variadic_split_shape_inference.hpp | 6 +- src/core/src/bound_evaluate.cpp | 5 +- src/core/src/op/concat.cpp | 6 +- src/core/src/op/convolution.cpp | 5 +- src/core/src/op/group_conv.cpp | 5 +- src/core/src/op/if.cpp | 6 +- src/core/src/op/loop.cpp | 10 +- src/core/src/op/lrn.cpp | 6 +- src/core/src/op/max_pool.cpp | 6 +- src/core/src/op/non_max_suppression.cpp | 29 +- src/core/src/op/normalize_l2.cpp | 10 +- src/core/src/op/reverse_sequence.cpp | 14 +- src/core/src/op/scatter_update.cpp | 4 +- src/core/src/op/shuffle_channels.cpp | 4 +- src/core/src/op/slice.cpp | 5 +- src/core/src/op/split.cpp | 6 +- src/core/src/op/squeeze.cpp | 6 +- src/core/src/op/tile.cpp | 5 +- src/core/src/op/transpose.cpp | 6 +- src/core/src/op/unique.cpp | 6 +- src/core/src/op/unsqueeze.cpp | 6 +- src/core/src/op/util/axes_util.cpp | 6 +- src/core/src/op/util/broadcast_base.cpp | 14 +- src/core/src/op/util/gather_base.cpp | 2 +- src/core/src/op/util/pad_base.cpp | 13 +- src/core/src/op/util/reduction_base.cpp | 4 +- src/core/src/op/util/scatter_base.cpp | 10 +- .../op/util/scatter_elements_update_base.cpp | 6 +- src/core/src/op/util/topk_base.cpp | 6 +- src/core/src/op/variadic_split.cpp | 7 +- src/core/src/validation_util.cpp | 540 ++++++++++-------- .../include/helper_ops/sparse_segment_ops.hpp | 6 +- 98 files changed, 766 insertions(+), 782 deletions(-) diff --git a/src/common/low_precision_transformations/CMakeLists.txt b/src/common/low_precision_transformations/CMakeLists.txt index 5ea74c9ab50..35ce97b5d85 100644 --- a/src/common/low_precision_transformations/CMakeLists.txt +++ b/src/common/low_precision_transformations/CMakeLists.txt @@ -25,7 +25,7 @@ target_compile_definitions(${TARGET_NAME}_obj PRIVATE IMPLEMENT_OPENVINO_API) ov_build_target_faster(${TARGET_NAME}_obj UNITY) -target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt) +target_link_libraries(${TARGET_NAME}_obj PRIVATE openvino::itt openvino::core::dev) target_include_directories(${TARGET_NAME}_obj PRIVATE $ $>) diff --git a/src/common/low_precision_transformations/src/concat.cpp b/src/common/low_precision_transformations/src/concat.cpp index 0658db33169..c0ddb6b13d5 100644 --- a/src/common/low_precision_transformations/src/concat.cpp +++ b/src/common/low_precision_transformations/src/concat.cpp @@ -9,14 +9,13 @@ #include #include -#include "openvino/pass/pattern/op/wrap_type.hpp" -#include "openvino/opsets/opset1.hpp" - +#include "itt.hpp" #include "low_precision/common/fake_quantize_dequantization.hpp" #include "low_precision/common/ie_lpt_exception.hpp" #include "low_precision/network_helper.hpp" -#include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "openvino/opsets/opset1.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -100,11 +99,9 @@ bool ConcatTransformation::transform(TransformationContext& context, ov::pass::p [](const FakeQuantizeDequantization& value) { return !value.isLowPrecision(); }); bool DqWithDifferentPrecision = someDqInLowPrecision && someDqInFpPrecision; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = ov::normalize_axis(concat->get_friendly_name(), - concat->get_axis(), - concat->get_output_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axis(concat->get_friendly_name(), + concat->get_axis(), + concat->get_output_partial_shape(0).rank()); OutputVector dataNodes; NodeVector convertNodes; @@ -217,9 +214,7 @@ bool ConcatTransformation::canBeTransformed(const TransformationContext& context return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t normalizedAxis = ov::normalize_axis(concat->get_friendly_name(), axis, outRank); - OPENVINO_SUPPRESS_DEPRECATED_END + const size_t normalizedAxis = ov::util::normalize_axis(concat->get_friendly_name(), axis, outRank); if (outPShape[normalizedAxis].is_dynamic()) { return false; } diff --git a/src/common/low_precision_transformations/src/gather.cpp b/src/common/low_precision_transformations/src/gather.cpp index d02146b6471..59fbf5d7f78 100644 --- a/src/common/low_precision_transformations/src/gather.cpp +++ b/src/common/low_precision_transformations/src/gather.cpp @@ -6,16 +6,15 @@ #include +#include "itt.hpp" +#include "low_precision/network_helper.hpp" +#include "low_precision/rt_info/precision_preserved_attribute.hpp" #include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset7.hpp" #include "openvino/opsets/opset8.hpp" #include "openvino/pass/pattern/op/or.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" - -#include "low_precision/network_helper.hpp" -#include "low_precision/rt_info/precision_preserved_attribute.hpp" -#include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -45,9 +44,8 @@ std::shared_ptr gatherDeqConstant( } const int64_t axis = ov::as_type_ptr(gather->get_input_node_shared_ptr(2))->cast_vector()[0]; - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t normalizedAxis = ov::normalize_axis(gather->get_friendly_name(), axis, gather->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const size_t normalizedAxis = + ov::util::normalize_axis(gather->get_friendly_name(), axis, gather->get_input_partial_shape(0).rank()); // Dequantization channel matches with gather axis if (constantShape[normalizedAxis] != 1ul) { @@ -172,9 +170,9 @@ bool GatherTransformation::canBeTransformed(const TransformationContext& context } } const int64_t axis = axisConstant->cast_vector()[0]; - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t normalizedAxis = ov::normalize_axis(operation->get_friendly_name(), axis, operation->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const size_t normalizedAxis = ov::util::normalize_axis(operation->get_friendly_name(), + axis, + operation->get_input_partial_shape(0).rank()); if (constantShape[normalizedAxis] != 1ul) { const auto indicesConstant = ov::as_type_ptr(operation->get_input_node_shared_ptr(1)); diff --git a/src/common/low_precision_transformations/src/network_helper.cpp b/src/common/low_precision_transformations/src/network_helper.cpp index b3925c850c5..327188c7003 100644 --- a/src/common/low_precision_transformations/src/network_helper.cpp +++ b/src/common/low_precision_transformations/src/network_helper.cpp @@ -9,23 +9,23 @@ #include #include #include +#include +#include #include #include #include #include -#include -#include -#include "openvino/core/rt_info.hpp" #include "low_precision/common/ie_lpt_exception.hpp" #include "low_precision/layer_transformation.hpp" -#include "low_precision/rt_info/precision_preserved_attribute.hpp" #include "low_precision/rt_info/intervals_alignment_attribute.hpp" +#include "low_precision/rt_info/precision_preserved_attribute.hpp" #include "low_precision/rt_info/quantization_alignment_attribute.hpp" -#include "openvino/core/validation_util.hpp" +#include "openvino/core/rt_info.hpp" #include "openvino/opsets/opset3.hpp" #include "openvino/opsets/opset6.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -741,9 +741,7 @@ std::shared_ptr NetworkHelper::foldFakeQuantize( subgraph = std::make_shared(subgraph, ov::opset6::Round::RoundMode::HALF_TO_EVEN); } - OPENVINO_SUPPRESS_DEPRECATED_START - const auto result = ov::get_constant_from_source(subgraph); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto result = ov::util::get_constant_from_source(subgraph); if (result != nullptr) { return foldConvert(result, original_et); } diff --git a/src/common/low_precision_transformations/src/reduce_base_transformation.cpp b/src/common/low_precision_transformations/src/reduce_base_transformation.cpp index 834ac169a67..deff7b51386 100644 --- a/src/common/low_precision_transformations/src/reduce_base_transformation.cpp +++ b/src/common/low_precision_transformations/src/reduce_base_transformation.cpp @@ -3,10 +3,11 @@ // #include "low_precision/reduce_base_transformation.hpp" + #include #include "low_precision/network_helper.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -49,9 +50,7 @@ bool ReduceBaseTransformation::canBeTransformed(const TransformationContext& con return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - const std::vector axes = ov::normalize_axes(reduce->get_friendly_name(), constData, inputRank); - OPENVINO_SUPPRESS_DEPRECATED_END + const std::vector axes = ov::util::normalize_axes(reduce->get_friendly_name(), constData, inputRank); const auto deqByReducedConst = [&](const std::shared_ptr& eltwise) { const auto constShape = eltwise->get_shape(); diff --git a/src/common/low_precision_transformations/src/shuffle_channels.cpp b/src/common/low_precision_transformations/src/shuffle_channels.cpp index 6439232908e..9587d47939b 100644 --- a/src/common/low_precision_transformations/src/shuffle_channels.cpp +++ b/src/common/low_precision_transformations/src/shuffle_channels.cpp @@ -5,13 +5,12 @@ #include "low_precision/shuffle_channels.hpp" #include -#include "openvino/opsets/opset1.hpp" -#include "openvino/pass/pattern/op/wrap_type.hpp" - -#include "low_precision/network_helper.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "low_precision/network_helper.hpp" +#include "openvino/opsets/opset1.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -48,12 +47,9 @@ bool ShuffleChannelsTransformation::transform(TransformationContext& context, ov if (shape_size(constShape) == 1ul) { return NetworkHelper::toScalar(normalizedConst); } else { - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t normalizedAxis = ov::normalize_axis( - shuffleChannels->get_friendly_name(), - shuffleChannels->get_axis(), - shuffleChannels->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const size_t normalizedAxis = ov::util::normalize_axis(shuffleChannels->get_friendly_name(), + shuffleChannels->get_axis(), + shuffleChannels->get_input_partial_shape(0).rank()); if (constShape[normalizedAxis] == 1ul) { return normalizedConst; diff --git a/src/common/low_precision_transformations/src/split.cpp b/src/common/low_precision_transformations/src/split.cpp index b9f733728b3..3a3a9eac953 100644 --- a/src/common/low_precision_transformations/src/split.cpp +++ b/src/common/low_precision_transformations/src/split.cpp @@ -3,13 +3,12 @@ // #include "low_precision/split.hpp" -#include "openvino/core/node.hpp" -#include "openvino/pass/pattern/op/wrap_type.hpp" - -#include "low_precision/network_helper.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "low_precision/network_helper.hpp" +#include "openvino/core/node.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -47,9 +46,8 @@ bool SplitTransformation::transform(TransformationContext& context, ov::pass::pa ov::copy_runtime_info(split, newSplit); const int64_t axis = ov::as_type_ptr(split->get_input_node_shared_ptr(1))->cast_vector()[0]; - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t normalizedAxis = ov::normalize_axis(split->get_friendly_name(), axis, split->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const size_t normalizedAxis = + ov::util::normalize_axis(split->get_friendly_name(), axis, split->get_input_partial_shape(0).rank()); const size_t outputSize = newSplit->get_output_size(); const auto splitConstant = [&](const std::shared_ptr operation) { diff --git a/src/common/low_precision_transformations/src/strided_slice.cpp b/src/common/low_precision_transformations/src/strided_slice.cpp index 694e88276ed..dbe9b852f87 100644 --- a/src/common/low_precision_transformations/src/strided_slice.cpp +++ b/src/common/low_precision_transformations/src/strided_slice.cpp @@ -6,10 +6,10 @@ #include -#include "openvino/pass/pattern/op/wrap_type.hpp" -#include "low_precision/network_helper.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "low_precision/network_helper.hpp" +#include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -46,9 +46,7 @@ std::shared_ptr stridedSliceDeqConstant( // step #2: update original begin & end & strides auto cast_vector = [](const std::shared_ptr& strided_slice, const size_t i) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto constant = ov::get_constant_from_source(strided_slice->get_input_source_output(i)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto constant = ov::util::get_constant_from_source(strided_slice->get_input_source_output(i)); assert(constant != nullptr); return constant->cast_vector(); }; @@ -155,13 +153,9 @@ bool StridedSliceTransformation::canBeTransformed(const TransformationContext& c return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - return - is_dequantization_scalar || - (ov::get_constant_from_source(operation->get_input_source_output(1)) && - ov::get_constant_from_source(operation->get_input_source_output(2)) && - ov::get_constant_from_source(operation->get_input_source_output(3))); - OPENVINO_SUPPRESS_DEPRECATED_END + return is_dequantization_scalar || (ov::util::get_constant_from_source(operation->get_input_source_output(1)) && + ov::util::get_constant_from_source(operation->get_input_source_output(2)) && + ov::util::get_constant_from_source(operation->get_input_source_output(3))); } bool StridedSliceTransformation::isPrecisionPreserved(std::shared_ptr layer) const noexcept { diff --git a/src/common/offline_transformations/src/pruning/init_masks.cpp b/src/common/offline_transformations/src/pruning/init_masks.cpp index 10b4bce709f..5c5a04756fe 100644 --- a/src/common/offline_transformations/src/pruning/init_masks.cpp +++ b/src/common/offline_transformations/src/pruning/init_masks.cpp @@ -3,11 +3,11 @@ // #include "mask_attribute.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/opsets/opset6.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/util/log.hpp" #include "pruning.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -85,9 +85,8 @@ public: while (!ov::is_type(cur_node) && cur_node->inputs().size()) { weights_calculation_nodes.push_back(cur_node); if (ov::is_type(cur_node)) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto forward_order = get_constant_from_source(cur_node->get_input_node_shared_ptr(1)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto forward_order = + ov::util::get_constant_from_source(cur_node->get_input_node_shared_ptr(1)); if (!forward_order) return false; const auto forward_order_vec = forward_order->cast_vector(); diff --git a/src/common/offline_transformations/src/pruning/propagate_masks.cpp b/src/common/offline_transformations/src/pruning/propagate_masks.cpp index b2ce77882d4..7837f563dbe 100644 --- a/src/common/offline_transformations/src/pruning/propagate_masks.cpp +++ b/src/common/offline_transformations/src/pruning/propagate_masks.cpp @@ -8,7 +8,6 @@ #include "mask_attribute.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/gelu.hpp" #include "openvino/op/max_pool.hpp" #include "openvino/op/shape_of.hpp" @@ -19,6 +18,7 @@ #include "openvino/reference/utils/coordinate_transform.hpp" #include "openvino/util/log.hpp" #include "pruning.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -398,9 +398,7 @@ public: return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - const auto constant = get_constant_from_source(m_shape.get_node_shared_ptr()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto constant = ov::util::get_constant_from_source(m_shape.get_node_shared_ptr()); if (!constant) { OPENVINO_DEBUG << "Can't get constant from source node " << m_shape.get_node()->get_friendly_name(); return false; @@ -1136,9 +1134,7 @@ public: auto constant = std::dynamic_pointer_cast(m_weights.get_node_shared_ptr()); if (!constant) { - OPENVINO_SUPPRESS_DEPRECATED_START - constant = get_constant_from_source(m_weights.get_node_shared_ptr()); - OPENVINO_SUPPRESS_DEPRECATED_END + constant = ov::util::get_constant_from_source(m_weights.get_node_shared_ptr()); if (!constant) { OPENVINO_DEBUG << "Can't process reshape node " << m_output.get_node()->get_friendly_name() << " with no constant node " << m_weights.get_node()->get_friendly_name() @@ -1383,9 +1379,7 @@ public: const auto& m_weights = pattern_map.at(weights); const auto& m_output = pattern_map.at(transpose); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto input_order_node = get_constant_from_source(m_weights.get_node_shared_ptr()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto input_order_node = ov::util::get_constant_from_source(m_weights.get_node_shared_ptr()); if (!input_order_node) { OPENVINO_DEBUG << "Can't process transpose node " << m_output.get_node()->get_friendly_name() << " with no constant node " << m_weights.get_node()->get_friendly_name() diff --git a/src/common/offline_transformations/src/pruning/shrink_weights.cpp b/src/common/offline_transformations/src/pruning/shrink_weights.cpp index 93242b4fc76..8bd032a467d 100644 --- a/src/common/offline_transformations/src/pruning/shrink_weights.cpp +++ b/src/common/offline_transformations/src/pruning/shrink_weights.cpp @@ -6,12 +6,12 @@ #include "mask_attribute.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/opsets/opset6.hpp" #include "openvino/pass/manager.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/util/log.hpp" #include "pruning.hpp" +#include "validation_util.hpp" template static std::string vec_to_str(const std::vector m) { @@ -38,9 +38,7 @@ static bool is_static_reshape_op(std::shared_ptr node) { if (input.get_partial_shape().is_dynamic() || shape.get_partial_shape().is_dynamic()) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto output_shape_const_op = get_constant_from_source(shape); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto output_shape_const_op = ov::util::get_constant_from_source(shape); if (!output_shape_const_op) return false; @@ -62,9 +60,7 @@ static bool maybe_adopt_reshape_node(std::shared_ptr reshape, ov::Mask return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - const auto constant = get_constant_from_source(shape); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto constant = ov::util::get_constant_from_source(shape); if (!constant) { return false; } @@ -318,9 +314,7 @@ bool ov::pass::ShrinkWeights::run_on_model(const std::shared_ptr& f) } } // Trying to fold sequence of Gather ops to avoid additional constant folding. - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto folded_const = ov::get_constant_from_source(last_output)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto folded_const = ov::util::get_constant_from_source(last_output)) { last_output = folded_const; } // as we insert Gather operations after Constant we need to reconnect all diff --git a/src/common/transformations/src/transformations/common_optimizations/add_fake_quantize_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/add_fake_quantize_fusion.cpp index 1395c2bc1df..5b7953648a4 100644 --- a/src/common/transformations/src/transformations/common_optimizations/add_fake_quantize_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/add_fake_quantize_fusion.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -21,6 +20,7 @@ #include "openvino/op/subtract.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" ov::pass::AddFakeQuantizeFusion::AddFakeQuantizeFusion() { MATCHER_SCOPE(AddFakeQuantizeFusion); @@ -115,15 +115,11 @@ ov::pass::AddFakeQuantizeFusion::AddFakeQuantizeFusion() { } auto input_low_sub = std::make_shared(fq->input_value(1), new_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_input_low = get_constant_from_source(input_low_sub); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_input_low = ov::util::get_constant_from_source(input_low_sub); if (!new_input_low) new_input_low = input_low_sub; auto input_high_sub = std::make_shared(fq->input_value(2), new_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_input_high = get_constant_from_source(input_high_sub); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_input_high = ov::util::get_constant_from_source(input_high_sub); if (!new_input_high) new_input_high = input_high_sub; auto new_fq = diff --git a/src/common/transformations/src/transformations/common_optimizations/conv_to_binary_conv.cpp b/src/common/transformations/src/transformations/common_optimizations/conv_to_binary_conv.cpp index e6d5c3ac145..f4c5b2bf87c 100644 --- a/src/common/transformations/src/transformations/common_optimizations/conv_to_binary_conv.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/conv_to_binary_conv.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/binary_convolution.hpp" #include "openvino/op/constant.hpp" @@ -19,6 +18,7 @@ #include "openvino/op/reduce_sum.hpp" #include "openvino/op/reshape.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" static std::vector binarize_weights(const std::vector& weights) { std::vector out; @@ -121,9 +121,7 @@ ov::pass::ConvToBinaryConv::ConvToBinaryConv() { weights_reduced, ov::op::v0::Constant::create(element::i64, Shape{weights_reduced_shape.size()}, weights_reduced_shape), false); - OPENVINO_SUPPRESS_DEPRECATED_START - weights_reduced_reshaped = ov::get_constant_from_source(weights_reduced_reshaped); - OPENVINO_SUPPRESS_DEPRECATED_END + weights_reduced_reshaped = ov::util::get_constant_from_source(weights_reduced_reshaped); auto add = std::make_shared(new_conv, weights_reduced_reshaped); auto mul = std::make_shared(add, ov::op::v0::Constant::create(element::f32, Shape{}, {0.5})); diff --git a/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp b/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp index ba238893189..b91af780ee7 100644 --- a/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/convert_quantize_dequantize.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/fake_quantize.hpp" @@ -17,6 +16,7 @@ #include "openvino/op/subtract.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" // ConvertQuantizeDequantize converts Quantize/Dequantize pair to a single FakeQuantize. // Since Quantize is decomposed to FakeQuantize and Dequantize is decomposed to Subtract->Multiply, @@ -168,14 +168,10 @@ ov::pass::ConvertQuantizeDequantize::ConvertQuantizeDequantize() { if (out_high_shape.rank().is_dynamic() || out_high_shape.rank().get_length() > data_shape.rank().get_length()) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr const_out_low = get_constant_from_source(new_out_low); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr const_out_low = ov::util::get_constant_from_source(new_out_low); if (const_out_low) new_out_low = const_out_low; - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr const_out_high = get_constant_from_source(new_out_high); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr const_out_high = ov::util::get_constant_from_source(new_out_high); if (const_out_high) new_out_high = const_out_high; diff --git a/src/common/transformations/src/transformations/common_optimizations/fq_mul_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/fq_mul_fusion.cpp index b655849fbd7..5885c8c068a 100644 --- a/src/common/transformations/src/transformations/common_optimizations/fq_mul_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/fq_mul_fusion.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convolution.hpp" #include "openvino/op/fake_quantize.hpp" @@ -18,6 +17,7 @@ #include "openvino/op/reshape.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" // This transformation multiplies the "output_low" and "output_high" inputs of the FQ operation // by the constant value that before transormation is used to multiply the output of FQ. @@ -107,9 +107,7 @@ ov::pass::FakeQuantizeMulFusion::FakeQuantizeMulFusion() { auto get_adjusted_output_range = [&](const Output& node) -> std::shared_ptr { auto ret = std::make_shared(node, mul_constant); copy_runtime_info(node.get_node_shared_ptr(), ret); - OPENVINO_SUPPRESS_DEPRECATED_START - auto constant = get_constant_from_source(ret); - OPENVINO_SUPPRESS_DEPRECATED_END + auto constant = ov::util::get_constant_from_source(ret); if (constant) return constant; return ret; @@ -120,10 +118,8 @@ ov::pass::FakeQuantizeMulFusion::FakeQuantizeMulFusion() { fq_node->input_value(2), get_adjusted_output_range(original_output_low), get_adjusted_output_range(original_output_high)}); - OPENVINO_SUPPRESS_DEPRECATED_START bool fq_on_weights = - is_type(data.get_node()) || get_constant_from_source(data) != nullptr; - OPENVINO_SUPPRESS_DEPRECATED_END + is_type(data.get_node()) || ov::util::get_constant_from_source(data) != nullptr; if (!fq_on_weights && transformation_callback(new_fq_node)) return false; diff --git a/src/common/transformations/src/transformations/common_optimizations/matmul_multiply_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/matmul_multiply_fusion.cpp index 383879fa55b..520ee14e5d7 100644 --- a/src/common/transformations/src/transformations/common_optimizations/matmul_multiply_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/matmul_multiply_fusion.cpp @@ -5,7 +5,6 @@ #include "transformations/common_optimizations/matmul_multiply_fusion.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/matmul.hpp" #include "openvino/op/multiply.hpp" @@ -13,6 +12,7 @@ #include "openvino/op/transpose.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; @@ -133,9 +133,7 @@ static std::shared_ptr fuse_const_to_weights(const std::shared_ptr& auto transpose = std::make_shared( new_const, ov::op::v0::Constant::create(element::i64, Shape{perm.size()}, perm)); - OPENVINO_SUPPRESS_DEPRECATED_START - return get_constant_from_source(transpose); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::get_constant_from_source(transpose); }; // If weights meant to be transposed - we need to also transpose constant @@ -173,9 +171,7 @@ pass::MatMulMultiplyFusion::MatMulMultiplyFusion() { // Constantfold new weights, only if old weights is a constant node. // To make sure that subgraphs with e.g. FakeQuantize don't get constant folded here. if (ov::is_type(weights.get_node())) { - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = get_constant_from_source(new_weights)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(new_weights)) { new_weights = constant; } } diff --git a/src/common/transformations/src/transformations/common_optimizations/mul_conv_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/mul_conv_fusion.cpp index cfbed99ff99..1870c4f7b1c 100644 --- a/src/common/transformations/src/transformations/common_optimizations/mul_conv_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/mul_conv_fusion.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convolution.hpp" #include "openvino/op/group_conv.hpp" @@ -18,6 +17,7 @@ #include "openvino/pass/pattern/matcher.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" ov::pass::MultiplyConvolutionFusion::MultiplyConvolutionFusion() { MATCHER_SCOPE(MultiplyConvolutionFusion); @@ -51,9 +51,7 @@ ov::pass::MultiplyConvolutionFusion::MultiplyConvolutionFusion() { } auto weights_multiply = std::make_shared(weights, mul_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_weights = get_constant_from_source(weights_multiply); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_weights = ov::util::get_constant_from_source(weights_multiply); if (!new_weights) new_weights = weights_multiply; @@ -118,9 +116,7 @@ ov::pass::MultiplyGroupConvolutionFusion::MultiplyGroupConvolutionFusion() { } auto weights_multiply = std::make_shared(weights, mul_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_weights = get_constant_from_source(weights_multiply); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_weights = ov::util::get_constant_from_source(weights_multiply); if (!new_weights) new_weights = weights_multiply; @@ -188,9 +184,7 @@ ov::pass::MultiplyConvolutionBackpropDataFusion::MultiplyConvolutionBackpropData } auto weights_multiply = std::make_shared(weights, mul_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_weights = get_constant_from_source(weights_multiply); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_weights = ov::util::get_constant_from_source(weights_multiply); if (!new_weights) new_weights = weights_multiply; @@ -260,9 +254,7 @@ ov::pass::MultiplyGroupConvolutionBackpropDataFusion::MultiplyGroupConvolutionBa } auto weights_multiply = std::make_shared(weights, mul_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_weights = get_constant_from_source(weights_multiply); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_weights = ov::util::get_constant_from_source(weights_multiply); if (!new_weights) new_weights = weights_multiply; diff --git a/src/common/transformations/src/transformations/common_optimizations/mul_fake_quantize_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/mul_fake_quantize_fusion.cpp index 0ece865690e..27be26ec5a0 100644 --- a/src/common/transformations/src/transformations/common_optimizations/mul_fake_quantize_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/mul_fake_quantize_fusion.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/divide.hpp" @@ -18,6 +17,7 @@ #include "openvino/op/reshape.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" ov::pass::MulFakeQuantizeFusion::MulFakeQuantizeFusion() { MATCHER_SCOPE(MulFakeQuantizeFusion); @@ -104,15 +104,11 @@ ov::pass::MulFakeQuantizeFusion::MulFakeQuantizeFusion() { } auto input_low_div = std::make_shared(fq->input_value(1), new_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_input_low = get_constant_from_source(input_low_div); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_input_low = ov::util::get_constant_from_source(input_low_div); if (!new_input_low) new_input_low = input_low_div; auto input_high_div = std::make_shared(fq->input_value(2), new_const); - OPENVINO_SUPPRESS_DEPRECATED_START - std::shared_ptr new_input_high = get_constant_from_source(input_high_div); - OPENVINO_SUPPRESS_DEPRECATED_END + std::shared_ptr new_input_high = ov::util::get_constant_from_source(input_high_div); if (!new_input_high) new_input_high = input_high_div; diff --git a/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp b/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp index 9ce5ea86b90..e7a9e19be64 100644 --- a/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/nop_elimination.cpp @@ -10,7 +10,6 @@ #include "compare.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -38,6 +37,7 @@ #include "openvino/util/log.hpp" #include "openvino/util/util.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace std; using namespace ov; @@ -344,10 +344,8 @@ pass::EliminatePad::EliminatePad() { matcher_pass_callback callback = [=](pattern::Matcher& m) { auto pad = m.get_match_root(); - OPENVINO_SUPPRESS_DEPRECATED_START - auto pad_begin_const = get_constant_from_source(pad->input_value(1)); - auto pad_end_const = get_constant_from_source(pad->input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto pad_begin_const = ov::util::get_constant_from_source(pad->input_value(1)); + auto pad_end_const = ov::util::get_constant_from_source(pad->input_value(2)); if (!pad_begin_const || !pad_end_const) { return false; diff --git a/src/common/transformations/src/transformations/common_optimizations/pad_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/pad_fusion.cpp index eed6ea287cb..800857a9b31 100644 --- a/src/common/transformations/src/transformations/common_optimizations/pad_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/pad_fusion.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/avg_pool.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convolution.hpp" @@ -17,6 +16,7 @@ #include "openvino/op/util/pad_base.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; @@ -31,9 +31,7 @@ static bool can_be_fused(const std::shared_ptr& pad, if (!node) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - auto pad_value_const = ov::get_constant_from_source(pad_value_node); - OPENVINO_SUPPRESS_DEPRECATED_END + auto pad_value_const = ov::util::get_constant_from_source(pad_value_node); if (!pad_value_const) return false; auto pad_value = pad_value_const->cast_vector()[0]; diff --git a/src/common/transformations/src/transformations/common_optimizations/pull_through_reduce.cpp b/src/common/transformations/src/transformations/common_optimizations/pull_through_reduce.cpp index 0ceac5ae44a..5b791b5d765 100644 --- a/src/common/transformations/src/transformations/common_optimizations/pull_through_reduce.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/pull_through_reduce.cpp @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/unsqueeze.hpp" @@ -17,6 +16,7 @@ #include "openvino/pass/pattern/op/wrap_type.hpp" #include "sequnce_generator.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" namespace { // Adjust axes of Unsqueeze/Reduce ops after Unsqueeze pulling @@ -134,11 +134,9 @@ ov::pass::PullUnsqueezeThroughReduce::PullUnsqueezeThroughReduce() { } auto unsqueeze_axes_val = unsqueeze_axes_input->cast_vector(); - OPENVINO_SUPPRESS_DEPRECATED_START - normalize_axes(unsqueeze_node.get(), - unsqueeze_node->get_output_partial_shape(0).rank().get_length(), - unsqueeze_axes_val); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(unsqueeze_node.get(), + unsqueeze_node->get_output_partial_shape(0).rank().get_length(), + unsqueeze_axes_val); const auto reduce_axes_val = reduce_node->get_reduction_axes().to_vector(); if (have_same_axes(unsqueeze_axes_val, reduce_axes_val)) { diff --git a/src/common/transformations/src/transformations/common_optimizations/pull_transpose_through_fq.cpp b/src/common/transformations/src/transformations/common_optimizations/pull_transpose_through_fq.cpp index 23b505e02c3..ce0b777ce23 100644 --- a/src/common/transformations/src/transformations/common_optimizations/pull_transpose_through_fq.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/pull_transpose_through_fq.cpp @@ -9,13 +9,13 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/fake_quantize.hpp" #include "openvino/op/transpose.hpp" #include "openvino/op/unsqueeze.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" ov::pass::PullTransposeThroughFQUp::PullTransposeThroughFQUp() { MATCHER_SCOPE(PullTransposeThroughFQUp); @@ -65,9 +65,7 @@ ov::pass::PullTransposeThroughFQUp::PullTransposeThroughFQUp() { new_ops.push_back(fq_input.get_node_shared_ptr()); } fq_input = std::make_shared(fq_input, transpose->input_value(1)); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = get_constant_from_source(fq_input)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(fq_input)) { fq_input = constant; } ov::copy_runtime_info(transpose, fq_input.get_node_shared_ptr()); diff --git a/src/common/transformations/src/transformations/common_optimizations/random_uniform_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/random_uniform_fusion.cpp index f7894923895..2894a962dec 100644 --- a/src/common/transformations/src/transformations/common_optimizations/random_uniform_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/random_uniform_fusion.cpp @@ -8,7 +8,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" @@ -16,6 +15,7 @@ #include "openvino/op/random_uniform.hpp" #include "openvino/pass/pattern/op/or.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" ov::pass::RandomUniformFusion::RandomUniformFusion() { MATCHER_SCOPE(RandomUniformFusion); @@ -63,10 +63,8 @@ ov::pass::RandomUniformFusion::RandomUniformFusion() { const auto new_mul_add1 = mul_add_ptr->clone_with_new_inputs({ru->input_value(1), new_const}); const auto new_mul_add2 = mul_add_ptr->clone_with_new_inputs({ru->input_value(2), new_const}); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto& folded_const1 = ov::get_constant_from_source(new_mul_add1); - const auto& folded_const2 = ov::get_constant_from_source(new_mul_add2); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto& folded_const1 = ov::util::get_constant_from_source(new_mul_add1); + const auto& folded_const2 = ov::util::get_constant_from_source(new_mul_add2); const auto new_ru = ru->clone_with_new_inputs( {data, folded_const1 ? folded_const1 : new_mul_add1, folded_const2 ? folded_const2 : new_mul_add2}); diff --git a/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp b/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp index b50a795205a..7d41a54b98c 100644 --- a/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/reduce_merge.cpp @@ -8,7 +8,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/reduce_l1.hpp" #include "openvino/op/reduce_l2.hpp" @@ -21,6 +20,7 @@ #include "openvino/op/reduce_sum.hpp" #include "openvino/pass/pattern/op/or.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::pass; @@ -67,9 +67,7 @@ bool fuse_reduce_operations(const std::shared_ptr& node) { std::shared_ptr axes = std::make_shared(OutputVector{top_reduce->input_value(1), bottom_reduce->input_value(1)}, int64_t(0)); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = ov::get_constant_from_source(axes)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(axes)) { axes = constant; } axes->set_friendly_name(bottom_reduce->get_friendly_name() + "/Axes"); diff --git a/src/common/transformations/src/transformations/common_optimizations/reverse_shape_and_type_infer.cpp b/src/common/transformations/src/transformations/common_optimizations/reverse_shape_and_type_infer.cpp index 47cc203bdb4..8d3e6e6212b 100644 --- a/src/common/transformations/src/transformations/common_optimizations/reverse_shape_and_type_infer.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/reverse_shape_and_type_infer.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/convert_like.hpp" #include "openvino/op/convolution.hpp" @@ -21,6 +20,7 @@ #include "openvino/op/util/binary_elementwise_arithmetic.hpp" #include "openvino/op/util/pad_base.hpp" #include "openvino/op/util/unary_elementwise_arithmetic.hpp" +#include "validation_util.hpp" bool ov::pass::ReverseShapeAndTypeInfer::inherit_output_shape(const std::shared_ptr& node, const std::vector& input_idxs) { @@ -283,9 +283,7 @@ bool ov::pass::ReverseShapeAndTypeInfer::run_on_model(const std::shared_ptr(op)) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto transpose_order = get_constant_from_source(op->input_value(1)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto transpose_order = ov::util::get_constant_from_source(op->input_value(1)); if (output_shape.rank().is_static()) { if (transpose_order) { // set more precise dimensions during reverse infer diff --git a/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp index 9e715d1b4d9..0934bc17463 100644 --- a/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/ric_fusion.cpp @@ -10,7 +10,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" @@ -29,6 +28,7 @@ #include "openvino/pass/pattern/op/wrap_type.hpp" #include "openvino/util/log.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" namespace ov { namespace pass { @@ -290,9 +290,7 @@ public: const auto& pattern_map = m.get_pattern_value_map(); const auto& output = pattern_map.at(pattern_root); - OPENVINO_SUPPRESS_DEPRECATED_START - auto axis = ov::get_constant_from_source(pattern_map.at(axis_p)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto axis = ov::util::get_constant_from_source(pattern_map.at(axis_p)); if (!axis) return false; @@ -304,9 +302,7 @@ public: return true; } - OPENVINO_SUPPRESS_DEPRECATED_START - auto order = ov::get_constant_from_source(pattern_map.at(indices_p)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto order = ov::util::get_constant_from_source(pattern_map.at(indices_p)); if (!order) return false; diff --git a/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp b/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp index 429d2c0ccd5..ed20857de40 100644 --- a/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/simplify_shape_of_sub_graph.cpp @@ -10,7 +10,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/fake_quantize.hpp" @@ -24,6 +23,7 @@ #include "transformations/common_optimizations/nop_elimination.hpp" #include "transformations/common_optimizations/shared_ops_optimization.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::op; @@ -128,9 +128,7 @@ pass::GatherNopElimination::GatherNopElimination() { return false; std::vector expected_vector(number_of_indices); std::iota(expected_vector.begin(), expected_vector.end(), 0); - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& indices = get_constant_from_source(gather->input_value(1))) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto& indices = ov::util::get_constant_from_source(gather->input_value(1))) { const auto& indices_values = indices->cast_vector(); if (indices_values != expected_vector) return false; diff --git a/src/common/transformations/src/transformations/common_optimizations/split_concat_pair_to_interpolate_fusion.cpp b/src/common/transformations/src/transformations/common_optimizations/split_concat_pair_to_interpolate_fusion.cpp index 168e425930c..a9aefacbd1a 100644 --- a/src/common/transformations/src/transformations/common_optimizations/split_concat_pair_to_interpolate_fusion.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/split_concat_pair_to_interpolate_fusion.cpp @@ -14,7 +14,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" @@ -26,6 +25,7 @@ #include "openvino/op/strided_slice.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/rt_info/disable_constant_folding.hpp" +#include "validation_util.hpp" using namespace ov; @@ -214,9 +214,7 @@ ov::pass::SplitConcatPairToInterpolateFusion::SplitConcatPairToInterpolateFusion std::shared_ptr sizes_node; if (use_shape_for_elimination) { - OPENVINO_SUPPRESS_DEPRECATED_START - sizes_node = get_constant_from_source(cast_mul_result_to_int); - OPENVINO_SUPPRESS_DEPRECATED_END + sizes_node = ov::util::get_constant_from_source(cast_mul_result_to_int); } else { disable_constant_folding(shape_node); } diff --git a/src/common/transformations/src/transformations/common_optimizations/strides_optimization.cpp b/src/common/transformations/src/transformations/common_optimizations/strides_optimization.cpp index 20cc162f845..6af066d05f5 100644 --- a/src/common/transformations/src/transformations/common_optimizations/strides_optimization.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/strides_optimization.cpp @@ -7,7 +7,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convolution.hpp" @@ -19,6 +18,7 @@ #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/rt_info/strides_property.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace std; using namespace ov; @@ -57,9 +57,7 @@ static void insert_pooling(const Output& first, Input& second, const const auto ones = rg.make(element::i64, Shape{diff}, vector(diff, 1)); const auto current_shape = rg.make(first); shared_ptr new_shape = rg.make(OutputVector{ones, current_shape}, 0); - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto constant_new_shape = get_constant_from_source(new_shape)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto constant_new_shape = ov::util::get_constant_from_source(new_shape)) { rg.add(constant_new_shape); new_shape = constant_new_shape; } @@ -75,9 +73,7 @@ static void insert_pooling(const Output& first, Input& second, const new_node = rg.make(new_node, rg.make(element::u64, Shape{diff}, axes)); } - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto constant_new_node = get_constant_from_source(new_node)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto constant_new_node = ov::util::get_constant_from_source(new_node)) { rg.add(constant_new_node); new_node = constant_new_node; } diff --git a/src/common/transformations/src/transformations/common_optimizations/transpose_sinking.cpp b/src/common/transformations/src/transformations/common_optimizations/transpose_sinking.cpp index 092f7454f74..60e6b4ebadf 100644 --- a/src/common/transformations/src/transformations/common_optimizations/transpose_sinking.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/transpose_sinking.cpp @@ -10,7 +10,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/fake_quantize.hpp" @@ -20,6 +19,7 @@ #include "openvino/op/unsqueeze.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; @@ -99,9 +99,7 @@ ov::pass::TransposeEltwise::TransposeEltwise() { if (ov::shape_size(shape) != 1) { eltwise_const_input = std::make_shared(eltwise_const_input, transpose->input_value(1)); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto const_node = ov::get_constant_from_source(eltwise_const_input)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto const_node = ov::util::get_constant_from_source(eltwise_const_input)) { eltwise_const_input = const_node; } } @@ -180,11 +178,9 @@ ov::pass::TransposeReduction::TransposeReduction() { if (!transpose_order || !reduction_axes) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto& non_negative_axes = normalize_axes(reduction->get_friendly_name(), - reduction_axes->cast_vector(), - reduction->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto& non_negative_axes = ov::util::normalize_axes(reduction->get_friendly_name(), + reduction_axes->cast_vector(), + reduction->get_input_partial_shape(0).rank()); reduction_axes = ov::op::v0::Constant::create(ov::element::i64, {non_negative_axes.size()}, non_negative_axes); ov::NodeVector new_ops; diff --git a/src/common/transformations/src/transformations/control_flow/unroll_if.cpp b/src/common/transformations/src/transformations/control_flow/unroll_if.cpp index d70656b55c6..18a62a4e661 100644 --- a/src/common/transformations/src/transformations/control_flow/unroll_if.cpp +++ b/src/common/transformations/src/transformations/control_flow/unroll_if.cpp @@ -10,11 +10,11 @@ #include "openvino/core/descriptor/tensor.hpp" #include "openvino/core/graph_util.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/if.hpp" #include "openvino/op/result.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" bool ov::pass::UnrollIf::run_on_model(const std::shared_ptr& f) { RUN_ON_FUNCTION_SCOPE(UnrollIf); @@ -31,9 +31,7 @@ bool ov::pass::UnrollIf::run_on_model(const std::shared_ptr& f) { continue; } Output cond = if_node->input_value(0); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto cond_is_const = ov::get_constant_from_source(cond); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto cond_is_const = ov::util::get_constant_from_source(cond); if (!cond_is_const) { continue; } diff --git a/src/common/transformations/src/transformations/op_conversions/batch_norm_decomposition.cpp b/src/common/transformations/src/transformations/op_conversions/batch_norm_decomposition.cpp index 16268f0d64d..751159dc3b6 100644 --- a/src/common/transformations/src/transformations/op_conversions/batch_norm_decomposition.cpp +++ b/src/common/transformations/src/transformations/op_conversions/batch_norm_decomposition.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/batch_norm.hpp" #include "openvino/op/broadcast.hpp" @@ -23,6 +22,7 @@ #include "openvino/pass/pattern/op/or.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; @@ -87,14 +87,12 @@ ov::pass::BatchNormDecomposition::BatchNormDecomposition() { mean_aligned, ov::op::v0::Constant::create(mean_aligned->get_output_element_type(0), Shape{}, {-1})); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = ov::get_constant_from_source(beta_aligned)) + if (auto constant = ov::util::get_constant_from_source(beta_aligned)) beta_aligned = constant; - if (auto constant = ov::get_constant_from_source(mean_negative)) + if (auto constant = ov::util::get_constant_from_source(mean_negative)) mean_negative = constant; - if (auto constant = ov::get_constant_from_source(gamma_div_scale_aligned)) + if (auto constant = ov::util::get_constant_from_source(gamma_div_scale_aligned)) gamma_div_scale_aligned = constant; - OPENVINO_SUPPRESS_DEPRECATED_END // input_sub_mean = input + mean * -1 auto input_sub_mean = register_new_node(m_input, mean_negative); diff --git a/src/common/transformations/src/transformations/op_conversions/convert_divide.cpp b/src/common/transformations/src/transformations/op_conversions/convert_divide.cpp index 192bc109ca8..6c38646ab31 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_divide.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_divide.cpp @@ -9,7 +9,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/divide.hpp" #include "openvino/op/multiply.hpp" @@ -18,6 +17,7 @@ #include "openvino/util/log.hpp" #include "transformations/rt_info/nonconvertible_divide.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" namespace { bool convert_divide(std::shared_ptr node) { @@ -32,14 +32,12 @@ bool convert_divide(std::shared_ptr node) { ov::op::v0::Constant::create(div->get_input_element_type(1), ov::Shape{}, {-1})); if (std::dynamic_pointer_cast(div->get_input_node_shared_ptr(1))) { - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto const_pow = ov::get_constant_from_source(pow)) { + if (auto const_pow = ov::util::get_constant_from_source(pow)) { pow = const_pow; } else { OPENVINO_DEBUG << "ConvertDivide has failed due to unsupported evaluate type in " << pow.get(); return false; } - OPENVINO_SUPPRESS_DEPRECATED_END } else { ov::copy_runtime_info(div, pow); } diff --git a/src/common/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp b/src/common/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp index 8cf3540faab..309894b4726 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_interpolate1_to_interpolate4.cpp @@ -15,6 +15,7 @@ #include "openvino/op/interpolate.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" ov::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolate4() { MATCHER_SCOPE(ConvertInterpolate1ToInterpolate4); @@ -34,9 +35,7 @@ ov::pass::ConvertInterpolate1ToInterpolate4::ConvertInterpolate1ToInterpolate4() element::f32); std::shared_ptr scales = std::make_shared(out_dims, in_dims); - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& constant = ov::get_constant_from_source(scales)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto& constant = ov::util::get_constant_from_source(scales)) { scales = constant; } auto axisConstant = ov::op::v0::Constant::create(ov::element::i64, {axes.size()}, axes); diff --git a/src/common/transformations/src/transformations/op_conversions/convert_scatter_elements_to_scatter.cpp b/src/common/transformations/src/transformations/op_conversions/convert_scatter_elements_to_scatter.cpp index 8420c6e7f7a..2cdc7c1a156 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_scatter_elements_to_scatter.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_scatter_elements_to_scatter.cpp @@ -10,13 +10,13 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/scatter_elements_update.hpp" #include "openvino/op/scatter_update.hpp" #include "openvino/op/squeeze.hpp" +#include "validation_util.hpp" ov::pass::ConvertScatterElementsToScatter::ConvertScatterElementsToScatter() { MATCHER_SCOPE(ConvertScatterElementsToScatter); @@ -61,10 +61,9 @@ ov::pass::ConvertScatterElementsToScatter::ConvertScatterElementsToScatter() { return false; } - OPENVINO_SUPPRESS_DEPRECATED_START - const size_t axis = - ov::normalize_axes(scatter->get_friendly_name(), axis_const->cast_vector(), data_pshape.rank())[0]; - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axes(scatter->get_friendly_name(), + axis_const->cast_vector(), + data_pshape.rank())[0]; struct Range { uint64_t l, r; diff --git a/src/common/transformations/src/transformations/op_conversions/convert_slice_to_strided_slice.cpp b/src/common/transformations/src/transformations/op_conversions/convert_slice_to_strided_slice.cpp index 9e7c865a6fe..82f50a6c8e8 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_slice_to_strided_slice.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_slice_to_strided_slice.cpp @@ -10,7 +10,6 @@ #include "itt.hpp" #include "openvino/core/node.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/scatter_update.hpp" #include "openvino/op/slice.hpp" @@ -18,6 +17,7 @@ #include "openvino/op/util/op_types.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; @@ -80,11 +80,9 @@ ov::pass::SliceToStridedSlice::SliceToStridedSlice(bool use_shapes) { std::shared_ptr step_const; if (use_shapes) { - OPENVINO_SUPPRESS_DEPRECATED_START - start_const = get_constant_from_source(slice_node->input_value(1)); - stop_const = get_constant_from_source(slice_node->input_value(2)); - step_const = get_constant_from_source(slice_node->input_value(3)); - OPENVINO_SUPPRESS_DEPRECATED_END + start_const = ov::util::get_constant_from_source(slice_node->input_value(1)); + stop_const = ov::util::get_constant_from_source(slice_node->input_value(2)); + step_const = ov::util::get_constant_from_source(slice_node->input_value(3)); } else { start_const = std::dynamic_pointer_cast(slice_node->input_value(1).get_node_shared_ptr()); @@ -100,12 +98,10 @@ ov::pass::SliceToStridedSlice::SliceToStridedSlice(bool use_shapes) { std::shared_ptr axes_const; if (slice_node->get_input_size() > 4) { - OPENVINO_SUPPRESS_DEPRECATED_START axes_const = use_shapes - ? get_constant_from_source(slice_node->input_value(4)) + ? ov::util::get_constant_from_source(slice_node->input_value(4)) : std::dynamic_pointer_cast(slice_node->input_value(4).get_node_shared_ptr()); - OPENVINO_SUPPRESS_DEPRECATED_END } else { axes_const = slice_node->get_default_const_axes(start_input); } @@ -115,9 +111,8 @@ ov::pass::SliceToStridedSlice::SliceToStridedSlice(bool use_shapes) { const auto& data_shape = slice_node->get_input_partial_shape(0); auto axes_vec = axes_const->cast_vector(); if (data_shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto norm_axes_vec = normalize_axes(slice_node->get_friendly_name(), axes_vec, data_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto norm_axes_vec = + ov::util::normalize_axes(slice_node->get_friendly_name(), axes_vec, data_shape.rank()); axes_vec = std::vector(norm_axes_vec.begin(), norm_axes_vec.end()); } else { const bool need_normalization = std::any_of(axes_vec.begin(), axes_vec.end(), [](int64_t axis) { diff --git a/src/common/transformations/src/transformations/op_conversions/convert_softmax_downgrade.cpp b/src/common/transformations/src/transformations/op_conversions/convert_softmax_downgrade.cpp index 1bd93f7a288..33ef591c77c 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_softmax_downgrade.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_softmax_downgrade.cpp @@ -6,9 +6,9 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/softmax.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" ov::pass::ConvertSoftMax8ToSoftMax1::ConvertSoftMax8ToSoftMax1() { MATCHER_SCOPE(ConvertSoftMax8ToSoftMax1); @@ -23,9 +23,7 @@ ov::pass::ConvertSoftMax8ToSoftMax1::ConvertSoftMax8ToSoftMax1() { auto v8_axis = softmax_v8_node->get_axis(); auto rank = softmax_v8_node->get_input_partial_shape(0).rank().get_length(); - OPENVINO_SUPPRESS_DEPRECATED_START - auto v1_axis = static_cast(ov::normalize_axis(softmax_v8_node->description(), v8_axis, rank)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto v1_axis = static_cast(ov::util::normalize_axis(softmax_v8_node->description(), v8_axis, rank)); auto softmax_v1_node = std::make_shared(softmax_v8_node->input_value(0), v1_axis); softmax_v1_node->set_friendly_name(softmax_v8_node->get_friendly_name()); diff --git a/src/common/transformations/src/transformations/op_conversions/convert_subtract.cpp b/src/common/transformations/src/transformations/op_conversions/convert_subtract.cpp index 81b77d0bd2a..fbaf3fd3849 100644 --- a/src/common/transformations/src/transformations/op_conversions/convert_subtract.cpp +++ b/src/common/transformations/src/transformations/op_conversions/convert_subtract.cpp @@ -6,13 +6,13 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/multiply.hpp" #include "openvino/op/subtract.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/rt_info/dequantization_node.hpp" +#include "validation_util.hpp" using namespace ov; @@ -34,9 +34,7 @@ static bool convert_subtract(const std::shared_ptr& node) { sub->input_value(1), ov::op::v0::Constant::create(sub->get_input_element_type(1), Shape{}, {-1})); NodeVector new_nodes; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = ov::get_constant_from_source(neg)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(neg)) { neg = constant; } else { new_nodes.push_back(neg); diff --git a/src/common/transformations/src/transformations/op_conversions/einsum_decomposition.cpp b/src/common/transformations/src/transformations/op_conversions/einsum_decomposition.cpp index ad61366b319..62af31c2059 100644 --- a/src/common/transformations/src/transformations/op_conversions/einsum_decomposition.cpp +++ b/src/common/transformations/src/transformations/op_conversions/einsum_decomposition.cpp @@ -8,7 +8,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/einsum.hpp" @@ -23,6 +22,7 @@ #include "openvino/op/unsqueeze.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" namespace { /// \brief Check if the EinsumDecomposition transformation is applicable to a given Einsum. @@ -305,9 +305,7 @@ ov::Output reshape_input_for_matmul(const ov::Output& input_ // if new shape is possible to compute on the shape infer stage, insert Constant node immediatelly // in order to prevent repeated computing during constant-folding pass std::shared_ptr reshaped_input_op; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto new_shape_const = ov::get_constant_from_source(new_shape_op)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto new_shape_const = ov::util::get_constant_from_source(new_shape_op)) { reshaped_input_op = std::make_shared(input_node, new_shape_const, false); subgraph_nodes.insert(subgraph_nodes.end(), {new_shape_const}); } else { @@ -672,9 +670,7 @@ void contract_two_inputs(ov::pass::EinsumDecomposition* einsum_decompose_ptr, // if new shape is possible to compute on the shape infer stage, insert Constant node immediatelly // in order to prevent repeated computing during constant-folding pass std::shared_ptr result_op; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto new_shape_const = ov::get_constant_from_source(result_shape_op)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto new_shape_const = ov::util::get_constant_from_source(result_shape_op)) { result_op = std::make_shared(matmul->output(0), new_shape_const, false); subgraph_nodes.insert(subgraph_nodes.end(), {new_shape_const}); } else { diff --git a/src/common/transformations/src/transformations/smart_reshape/shape_of_const_folding.cpp b/src/common/transformations/src/transformations/smart_reshape/shape_of_const_folding.cpp index 17187ee57be..8eac887b1f1 100644 --- a/src/common/transformations/src/transformations/smart_reshape/shape_of_const_folding.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/shape_of_const_folding.cpp @@ -6,10 +6,10 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" +#include "validation_util.hpp" ov::pass::ShapeOfConstFolding::ShapeOfConstFolding() { MATCHER_SCOPE(ShapeOfConstFolding); @@ -18,9 +18,7 @@ ov::pass::ShapeOfConstFolding::ShapeOfConstFolding() { matcher_pass_callback callback = [=](pattern::Matcher& m) -> bool { auto node = m.get_match_root(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = get_constant_from_source(node)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(node)) { constant->set_friendly_name(node->get_friendly_name()); copy_runtime_info(node, constant); replace_node(node, constant); diff --git a/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp b/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp index 5c5562187d4..e3ebaadbc8d 100644 --- a/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/rt_info.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/squeeze.hpp" #include "openvino/op/strided_slice.hpp" @@ -14,6 +13,7 @@ #include "openvino/pass/pattern/matcher.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations_visibility.hpp" +#include "validation_util.hpp" ov::pass::StridedSliceSqueeze::StridedSliceSqueeze() { // TODO: enable conditional compile @@ -58,11 +58,9 @@ ov::pass::StridedSliceSqueeze::StridedSliceSqueeze() { })) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto& axes = normalize_axes(squeeze->description(), - const_axes->cast_vector(), - squeeze->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axes = ov::util::normalize_axes(squeeze->description(), + const_axes->cast_vector(), + squeeze->get_input_partial_shape(0).rank()); // Here squeeze input shape is equal to stridedslice input shape, // since new_axis_mask, shrink_axis_mask and ellipsis_mask are all zeros. @@ -163,11 +161,9 @@ ov::pass::SqueezeStridedSlice::SqueezeStridedSlice() { })) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - auto axes = normalize_axes(squeeze->description(), - const_axes->cast_vector(), - squeeze->get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + auto axes = ov::util::normalize_axes(squeeze->description(), + const_axes->cast_vector(), + squeeze->get_input_partial_shape(0).rank()); std::sort(axes.begin(), axes.end()); for (const auto& axis : axes) { begin_vec.insert(begin_vec.begin() + axis, 0); @@ -214,11 +210,9 @@ bool squeezes_perform_the_same(std::shared_ptr lhs, std::sh const auto l_axes = std::dynamic_pointer_cast(lhs->get_input_node_shared_ptr(1)); const auto r_axes = std::dynamic_pointer_cast(rhs->get_input_node_shared_ptr(1)); if (l_axes && r_axes) { - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::normalize_axes(lhs->description(), l_axes->cast_vector(), rank) == - ov::normalize_axes(rhs->description(), r_axes->cast_vector(), rank); + return ov::util::normalize_axes(lhs->description(), l_axes->cast_vector(), rank) == + ov::util::normalize_axes(rhs->description(), r_axes->cast_vector(), rank); } - OPENVINO_SUPPRESS_DEPRECATED_END return false; } diff --git a/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp b/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp index 943c912bf68..3d31a3fe0fd 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/matmul.hpp" @@ -16,6 +15,7 @@ #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov::symbol::util; @@ -71,9 +71,7 @@ void get_dims(const ov::Output& source, std::vector non_constant_ids; for (size_t i = from; i < to; ++i) { auto node = ov::op::util::node_to_get_shape_value_of_indices_from_shape_source(source, {i}, copy_rt_info_from); - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto constant = ov::get_constant_from_source(node)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto constant = ov::util::get_constant_from_source(node)) { node = constant; } else { non_constant_ids.push_back(i); diff --git a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp index 1437845fb9a..2e92e5ade00 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/symbolic_optimizations.cpp @@ -6,7 +6,6 @@ #include "itt.hpp" #include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/util/symbolic_info.hpp" #include "openvino/pass/manager.hpp" @@ -24,6 +23,7 @@ #include "transformations/symbolic_transformations/nop_broadcast.hpp" #include "transformations/symbolic_transformations/reshape_optimizations.hpp" #include "transformations/symbolic_transformations/utils.hpp" +#include "validation_util.hpp" using namespace ov::pass; using namespace ov::symbol::util; @@ -57,9 +57,7 @@ void special_case_range_label_propagation(const std::shared_ptr& node) if (output_shape.rank().is_dynamic() || output_shape.size() != 1) return; - OPENVINO_SUPPRESS_DEPRECATED_START - auto step_value = ov::get_constant_from_source(node->input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END + auto step_value = ov::util::get_constant_from_source(node->input_value(2)); if (!step_value || step_value->cast_vector()[0] != 1) return; diff --git a/src/common/transformations/src/transformations/transpose_sinking/ts_reduction.cpp b/src/common/transformations/src/transformations/transpose_sinking/ts_reduction.cpp index be01f1c10ab..17544b1d080 100644 --- a/src/common/transformations/src/transformations/transpose_sinking/ts_reduction.cpp +++ b/src/common/transformations/src/transformations/transpose_sinking/ts_reduction.cpp @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/transpose.hpp" #include "openvino/op/util/arithmetic_reductions_keep_dims.hpp" @@ -17,6 +16,7 @@ #include "transformations/rt_info/transpose_sinking_attr.hpp" #include "transformations/transpose_sinking/ts_utils.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::pass::pattern; @@ -52,10 +52,8 @@ TSReductionForward::TSReductionForward() { return false; auto rank = main_node->get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START auto non_negative_axes = - normalize_axes(main_node->get_friendly_name(), reduction_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(main_node->get_friendly_name(), reduction_axes->cast_vector(), rank); auto transpose_order_values = transpose_order->cast_vector(); std::vector new_values; @@ -118,10 +116,8 @@ TSReductionBackward::TSReductionBackward() { return false; auto rank = main_node->get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START auto non_negative_axes = - normalize_axes(main_node->get_friendly_name(), reduction_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(main_node->get_friendly_name(), reduction_axes->cast_vector(), rank); auto transpose_order_values = transpose_order->cast_vector(); if (!keep_dims) { @@ -151,4 +147,4 @@ TSReductionBackward::TSReductionBackward() { auto m = std::make_shared(transpose_label, matcher_name); register_matcher(m, matcher_pass_callback); -} \ No newline at end of file +} diff --git a/src/common/transformations/src/transformations/transpose_sinking/ts_squeeze.cpp b/src/common/transformations/src/transformations/transpose_sinking/ts_squeeze.cpp index 7e9a85c68be..d51f66bf6f4 100644 --- a/src/common/transformations/src/transformations/transpose_sinking/ts_squeeze.cpp +++ b/src/common/transformations/src/transformations/transpose_sinking/ts_squeeze.cpp @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/squeeze.hpp" @@ -18,6 +17,7 @@ #include "transformations/rt_info/transpose_sinking_attr.hpp" #include "transformations/transpose_sinking/ts_utils.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::pass::pattern; @@ -122,10 +122,9 @@ TSSqueezeForward::TSSqueezeForward() { } } else { auto rank = main_node->get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START - non_negative_axes = - normalize_axes(main_node->get_friendly_name(), squeeze_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + non_negative_axes = ov::util::normalize_axes(main_node->get_friendly_name(), + squeeze_axes->cast_vector(), + rank); } } @@ -231,10 +230,9 @@ TSSqueezeBackward::TSSqueezeBackward() { } } else { auto rank = main_node->get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START - non_negative_axes = - normalize_axes(main_node->get_friendly_name(), squeeze_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + non_negative_axes = ov::util::normalize_axes(main_node->get_friendly_name(), + squeeze_axes->cast_vector(), + rank); } } @@ -293,4 +291,4 @@ TSSqueezeBackward::TSSqueezeBackward() { auto m = std::make_shared(transpose_label, matcher_name); register_matcher(m, matcher_pass_callback); -} \ No newline at end of file +} diff --git a/src/common/transformations/src/transformations/transpose_sinking/ts_unsqueeze.cpp b/src/common/transformations/src/transformations/transpose_sinking/ts_unsqueeze.cpp index 7abbf6f1699..db349acbc02 100644 --- a/src/common/transformations/src/transformations/transpose_sinking/ts_unsqueeze.cpp +++ b/src/common/transformations/src/transformations/transpose_sinking/ts_unsqueeze.cpp @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/transpose.hpp" @@ -17,6 +16,7 @@ #include "transformations/rt_info/transpose_sinking_attr.hpp" #include "transformations/transpose_sinking/ts_utils.hpp" #include "transformations/utils/utils.hpp" +#include "validation_util.hpp" using namespace ov; using namespace ov::pass::pattern; @@ -121,10 +121,8 @@ TSUnsqueezeForward::TSUnsqueezeForward() { } } else { auto rank = main_node->get_output_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START non_negative_axes = - normalize_axes(main_node->get_friendly_name(), unsqueeze_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(main_node->get_friendly_name(), unsqueeze_axes->cast_vector(), rank); } auto ts_order_values = transpose_info.transpose_const->cast_vector(); @@ -193,10 +191,8 @@ TSUnsqueezeBackward::TSUnsqueezeBackward() { } } else { auto rank = main_node->get_output_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START non_negative_axes = - normalize_axes(main_node->get_friendly_name(), unsqueeze_axes->cast_vector(), rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(main_node->get_friendly_name(), unsqueeze_axes->cast_vector(), rank); } auto transpose_order_values = transpose_order->cast_vector(); diff --git a/src/common/transformations/src/transformations/utils/utils.cpp b/src/common/transformations/src/transformations/utils/utils.cpp index 60a91f0227b..e1eb0303047 100644 --- a/src/common/transformations/src/transformations/utils/utils.cpp +++ b/src/common/transformations/src/transformations/utils/utils.cpp @@ -9,13 +9,13 @@ #include #include -#include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" #include "openvino/op/reshape.hpp" #include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset3.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -426,9 +426,7 @@ float cast_eps_to_float(double eps_d) { } bool is_constant_and_all_values_equal_int(const Output& output, const int64_t& v) { - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& constant = ov::get_constant_from_source(output)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto& constant = ov::util::get_constant_from_source(output)) { const auto& values = constant->cast_vector(); return std::all_of(values.begin(), values.end(), [&](const int64_t& i) { return i == v; diff --git a/src/core/dev_api/validation_util.hpp b/src/core/dev_api/validation_util.hpp index 92a484f5641..82f1f193c52 100644 --- a/src/core/dev_api/validation_util.hpp +++ b/src/core/dev_api/validation_util.hpp @@ -77,14 +77,14 @@ Tensor make_tensor_of_min_value(const element::Type_t et); /// /// \return true if auto padding was applied successfully (all needed informations such as /// spatial dims are known), false otherwise. -OPENVINO_API -bool try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below); +OPENVINO_DEPRECATED("This function is deprecated and will be removed.") +OPENVINO_API bool try_apply_auto_padding(const PartialShape& image_shape, + const Shape& filter_shape, + const Strides& filter_strides, + const Strides& filter_dilations, + const op::PadType pad_type, + CoordinateDiff& padding_above, + CoordinateDiff& padding_below); /// @brief Get the tensors shapes as ov::PartialShape. /// @@ -106,5 +106,148 @@ OPENVINO_API std::vector get_node_input_partial_shapes(const ov::N /// /// \return True if rank compatible to any of others, otherwise false. OPENVINO_API bool is_rank_compatible_any_of(const Rank& r, std::initializer_list others); + +/// \brief Infers the output batch shape for convolution forward propagation. +/// +/// \return Infered output shape. +OPENVINO_DEPRECATED("This function is deprecated and will be removed.") +OPENVINO_API PartialShape infer_convolution_forward(const Node* node, + const PartialShape& data_batch_shape, + const Strides& data_dilation, + const CoordinateDiff& data_padding_below, + const CoordinateDiff& data_padding_above, + const PartialShape& filters_shape, + const Strides& filter_strides, + const Strides& filter_dilation); + +/// \brief Infers image paddings. +OPENVINO_DEPRECATED("This function is deprecated and will be removed.") +OPENVINO_API void infer_auto_padding(const Shape& image_shape, + const Shape& filter_shape, + const Strides& filter_strides, + const Strides& filter_dilations, + const op::PadType pad_type, + CoordinateDiff& padding_above, + CoordinateDiff& padding_below); + +/// \brief Evaluates lower and upper value estimations for the output tensor. Estimation would be represented as partial +/// shape object using Dimension(min, max) for each element. +/// +/// \param output Node output pointing to the tensor for estimation. +/// \param pshape Resulting estimation would be stored in this PartialShape. +/// +/// \return True if estimations evaluation was successful, false otherwise. +OPENVINO_API bool evaluate_as_partial_shape(const Output& output, PartialShape& pshape); + +/// \brief Propagates value label from 0 input to the only output through an operation. Not applicable for operations +/// which require values interaction (example: mathematical operations). Could be used for movement operations (example: +/// gathering, shape change) +/// +/// \param node Operation to be performed +/// \param output_labels Vector of TensorLabel objects representing resulting value labels +/// +/// \return True if label evaluation was successful, false otherwise. +OPENVINO_API bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels); + +/// \brief Generates default order of axes transposition at the end of input vector. +/// +/// The default axes order is a descending sequence of numbers starting at `length - 1`. +/// +/// \param axes_order Vector where default order will be generated. +/// \param length Sequence length of axes order. +OPENVINO_API void generate_transpose_default_order(std::vector& axes_order, size_t length); + +/// \brief Checks whether axes order has valid values. +/// +/// Axes order has to be a set of unique numbers in range [0, size). +/// +/// \param axes_order Vector with axes order to check. +/// \param size Input for transpose rank size. +/// +/// \return True if axes order is valid, false otherwise. +OPENVINO_API bool is_valid_axes_order(const std::vector& axes_order, size_t size); + +/// \brief Checks whether label tensor has no labels. +/// +/// \param labels Label tensor to check. +/// \return True if there are no labels, false otherwise. +OPENVINO_API bool has_no_labels(const TensorLabel& labels); + +/// \brief Handles out of range axis. +/// +/// \param[in] node The node with requested axis. +/// \param[in] axis The requested axis value. +/// \param[in] tensor_rank The corresponding tensor rank. +/// +/// \return Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise +/// returns error. If negative axis, it counts from the last to the first axis, +/// by adding tensor_rank to axis. +OPENVINO_API int64_t normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank); + +/// \brief Handles out of range axis. +/// +/// \param[in] node_description The node with requested axis. +/// \param[in] axis The requested axis value. +/// \param[in] tensor_rank The corresponding tensor rank. +/// +/// \return Checking if axis is in range [-tensor_rank, tensor_rank-1], otherwise +/// returns error. If negative axis, it counts from the last to the first axis, +/// by adding tensor_rank to axis. +OPENVINO_API int64_t normalize_axis(const std::string& node_description, std::int64_t axis, const Rank& tensor_rank); + +/// \brief Handles out of range axis. +/// +/// \param[in] node The node with requested axis. +/// \param[in] axis The requested axis value. +/// \param[in] tensor_rank The corresponding tensor rank. +/// \param[in] axis_range_min The min value of accepted range for axis. +/// \param[in] axis_range_max The max value of accepted range for axis. +/// +/// \return Checking if axis is in range [axis_range_min, axis_range_max], otherwise +/// returns error. If negative axis, it counts from the last to the first axis, +/// by adding tensor_rank to axis. +OPENVINO_API int64_t normalize_axis(const Node* node, + std::int64_t axis, + std::uint64_t tensor_rank, + std::int64_t axis_range_min, + std::int64_t axis_range_max); + +/// \brief Handles out of range axis. +/// +/// \param[in] node_description The name of node with requested axis. +/// \param[in] axis The requested axis value. +/// \param[in] tensor_rank The corresponding tensor rank. +/// \param[in] axis_range_min The min value of accepted range for axis. +/// \param[in] axis_range_max The max value of accepted range for axis. +/// +/// \return Checking if axis is in range [axis_range_min, axis_range_max], otherwise +/// returns error. If negative axis, it counts from the last to the first axis, +/// by adding tensor_rank to axis. +OPENVINO_API int64_t normalize_axis(const std::string& node_description, + std::int64_t axis, + std::uint64_t tensor_rank, + std::int64_t axis_range_min, + std::int64_t axis_range_max); + +/// \brief Handles out of range axes in vector. +/// +/// \param[in] node_description The name of node with requested axes. +/// \param[in] axes The requested vector of axes. +/// \param[in] tensor_rank The corresponding tensor rank. +/// +/// \return If any negative axis in vector, it counts from the last to the first +/// axis, by adding tensor_rank to axis. +OPENVINO_API std::vector normalize_axes(const std::string& node_description, + const std::vector& axes, + const Rank& tensor_rank); + +/// \brief Handles out of range axes in vector. +/// If any negative axis in vector, it counts from the last to the first axis, +/// by adding tensor_rank to axis. Changes axes vector inplace. +/// +/// \param[in] node The node with requested axes. +/// \param[in] tensor_rank The corresponding tensor rank. +/// \param[in,out] axes The requested vector of axes. +OPENVINO_API void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes); } // namespace util } // namespace ov diff --git a/src/core/shape_inference/include/concat_shape_inference.hpp b/src/core/shape_inference/include/concat_shape_inference.hpp index cc35390164b..d76e16e725d 100644 --- a/src/core/shape_inference/include/concat_shape_inference.hpp +++ b/src/core/shape_inference/include/concat_shape_inference.hpp @@ -4,9 +4,9 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -28,18 +28,14 @@ std::vector shape_infer(const Concat* op, const std::vector& input_s output_shape = PartialShape::dynamic(); } else { output_shape = input_shapes.front(); - OPENVINO_SUPPRESS_DEPRECATED_START - concat_axis = ov::normalize_axis(op, concat_axis, output_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + concat_axis = ov::util::normalize_axis(op, concat_axis, output_shape.rank()); output_shape[concat_axis] = empty_dim; } for (auto& input : input_shapes) { const auto& input_rank = input.rank(); if (input_rank.is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - concat_axis = ov::normalize_axis(op, concat_axis, input_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + concat_axis = ov::util::normalize_axis(op, concat_axis, input_rank); auto in_copy = TRShape(input); concat_dim += in_copy[concat_axis]; in_copy[concat_axis] = empty_dim; diff --git a/src/core/shape_inference/include/fft_common_validation.hpp b/src/core/shape_inference/include/fft_common_validation.hpp index 16a3692dfe0..728509ae85d 100644 --- a/src/core/shape_inference/include/fft_common_validation.hpp +++ b/src/core/shape_inference/include/fft_common_validation.hpp @@ -1,11 +1,13 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + #pragma once -#include #include "openvino/core/axis_vector.hpp" +#include "openvino/op/util/fft_base.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -72,9 +74,7 @@ void validate_axes(const ov::op::util::FFTBase* op, // according to the RDFT operation specification, axes should be integers from -r to (r - 1) // inclusively, where r = rank(data). A negative axis 'a' is interpreted as an axis 'r + a'. const int64_t axis_correction = (fft_kind == FFTKind::RealInput) ? input_rank : (input_rank - 1); - OPENVINO_SUPPRESS_DEPRECATED_START - ov::normalize_axes(op, axis_correction, axes); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, axis_correction, axes); auto axes_set = AxisSet(std::vector(axes.begin(), axes.end())); NODE_VALIDATION_CHECK(op, axes.size() == axes_set.size(), "Each axis must be unique."); diff --git a/src/core/shape_inference/include/gather_elements_shape_inference.hpp b/src/core/shape_inference/include/gather_elements_shape_inference.hpp index 2447ca40eea..b8b84c35b5d 100644 --- a/src/core/shape_inference/include/gather_elements_shape_inference.hpp +++ b/src/core/shape_inference/include/gather_elements_shape_inference.hpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include +#include "openvino/op/gather_elements.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -23,9 +24,7 @@ std::vector shape_infer(const GatherElements* op, const std::vector& int64_t axis = op->get_axis(); if (data_rank.is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(op, axis, data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(op, axis, data_rank); } NODE_VALIDATION_CHECK(op, data_rank.is_dynamic() || data_rank.get_length() >= 1, "data rank must be >= 1."); diff --git a/src/core/shape_inference/include/gather_shape_inference.hpp b/src/core/shape_inference/include/gather_shape_inference.hpp index f7440798d1c..0782a9577c0 100644 --- a/src/core/shape_inference/include/gather_shape_inference.hpp +++ b/src/core/shape_inference/include/gather_shape_inference.hpp @@ -2,9 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // #pragma once -#include +#include "openvino/op/util/gather_base.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -43,9 +44,7 @@ std::vector shape_infer(const util::GatherBase* op, axis_is_set = true; if (data_rank.is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - axis = ov::normalize_axis(op, axis, data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + axis = ov::util::normalize_axis(op, axis, data_rank); } // batch_dims, axis both can be positive by default or after normalization if data_rank & // indices_rank are static. diff --git a/src/core/shape_inference/include/one_hot_shape_inference.hpp b/src/core/shape_inference/include/one_hot_shape_inference.hpp index 5b2e9611ea3..04faa27ddee 100644 --- a/src/core/shape_inference/include/one_hot_shape_inference.hpp +++ b/src/core/shape_inference/include/one_hot_shape_inference.hpp @@ -5,6 +5,7 @@ #include "openvino/op/one_hot.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -31,9 +32,7 @@ void inline resolve_axis(OneHot* op) { const auto& indices_shape = op->get_input_partial_shape(0); if (indices_shape.rank().is_static()) { const auto indices_rank = indices_shape.rank().get_length(); - OPENVINO_SUPPRESS_DEPRECATED_START - op->m_axis = ov::normalize_axis(op, op->m_axis, indices_rank + 1, -indices_rank - 1, indices_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + op->m_axis = ov::util::normalize_axis(op, op->m_axis, indices_rank + 1, -indices_rank - 1, indices_rank); } } @@ -65,9 +64,8 @@ std::vector shape_infer(const OneHot* op, if (indices_shape.rank().is_static()) { result_shape = indices_shape; const auto indices_rank = indices_shape.rank().get_length(); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = ov::normalize_axis(op, op->get_axis(), indices_rank + 1, -indices_rank - 1, indices_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = + ov::util::normalize_axis(op, op->get_axis(), indices_rank + 1, -indices_rank - 1, indices_rank); auto depth_as_shape = get_input_const_data_as_shape(op, 1, ta, util::GetNotNegative(op)); diff --git a/src/core/shape_inference/include/reduce_shape_inference.hpp b/src/core/shape_inference/include/reduce_shape_inference.hpp index 236a7876516..7ba50b3b631 100644 --- a/src/core/shape_inference/include/reduce_shape_inference.hpp +++ b/src/core/shape_inference/include/reduce_shape_inference.hpp @@ -60,9 +60,7 @@ std::vector reduce_shape_infer(const util::ReductionBase* op, const auto axes_val = ov::op::get_input_const_data_as(op, 1, tensor_accessor); if (data_rank.is_static() && axes_val) { - OPENVINO_SUPPRESS_DEPRECATED_START - ov::normalize_axes(op, data_rank.get_length(), *axes_val); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, data_rank.get_length(), *axes_val); output_shapes.push_back(util::reduce_shape(data_shape, *axes_val, keep_dims)); } else { diff --git a/src/core/shape_inference/include/region_yolo_shape_inference.hpp b/src/core/shape_inference/include/region_yolo_shape_inference.hpp index c63a4a49c42..380c8e6ad62 100644 --- a/src/core/shape_inference/include/region_yolo_shape_inference.hpp +++ b/src/core/shape_inference/include/region_yolo_shape_inference.hpp @@ -6,9 +6,9 @@ #include -#include "openvino/core/validation_util.hpp" #include "openvino/op/region_yolo.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -35,10 +35,8 @@ std::vector shape_infer(const RegionYolo* op, const std::vector output_shape.reserve(out_rank); if (op->get_do_softmax()) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = ov::normalize_axis(op, op->get_axis(), input_rank); - const auto end_axis = ov::normalize_axis(op, op->get_end_axis(), input_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axis(op, op->get_axis(), input_rank); + const auto end_axis = ov::util::normalize_axis(op, op->get_end_axis(), input_rank); auto input_it = input_shape.cbegin(); auto out_it = std::copy_n(input_it, axis + 1, std::back_inserter(output_shape)); diff --git a/src/core/shape_inference/include/reverse_sequence_shape_inference.hpp b/src/core/shape_inference/include/reverse_sequence_shape_inference.hpp index 235eb8eb64d..f7e2da88b64 100644 --- a/src/core/shape_inference/include/reverse_sequence_shape_inference.hpp +++ b/src/core/shape_inference/include/reverse_sequence_shape_inference.hpp @@ -3,10 +3,9 @@ // #pragma once -#include -#include - +#include "openvino/op/reverse_sequence.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -32,9 +31,7 @@ std::vector shape_infer(const ReverseSequence* op, const std::vectorget_origin_batch_axis(), data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto normalized_batch_axis = ov::util::normalize_axis(op, op->get_origin_batch_axis(), data_rank); DimType merged_sequence_length; NODE_VALIDATION_CHECK( op, diff --git a/src/core/shape_inference/include/roll_shape_inference.hpp b/src/core/shape_inference/include/roll_shape_inference.hpp index 9ef3bd1fb48..426e0b6f52a 100644 --- a/src/core/shape_inference/include/roll_shape_inference.hpp +++ b/src/core/shape_inference/include/roll_shape_inference.hpp @@ -4,9 +4,9 @@ #pragma once -#include - +#include "openvino/op/roll.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -40,9 +40,7 @@ std::vector shape_infer(const Roll* op, if (data_pshape.rank().is_static()) { if (const auto axes = get_input_const_data_as(op, 2, ta)) { - OPENVINO_SUPPRESS_DEPRECATED_START - ov::normalize_axes(op, data_pshape.size(), *axes); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, data_pshape.size(), *axes); } } diff --git a/src/core/shape_inference/include/scatter_elements_update_shape_inference.hpp b/src/core/shape_inference/include/scatter_elements_update_shape_inference.hpp index fbc01119328..46ffdcaa73b 100644 --- a/src/core/shape_inference/include/scatter_elements_update_shape_inference.hpp +++ b/src/core/shape_inference/include/scatter_elements_update_shape_inference.hpp @@ -4,9 +4,9 @@ #pragma once -#include - +#include "openvino/op/scatter_elements_update.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -49,9 +49,7 @@ std::vector shape_infer(const util::ScatterElementsUpdateBase* op, if (data_shape.rank().is_static()) { if (const auto axis_input = get_input_const_data_as(op, 3, ta)) { - OPENVINO_SUPPRESS_DEPRECATED_START - ov::normalize_axis(op, (*axis_input)[0], data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axis(op, (*axis_input)[0], data_rank); } } return {data_shape}; diff --git a/src/core/shape_inference/include/shuffle_channels_shape_inference.hpp b/src/core/shape_inference/include/shuffle_channels_shape_inference.hpp index 1d5c93abdcc..ef4a72cbb72 100644 --- a/src/core/shape_inference/include/shuffle_channels_shape_inference.hpp +++ b/src/core/shape_inference/include/shuffle_channels_shape_inference.hpp @@ -4,10 +4,9 @@ #pragma once -#include - -#include "openvino/core/validation_util.hpp" +#include "openvino/op/shuffle_channels.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -27,9 +26,7 @@ std::vector shape_infer(const ShuffleChannels* op, const std::vector= 1, "The input tensor's shape is expected to be at least 1D."); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis_zb = static_cast(normalize_axis(op, op->get_axis(), input_shape_rank)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis_zb = static_cast(ov::util::normalize_axis(op, op->get_axis(), input_shape_rank)); const auto& channel_dim = input_shape[axis_zb]; NODE_VALIDATION_CHECK(op, channel_dim.is_dynamic() || (channel_dim.get_length() % group) == 0, diff --git a/src/core/shape_inference/include/slice_shape_inference.hpp b/src/core/shape_inference/include/slice_shape_inference.hpp index 04461484a81..0685c5a83ff 100644 --- a/src/core/shape_inference/include/slice_shape_inference.hpp +++ b/src/core/shape_inference/include/slice_shape_inference.hpp @@ -5,9 +5,10 @@ #pragma once #include -#include +#include "openvino/op/slice.hpp" #include "slice_shape_inference_utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -108,9 +109,7 @@ std::vector shape_infer(const Slice* op, "Slice `axes` input must have compatible shape with `start`, `stop`, `step` inputs."); if (auto axes = get_input_const_data_as(op, 4, ta)) { - OPENVINO_SUPPRESS_DEPRECATED_START - ov::normalize_axes(op, input_shape.rank().get_length(), *axes); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, input_shape.rank().get_length(), *axes); axes_map.add(*axes); NODE_VALIDATION_CHECK(op, axes_map.is_valid, "Slice values in `axes` input must be unique."); } diff --git a/src/core/shape_inference/include/split_shape_inference.hpp b/src/core/shape_inference/include/split_shape_inference.hpp index 5ad007b79cd..f413ee46541 100644 --- a/src/core/shape_inference/include/split_shape_inference.hpp +++ b/src/core/shape_inference/include/split_shape_inference.hpp @@ -4,9 +4,9 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/split.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -47,9 +47,7 @@ std::vector shape_infer(const Split* op, axes_values->size(), " axes"); - OPENVINO_SUPPRESS_DEPRECATED_START - auto axis = ov::normalize_axis(op, (*axes_values)[0], data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + auto axis = ov::util::normalize_axis(op, (*axes_values)[0], data_rank); if (data_ps[axis].is_static()) { const auto dimension_at_axis = data_ps[axis].get_length(); diff --git a/src/core/shape_inference/include/squeeze_shape_inference.hpp b/src/core/shape_inference/include/squeeze_shape_inference.hpp index adbadbdd7b0..20c18f02a2b 100644 --- a/src/core/shape_inference/include/squeeze_shape_inference.hpp +++ b/src/core/shape_inference/include/squeeze_shape_inference.hpp @@ -6,6 +6,7 @@ #include "openvino/op/squeeze.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -49,9 +50,7 @@ std::vector shape_infer(const Squeeze* op, if (arg_rank.is_static() && axes_shape.is_static()) { if (auto axes = get_input_const_data_as(op, 1, ta)) { // The values of `axes` input are known - OPENVINO_SUPPRESS_DEPRECATED_START - normalize_axes(op, arg_rank.get_length(), *axes); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, arg_rank.get_length(), *axes); unique_axes.reset(new std::set(axes->cbegin(), axes->cend())); } else if (arg_rank.get_length() > 0 && shape_size(axes_shape.to_shape()) == 1) { // The `axes` input is a single element tensor which is unique by definition, deducing output rank diff --git a/src/core/shape_inference/include/topk_shape_inference.hpp b/src/core/shape_inference/include/topk_shape_inference.hpp index 8bd6ca9f39a..25354aabd11 100644 --- a/src/core/shape_inference/include/topk_shape_inference.hpp +++ b/src/core/shape_inference/include/topk_shape_inference.hpp @@ -4,10 +4,9 @@ #pragma once -#include -#include - +#include "openvino/op/topk.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -69,9 +68,7 @@ std::vector shape_infer(const util::TopKBase* op, TRShape output_shape = input_shape; if (input_shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto normalized_axis = ov::normalize_axis(op, op->get_provided_axis(), input_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto normalized_axis = ov::util::normalize_axis(op, op->get_provided_axis(), input_shape.rank()); auto& dim_axis = output_shape[normalized_axis]; if (auto k_as_shape = diff --git a/src/core/shape_inference/include/transpose_shape_inference.hpp b/src/core/shape_inference/include/transpose_shape_inference.hpp index 05b6ab2b402..0fd930c227b 100644 --- a/src/core/shape_inference/include/transpose_shape_inference.hpp +++ b/src/core/shape_inference/include/transpose_shape_inference.hpp @@ -5,6 +5,7 @@ #include "openvino/op/transpose.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -26,18 +27,14 @@ TRShape calc_output_shape(const Transpose* const op, const T& input_shape, std:: const auto output_rank = input_shape.size(); if (axes_order.empty()) { - OPENVINO_SUPPRESS_DEPRECATED_START - generate_transpose_default_order(axes_order, output_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::generate_transpose_default_order(axes_order, output_rank); } else { - OPENVINO_SUPPRESS_DEPRECATED_START NODE_VALIDATION_CHECK(op, - is_valid_axes_order(axes_order, output_rank), + ov::util::is_valid_axes_order(axes_order, output_rank), "Permutation ", AxisVector(axes_order.begin(), axes_order.end()), " is not valid for input shape ", input_shape); - OPENVINO_SUPPRESS_DEPRECATED_END } TRShape output_shape; diff --git a/src/core/shape_inference/include/unsqueeze_shape_inference.hpp b/src/core/shape_inference/include/unsqueeze_shape_inference.hpp index c4167a4ceb6..4ed59851738 100644 --- a/src/core/shape_inference/include/unsqueeze_shape_inference.hpp +++ b/src/core/shape_inference/include/unsqueeze_shape_inference.hpp @@ -5,6 +5,7 @@ #include "openvino/op/unsqueeze.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -39,9 +40,7 @@ std::vector shape_infer(const Unsqueeze* op, const auto expanded_rank = arg_shape.rank().get_length() + unique_axes.size(); // Normalize then remove repeated axes after normalization. - OPENVINO_SUPPRESS_DEPRECATED_START - normalize_axes(op, expanded_rank, unique_axes); - OPENVINO_SUPPRESS_DEPRECATED_END + ov::util::normalize_axes(op, expanded_rank, unique_axes); const std::set axes(unique_axes.begin(), unique_axes.end()); out_shape = arg_shape; diff --git a/src/core/shape_inference/include/utils.hpp b/src/core/shape_inference/include/utils.hpp index 4b302b6618b..b34002d31fe 100644 --- a/src/core/shape_inference/include/utils.hpp +++ b/src/core/shape_inference/include/utils.hpp @@ -319,9 +319,7 @@ ov::optional get_input_const_data_as_shape(const ov::Node* op, c->get_data_ptr(), shape_size(c->get_shape()), std::forward(func))); - OPENVINO_SUPPRESS_DEPRECATED_START - } else if (ov::evaluate_as_partial_shape(op->input_value(port), s)) { - OPENVINO_SUPPRESS_DEPRECATED_END + } else if (ov::util::evaluate_as_partial_shape(op->input_value(port), s)) { shape = std::move(s); } } diff --git a/src/core/shape_inference/include/variadic_split_shape_inference.hpp b/src/core/shape_inference/include/variadic_split_shape_inference.hpp index a80ec8302f3..00a93c466ce 100644 --- a/src/core/shape_inference/include/variadic_split_shape_inference.hpp +++ b/src/core/shape_inference/include/variadic_split_shape_inference.hpp @@ -4,9 +4,9 @@ #pragma once -#include "openvino/core/validation_util.hpp" #include "openvino/op/variadic_split.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -50,9 +50,7 @@ std::vector shape_infer(const VariadicSplit* op, " axes"); const auto axis_val = (*axis_values)[0]; // Adjust split axis in case of negatives - OPENVINO_SUPPRESS_DEPRECATED_START - const int64_t axis = ov::normalize_axis(op, axis_val, data_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const int64_t axis = ov::util::normalize_axis(op, axis_val, data_shape.rank()); if (auto split_lengths = get_input_const_data_as(op, 2, ta)) { // Adjust split lengths in case of negatives diff --git a/src/core/src/bound_evaluate.cpp b/src/core/src/bound_evaluate.cpp index 60d61126acc..ceeebbbd38b 100644 --- a/src/core/src/bound_evaluate.cpp +++ b/src/core/src/bound_evaluate.cpp @@ -12,6 +12,7 @@ #include "openvino/opsets/opset10.hpp" #include "transformations/rt_info/decompression.hpp" #include "transformations/rt_info/is_shape_subgraph.hpp" +#include "validation_util.hpp" namespace { using namespace ov; @@ -580,9 +581,7 @@ bool ov::default_label_evaluator(const Node* node, for (size_t i = 0; i < inputs_count; ++i) { if (std::find(labeled_inputs.begin(), labeled_inputs.end(), i) != labeled_inputs.end()) { auto labels = node->get_input_tensor(i).get_value_label(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (!has_no_labels(labels) && !has_any_input_labels) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (!ov::util::has_no_labels(labels) && !has_any_input_labels) { has_any_input_labels = true; } diff --git a/src/core/src/op/concat.cpp b/src/core/src/op/concat.cpp index 809fcdba7e9..57a3fb24762 100644 --- a/src/core/src/op/concat.cpp +++ b/src/core/src/op/concat.cpp @@ -8,8 +8,8 @@ #include "concat_shape_inference.hpp" #include "itt.hpp" #include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/concat.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -101,9 +101,7 @@ bool Concat::evaluate_label(TensorLabelVector& output_labels) const { const auto& inputs = input_values(); if (std::all_of(inputs.cbegin(), inputs.cend(), [](const Output& out) { const auto& labels = out.get_tensor().get_value_label(); - OPENVINO_SUPPRESS_DEPRECATED_START - return has_no_labels(labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::has_no_labels(labels); })) { return false; } diff --git a/src/core/src/op/convolution.cpp b/src/core/src/op/convolution.cpp index 9b870b4242d..8883a4b8751 100644 --- a/src/core/src/op/convolution.cpp +++ b/src/core/src/op/convolution.cpp @@ -9,6 +9,7 @@ #include "convolution_shape_inference.hpp" #include "itt.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" +#include "validation_util.hpp" using namespace std; @@ -129,9 +130,7 @@ bool op::v1::ConvolutionBackpropData::is_dynamic() const { const ov::PartialShape op::v1::ConvolutionBackpropData::get_output_shape() const { auto shape = PartialShape::dynamic(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (get_input_size() < 3 || !evaluate_as_partial_shape(input_value(2), shape)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (get_input_size() < 3 || !ov::util::evaluate_as_partial_shape(input_value(2), shape)) { const auto& data_rank = get_input_partial_shape(0).rank(); const auto& filter_rank = get_input_partial_shape(1).rank(); diff --git a/src/core/src/op/group_conv.cpp b/src/core/src/op/group_conv.cpp index 6d743553d1d..d8913c60af6 100644 --- a/src/core/src/op/group_conv.cpp +++ b/src/core/src/op/group_conv.cpp @@ -9,6 +9,7 @@ #include "group_convolution_shape_inference.hpp" #include "itt.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" +#include "validation_util.hpp" //------------------------------------------------------------------------------ // v1::GroupConvolution @@ -151,9 +152,7 @@ bool op::v1::GroupConvolutionBackpropData::is_dynamic() const { const ov::PartialShape op::v1::GroupConvolutionBackpropData::get_convolution_output_shape() const { auto shape = PartialShape::dynamic(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (get_input_size() < 3 || !evaluate_as_partial_shape(input_value(2), shape)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (get_input_size() < 3 || !ov::util::evaluate_as_partial_shape(input_value(2), shape)) { const auto& data_rank = get_input_partial_shape(0).rank(); const auto& filter_rank = get_input_partial_shape(1).rank(); diff --git a/src/core/src/op/if.cpp b/src/core/src/op/if.cpp index 3bbb7613b0b..fd1fa0e743d 100644 --- a/src/core/src/op/if.cpp +++ b/src/core/src/op/if.cpp @@ -9,9 +9,9 @@ #include "itt.hpp" #include "openvino/core/graph_util.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/util/multi_subgraph_base.hpp" #include "openvino/reference/if.hpp" +#include "validation_util.hpp" ov::op::v8::If::If() : MultiSubGraphOp(2) {} @@ -94,9 +94,7 @@ void ov::op::v8::If::validate_and_infer_types() { } // Trying to get cond as const value - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& cond_value = get_constant_from_source(if_condition)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto cond_value = ov::util::get_constant_from_source(if_condition)) { // If cond is const shape and inference is run for one of bodies another body is skipped auto val = cond_value->cast_vector(); NODE_VALIDATION_CHECK(this, diff --git a/src/core/src/op/loop.cpp b/src/core/src/op/loop.cpp index e9a7f1c6336..f7589b12689 100644 --- a/src/core/src/op/loop.cpp +++ b/src/core/src/op/loop.cpp @@ -7,7 +7,6 @@ #include #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/tensor_iterator.hpp" #include "openvino/reference/loop.hpp" #include "openvino/runtime/tensor.hpp" @@ -160,9 +159,8 @@ void Loop::validate_and_infer_types() { body_parameter->set_partial_shape(PartialShape::dynamic()); } else { auto out_shape = input_partial_shape; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = normalize_axis(this, slice_input_description->m_axis, input_partial_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = + ov::util::normalize_axis(this, slice_input_description->m_axis, input_partial_shape.rank()); out_shape[axis] = slice_input_description->m_part_size; body_parameter->set_partial_shape(out_shape); } @@ -271,9 +269,7 @@ void Loop::validate_and_infer_types() { if (zero_number_of_iter) { out_shape = PartialShape{0}; } else if (out_shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axis = normalize_axis(this, concat_output_description->m_axis, out_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axis = ov::util::normalize_axis(this, concat_output_description->m_axis, out_shape.rank()); const auto rank = out_shape.rank().get_length(); if (rank == 0) { out_shape = PartialShape{1}; diff --git a/src/core/src/op/lrn.cpp b/src/core/src/op/lrn.cpp index f80cb91103c..908f3f6c5d9 100644 --- a/src/core/src/op/lrn.cpp +++ b/src/core/src/op/lrn.cpp @@ -6,9 +6,9 @@ #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/multiply.hpp" +#include "validation_util.hpp" namespace ov { op::v0::LRN::LRN(const Output& arg, double alpha, double beta, double bias, size_t size) @@ -26,9 +26,7 @@ op::v0::LRN::LRN(const Output& arg, const Output& axes, double alpha AxisSet op::v0::LRN::get_reduction_axes() const { AxisSet axes{1}; // channel axis as default auto axes_input_node = input_value(1).get_node_shared_ptr(); - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& const_op = get_constant_from_source(axes_input_node)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (const auto& const_op = ov::util::get_constant_from_source(axes_input_node)) { axes = const_op->get_axis_set_val(); } return axes; diff --git a/src/core/src/op/max_pool.cpp b/src/core/src/op/max_pool.cpp index c7afdb77187..f07980ce75a 100644 --- a/src/core/src/op/max_pool.cpp +++ b/src/core/src/op/max_pool.cpp @@ -7,8 +7,8 @@ #include "itt.hpp" #include "max_pool_shape_inference.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/max_pool.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -166,9 +166,7 @@ void MaxPool::validate_and_infer_types() { const auto input_shape = get_input_partial_shape(0); if (input_shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - m_axis = normalize_axis(this, m_axis, input_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + m_axis = ov::util::normalize_axis(this, m_axis, input_shape.rank()); } OPENVINO_SUPPRESS_DEPRECATED_START diff --git a/src/core/src/op/non_max_suppression.cpp b/src/core/src/op/non_max_suppression.cpp index 75e649230a5..09f4cd21741 100644 --- a/src/core/src/op/non_max_suppression.cpp +++ b/src/core/src/op/non_max_suppression.cpp @@ -12,6 +12,7 @@ #include "openvino/core/attribute_visitor.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/util/op_types.hpp" +#include "validation_util.hpp" namespace ov { // ------------------------------ V1 ------------------------------ @@ -81,9 +82,7 @@ void op::v1::NonMaxSuppression::validate_and_infer_types() { int64_t op::v1::NonMaxSuppression::max_boxes_output_from_input() const { int64_t max_output_boxes{0}; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto max_output_boxes_input = get_constant_from_source(input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto max_output_boxes_input = ov::util::get_constant_from_source(input_value(2)); max_output_boxes = max_output_boxes_input->cast_vector().at(0); return max_output_boxes; @@ -179,9 +178,7 @@ void op::v3::NonMaxSuppression::validate_and_infer_types() { int64_t op::v3::NonMaxSuppression::max_boxes_output_from_input() const { int64_t max_output_boxes{0}; - OPENVINO_SUPPRESS_DEPRECATED_START - const auto max_output_boxes_input = get_constant_from_source(input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto max_output_boxes_input = ov::util::get_constant_from_source(input_value(2)); max_output_boxes = max_output_boxes_input->cast_vector().at(0); return max_output_boxes; @@ -450,9 +447,7 @@ int64_t op::v5::NonMaxSuppression::max_boxes_output_from_input() const { return 0; } - OPENVINO_SUPPRESS_DEPRECATED_START - const auto max_output_boxes_input = get_constant_from_source(input_value(max_output_boxes_port)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto max_output_boxes_input = ov::util::get_constant_from_source(input_value(max_output_boxes_port)); max_output_boxes = max_output_boxes_input->cast_vector().at(0); return max_output_boxes; @@ -465,9 +460,7 @@ float op::v5::NonMaxSuppression::iou_threshold_from_input() const { return iou_threshold; } - OPENVINO_SUPPRESS_DEPRECATED_START - const auto iou_threshold_input = get_constant_from_source(input_value(iou_threshold_port)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto iou_threshold_input = ov::util::get_constant_from_source(input_value(iou_threshold_port)); iou_threshold = iou_threshold_input->cast_vector().at(0); return iou_threshold; @@ -481,7 +474,7 @@ float op::v5::NonMaxSuppression::score_threshold_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto score_threshold_input = get_constant_from_source(input_value(score_threshold_port)); + const auto score_threshold_input = ov::util::get_constant_from_source(input_value(score_threshold_port)); OPENVINO_SUPPRESS_DEPRECATED_END score_threshold = score_threshold_input->cast_vector().at(0); @@ -496,7 +489,7 @@ float op::v5::NonMaxSuppression::soft_nms_sigma_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto soft_nms_sigma_input = get_constant_from_source(input_value(soft_nms_sigma_port)); + const auto soft_nms_sigma_input = ov::util::get_constant_from_source(input_value(soft_nms_sigma_port)); OPENVINO_SUPPRESS_DEPRECATED_END soft_nms_sigma = soft_nms_sigma_input->cast_vector().at(0); @@ -686,7 +679,7 @@ int64_t op::v9::NonMaxSuppression::max_boxes_output_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto max_output_boxes_input = get_constant_from_source(input_value(max_output_boxes_port)); + const auto max_output_boxes_input = ov::util::get_constant_from_source(input_value(max_output_boxes_port)); OPENVINO_SUPPRESS_DEPRECATED_END max_output_boxes = max_output_boxes_input->cast_vector().at(0); @@ -701,7 +694,7 @@ float op::v9::NonMaxSuppression::iou_threshold_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto iou_threshold_input = get_constant_from_source(input_value(iou_threshold_port)); + const auto iou_threshold_input = ov::util::get_constant_from_source(input_value(iou_threshold_port)); OPENVINO_SUPPRESS_DEPRECATED_END iou_threshold = iou_threshold_input->cast_vector().at(0); @@ -716,7 +709,7 @@ float op::v9::NonMaxSuppression::score_threshold_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto score_threshold_input = get_constant_from_source(input_value(score_threshold_port)); + const auto score_threshold_input = ov::util::get_constant_from_source(input_value(score_threshold_port)); OPENVINO_SUPPRESS_DEPRECATED_END score_threshold = score_threshold_input->cast_vector().at(0); @@ -731,7 +724,7 @@ float op::v9::NonMaxSuppression::soft_nms_sigma_from_input() const { } OPENVINO_SUPPRESS_DEPRECATED_START - const auto soft_nms_sigma_input = get_constant_from_source(input_value(soft_nms_sigma_port)); + const auto soft_nms_sigma_input = ov::util::get_constant_from_source(input_value(soft_nms_sigma_port)); OPENVINO_SUPPRESS_DEPRECATED_END soft_nms_sigma = soft_nms_sigma_input->cast_vector().at(0); diff --git a/src/core/src/op/normalize_l2.cpp b/src/core/src/op/normalize_l2.cpp index 4b33d5ee93e..a5dc52b40b9 100644 --- a/src/core/src/op/normalize_l2.cpp +++ b/src/core/src/op/normalize_l2.cpp @@ -5,7 +5,7 @@ #include "openvino/op/normalize_l2.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" using namespace std; @@ -57,14 +57,10 @@ void ov::op::v0::NormalizeL2::validate_and_infer_types() { ov::AxisSet ov::op::v0::NormalizeL2::get_reduction_axes() const { AxisSet axes; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto const_op = ov::get_constant_from_source(input_value(1))) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto const_op = ov::util::get_constant_from_source(input_value(1))) { const auto const_data = const_op->cast_vector(); const auto input_data_rank = get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto normalized_axes = ov::normalize_axes(get_friendly_name(), const_data, input_data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto normalized_axes = ov::util::normalize_axes(get_friendly_name(), const_data, input_data_rank); axes = AxisSet{normalized_axes}; } return axes; diff --git a/src/core/src/op/reverse_sequence.cpp b/src/core/src/op/reverse_sequence.cpp index 9e5c1bbcf2e..eefc6f633a9 100644 --- a/src/core/src/op/reverse_sequence.cpp +++ b/src/core/src/op/reverse_sequence.cpp @@ -9,8 +9,8 @@ #include "itt.hpp" #include "openvino/core/attribute_visitor.hpp" -#include "openvino/core/validation_util.hpp" #include "reverse_sequence_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { op::v0::ReverseSequence::ReverseSequence(const Output& arg, @@ -41,9 +41,7 @@ void op::v0::ReverseSequence::validate_and_infer_types() { const auto output_shape = shape_infer(this, ov::util::get_node_input_partial_shapes(*this)).front(); set_output_type(0, get_input_element_type(0), output_shape); - OPENVINO_SUPPRESS_DEPRECATED_START - m_normalized_seq_axis = ov::normalize_axis(this, m_seq_axis, get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + m_normalized_seq_axis = ov::util::normalize_axis(this, m_seq_axis, get_input_partial_shape(0).rank()); } std::shared_ptr op::v0::ReverseSequence::clone_with_new_inputs(const OutputVector& new_args) const { @@ -58,15 +56,11 @@ void op::v0::ReverseSequence::set_batch_axis(int64_t batch_axis) { size_t op::v0::ReverseSequence::get_batch_axis() const { const auto& data_rank = get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START - return static_cast(ov::normalize_axis(this, m_batch_axis, data_rank)); - OPENVINO_SUPPRESS_DEPRECATED_END + return static_cast(ov::util::normalize_axis(this, m_batch_axis, data_rank)); } void op::v0::ReverseSequence::set_sequence_axis(int64_t sequence_axis) { m_seq_axis = sequence_axis; - OPENVINO_SUPPRESS_DEPRECATED_START - m_normalized_seq_axis = ov::normalize_axis(this, m_seq_axis, get_input_partial_shape(0).rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + m_normalized_seq_axis = ov::util::normalize_axis(this, m_seq_axis, get_input_partial_shape(0).rank()); } } // namespace ov diff --git a/src/core/src/op/scatter_update.cpp b/src/core/src/op/scatter_update.cpp index 4c9f82b36f6..f32b6e55c28 100644 --- a/src/core/src/op/scatter_update.cpp +++ b/src/core/src/op/scatter_update.cpp @@ -60,9 +60,7 @@ bool ScatterUpdate::evaluate(TensorVector& outputs, const TensorVector& inputs) output.set_shape(data_shape); auto axis_val = get_tensor_data_as(axis)[0]; - OPENVINO_SUPPRESS_DEPRECATED_START - axis_val = ov::normalize_axis(this, axis_val, static_cast(data_shape.size())); - OPENVINO_SUPPRESS_DEPRECATED_END + axis_val = ov::util::normalize_axis(this, axis_val, static_cast(data_shape.size())); const auto indices_casted_vector = get_tensor_data_as(indices); diff --git a/src/core/src/op/shuffle_channels.cpp b/src/core/src/op/shuffle_channels.cpp index d34396f1bc4..29f998dbd7e 100644 --- a/src/core/src/op/shuffle_channels.cpp +++ b/src/core/src/op/shuffle_channels.cpp @@ -32,9 +32,7 @@ bool ShuffleChannels::visit_attributes(AttributeVisitor& visitor) { size_t ShuffleChannels::get_zero_based_axis() const { const auto input_rank = get_input_partial_shape(0).rank(); if (input_rank.is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::normalize_axis(this, m_axis, input_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::normalize_axis(this, m_axis, input_rank); } else { OPENVINO_THROW("Cannot request zero-based axis with a input of unknown rank"); } diff --git a/src/core/src/op/slice.cpp b/src/core/src/op/slice.cpp index 7f94ce5ab46..03811bd10ed 100644 --- a/src/core/src/op/slice.cpp +++ b/src/core/src/op/slice.cpp @@ -8,6 +8,7 @@ #include "itt.hpp" #include "openvino/reference/slice.hpp" #include "slice_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -146,9 +147,7 @@ bool Slice::evaluate_upper(ov::TensorVector& output_values) const { } bool Slice::evaluate_label(TensorLabelVector& output_labels) const { - OPENVINO_SUPPRESS_DEPRECATED_START - return slice_bound_check(this) && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return slice_bound_check(this) && ov::util::default_label_evaluator(this, output_labels); } } // namespace v8 } // namespace op diff --git a/src/core/src/op/split.cpp b/src/core/src/op/split.cpp index a8f938c4a2c..7567fc3e7e0 100644 --- a/src/core/src/op/split.cpp +++ b/src/core/src/op/split.cpp @@ -8,9 +8,9 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/split.hpp" #include "split_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -120,9 +120,7 @@ bool Split::evaluate_upper(ov::TensorVector& output_values) const { bool Split::evaluate_label(TensorLabelVector& output_labels) const { OPENVINO_ASSERT(output_labels.size() == get_num_splits()); - OPENVINO_SUPPRESS_DEPRECATED_START - return get_input_tensor(1).has_and_set_bound() && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return get_input_tensor(1).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); } } // namespace v1 } // namespace op diff --git a/src/core/src/op/squeeze.cpp b/src/core/src/op/squeeze.cpp index 83a45cedbdf..86e99677b5a 100644 --- a/src/core/src/op/squeeze.cpp +++ b/src/core/src/op/squeeze.cpp @@ -8,9 +8,9 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/constant.hpp" #include "squeeze_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -101,9 +101,7 @@ bool Squeeze::evaluate_upper(TensorVector& output_values) const { } bool Squeeze::evaluate_label(TensorLabelVector& output_labels) const { - OPENVINO_SUPPRESS_DEPRECATED_START - return validate::axes_has_and_set_bound(*this) && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return validate::axes_has_and_set_bound(*this) && ov::util::default_label_evaluator(this, output_labels); } bool Squeeze::constant_fold(OutputVector& output_values, const OutputVector& inputs_values) { diff --git a/src/core/src/op/tile.cpp b/src/core/src/op/tile.cpp index 8d660d4563c..6f56996435a 100644 --- a/src/core/src/op/tile.cpp +++ b/src/core/src/op/tile.cpp @@ -9,6 +9,7 @@ #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "openvino/reference/tile.hpp" #include "tile_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -85,9 +86,7 @@ bool Tile::evaluate_label(TensorLabelVector& output_labels) const { OV_OP_SCOPE(v0_Tile_evaluate_label); OPENVINO_ASSERT(output_labels.size() == 1); - OPENVINO_SUPPRESS_DEPRECATED_START - return get_input_tensor(1).has_and_set_bound() && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return get_input_tensor(1).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); } } // namespace v0 } // namespace op diff --git a/src/core/src/op/transpose.cpp b/src/core/src/op/transpose.cpp index d07cd72a29d..e4cb7d7ae32 100644 --- a/src/core/src/op/transpose.cpp +++ b/src/core/src/op/transpose.cpp @@ -6,9 +6,9 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/transpose.hpp" #include "transpose_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -78,9 +78,7 @@ bool Transpose::evaluate_upper(ov::TensorVector& output_values) const { } bool Transpose::evaluate_label(TensorLabelVector& output_labels) const { - OPENVINO_SUPPRESS_DEPRECATED_START - return get_input_tensor(ORDER).has_and_set_bound() && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return get_input_tensor(ORDER).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); } } // namespace v1 } // namespace op diff --git a/src/core/src/op/unique.cpp b/src/core/src/op/unique.cpp index 21d68558410..b9c6016334a 100644 --- a/src/core/src/op/unique.cpp +++ b/src/core/src/op/unique.cpp @@ -6,9 +6,9 @@ #include "element_visitor.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/unique.hpp" #include "openvino/op/util/op_types.hpp" +#include "validation_util.hpp" namespace ov { namespace { @@ -141,9 +141,7 @@ void op::v10::Unique::validate_and_infer_types() { extract_axis(std::dynamic_pointer_cast(input_value(1).get_node_shared_ptr())); if (input_shape.rank().is_static()) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto normalized_axis = ov::normalize_axis(this, axis, input_shape.rank()); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto normalized_axis = ov::util::normalize_axis(this, axis, input_shape.rank()); const auto dim_at_axis = input_shape[normalized_axis]; Dimension output_dim_at_axis; diff --git a/src/core/src/op/unsqueeze.cpp b/src/core/src/op/unsqueeze.cpp index ed581328b40..61600c0e30d 100644 --- a/src/core/src/op/unsqueeze.cpp +++ b/src/core/src/op/unsqueeze.cpp @@ -10,8 +10,8 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "unsqueeze_shape_inference.hpp" +#include "validation_util.hpp" ov::op::v0::Unsqueeze::Unsqueeze(const ov::Output& data, const ov::Output& axes) : Op({data, axes}) { @@ -74,9 +74,7 @@ bool ov::op::v0::Unsqueeze::evaluate_upper(ov::TensorVector& output_values) cons bool ov::op::v0::Unsqueeze::evaluate_label(TensorLabelVector& output_labels) const { if (!get_input_tensor(1).has_and_set_bound()) return false; - OPENVINO_SUPPRESS_DEPRECATED_START - return default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::default_label_evaluator(this, output_labels); } bool ov::op::v0::Unsqueeze::constant_fold(OutputVector& output_values, const OutputVector& inputs_values) { diff --git a/src/core/src/op/util/axes_util.cpp b/src/core/src/op/util/axes_util.cpp index 1736025527f..6b5539cae88 100644 --- a/src/core/src/op/util/axes_util.cpp +++ b/src/core/src/op/util/axes_util.cpp @@ -4,8 +4,8 @@ #include "openvino/op/util/axes_util.hpp" -#include "openvino/core/validation_util.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -13,9 +13,7 @@ namespace util { AxisSet get_normalized_axes_from_tensor(const Node* const node, const Tensor& tensor, const Rank& rank) { const auto axes = ov::get_tensor_data_as(tensor); - OPENVINO_SUPPRESS_DEPRECATED_START - return {normalize_axes(node->get_friendly_name(), axes, rank)}; - OPENVINO_SUPPRESS_DEPRECATED_END + return {ov::util::normalize_axes(node->get_friendly_name(), axes, rank)}; } } // namespace util } // namespace op diff --git a/src/core/src/op/util/broadcast_base.cpp b/src/core/src/op/util/broadcast_base.cpp index 86abeed1455..adf496d43f8 100644 --- a/src/core/src/op/util/broadcast_base.cpp +++ b/src/core/src/op/util/broadcast_base.cpp @@ -8,10 +8,10 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "openvino/reference/broadcast.hpp" +#include "validation_util.hpp" ov::op::util::BroadcastBase::BroadcastBase(const Output& arg, const Output& target_shape, @@ -190,9 +190,7 @@ void ov::op::util::BroadcastBase::validate_and_infer_types() { } PartialShape output_shape; - OPENVINO_SUPPRESS_DEPRECATED_START - bool output_shape_defined = ov::evaluate_as_partial_shape(get_input_source_output(1), output_shape); - OPENVINO_SUPPRESS_DEPRECATED_END + bool output_shape_defined = ov::util::evaluate_as_partial_shape(get_input_source_output(1), output_shape); if (auto concat = ov::as_type_ptr(input_value(1).get_node_shared_ptr())) { auto concat_inputs = concat->inputs(); @@ -233,9 +231,7 @@ void ov::op::util::BroadcastBase::validate_and_infer_types() { input_rank); if (output_shape_defined && has_and_set_equal_bounds(input_value(2))) { - OPENVINO_SUPPRESS_DEPRECATED_START - auto axes_mapping_val = get_constant_from_source(input_value(2))->get_axis_vector_val(); - OPENVINO_SUPPRESS_DEPRECATED_END + auto axes_mapping_val = ov::util::get_constant_from_source(input_value(2))->get_axis_vector_val(); validate_target_shape_none(arg_shape, axes_mapping_val, output_shape); } } @@ -292,9 +288,7 @@ std::pair ov::op::util::BroadcastBase::get_broadcast_axes() c bool axes_known = false; if (m_mode.m_type == BroadcastType::NONE) { - OPENVINO_SUPPRESS_DEPRECATED_START - const auto axes_mapping_constant = get_constant_from_source(input_value(2)); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto axes_mapping_constant = ov::util::get_constant_from_source(input_value(2)); if (get_input_partial_shape(1).is_static() && axes_mapping_constant) { auto axes_mapping_val = axes_mapping_constant->get_axis_vector_val(); auto target_shape = get_input_shape(1); diff --git a/src/core/src/op/util/gather_base.cpp b/src/core/src/op/util/gather_base.cpp index 6d6f338bb50..a05bcdf1c55 100644 --- a/src/core/src/op/util/gather_base.cpp +++ b/src/core/src/op/util/gather_base.cpp @@ -227,7 +227,7 @@ bool GatherBase::evaluate_upper(TensorVector& output_values) const { bool GatherBase::evaluate_label(TensorLabelVector& output_labels) const { OPENVINO_SUPPRESS_DEPRECATED_START - return gather::have_indices_and_axis_bound_set(this) && default_label_evaluator(this, output_labels); + return gather::have_indices_and_axis_bound_set(this) && ov::util::default_label_evaluator(this, output_labels); OPENVINO_SUPPRESS_DEPRECATED_END } diff --git a/src/core/src/op/util/pad_base.cpp b/src/core/src/op/util/pad_base.cpp index 5f08445ea43..0b6a90ee773 100644 --- a/src/core/src/op/util/pad_base.cpp +++ b/src/core/src/op/util/pad_base.cpp @@ -10,6 +10,7 @@ #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "openvino/reference/pad.hpp" #include "pad_shape_inference.hpp" +#include "validation_util.hpp" namespace ov { op::util::PadBase::PadBase(const Output& arg, @@ -35,9 +36,7 @@ op::util::PadBase::PadBase(const Output& arg, CoordinateDiff op::util::PadBase::get_pads_begin() const { CoordinateDiff pads_begin_coord{}; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto pads_begin_const = get_constant_from_source(input_value(1))) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto pads_begin_const = ov::util::get_constant_from_source(input_value(1))) { pads_begin_coord = pads_begin_const->cast_vector(); } return pads_begin_coord; @@ -45,9 +44,7 @@ CoordinateDiff op::util::PadBase::get_pads_begin() const { CoordinateDiff op::util::PadBase::get_pads_end() const { CoordinateDiff pads_end_coord{}; - OPENVINO_SUPPRESS_DEPRECATED_START - if (auto pads_end_const = get_constant_from_source(input_value(2))) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (auto pads_end_const = ov::util::get_constant_from_source(input_value(2))) { pads_end_coord = pads_end_const->cast_vector(); } return pads_end_coord; @@ -155,9 +152,7 @@ bool op::util::PadBase::evaluate_upper(TensorVector& output_values) const { bool op::util::PadBase::evaluate_label(TensorLabelVector& output_labels) const { OV_OP_SCOPE(util_PadBase_evaluate_label); - OPENVINO_SUPPRESS_DEPRECATED_START - return default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::default_label_evaluator(this, output_labels); } } // namespace ov diff --git a/src/core/src/op/util/reduction_base.cpp b/src/core/src/op/util/reduction_base.cpp index 30d56715c24..f6d665d7da2 100644 --- a/src/core/src/op/util/reduction_base.cpp +++ b/src/core/src/op/util/reduction_base.cpp @@ -28,9 +28,7 @@ const ov::AxisSet ov::op::util::ReductionBase::get_reduction_axes() const { if (const auto& const_op = ov::util::get_constant_from_source(input_value(1))) { const auto const_data = const_op->cast_vector(); const auto input_data_rank = get_input_partial_shape(0).rank(); - OPENVINO_SUPPRESS_DEPRECATED_START - const auto normalized_axes = ov::normalize_axes(get_friendly_name(), const_data, input_data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const auto normalized_axes = ov::util::normalize_axes(get_friendly_name(), const_data, input_data_rank); return {normalized_axes}; } else { return {}; diff --git a/src/core/src/op/util/scatter_base.cpp b/src/core/src/op/util/scatter_base.cpp index 8ae559ffbc3..602f7901365 100644 --- a/src/core/src/op/util/scatter_base.cpp +++ b/src/core/src/op/util/scatter_base.cpp @@ -5,7 +5,7 @@ #include "openvino/op/util/scatter_base.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" ov::op::util::ScatterBase::ScatterBase(const Output& data, const Output& indices, @@ -70,13 +70,11 @@ void ov::op::util::ScatterBase::validate_and_infer_types() { return; // Get axis value if possible. - OPENVINO_SUPPRESS_DEPRECATED_START - if (const auto& axis_const_input = get_constant_from_source(input_value(AXIS))) { + if (const auto& axis_const_input = ov::util::get_constant_from_source(input_value(AXIS))) { bool compatible = true; int64_t axis = axis_const_input->cast_vector().at(0); - int64_t data_rank = data_shape.rank().get_length(); - axis = ov::normalize_axis(this, axis, data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + const int64_t data_rank = data_shape.rank().get_length(); + axis = ov::util::normalize_axis(this, axis, data_rank); if (indices_shape.rank().is_static() && updates_shape.rank().is_static()) { int64_t indices_rank = indices_shape.rank().get_length(); diff --git a/src/core/src/op/util/scatter_elements_update_base.cpp b/src/core/src/op/util/scatter_elements_update_base.cpp index 8b6fdcacd4b..0c65ddf8006 100644 --- a/src/core/src/op/util/scatter_elements_update_base.cpp +++ b/src/core/src/op/util/scatter_elements_update_base.cpp @@ -6,9 +6,9 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "scatter_elements_update_shape_inference.hpp" #include "utils.hpp" +#include "validation_util.hpp" namespace ov { namespace op { @@ -110,9 +110,7 @@ int64_t util::ScatterElementsUpdateBase::get_normalized_axis(const TensorVector& const auto axis = get_tensor_data_as(axis_input)[0]; const auto data_rank = static_cast(inputs[0].get_shape().size()); - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::normalize_axis(this, axis, data_rank); - OPENVINO_SUPPRESS_DEPRECATED_END + return ov::util::normalize_axis(this, axis, data_rank); } } // namespace op } // namespace ov diff --git a/src/core/src/op/util/topk_base.cpp b/src/core/src/op/util/topk_base.cpp index bc2db6190b5..80c23c59edc 100644 --- a/src/core/src/op/util/topk_base.cpp +++ b/src/core/src/op/util/topk_base.cpp @@ -9,6 +9,7 @@ #include "itt.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "topk_shape_inference.hpp" +#include "validation_util.hpp" namespace { constexpr auto UNKNOWN_NORMALIZED_AXIS = std::numeric_limits::max(); @@ -148,9 +149,8 @@ void ov::op::util::TopKBase::set_axis(const int64_t axis) { } void ov::op::util::TopKBase::set_axis(const Rank& input_rank, const int64_t axis) { - OPENVINO_SUPPRESS_DEPRECATED_START - m_normalized_axis = input_rank.is_static() ? normalize_axis(this, axis, input_rank) : UNKNOWN_NORMALIZED_AXIS; - OPENVINO_SUPPRESS_DEPRECATED_END + m_normalized_axis = + input_rank.is_static() ? ov::util::normalize_axis(this, axis, input_rank) : UNKNOWN_NORMALIZED_AXIS; m_axis = axis; } diff --git a/src/core/src/op/variadic_split.cpp b/src/core/src/op/variadic_split.cpp index 8319dd578ff..7a8d4e55528 100644 --- a/src/core/src/op/variadic_split.cpp +++ b/src/core/src/op/variadic_split.cpp @@ -9,8 +9,8 @@ #include "bound_evaluate.hpp" #include "compare.hpp" #include "itt.hpp" -#include "openvino/core/validation_util.hpp" #include "openvino/reference/slice.hpp" +#include "validation_util.hpp" #include "variadic_split_shape_inference.hpp" namespace ov { @@ -121,9 +121,8 @@ bool VariadicSplit::evaluate_upper(TensorVector& output_values) const { } bool VariadicSplit::evaluate_label(TensorLabelVector& output_labels) const { - OPENVINO_SUPPRESS_DEPRECATED_START - return variadic_split::has_axis_and_splits_bound_set(this) && default_label_evaluator(this, output_labels); - OPENVINO_SUPPRESS_DEPRECATED_END + return variadic_split::has_axis_and_splits_bound_set(this) && + ov::util::default_label_evaluator(this, output_labels); } } // namespace v1 } // namespace op diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp index 0048585bf10..5a4f9dce1c0 100644 --- a/src/core/src/validation_util.cpp +++ b/src/core/src/validation_util.cpp @@ -968,48 +968,13 @@ void ov::infer_auto_padding(const Shape& image_shape, const op::PadType pad_type, CoordinateDiff& padding_above, CoordinateDiff& padding_below) { - const auto image_dims = std::vector(std::begin(image_shape), std::end(image_shape)); - // because image_shape is fully known result of try_apply_infer_auto_padding is ignored - ov::util::try_apply_auto_padding(image_dims, - filter_shape, - filter_strides, - filter_dilations, - pad_type, - padding_above, - padding_below); -} - -bool ov::util::try_apply_auto_padding(const PartialShape& image_shape, - const Shape& filter_shape, - const Strides& filter_strides, - const Strides& filter_dilations, - const op::PadType pad_type, - CoordinateDiff& padding_above, - CoordinateDiff& padding_below) { - OPENVINO_ASSERT(pad_type == op::PadType::SAME_UPPER || pad_type == op::PadType::SAME_LOWER); - - if (image_shape.rank().is_dynamic()) { - return false; - } - const auto image_dims = static_cast>(image_shape); - for (size_t i = 0; i < static_cast(filter_shape.size()); i++) { - if (image_dims[i + 2].is_static()) { - auto image_size = static_cast(image_dims[i + 2].get_length()); - int64_t filter_size = (static_cast(filter_shape[i]) - 1) * filter_dilations[i] + 1; - auto filter_stride = static_cast(filter_strides[i]); - auto output_size = (image_size + filter_stride - 1) / filter_stride; - - auto padding_needed = std::max(int64_t(0), (output_size - 1) * filter_stride + filter_size - image_size); - auto padding_lhs = padding_needed / 2; - auto padding_rhs = padding_needed - padding_lhs; - padding_below.push_back(pad_type == op::PadType::SAME_UPPER ? padding_lhs : padding_rhs); - padding_above.push_back(pad_type == op::PadType::SAME_UPPER ? padding_rhs : padding_lhs); - } else { - padding_below.push_back(0); - padding_above.push_back(0); - } - } - return true; + ov::util::infer_auto_padding(image_shape, + filter_shape, + filter_strides, + filter_dilations, + pad_type, + padding_above, + padding_below); } namespace { @@ -1037,47 +1002,21 @@ int64_t ov::util::normalize(const int64_t& value, const int64_t& max) { }; void ov::normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes) { - const auto axis_checker = cmp::Between(-tensor_rank, tensor_rank ? (tensor_rank - 1) : 0); - const auto invalid_axis = std::find_if_not(axes.cbegin(), axes.cend(), axis_checker); - NODE_VALIDATION_CHECK(node, - invalid_axis == axes.cend(), - normalize_axis_error_msg(*invalid_axis, axis_checker.lower(), axis_checker.upper())); - std::for_each(axes.begin(), axes.end(), normalize_axis_to(tensor_rank)); + ov::util::normalize_axes(node, tensor_rank, axes); } std::vector ov::normalize_axes(const std::string& node_description, const std::vector& axes, const Rank& tensor_rank) { - std::vector new_axes; - new_axes.reserve(axes.size()); - for (const auto& axis : axes) { - new_axes.push_back(normalize_axis(node_description, axis, tensor_rank)); - } - return new_axes; + return ov::util::normalize_axes(node_description, axes, tensor_rank); } int64_t ov::normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank) { - return normalize_axis(node->description(), axis, tensor_rank); + return ov::util::normalize_axis(node, axis, tensor_rank); } int64_t ov::normalize_axis(const std::string& node_description, std::int64_t axis, const Rank& tensor_rank) { - if (axis < 0) { - // Handling negative axis requires static tensor rank - OPENVINO_ASSERT(tensor_rank.is_static(), - node_description, - " Rank must be static in order to normalize negative axis=", - axis); - } - if (tensor_rank.is_dynamic()) { - return axis; - } - - const auto tensor_rank_value = tensor_rank.get_length(); - return normalize_axis(node_description, - axis, - tensor_rank_value, - -tensor_rank_value, - tensor_rank_value ? (tensor_rank_value - 1) : 0); + return ov::util::normalize_axis(node_description, axis, tensor_rank); } int64_t ov::normalize_axis(const Node* node, @@ -1085,7 +1024,7 @@ int64_t ov::normalize_axis(const Node* node, std::uint64_t tensor_rank, std::int64_t axis_range_min, std::int64_t axis_range_max) { - return normalize_axis(node->description(), axis, tensor_rank, axis_range_min, axis_range_max); + return ov::util::normalize_axis(node, axis, tensor_rank, axis_range_min, axis_range_max); } int64_t ov::normalize_axis(const std::string& node_description, @@ -1093,48 +1032,15 @@ int64_t ov::normalize_axis(const std::string& node_description, std::uint64_t tensor_rank, std::int64_t axis_range_min, std::int64_t axis_range_max) { - // Accepted range of value for axis is [axis_range_min, axis_range_max]. - OPENVINO_ASSERT((axis_range_min <= axis) && (axis <= axis_range_max), - node_description, - normalize_axis_error_msg(axis, axis_range_min, axis_range_max)); - return util::normalize(axis, tensor_rank); + return ov::util::normalize_axis(node_description, axis, tensor_rank, axis_range_min, axis_range_max); } bool ov::evaluate_as_partial_shape(const Output& output, PartialShape& pshape) { - Tensor lb, ub; - std::tie(lb, ub) = ov::evaluate_both_bounds(output); - bool shape_defined = false; - if (lb && ub) { - auto lower_bound = std::make_shared(lb.get_element_type(), lb.get_shape(), lb.data()) - ->cast_vector(); - auto upper_bound = std::make_shared(ub.get_element_type(), ub.get_shape(), ub.data()) - ->cast_vector(); - OPENVINO_ASSERT(lower_bound.size() == upper_bound.size()); - const TensorLabel& labels = output.get_tensor().get_value_label(); - OPENVINO_ASSERT(labels.empty() || lower_bound.size() == labels.size()); - - std::vector resulting_pshape(lower_bound.size()); - for (size_t i = 0; i < lower_bound.size(); ++i) { - auto low = lower_bound[i], up = upper_bound[i]; - OPENVINO_ASSERT(low >= 0 && up >= 0, "Value for partial shape evaluation can't be lower than zero."); - if (output.get_element_type() == element::i32 && low != up) { - if (up == std::numeric_limits::max()) - up = std::numeric_limits::max(); - if (low == std::numeric_limits::max()) - low = std::numeric_limits::max(); - } - resulting_pshape[i] = {low, up}; - if (!labels.empty() && labels[i]) - ov::DimensionTracker::set_label(resulting_pshape[i], labels[i]); - } - pshape = PartialShape(resulting_pshape); - shape_defined = true; - } - return shape_defined; + return ov::util::evaluate_as_partial_shape(output, pshape); } bool ov::default_label_evaluator(const Node* node, TensorLabelVector& output_labels) { - return default_label_evaluator(node, {0}, output_labels); + return ov::util::default_label_evaluator(node, output_labels); } std::shared_ptr ov::get_constant_from_source(const Output& source) { @@ -1142,17 +1048,15 @@ std::shared_ptr ov::get_constant_from_source(const Output< } bool ov::has_no_labels(const ov::TensorLabel& labels) { - return std::all_of(labels.cbegin(), labels.cend(), cmp::Equal(no_label)); + return ov::util::has_no_labels(labels); } void ov::generate_transpose_default_order(std::vector& axes_order, const size_t length) { - axes_order.reserve(length); - std::generate_n(std::back_inserter(axes_order), length, ov::SeqGen(length - 1)); + ov::util::generate_transpose_default_order(axes_order, length); } bool ov::is_valid_axes_order(const std::vector& axes_order, const size_t size) { - return util::are_unique(axes_order) && - std::all_of(axes_order.cbegin(), axes_order.cend(), ov::cmp::Between(0, size)); + return ov::util::is_valid_axes_order(axes_order, size); } bool ov::util::are_unique(const std::vector& data) { @@ -1198,7 +1102,7 @@ std::shared_ptr ov::util::constantfold_subgraph(const Outp } // -// Infers the output batch shape and element type for convolution fprop. +// Infers the output batch shape for convolution fprop. // ov::PartialShape ov::infer_convolution_forward(const Node* node, const PartialShape& data_batch_shape, @@ -1208,117 +1112,14 @@ ov::PartialShape ov::infer_convolution_forward(const Node* node, const PartialShape& filters_shape, const Strides& filter_strides, const Strides& filter_dilation) { - Rank data_batch_filters_rank{Rank::dynamic()}; - - NODE_VALIDATION_CHECK(node, - Rank::merge(data_batch_filters_rank, data_batch_shape.rank(), filters_shape.rank()), - "Data batch and filters rank do not match (data batch shape: ", - data_batch_shape, - ", filters shape: ", - filters_shape, - ")."); - - NODE_VALIDATION_CHECK(node, - data_batch_filters_rank.is_dynamic() || data_batch_filters_rank.get_length() >= 3, - "Data batch and filters must have rank of at least 3 (one batch axis, ", - "one input-channel axis, and at least one spatial dimension) ", - "(data batch shape: ", - data_batch_shape, - ", filters shape: ", - filters_shape, - ")."); - - Rank spatial_rank{Rank::dynamic()}; - NODE_VALIDATION_CHECK(node, - Rank::merge(spatial_rank, spatial_rank, data_batch_filters_rank - 2) && - Rank::merge(spatial_rank, spatial_rank, data_dilation.size()) && - Rank::merge(spatial_rank, spatial_rank, data_padding_below.size()) && - Rank::merge(spatial_rank, spatial_rank, data_padding_above.size()) && - Rank::merge(spatial_rank, spatial_rank, filter_strides.size()) && - Rank::merge(spatial_rank, spatial_rank, filter_dilation.size()), - "Ranks for data item shape/filters shape (data batch has shape ", - data_batch_shape, - ", so data item rank is ", - (data_batch_shape.rank() - 2), - " and filters have shape ", - filters_shape, - ", so filters spatial rank is ", - (filters_shape.rank() - 2), - "), data dilation (", - data_dilation, - "), padding below (", - data_padding_below, - "), padding above (", - data_padding_above, - "), filter strides (", - filter_strides, - "), and filter dilation (", - filter_dilation, - ") do not match."); - - Dimension batch_size = (data_batch_shape.rank().is_static() ? data_batch_shape[0] : Dimension::dynamic()); - Dimension data_channel_count = (data_batch_shape.rank().is_static() ? data_batch_shape[1] : Dimension::dynamic()); - PartialShape data_spatial_shape(PartialShape::dynamic(spatial_rank)); - - Dimension filter_output_channel_count = - (filters_shape.rank().is_static() ? filters_shape[0] : Dimension::dynamic()); - Dimension filter_input_channel_count = (filters_shape.rank().is_static() ? filters_shape[1] : Dimension::dynamic()); - PartialShape filter_spatial_shape(PartialShape::dynamic(spatial_rank)); - - // - // Note: spatial_rank is definitely static at this point. - // - - for (int64_t i = 0; i < spatial_rank.get_length(); i++) { - if (data_batch_shape.rank().is_static()) { - data_spatial_shape[i] = data_batch_shape[i + 2]; - } - - if (filters_shape.rank().is_static()) { - filter_spatial_shape[i] = filters_shape[i + 2]; - } - } - - NODE_VALIDATION_CHECK(node, batch_size.is_dynamic() || batch_size.get_length() > 0, "Batch size is zero."); - - Dimension merged_channel_count; - - NODE_VALIDATION_CHECK(node, - Dimension::merge(merged_channel_count, data_channel_count, filter_input_channel_count), - "Data batch channel count (", - data_channel_count, - ") does not match filter input ", - "channel count (", - filter_input_channel_count, - ")."); - - NODE_VALIDATION_CHECK(node, - merged_channel_count.is_dynamic() || merged_channel_count.get_length() > 0, - "Data batch channel count and/or filter input channel count is zero."); - - NODE_VALIDATION_CHECK(node, - filter_output_channel_count.is_dynamic() || filter_output_channel_count.get_length() > 0, - "Filter output channel count is zero."); - - PartialShape data_output_shape = ngraph::infer_windowed_reduction_output_shape(node, - data_spatial_shape, - data_dilation, - data_padding_below, - data_padding_above, - filter_spatial_shape, - filter_strides, - filter_dilation, - true); - - PartialShape batch_output_shape(PartialShape::dynamic(spatial_rank + 2)); - batch_output_shape[0] = batch_size; - batch_output_shape[1] = filter_output_channel_count; - - for (int64_t i = 0; i < spatial_rank.get_length(); i++) { - batch_output_shape[i + 2] = data_output_shape[i]; - } - - return batch_output_shape; + return ov::util::infer_convolution_forward(node, + data_batch_shape, + data_dilation, + data_padding_below, + data_padding_above, + filters_shape, + filter_strides, + filter_dilation); } namespace ov { @@ -1442,5 +1243,292 @@ bool is_rank_compatible_any_of(const Rank& r, std::initializer_list others return r.compatible(other); }); } + +PartialShape infer_convolution_forward(const Node* node, + const PartialShape& data_batch_shape, + const Strides& data_dilation, + const CoordinateDiff& data_padding_below, + const CoordinateDiff& data_padding_above, + const PartialShape& filters_shape, + const Strides& filter_strides, + const Strides& filter_dilation) { + Rank data_batch_filters_rank{Rank::dynamic()}; + + NODE_VALIDATION_CHECK(node, + Rank::merge(data_batch_filters_rank, data_batch_shape.rank(), filters_shape.rank()), + "Data batch and filters rank do not match (data batch shape: ", + data_batch_shape, + ", filters shape: ", + filters_shape, + ")."); + + NODE_VALIDATION_CHECK(node, + data_batch_filters_rank.is_dynamic() || data_batch_filters_rank.get_length() >= 3, + "Data batch and filters must have rank of at least 3 (one batch axis, ", + "one input-channel axis, and at least one spatial dimension) ", + "(data batch shape: ", + data_batch_shape, + ", filters shape: ", + filters_shape, + ")."); + + Rank spatial_rank{Rank::dynamic()}; + NODE_VALIDATION_CHECK(node, + Rank::merge(spatial_rank, spatial_rank, data_batch_filters_rank - 2) && + Rank::merge(spatial_rank, spatial_rank, data_dilation.size()) && + Rank::merge(spatial_rank, spatial_rank, data_padding_below.size()) && + Rank::merge(spatial_rank, spatial_rank, data_padding_above.size()) && + Rank::merge(spatial_rank, spatial_rank, filter_strides.size()) && + Rank::merge(spatial_rank, spatial_rank, filter_dilation.size()), + "Ranks for data item shape/filters shape (data batch has shape ", + data_batch_shape, + ", so data item rank is ", + (data_batch_shape.rank() - 2), + " and filters have shape ", + filters_shape, + ", so filters spatial rank is ", + (filters_shape.rank() - 2), + "), data dilation (", + data_dilation, + "), padding below (", + data_padding_below, + "), padding above (", + data_padding_above, + "), filter strides (", + filter_strides, + "), and filter dilation (", + filter_dilation, + ") do not match."); + + Dimension batch_size = (data_batch_shape.rank().is_static() ? data_batch_shape[0] : Dimension::dynamic()); + Dimension data_channel_count = (data_batch_shape.rank().is_static() ? data_batch_shape[1] : Dimension::dynamic()); + PartialShape data_spatial_shape(PartialShape::dynamic(spatial_rank)); + + Dimension filter_output_channel_count = + (filters_shape.rank().is_static() ? filters_shape[0] : Dimension::dynamic()); + Dimension filter_input_channel_count = (filters_shape.rank().is_static() ? filters_shape[1] : Dimension::dynamic()); + PartialShape filter_spatial_shape(PartialShape::dynamic(spatial_rank)); + + // + // Note: spatial_rank is definitely static at this point. + // + + for (int64_t i = 0; i < spatial_rank.get_length(); i++) { + if (data_batch_shape.rank().is_static()) { + data_spatial_shape[i] = data_batch_shape[i + 2]; + } + + if (filters_shape.rank().is_static()) { + filter_spatial_shape[i] = filters_shape[i + 2]; + } + } + + NODE_VALIDATION_CHECK(node, batch_size.is_dynamic() || batch_size.get_length() > 0, "Batch size is zero."); + + Dimension merged_channel_count; + + NODE_VALIDATION_CHECK(node, + Dimension::merge(merged_channel_count, data_channel_count, filter_input_channel_count), + "Data batch channel count (", + data_channel_count, + ") does not match filter input ", + "channel count (", + filter_input_channel_count, + ")."); + + NODE_VALIDATION_CHECK(node, + merged_channel_count.is_dynamic() || merged_channel_count.get_length() > 0, + "Data batch channel count and/or filter input channel count is zero."); + + NODE_VALIDATION_CHECK(node, + filter_output_channel_count.is_dynamic() || filter_output_channel_count.get_length() > 0, + "Filter output channel count is zero."); + + PartialShape data_output_shape = ngraph::infer_windowed_reduction_output_shape(node, + data_spatial_shape, + data_dilation, + data_padding_below, + data_padding_above, + filter_spatial_shape, + filter_strides, + filter_dilation, + true); + + PartialShape batch_output_shape(PartialShape::dynamic(spatial_rank + 2)); + batch_output_shape[0] = batch_size; + batch_output_shape[1] = filter_output_channel_count; + + for (int64_t i = 0; i < spatial_rank.get_length(); i++) { + batch_output_shape[i + 2] = data_output_shape[i]; + } + + return batch_output_shape; +} + +bool try_apply_auto_padding(const PartialShape& image_shape, + const Shape& filter_shape, + const Strides& filter_strides, + const Strides& filter_dilations, + const op::PadType pad_type, + CoordinateDiff& padding_above, + CoordinateDiff& padding_below) { + OPENVINO_ASSERT(pad_type == op::PadType::SAME_UPPER || pad_type == op::PadType::SAME_LOWER); + + if (image_shape.rank().is_dynamic()) { + return false; + } + const auto image_dims = static_cast>(image_shape); + for (size_t i = 0; i < static_cast(filter_shape.size()); i++) { + if (image_dims[i + 2].is_static()) { + auto image_size = static_cast(image_dims[i + 2].get_length()); + int64_t filter_size = (static_cast(filter_shape[i]) - 1) * filter_dilations[i] + 1; + auto filter_stride = static_cast(filter_strides[i]); + auto output_size = (image_size + filter_stride - 1) / filter_stride; + + auto padding_needed = std::max(int64_t(0), (output_size - 1) * filter_stride + filter_size - image_size); + auto padding_lhs = padding_needed / 2; + auto padding_rhs = padding_needed - padding_lhs; + padding_below.push_back(pad_type == op::PadType::SAME_UPPER ? padding_lhs : padding_rhs); + padding_above.push_back(pad_type == op::PadType::SAME_UPPER ? padding_rhs : padding_lhs); + } else { + padding_below.push_back(0); + padding_above.push_back(0); + } + } + return true; +} + +void infer_auto_padding(const Shape& image_shape, + const Shape& filter_shape, + const Strides& filter_strides, + const Strides& filter_dilations, + const op::PadType pad_type, + CoordinateDiff& padding_above, + CoordinateDiff& padding_below) { + const auto image_dims = std::vector(std::begin(image_shape), std::end(image_shape)); + // because image_shape is fully known result of try_apply_infer_auto_padding is ignored + try_apply_auto_padding(image_dims, + filter_shape, + filter_strides, + filter_dilations, + pad_type, + padding_above, + padding_below); +} + +bool evaluate_as_partial_shape(const Output& output, PartialShape& pshape) { + Tensor lb, ub; + std::tie(lb, ub) = evaluate_both_bounds(output); + bool shape_defined = false; + if (lb && ub) { + auto lower_bound = std::make_shared(lb.get_element_type(), lb.get_shape(), lb.data()) + ->cast_vector(); + auto upper_bound = std::make_shared(ub.get_element_type(), ub.get_shape(), ub.data()) + ->cast_vector(); + OPENVINO_ASSERT(lower_bound.size() == upper_bound.size()); + const TensorLabel& labels = output.get_tensor().get_value_label(); + OPENVINO_ASSERT(labels.empty() || lower_bound.size() == labels.size()); + + std::vector resulting_pshape(lower_bound.size()); + for (size_t i = 0; i < lower_bound.size(); ++i) { + auto low = lower_bound[i], up = upper_bound[i]; + OPENVINO_ASSERT(low >= 0 && up >= 0, "Value for partial shape evaluation can't be lower than zero."); + if (output.get_element_type() == element::i32 && low != up) { + if (up == std::numeric_limits::max()) + up = std::numeric_limits::max(); + if (low == std::numeric_limits::max()) + low = std::numeric_limits::max(); + } + resulting_pshape[i] = {low, up}; + if (!labels.empty() && labels[i]) + DimensionTracker::set_label(resulting_pshape[i], labels[i]); + } + pshape = PartialShape(resulting_pshape); + shape_defined = true; + } + return shape_defined; +} + +bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels) { + return default_label_evaluator(node, {0}, output_labels); +} + +void generate_transpose_default_order(std::vector& axes_order, const size_t length) { + axes_order.reserve(axes_order.size() + length); + std::generate_n(std::back_inserter(axes_order), length, ov::SeqGen(length - 1)); +} + +bool is_valid_axes_order(const std::vector& axes_order, const size_t size) { + return are_unique(axes_order) && + std::all_of(axes_order.cbegin(), axes_order.cend(), ov::cmp::Between(0, size)); +} + +bool has_no_labels(const ov::TensorLabel& labels) { + return std::all_of(labels.cbegin(), labels.cend(), cmp::Equal(no_label)); +} + +std::vector normalize_axes(const std::string& node_description, + const std::vector& axes, + const Rank& tensor_rank) { + std::vector new_axes; + new_axes.reserve(axes.size()); + for (const auto& axis : axes) { + new_axes.push_back(ov::util::normalize_axis(node_description, axis, tensor_rank)); + } + return new_axes; +} + +void normalize_axes(const Node* node, const int64_t& tensor_rank, std::vector& axes) { + const auto axis_checker = cmp::Between(-tensor_rank, tensor_rank ? (tensor_rank - 1) : 0); + const auto invalid_axis = std::find_if_not(axes.cbegin(), axes.cend(), axis_checker); + NODE_VALIDATION_CHECK(node, + invalid_axis == axes.cend(), + normalize_axis_error_msg(*invalid_axis, axis_checker.lower(), axis_checker.upper())); + std::for_each(axes.begin(), axes.end(), normalize_axis_to(tensor_rank)); +} + +int64_t normalize_axis(const Node* node, std::int64_t axis, const Rank& tensor_rank) { + return ov::util::normalize_axis(node->description(), axis, tensor_rank); +} + +int64_t normalize_axis(const std::string& node_description, std::int64_t axis, const Rank& tensor_rank) { + if (axis < 0) { + // Handling negative axis requires static tensor rank + OPENVINO_ASSERT(tensor_rank.is_static(), + node_description, + " Rank must be static in order to normalize negative axis=", + axis); + } + if (tensor_rank.is_dynamic()) { + return axis; + } + + const auto tensor_rank_value = tensor_rank.get_length(); + return normalize_axis(node_description, + axis, + tensor_rank_value, + -tensor_rank_value, + tensor_rank_value ? (tensor_rank_value - 1) : 0); +} + +int64_t normalize_axis(const Node* node, + std::int64_t axis, + std::uint64_t tensor_rank, + std::int64_t axis_range_min, + std::int64_t axis_range_max) { + return normalize_axis(node->description(), axis, tensor_rank, axis_range_min, axis_range_max); +} + +int64_t normalize_axis(const std::string& node_description, + std::int64_t axis, + std::uint64_t tensor_rank, + std::int64_t axis_range_min, + std::int64_t axis_range_max) { + // Accepted range of value for axis is [axis_range_min, axis_range_max]. + OPENVINO_ASSERT((axis_range_min <= axis) && (axis <= axis_range_max), + node_description, + normalize_axis_error_msg(axis, axis_range_min, axis_range_max)); + return normalize(axis, tensor_rank); +} } // namespace util } // namespace ov diff --git a/src/frontends/tensorflow_common/include/helper_ops/sparse_segment_ops.hpp b/src/frontends/tensorflow_common/include/helper_ops/sparse_segment_ops.hpp index 225ae8d2205..af3e548de4c 100644 --- a/src/frontends/tensorflow_common/include/helper_ops/sparse_segment_ops.hpp +++ b/src/frontends/tensorflow_common/include/helper_ops/sparse_segment_ops.hpp @@ -8,7 +8,7 @@ #include #include "helper_ops/internal_operation.hpp" -#include "openvino/core/validation_util.hpp" +#include "validation_util.hpp" namespace ov { namespace frontend { @@ -56,9 +56,7 @@ public: // num_segments input is optional so it is not always possible to deduce the first dimension of the output shape if (get_input_size() > 3) { ov::PartialShape num_segments_value; - OPENVINO_SUPPRESS_DEPRECATED_START - if (output_rank.is_static() && ov::evaluate_as_partial_shape(input_value(3), num_segments_value)) { - OPENVINO_SUPPRESS_DEPRECATED_END + if (output_rank.is_static() && ov::util::evaluate_as_partial_shape(input_value(3), num_segments_value)) { FRONT_END_OP_CONVERSION_CHECK(output_rank.get_length() >= 1, "Data input of SparseSegmentSum must be of rank >= 1."); output_shape[0] = num_segments_value[0];