From 9093db5febd8f7af76ab8b71538cd03316f766ce Mon Sep 17 00:00:00 2001 From: Evgenya Nugmanova Date: Mon, 25 Mar 2024 18:21:18 +0400 Subject: [PATCH] Symbol Tracking API updated and made public (#23136) ### Details: - dev_api `ov::DimensionTracker` and `ov::TableOfEquivalence` classes deleted, logic moved to `ov::Symbol` which is now stored by `ov::Dimension` - new implementation moves responsibility to store and report relations between Symbols directly to the Symbol object. Hence, there is no need for `ov::TableOfEquivalence` and no need for synchronization point anymore. - Equivalence is being tracked by using [Disjoint-set_data_structure](https://en.wikipedia.org/wiki/Disjoint-set_data_structure) which uses less memory than previous implementation. ![image](https://github.com/openvinotoolkit/openvino/assets/55839243/f1266f32-976d-44f9-a6ea-cd04dce07407) ![image](https://github.com/openvinotoolkit/openvino/assets/55839243/3108d1ad-0d30-4041-aa93-c4de1f1fb979) ### Tickets: - *CVS-133123* --- .../dimension_tracking.hpp | 12 +- .../chained_maximum.hpp | 2 +- .../dereshape_matmul.hpp | 8 +- ...timization.hpp => symbol_optimization.hpp} | 20 +- .../symbolic_optimizations.hpp | 4 - .../symbolic_transformations/utils.hpp | 32 +- .../dimension_tracking.cpp | 104 +++--- .../smart_reshape/lstm_states_broadcast.cpp | 19 +- .../chained_maximum.cpp | 14 +- .../dereshape_matmul.cpp | 12 +- .../nop_broadcast.cpp | 8 +- .../reshape_optimizations.cpp | 1 - ...timization.cpp => symbol_optimization.cpp} | 165 +++++---- .../symbolic_optimizations.cpp | 85 +++-- .../symbolic_transformations/utils.cpp | 31 +- .../dimension_tracking.cpp | 113 ++++--- .../chained_maximum.cpp | 1 - .../dereshape_fullyconnected.cpp | 32 +- .../dereshape_matmul.cpp | 8 +- .../label_optimization.cpp | 38 +-- .../nop_broadcast.cpp | 56 ++- .../reshape_optimizations.cpp | 46 +-- .../openvino/core/dimension_tracker.hpp | 64 ---- .../dev_api/openvino/core/validation_util.hpp | 16 +- .../openvino/core/descriptor/tensor.hpp | 21 +- src/core/include/openvino/core/dimension.hpp | 21 +- src/core/include/openvino/core/node.hpp | 2 +- src/core/include/openvino/core/symbol.hpp | 43 +++ src/core/include/openvino/op/concat.hpp | 2 +- src/core/include/openvino/op/convert.hpp | 2 +- src/core/include/openvino/op/reshape.hpp | 2 +- .../include/openvino/op/scatter_nd_update.hpp | 2 +- .../include/openvino/op/scatter_update.hpp | 2 +- src/core/include/openvino/op/shape_of.hpp | 4 +- src/core/include/openvino/op/slice.hpp | 2 +- src/core/include/openvino/op/split.hpp | 2 +- src/core/include/openvino/op/squeeze.hpp | 2 +- .../include/openvino/op/strided_slice.hpp | 2 +- src/core/include/openvino/op/tile.hpp | 2 +- src/core/include/openvino/op/transpose.hpp | 2 +- src/core/include/openvino/op/unsqueeze.hpp | 2 +- .../include/openvino/op/util/gather_base.hpp | 2 +- .../include/openvino/op/util/pad_base.hpp | 2 +- .../op/util/scatter_elements_update_base.hpp | 2 +- .../openvino/op/util/symbolic_info.hpp | 35 +- .../include/openvino/op/variadic_split.hpp | 2 +- .../include/openvino/pass/visualize_tree.hpp | 1 + src/core/reference/src/op/einsum.cpp | 20 +- .../include/fft_base_shape_inference.hpp | 12 +- .../include/reshape_shape_inference.hpp | 32 +- src/core/src/bound_evaluate.cpp | 143 ++++++-- src/core/src/bound_evaluate.hpp | 15 +- src/core/src/descriptor/tensor.cpp | 16 +- src/core/src/dimension.cpp | 62 ++-- src/core/src/dimension_tracker.cpp | 93 ----- src/core/src/node.cpp | 2 +- src/core/src/op/concat.cpp | 36 +- src/core/src/op/convert.cpp | 8 +- src/core/src/op/reshape.cpp | 6 +- src/core/src/op/scatter_nd_update.cpp | 6 +- src/core/src/op/scatter_update.cpp | 6 +- src/core/src/op/shape_of.cpp | 26 +- src/core/src/op/slice.cpp | 4 +- src/core/src/op/split.cpp | 6 +- src/core/src/op/squeeze.cpp | 4 +- src/core/src/op/strided_slice.cpp | 4 +- src/core/src/op/tile.cpp | 8 +- src/core/src/op/transpose.cpp | 4 +- src/core/src/op/unsqueeze.cpp | 4 +- src/core/src/op/util/gather_base.cpp | 4 +- src/core/src/op/util/pad_base.cpp | 6 +- .../op/util/scatter_elements_update_base.cpp | 6 +- src/core/src/op/util/symbolic_info.cpp | 75 ++-- src/core/src/op/variadic_split.cpp | 4 +- src/core/src/partial_shape.cpp | 4 +- src/core/src/pass/visualize_tree.cpp | 100 +++++- src/core/src/symbol.cpp | 35 ++ src/core/src/validation_util.cpp | 18 +- src/core/tests/dimension.cpp | 36 +- src/core/tests/evaluate_bound/concat.cpp | 111 ------ src/core/tests/evaluate_bound/transpose.cpp | 173 ---------- .../tests/type_prop/adaptive_avg_pool.cpp | 30 +- .../tests/type_prop/adaptive_max_pool.cpp | 27 +- src/core/tests/type_prop/arithmetic_ops.hpp | 320 ++++++++++-------- src/core/tests/type_prop/avg_pool.cpp | 4 +- src/core/tests/type_prop/batch_to_space.cpp | 11 +- .../tests/type_prop/binary_convolution.cpp | 28 +- .../tests/type_prop/binary_elementwise.cpp | 71 ++-- src/core/tests/type_prop/bitwise_not.cpp | 8 +- src/core/tests/type_prop/bitwise_ops.hpp | 314 +++++++++-------- src/core/tests/type_prop/broadcast.cpp | 153 +++++---- src/core/tests/type_prop/bucketize.cpp | 4 +- src/core/tests/type_prop/concat.cpp | 27 +- src/core/tests/type_prop/convert.cpp | 10 +- .../type_prop/convert_color_i420_base.hpp | 43 +-- .../type_prop/convert_color_nv12_base.hpp | 42 +-- .../tests/type_prop/convert_promote_types.cpp | 8 +- src/core/tests/type_prop/convolution.cpp | 21 +- .../type_prop/convolution_backprop_data.cpp | 25 +- .../tests/type_prop/ctc_greedy_decoder.cpp | 21 +- .../type_prop/ctc_greedy_decoder_seq_len.cpp | 27 +- src/core/tests/type_prop/ctc_loss.cpp | 28 +- .../type_prop/deformable_convolution.cpp | 27 +- .../deformable_convolution_opset8.cpp | 19 +- .../type_prop/deformable_psroi_pooling.cpp | 5 +- src/core/tests/type_prop/depth_to_space.cpp | 10 +- src/core/tests/type_prop/detection_output.cpp | 75 ++-- src/core/tests/type_prop/einsum.cpp | 61 ++-- .../type_prop/embedding_segments_sum.cpp | 7 +- .../type_prop/embeddingbag_offsetssum.cpp | 7 +- .../type_prop/embeddingbag_packedsum.cpp | 16 +- ...xperimental_detectron_detection_output.cpp | 26 +- ...erimental_detectron_generate_proposals.cpp | 16 +- ...imental_detectron_prior_grid_generator.cpp | 40 +-- ...mental_detectron_roi_feature_extractor.cpp | 54 +-- .../experimental_detectron_topkrois.cpp | 18 +- .../tests/type_prop/extractimagepatches.cpp | 20 +- src/core/tests/type_prop/eye.cpp | 36 +- src/core/tests/type_prop/fake_convert.cpp | 6 +- src/core/tests/type_prop/fft_base_complex.cpp | 153 +++++---- src/core/tests/type_prop/gather.cpp | 33 +- src/core/tests/type_prop/gather_elements.cpp | 23 +- src/core/tests/type_prop/gather_nd.cpp | 59 ++-- src/core/tests/type_prop/gather_tree.cpp | 21 +- .../tests/type_prop/generate_proposals.cpp | 24 +- src/core/tests/type_prop/grid_sample.cpp | 24 +- .../tests/type_prop/group_convolution.cpp | 32 +- .../group_convolution_backprop_data.cpp | 32 +- .../tests/type_prop/group_normalization.cpp | 18 +- src/core/tests/type_prop/interpolate.cpp | 68 ++-- src/core/tests/type_prop/irdft.cpp | 91 ++--- src/core/tests/type_prop/logical_not.cpp | 6 +- src/core/tests/type_prop/logical_ops.hpp | 26 +- src/core/tests/type_prop/matmul.cpp | 75 ++-- src/core/tests/type_prop/max_pool.cpp | 23 +- src/core/tests/type_prop/multiclass_nms.cpp | 22 +- src/core/tests/type_prop/nms_rotated.cpp | 30 +- .../tests/type_prop/non_max_suppression.cpp | 48 +-- src/core/tests/type_prop/one_hot.cpp | 35 +- src/core/tests/type_prop/pad.cpp | 52 +-- src/core/tests/type_prop/prior_box.cpp | 40 +-- .../tests/type_prop/prior_box_clustered.cpp | 40 +-- src/core/tests/type_prop/proposal.cpp | 60 ++-- src/core/tests/type_prop/psroi_pooling.cpp | 42 +-- src/core/tests/type_prop/random_uniform.cpp | 4 +- src/core/tests/type_prop/rdft.cpp | 273 ++++++++------- src/core/tests/type_prop/read_value.cpp | 12 +- src/core/tests/type_prop/reduce_ops.hpp | 41 +-- src/core/tests/type_prop/region_yolo.cpp | 37 +- src/core/tests/type_prop/reorg_yolo.cpp | 8 +- src/core/tests/type_prop/reshape.cpp | 311 ++++++++++------- src/core/tests/type_prop/reverse.cpp | 8 +- src/core/tests/type_prop/reverse_sequence.cpp | 22 +- src/core/tests/type_prop/rnn_cell_base.cpp | 28 +- src/core/tests/type_prop/rnn_seq_base.cpp | 80 ++--- src/core/tests/type_prop/roi_align.cpp | 38 ++- src/core/tests/type_prop/roi_pooling.cpp | 18 +- src/core/tests/type_prop/roll.cpp | 12 +- .../scaled_dot_product_attention.cpp | 11 +- .../type_prop/scatter_elements_update.cpp | 15 +- .../tests/type_prop/scatter_nd_update.cpp | 21 +- src/core/tests/type_prop/scatter_update.cpp | 15 +- src/core/tests/type_prop/select.cpp | 137 ++++---- src/core/tests/type_prop/shape_of.cpp | 11 +- src/core/tests/type_prop/shuffle_channels.cpp | 5 +- src/core/tests/type_prop/slice.cpp | 48 +-- src/core/tests/type_prop/space_to_batch.cpp | 13 +- src/core/tests/type_prop/space_to_depth.cpp | 16 +- src/core/tests/type_prop/split.cpp | 64 ++-- src/core/tests/type_prop/squeeze.cpp | 67 ++-- src/core/tests/type_prop/strided_slice.cpp | 86 +++-- src/core/tests/type_prop/tile.cpp | 63 ++-- src/core/tests/type_prop/top_k.cpp | 82 ++--- src/core/tests/type_prop/transpose.cpp | 42 ++- src/core/tests/type_prop/unsqueeze.cpp | 60 ++-- src/core/tests/type_prop/variadic_split.cpp | 67 ++-- src/inference/src/check_network_batchable.cpp | 6 +- src/plugins/auto_batch/src/plugin.cpp | 10 +- .../tests/unit/async_infer_request_test.cpp | 2 +- .../tests/unit/plugin_compile_model_test.cpp | 6 +- .../tests/unit/sync_infer_request_test.cpp | 2 +- .../cpu_opset/common/pass/ngram_fusion.cpp | 28 +- .../cpu_opset/common/pass/rope_fusion.cpp | 28 +- .../common/pass/stateful_sdpa_fusion.cpp | 4 +- src/plugins/intel_gpu/src/plugin/plugin.cpp | 5 +- .../include/common_test_utils/type_prop.hpp | 22 +- .../common_test_utils/src/type_prop.cpp | 40 +-- 187 files changed, 3345 insertions(+), 3404 deletions(-) rename src/common/transformations/include/transformations/symbolic_transformations/{label_optimization.hpp => symbol_optimization.hpp} (51%) rename src/common/transformations/src/transformations/symbolic_transformations/{label_optimization.cpp => symbol_optimization.cpp} (64%) delete mode 100644 src/core/dev_api/openvino/core/dimension_tracker.hpp create mode 100644 src/core/include/openvino/core/symbol.hpp delete mode 100644 src/core/src/dimension_tracker.cpp create mode 100644 src/core/src/symbol.cpp delete mode 100644 src/core/tests/evaluate_bound/concat.cpp delete mode 100644 src/core/tests/evaluate_bound/transpose.cpp diff --git a/src/common/transformations/include/transformations/common_optimizations/dimension_tracking.hpp b/src/common/transformations/include/transformations/common_optimizations/dimension_tracking.hpp index a4c655a9591ed8..745f6e0bb9396c 100644 --- a/src/common/transformations/include/transformations/common_optimizations/dimension_tracking.hpp +++ b/src/common/transformations/include/transformations/common_optimizations/dimension_tracking.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -10,7 +10,8 @@ #include "openvino/pass/graph_rewrite.hpp" #include "transformations_visibility.hpp" -using P2Btype = std::unordered_map, std::unordered_set>; +using P2Btype = + std::unordered_map, std::unordered_set>>; namespace ov { namespace pass { @@ -33,22 +34,21 @@ class ov::pass::FindBatch : public ov::pass::ModelPass { }; namespace ov { -class DimensionTracker; namespace batch_util { void mark_batch(const std::shared_ptr& parameter, P2Btype& map, - const std::unordered_set& batches); + const std::unordered_set>& batches); void mark_no_batch(const std::shared_ptr& parameter, P2Btype& map); void mark_layout_independent_batch(const std::shared_ptr& parameter, const std::shared_ptr& result, P2Btype& map); -void mark_with_unique_dimension_labels(const std::shared_ptr& m, const ov::DimensionTracker& dt); +void mark_with_unique_dimension_symbols(const std::shared_ptr& m); void restore_original_dimensions( const std::shared_ptr& model, const std::map, ov::PartialShape>& parameter_to_shape, bool leave_batch_dynamic = true, - bool clear_labels = false); + bool clear_symbols = false); bool check_batch_tracks_through_all_the_nodes(const std::shared_ptr& m); P2Btype find_batch(const std::shared_ptr& m); bool detach_detection_output(const std::shared_ptr& f); diff --git a/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp b/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp index 49e848449350a5..203259ecdcf7ce 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/chained_maximum.hpp @@ -15,7 +15,7 @@ class TRANSFORMATIONS_API ChainedMaximumOptimization; /** * @ingroup ov_transformation_common_api - * @brief Optimizes graphs based on value labels / symbols + * @brief Optimizes graphs based on value symbols * Maximum(Maximum(A, B), B) -> Maximum(A, B) * Maximum(Maximum(A, B), A) -> Maximum(A, B) */ diff --git a/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp b/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp index 72a2224da2351e..037a9cce421a11 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/dereshape_matmul.hpp @@ -16,7 +16,7 @@ class TRANSFORMATIONS_API DeReshapeFullyConnected; /** * @ingroup ov_transformation_common_api - * @brief Transformation uses symbol / label information to optimize out Reshape operations surrounding MatMul. + * @brief Transformation uses symbol information to optimize out Reshape operations surrounding MatMul. * It checks that surrounding Reshapes are only manipulating with batch dimensions of tensor in a do-undo kind of way. * * Example: @@ -46,9 +46,9 @@ class TRANSFORMATIONS_API DeReshapeFullyConnected; * Binary Elementwise Arithmetic operation without second input scalar restriction. * MatMul -[-> BEA -]-> Reshape * this pattern variation is only applicable for the case when input reshapes are 4D -> 3D and output reshape is 3D -> - * 4D. Additionally, shape labels on output of MatMul should be equal to the input shape labels of the last Reshape, + * 4D. Additionally, shape symbols on output of MatMul should be equal to the input shape symbols of the last Reshape, * meaning that this Binary Elementwise Arithmetic doesn't perform any broadcasting of input coming from MatMul -- only - * other input may be broadcasted to the MatMul input of this BEA. This effect (equality of MatMul output shape labels + * other input may be broadcasted to the MatMul input of this BEA. This effect (equality of MatMul output shape symbols * and output shape of BEA) is being handled by LabelResolvingThroughSelect transformation in the particular models * that this variation targets. * @@ -68,7 +68,7 @@ class ov::pass::DeReshapeMatMul : public ov::pass::MatcherPass { /** * @ingroup ov_transformation_common_api - * @brief Transformation uses symbol / label information to optimize out Reshape operations surrounding special cases of + * @brief Transformation uses symbol information to optimize out Reshape operations surrounding special cases of * MatMul. It checks that surrounding Reshapes are only manipulating with batch dimensions of tensor in a do-undo kind * of way. The difference with previous optimization is that this case has Reshape only on one input of MatMul and the * other input is strictly 2D. Such MatMuls are also called FullyConnected diff --git a/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp b/src/common/transformations/include/transformations/symbolic_transformations/symbol_optimization.hpp similarity index 51% rename from src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp rename to src/common/transformations/include/transformations/symbolic_transformations/symbol_optimization.hpp index c76dcc54d84e25..179bc7d6cfcf52 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/label_optimization.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/symbol_optimization.hpp @@ -9,29 +9,29 @@ namespace ov { namespace pass { -class TRANSFORMATIONS_API ApplyTableOfEquivalence; -class TRANSFORMATIONS_API OptimizeLabelsUsedAsValues; +class TRANSFORMATIONS_API ApplySymbolEquivalence; +class TRANSFORMATIONS_API OptimizeSymbolsUsedAsValues; } // namespace pass } // namespace ov /** * @ingroup ov_transformation_common_api - * @brief Resets symbols / labels on output shapes and values according to table of symbol / label equivalence. It - * allows to reduce number of labels used in the model and to disambiguate label values. + * @brief Resets symbols on output shapes and values according to symbol equivalence. It + * allows to reduce number of labels used in the model and to disambiguate symbol values. */ -class ov::pass::ApplyTableOfEquivalence : public ov::pass::ModelPass { +class ov::pass::ApplySymbolEquivalence : public ov::pass::ModelPass { public: - OPENVINO_RTTI("ApplyTableOfEquivalence", "0"); + OPENVINO_RTTI("ApplySymbolEquivalence", "0"); bool run_on_model(const std::shared_ptr& m) override; }; /** * @ingroup ov_transformation_common_api - * @brief Collects sources where each symbol / label initially appeared (on shape or shape sub-graph) and attaches all + * @brief Collects sources where each symbol initially appeared (on shape or shape sub-graph) and attaches all * value usages of this label to this initial source */ -class ov::pass::OptimizeLabelsUsedAsValues : public ov::pass::ModelPass { +class ov::pass::OptimizeSymbolsUsedAsValues : public ov::pass::ModelPass { public: - OPENVINO_RTTI("OptimizeLabelsUsedAsValues", "0"); + OPENVINO_RTTI("OptimizeSymbolsUsedAsValues", "0"); bool run_on_model(const std::shared_ptr& m) override; -}; \ No newline at end of file +}; diff --git a/src/common/transformations/include/transformations/symbolic_transformations/symbolic_optimizations.hpp b/src/common/transformations/include/transformations/symbolic_transformations/symbolic_optimizations.hpp index ff11473633ba31..17a5d8503cbcb9 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/symbolic_optimizations.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/symbolic_optimizations.hpp @@ -43,11 +43,7 @@ class ov::pass::SymbolicOptimizations : public ov::pass::ModelPass { class ov::pass::SymbolicPropagation : public ov::pass::ModelPass { public: OPENVINO_RTTI("SymbolicPropagation"); - SymbolicPropagation(); bool run_on_model(const std::shared_ptr& m) override; - -private: - std::shared_ptr m_te; }; /** diff --git a/src/common/transformations/include/transformations/symbolic_transformations/utils.hpp b/src/common/transformations/include/transformations/symbolic_transformations/utils.hpp index 2819dbd95723c4..1ab333cd4070a2 100644 --- a/src/common/transformations/include/transformations/symbolic_transformations/utils.hpp +++ b/src/common/transformations/include/transformations/symbolic_transformations/utils.hpp @@ -14,37 +14,37 @@ namespace ov { namespace symbol { namespace util { -/// \brief Collects labels from shape. Labels of static dimensions are guaranteed to be ov::no_labels +/// \brief Collects symbols from shape. Symbols of static dimensions are guaranteed to be nullptr /// -/// \param shape Shape object to collect labels from -/// \param labels TensorLabel object to collect labels to +/// \param shape Shape object to collect symbols from +/// \param symbols TensorSymbol object to collect symbols to /// -/// \return Status of collecting the labels (false if rank is static else true) -TRANSFORMATIONS_API bool get_labels(const ov::PartialShape& shape, ov::TensorLabel& labels); +/// \return Status of collecting the symbols (false if rank is static else true) +TRANSFORMATIONS_API bool get_symbols(const ov::PartialShape& shape, ov::TensorSymbol& symbols); -/// \brief Collects labels from tensor of Output object +/// \brief Collects symbols from tensor of Output object /// -/// \param output Output object to collect labels from -/// \param labels TensorLabel object to collect labels to +/// \param output Output object to collect symbols from +/// \param symbols TensorSymbol object to collect symbols to /// -/// \return Status of collecting the labels (false if tensor has no labels else true) -TRANSFORMATIONS_API bool get_labels(const ov::Output& output, ov::TensorLabel& labels); +/// \return Status of collecting the symbols (false if tensor has no symbols else true) +TRANSFORMATIONS_API bool get_symbols(const ov::Output& output, ov::TensorSymbol& symbols); /// \brief Compares /// -/// \param lhs TensorLabel object to compare -/// \param rhs TensorLabel object to compare +/// \param lhs TensorSymbol object to compare +/// \param rhs TensorSymbol object to compare /// -/// \return true if labels are unique and equal between lhs and rhs else false -TRANSFORMATIONS_API bool are_unique_and_equal_labels(const ov::TensorLabel& lhs, const ov::TensorLabel& rhs); +/// \return true if symbols are unique and equal between lhs and rhs else false +TRANSFORMATIONS_API bool are_unique_and_equal_symbols(const ov::TensorSymbol& lhs, const ov::TensorSymbol& rhs); /// \brief Compares dimensions: if dimensions are static compares values of dimensions, if dimensions are dynamic -/// compares their respective labels using TableOfEquivalence +/// compares their respective symbols /// /// \param lhs Dimension object to compare /// \param rhs Dimension object to compare /// -/// \return true if static dimensions are equal and dynamic dimensions have equal labels else false +/// \return true if static dimensions are equal and dynamic dimensions have equal symbols else false TRANSFORMATIONS_API bool dims_are_equal(const ov::Dimension& lhs, const ov::Dimension& rhs); } // namespace util diff --git a/src/common/transformations/src/transformations/common_optimizations/dimension_tracking.cpp b/src/common/transformations/src/transformations/common_optimizations/dimension_tracking.cpp index 18f03bd99e13c6..c4757299b8b174 100644 --- a/src/common/transformations/src/transformations/common_optimizations/dimension_tracking.cpp +++ b/src/common/transformations/src/transformations/common_optimizations/dimension_tracking.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -8,7 +8,6 @@ #include #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/convert_like.hpp" @@ -21,13 +20,11 @@ #include "openvino/op/result.hpp" #include "openvino/op/shape_of.hpp" -void ov::batch_util::mark_with_unique_dimension_labels(const std::shared_ptr& m, - const ov::DimensionTracker& dt) { - ov::label_t i = 1; +void ov::batch_util::mark_with_unique_dimension_symbols(const std::shared_ptr& m) { for (auto& parameter : m->get_parameters()) { ov::PartialShape new_shape = ov::PartialShape::dynamic(parameter->get_partial_shape().rank()); for (auto& dim : new_shape) - dt.set_up_for_tracking(dim, i++); + dim.set_symbol(std::make_shared()); parameter->set_partial_shape(new_shape); } m->validate_nodes_and_infer_types(); @@ -35,17 +32,17 @@ void ov::batch_util::mark_with_unique_dimension_labels(const std::shared_ptr& parameter, P2Btype& map, - const std::unordered_set& batches) { + const std::unordered_set>& batches) { auto& shape = parameter->get_partial_shape(); if (map.count(parameter)) { // we already marked this parameter as having a batch - std::unordered_set intersection_in_all_three_sources_of_batch; + std::unordered_set> intersection_in_all_three_sources_of_batch; auto mapped_batches = map[parameter]; for (auto& dim : shape) { - const auto& dim_label = ov::DimensionTracker::get_label(dim); - if (batches.count(dim_label) && mapped_batches.count(dim_label)) { - intersection_in_all_three_sources_of_batch.insert(dim_label); + const auto& dim_symbol = dim.get_symbol(); + if (batches.count(dim_symbol) && mapped_batches.count(dim_symbol)) { + intersection_in_all_three_sources_of_batch.insert(dim_symbol); } else { - ov::DimensionTracker::reset_tracking_info(dim); + dim.set_symbol(nullptr); } } } else { @@ -53,11 +50,11 @@ void ov::batch_util::mark_batch(const std::shared_ptr& pa // 1) It is our first time marking batch for this node // 2) This node was marked as 'no_batch' previously. 'no_batch' has higher priority, batch won't be set for (auto& dim : shape) { - const auto& dim_label = ov::DimensionTracker::get_label(dim); - if (batches.count(dim_label)) { // this is one of the batches - map[parameter].insert(dim_label); + const auto& dim_symbol = dim.get_symbol(); + if (batches.count(dim_symbol)) { // this is one of the batches + map[parameter].insert(dim_symbol); } else { - ov::DimensionTracker::reset_tracking_info(dim); + dim.set_symbol(nullptr); } } } @@ -68,15 +65,15 @@ void ov::batch_util::mark_batch(const std::shared_ptr& pa void ov::batch_util::mark_layout_independent_batch(const std::shared_ptr& parameter, const std::shared_ptr& result, P2Btype& map) { - TensorLabel p_labels, r_labels; + TensorSymbol p_symbols, r_symbols; for (const auto& dim : result->get_output_partial_shape(0)) - if (const auto& label = ov::DimensionTracker::get_label(dim)) - r_labels.push_back(label); + if (const auto& symbol = dim.get_symbol()) + r_symbols.push_back(symbol); for (const auto& dim : parameter->get_partial_shape()) { - if (const auto& label = ov::DimensionTracker::get_label(dim)) { - if (std::find(r_labels.begin(), r_labels.end(), label) != r_labels.end()) { - mark_batch(parameter, map, std::unordered_set{label}); + if (const auto& symbol = dim.get_symbol()) { + if (std::find(r_symbols.begin(), r_symbols.end(), symbol) != r_symbols.end()) { + mark_batch(parameter, map, {symbol}); return; } } @@ -90,7 +87,7 @@ void ov::batch_util::mark_no_batch(const std::shared_ptr& map.erase(parameter); auto& shape = parameter->get_partial_shape(); for (auto& dim : shape) - ov::DimensionTracker::reset_tracking_info(dim); + dim.set_symbol(nullptr); parameter->set_partial_shape(shape); parameter->validate_and_infer_types(); } @@ -105,7 +102,7 @@ P2Btype ov::batch_util::find_batch(const std::shared_ptr& f) { {ov::op::v0::MatMul::get_type_info_static(), {0, 0}}, // transpose_a situation }; - P2Btype parameter_to_batch_labels; + P2Btype parameter_to_batch_symbols; for (const auto& parameter : f->get_parameters()) { auto raw_parameter = parameter.get(); @@ -123,26 +120,26 @@ P2Btype ov::batch_util::find_batch(const std::shared_ptr& f) { if (type_input_port_batch_index.count(curr_node->get_type_info())) { auto batch_placement = type_input_port_batch_index[curr_node->get_type_info()]; const auto& shape = curr_node->input_value(batch_placement.first).get_partial_shape(); - const auto& batch_dim_label = ov::DimensionTracker::get_label(shape[batch_placement.second]); - if (batch_dim_label == 0) - mark_no_batch(parameter, parameter_to_batch_labels); + const auto& batch_dim_symbol = shape[batch_placement.second].get_symbol(); + if (batch_dim_symbol == nullptr) + mark_no_batch(parameter, parameter_to_batch_symbols); else - mark_batch(parameter, parameter_to_batch_labels, {batch_dim_label}); + mark_batch(parameter, parameter_to_batch_symbols, {batch_dim_symbol}); continue; // batch was or was not found at this point -- there is no point in searching further } } // node is not layout obvious -- checking if dims were propagated through - bool all_outputs_labeled = true; + bool all_outputs_symboled = true; for (const auto& output : curr_node->outputs()) { const auto& output_shape = output.get_partial_shape(); bool name_stays = std::any_of(output_shape.cbegin(), output_shape.cend(), [](const Dimension& d) { - return ov::DimensionTracker::get_label(d) != 0; + return d.get_symbol() != nullptr; }); - all_outputs_labeled &= name_stays; + all_outputs_symboled &= name_stays; } - if (!all_outputs_labeled) { - mark_no_batch(parameter, parameter_to_batch_labels); - continue; // label propagation stopped + if (!all_outputs_symboled) { + mark_no_batch(parameter, parameter_to_batch_symbols); + continue; // symbol propagation stopped } if (ov::is_type(curr_node)) @@ -163,16 +160,16 @@ P2Btype ov::batch_util::find_batch(const std::shared_ptr& f) { for (auto& result : layout_independent_results) // there are no layout obvious operations on the Parameter-Result path // considering the outermost matching dimension is batch - mark_layout_independent_batch(parameter, result->shared_from_this(), parameter_to_batch_labels); + mark_layout_independent_batch(parameter, result->shared_from_this(), parameter_to_batch_symbols); } - return parameter_to_batch_labels; + return parameter_to_batch_symbols; } void ov::batch_util::restore_original_dimensions( const std::shared_ptr& model, const std::map, ov::PartialShape>& parameter_to_shape, bool leave_batch_dynamic, - bool clear_labels) { + bool clear_symbols) { for (const auto& item : parameter_to_shape) { const auto& batch_marked_shape = item.first->get_partial_shape(); auto original_shape = item.second; @@ -180,32 +177,31 @@ void ov::batch_util::restore_original_dimensions( OPENVINO_ASSERT(batch_marked_shape.size() == original_shape.size()); for (size_t n = 0; n < batch_marked_shape.size(); ++n) { - if (const auto& label = ov::DimensionTracker::get_label(batch_marked_shape[n])) { + if (const auto& symbol = batch_marked_shape[n].get_symbol()) { if (leave_batch_dynamic) original_shape[n] = Dimension::dynamic(); - if (!clear_labels) - ov::DimensionTracker::set_label(original_shape[n], label); + if (!clear_symbols) + original_shape[n].set_symbol(symbol); } } item.first->set_partial_shape(original_shape); } std::unordered_map, ov::PartialShape> output_to_shape; - if (!clear_labels) { + if (!clear_symbols) { for (const auto& result : model->get_results()) output_to_shape[result] = result->get_output_partial_shape(0); } model->validate_nodes_and_infer_types(); - if (!clear_labels) { + if (!clear_symbols) { for (const auto& item : output_to_shape) { - auto labeled_shape = item.second, current_shape = item.first->get_output_partial_shape(0); - auto labeled_rank = labeled_shape.rank(), current_rank = current_shape.rank(); - if (labeled_rank.is_static() && current_rank.is_static() && labeled_rank == current_rank) { - for (size_t i = 0; i < labeled_shape.size(); ++i) { - auto label = ov::DimensionTracker::get_label(labeled_shape[i]); - if (label != ov::no_label) - ov::DimensionTracker::set_label(current_shape[i], label); + auto symboled_shape = item.second, current_shape = item.first->get_output_partial_shape(0); + auto symboled_rank = symboled_shape.rank(), current_rank = current_shape.rank(); + if (symboled_rank.is_static() && current_rank.is_static() && symboled_rank == current_rank) { + for (size_t i = 0; i < symboled_shape.size(); ++i) { + if (auto symbol = symboled_shape[i].get_symbol()) + current_shape[i].set_symbol(symbol); } item.first->set_output_type(0, item.first->get_element_type(), current_shape); } @@ -222,7 +218,7 @@ bool ov::batch_util::check_batch_tracks_through_all_the_nodes(const std::shared_ bool name_stays = false; bool others_are_static = true; for (const auto& dim : input_shape) - if (ov::DimensionTracker::get_label(dim) == 0) + if (dim.get_symbol() == nullptr) others_are_static = others_are_static && dim.is_static(); else name_stays = true; @@ -234,7 +230,7 @@ bool ov::batch_util::check_batch_tracks_through_all_the_nodes(const std::shared_ bool name_stays = false; bool others_are_static = true; for (const auto& dim : output_shape) - if (ov::DimensionTracker::get_label(dim) == 0) + if (dim.get_symbol() == nullptr) others_are_static = others_are_static && dim.is_static(); else name_stays = true; @@ -250,7 +246,7 @@ bool ov::batch_util::check_batch_tracks_through_all_the_nodes(const std::shared_ for (const auto& result : results) { const auto& input_shape = result->get_input_partial_shape(0); bool name_stays = std::any_of(input_shape.cbegin(), input_shape.cend(), [](const ov::Dimension& d) { - return ov::DimensionTracker::get_label(d); + return d.get_symbol(); }); failed_to_propagate_batch |= !name_stays; } @@ -297,8 +293,6 @@ std::map, ov::PartialShape> collect_origi bool ov::pass::FindBatch::run_on_model(const std::shared_ptr& m) { RUN_ON_MODEL_SCOPE(FindBatch); - auto te = std::make_shared(); - ov::DimensionTracker dt(te); bool model_has_changed = false; if (detach_do) @@ -308,7 +302,7 @@ bool ov::pass::FindBatch::run_on_model(const std::shared_ptr& m) { if (parameter_to_shape.empty()) return model_has_changed; - ov::batch_util::mark_with_unique_dimension_labels(m, dt); + ov::batch_util::mark_with_unique_dimension_symbols(m); ov::batch_util::find_batch(m); diff --git a/src/common/transformations/src/transformations/smart_reshape/lstm_states_broadcast.cpp b/src/common/transformations/src/transformations/smart_reshape/lstm_states_broadcast.cpp index 108b8694c69b8e..b828b7a6a16f65 100644 --- a/src/common/transformations/src/transformations/smart_reshape/lstm_states_broadcast.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/lstm_states_broadcast.cpp @@ -7,7 +7,7 @@ #include #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -42,9 +42,8 @@ shared_ptr deduce_outer_source_of_batch_for_inner_lstm_cell( const auto& body = ti->get_body(); // body is not nullptr -- we checked earlier map original_shapes; - ov::label_t label = 1; - // mark all input dimensions with labels and making them dynamic, keeping original shapes + // mark all input dimensions with symbols and making them dynamic, keeping original shapes for (auto& parameter : body->get_parameters()) { auto pshape = parameter->get_partial_shape(); original_shapes[parameter.get()] = pshape; @@ -52,34 +51,34 @@ shared_ptr deduce_outer_source_of_batch_for_inner_lstm_cell( continue; for (ov::Dimension& n : pshape) { n = ov::Dimension::dynamic(); - ov::DimensionTracker::set_label(n, label++); + n.set_symbol(std::make_shared()); } parameter->set_partial_shape(pshape); } - // propagate labels through TI body + // propagate symbols through TI body body->validate_nodes_and_infer_types(); - // if lstm first input has undefined rank or if tracked label is zero -- we failed to track batch dimension + // if lstm first input has undefined rank or if tracked symbol is zero -- we failed to track batch dimension // returning body to initial state if (lstm_cell->get_input_partial_shape(0).rank().is_dynamic() || - ov::DimensionTracker::get_label(lstm_cell->get_input_partial_shape(0)[0]) == 0) { + !lstm_cell->get_input_partial_shape(0)[0].has_symbol()) { for (auto& item : original_shapes) item.first->set_partial_shape(item.second); body->validate_nodes_and_infer_types(); return nullptr; } - // batch label was tracked -- finding parameter that delivered it + // batch symbol was tracked -- finding parameter that delivered it shared_ptr batch_delivering_parameter; size_t index_of_batch_dim = 0; - ov::label_t batch_label = ov::DimensionTracker::get_label(lstm_cell->get_input_partial_shape(0)[0]); + auto batch_symbol = lstm_cell->get_input_partial_shape(0)[0].get_symbol(); for (auto& parameter : body->get_parameters()) { auto pshape = parameter->get_partial_shape(); if (pshape.rank().is_dynamic()) continue; for (size_t i = 0; i < pshape.size(); ++i) { - if (ov::DimensionTracker::get_label(pshape[i]) == batch_label) { + if (pshape[i].get_symbol() == batch_symbol) { batch_delivering_parameter = parameter; index_of_batch_dim = i; break; diff --git a/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp b/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp index faea81d8ff3b99..4c7bc7142c3736 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/chained_maximum.cpp @@ -5,7 +5,7 @@ #include "transformations/symbolic_transformations/chained_maximum.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/maximum.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" @@ -26,18 +26,18 @@ ov::pass::ChainedMaximumOptimization::ChainedMaximumOptimization() { auto A = vm.at(A_input), B = vm.at(B_input), C = vm.at(C_input); auto output_to_replace = vm.at(first_maximum); - ov::TensorLabel A_labels, B_labels, C_labels; - bool A_read = get_labels(A, A_labels); - bool B_read = get_labels(B, B_labels); - bool C_read = get_labels(C, C_labels); + ov::TensorSymbol A_symbols, B_symbols, C_symbols; + bool A_read = get_symbols(A, A_symbols); + bool B_read = get_symbols(B, B_symbols); + bool C_read = get_symbols(C, C_symbols); if (!A_read && !B_read && !C_read) return false; - if (are_unique_and_equal_labels(A_labels, C_labels)) { + if (are_unique_and_equal_symbols(A_symbols, C_symbols)) { // Matched Maximum(Maximum(A, B), C) with A == C -> Maximum(B, C) return ov::replace_output_update_name(output_to_replace, B); - } else if (are_unique_and_equal_labels(B_labels, C_labels)) { + } else if (are_unique_and_equal_symbols(B_symbols, C_symbols)) { // Matched Maximum(Maximum(A, B), C) with B == C -> Maximum(A, C) return ov::replace_output_update_name(output_to_replace, A); } 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 3b0efe486d1fcb..de35c596a64f69 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/dereshape_matmul.cpp @@ -5,7 +5,7 @@ #include "transformations/symbolic_transformations/dereshape_matmul.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/convert.hpp" @@ -233,13 +233,13 @@ ov::pass::DeReshapeMatMul::DeReshapeMatMul() { auto input_0_pshape = out.get_node_shared_ptr()->get_input_partial_shape(0); auto input_1_pshape = out.get_node_shared_ptr()->get_input_partial_shape(1); auto output_pshape = out.get_partial_shape(); - ov::TensorLabel output_labels, input_0_labels, input_1_labels; - if (get_labels(input_0_pshape, input_0_labels) && get_labels(input_1_pshape, input_1_labels) && - get_labels(output_pshape, output_labels)) { + ov::TensorSymbol output_symbols, input_0_symbols, input_1_symbols; + if (get_symbols(input_0_pshape, input_0_symbols) && get_symbols(input_1_pshape, input_1_symbols) && + get_symbols(output_pshape, output_symbols)) { if (input_0_pshape.size() != 3 || input_1_pshape.size() != 3 || output_pshape.size() != 3) return false; - return are_unique_and_equal_labels(input_0_labels, output_labels) || - are_unique_and_equal_labels(input_1_labels, output_labels); + return are_unique_and_equal_symbols(input_0_symbols, output_symbols) || + are_unique_and_equal_symbols(input_1_symbols, output_symbols); } else { return false; } diff --git a/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp b/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp index 7b94b625af3925..a4e54f9902ed03 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/nop_broadcast.cpp @@ -6,7 +6,7 @@ #include "compare.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/maximum.hpp" #include "openvino/op/shape_of.hpp" @@ -48,9 +48,9 @@ ov::pass::NopBroadcast::NopBroadcast() { auto data = vm.at(data_label); auto shape = vm.at(shape_label); - ov::TensorLabel data_labels, shape_labels; - if (!get_labels(data.get_partial_shape(), data_labels) || !get_labels(shape, shape_labels) || - !are_unique_and_equal_labels(data_labels, shape_labels)) + ov::TensorSymbol data_symbols, shape_symbols; + if (!get_symbols(data.get_partial_shape(), data_symbols) || !get_symbols(shape, shape_symbols) || + !are_unique_and_equal_symbols(data_symbols, shape_symbols)) return false; return ov::replace_output_update_name(m.get_match_root(), data); }; diff --git a/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp b/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp index 27565ad67cdd63..a7233f45e854cd 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/reshape_optimizations.cpp @@ -6,7 +6,6 @@ #include "compare.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/pass/pattern/op/wrap_type.hpp" #include "transformations/symbolic_transformations/utils.hpp" #include "transformations/utils/utils.hpp" diff --git a/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp b/src/common/transformations/src/transformations/symbolic_transformations/symbol_optimization.cpp similarity index 64% rename from src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp rename to src/common/transformations/src/transformations/symbolic_transformations/symbol_optimization.cpp index 4411935bd149d8..f779c73d86e487 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/label_optimization.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/symbol_optimization.cpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/symbolic_transformations/label_optimization.hpp" +#include "transformations/symbolic_transformations/symbol_optimization.hpp" #include "itt.hpp" #include "openvino/core/bound_evaluation_util.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" @@ -16,70 +15,64 @@ #include "openvino/op/shape_of.hpp" #include "openvino/op/squeeze.hpp" #include "openvino/op/util/multi_subgraph_base.hpp" -#include "openvino/op/util/symbolic_info.hpp" #include "transformations/utils/utils.hpp" namespace { -void update_label(const ov::EqTable& table, ov::label_t& label) { - if (label != ov::no_label && table.count(label)) { - const auto& alternative_label = *table.at(label)->begin(); - if (alternative_label != ov::no_label) - label = std::min(label, alternative_label); - } +void update_symbol(std::shared_ptr& symbol) { + if (symbol != nullptr) + symbol = ov::symbol::ancestor_of(symbol); } -void apply_table_of_equivalence_on_model(const std::shared_ptr& m, const ov::EqTable& table) { +void apply_table_of_equivalence_on_model(const std::shared_ptr& m) { for (const auto& op : m->get_ordered_ops()) { // handle inner sub-graphs if (auto multi_subgraph_op = std::dynamic_pointer_cast(op)) for (const auto& sub_graph : multi_subgraph_op->get_functions()) if (sub_graph) - apply_table_of_equivalence_on_model(sub_graph, table); + apply_table_of_equivalence_on_model(sub_graph); for (auto& output : op->outputs()) { - // shape relabeling + // re-setting root symbols for shapes auto shape = output.get_partial_shape(); for (auto& d : shape) { if (d.is_static()) continue; - auto label = ov::DimensionTracker::get_label(d); - update_label(table, label); - if (label != ov::no_label) - ov::DimensionTracker::set_label(d, label); + auto symbol = d.get_symbol(); + update_symbol(symbol); + d.set_symbol(symbol); } op->set_output_type(output.get_index(), output.get_element_type(), shape); - // value relabeling - auto value_labels = output.get_tensor().get_value_label(); - for (auto& label : value_labels) - update_label(table, label); - output.get_tensor().set_value_label(value_labels); + // re-setting root symbols for values + auto value_symbols = output.get_tensor().get_value_symbol(); + for (auto& symbol : value_symbols) + update_symbol(symbol); + output.get_tensor().set_value_symbol(value_symbols); } } } } // namespace -bool ov::pass::ApplyTableOfEquivalence::run_on_model(const std::shared_ptr& m) { - RUN_ON_FUNCTION_SCOPE(ApplyTableOfEquivalence); - if (auto te = ov::table_of_equivalence(m)) - apply_table_of_equivalence_on_model(m, te->get_equivalence_table()); +bool ov::pass::ApplySymbolEquivalence::run_on_model(const std::shared_ptr& m) { + RUN_ON_FUNCTION_SCOPE(ApplySymbolEquivalence); + apply_table_of_equivalence_on_model(m); return false; } -// label to source map -using LTS_map = std::unordered_map>; +// Symbol to source map +using STS_map = std::unordered_map, ov::Output>; namespace { -int64_t get_idx_of_label_in_source(const ov::Output& source, const ov::label_t& label) { +int64_t get_idx_of_symbol_in_source(const ov::Output& source, const std::shared_ptr& symbol) { int64_t idx = -1; - if (label == ov::no_label) + if (symbol == nullptr) return idx; auto pshape = source.get_partial_shape(); auto rank = pshape.rank(); if (rank.is_dynamic()) return idx; for (int64_t i = 0; i < rank.get_length(); ++i) { - auto l = ov::DimensionTracker::get_label(pshape[i]); - if (l == label) { + auto s = pshape[i].get_symbol(); + if (ov::symbol::are_equal(s, symbol)) { idx = i; break; } @@ -87,12 +80,12 @@ int64_t get_idx_of_label_in_source(const ov::Output& source, const ov: return idx; } -ov::Output alternative_source_from_existing_value(const ov::label_t& label, +ov::Output alternative_source_from_existing_value(const std::shared_ptr& symbol, const ov::Output& original_output, - LTS_map& label_value_source) { + STS_map& symbol_value_source) { auto alternative_source = ov::Output(); - if (label_value_source.count(label)) { - alternative_source = label_value_source[label]; + if (symbol_value_source.count(symbol)) { + alternative_source = symbol_value_source[symbol]; const auto &original_shape = original_output.get_shape(), &alternative_shape = alternative_source.get_shape(); const auto &original_et = original_output.get_element_type(), &alternative_et = alternative_source.get_element_type(); @@ -115,15 +108,15 @@ ov::Output alternative_source_from_existing_value(const ov::label_t& l return alternative_source; } -ov::Output alternative_source_from_shape_source(const LTS_map& label_shape_source, - const ov::label_t& label, +ov::Output alternative_source_from_shape_source(const STS_map& symbol_shape_source, + const std::shared_ptr& symbol, const ov::Output& original_output, - LTS_map& label_value_source) { + STS_map& symbol_value_source) { auto alternative_source = ov::Output(); - if (label_shape_source.count(label)) { - // replacing via constructing the label source and saving it for the future - const auto& source = label_shape_source.at(label); - const int64_t& idx = get_idx_of_label_in_source(source, label); + if (symbol_shape_source.count(symbol)) { + // replacing via constructing the symbol source and saving it for the future + const auto& source = symbol_shape_source.at(symbol); + const int64_t& idx = get_idx_of_symbol_in_source(source, symbol); if (idx == -1) return alternative_source; const auto& original_et = original_output.get_element_type(); @@ -140,111 +133,113 @@ ov::Output alternative_source_from_shape_source(const LTS_map& label_s auto gather = std::make_shared(shape, indices, axis); ov::copy_runtime_info(original_output.get_node_shared_ptr(), {shape, indices, axis, gather}); alternative_source = gather; - label_value_source[label] = alternative_source; + symbol_value_source[symbol] = alternative_source; } return alternative_source; } -ov::Output get_alternative_source_from_value_or_shape_source(const LTS_map& label_shape_source, - const ov::label_t& label, +ov::Output get_alternative_source_from_value_or_shape_source(const STS_map& symbol_shape_source, + const std::shared_ptr& symbol, const ov::Output& original_output, - LTS_map& label_value_source) { + STS_map& symbol_value_source) { auto alternative_source = ov::Output(); - if (label == ov::no_label) + if (symbol == nullptr) return alternative_source; - alternative_source = alternative_source_from_existing_value(label, original_output, label_value_source); + alternative_source = alternative_source_from_existing_value(symbol, original_output, symbol_value_source); if (!alternative_source.get_node_shared_ptr()) alternative_source = - alternative_source_from_shape_source(label_shape_source, label, original_output, label_value_source); + alternative_source_from_shape_source(symbol_shape_source, symbol, original_output, symbol_value_source); return alternative_source; } -ov::Output alternative_source_from_concat_input_sources(const LTS_map& label_shape_source, - const ov::label_t& label, +ov::Output alternative_source_from_concat_input_sources(const STS_map& symbol_shape_source, + const std::shared_ptr& symbol, const ov::Output& original_output, - LTS_map& label_value_source) { + STS_map& symbol_value_source) { auto alternative_source = ov::Output(); - if (label_shape_source.count(label)) { - const auto& source = label_shape_source.at(label); + if (symbol_shape_source.count(symbol)) { + const auto& source = symbol_shape_source.at(symbol); auto concat = ov::as_type_ptr(source.get_node_shared_ptr()); if (!concat || concat->get_input_size() != 2) return alternative_source; - int64_t idx = get_idx_of_label_in_source(source, label); + int64_t idx = get_idx_of_symbol_in_source(source, symbol); if (idx == -1 || idx != concat->get_concatenation_axis()) return alternative_source; // optimize using the knowledge of the Concat SI and what happens on the axis const auto& lhs_pshape = concat->get_input_partial_shape(0); const auto& rhs_pshape = concat->get_input_partial_shape(1); if (lhs_pshape.rank().is_static() && rhs_pshape.rank().is_static()) { - auto lhs_label = ov::DimensionTracker::get_label(lhs_pshape[idx]); - auto lhs_alternative = get_alternative_source_from_value_or_shape_source(label_shape_source, - lhs_label, + auto lhs_symbol = lhs_pshape[idx].get_symbol(); + auto lhs_alternative = get_alternative_source_from_value_or_shape_source(symbol_shape_source, + lhs_symbol, original_output, - label_value_source); + symbol_value_source); - auto rhs_label = ov::DimensionTracker::get_label(rhs_pshape[idx]); - auto rhs_alternative = get_alternative_source_from_value_or_shape_source(label_shape_source, - rhs_label, + auto rhs_symbol = rhs_pshape[idx].get_symbol(); + auto rhs_alternative = get_alternative_source_from_value_or_shape_source(symbol_shape_source, + rhs_symbol, original_output, - label_value_source); + symbol_value_source); if (lhs_alternative.get_node_shared_ptr() && rhs_alternative.get_node_shared_ptr()) { alternative_source = std::make_shared(lhs_alternative, rhs_alternative); ov::copy_runtime_info(original_output.get_node_shared_ptr(), alternative_source.get_node_shared_ptr()); - alternative_source.get_tensor().set_value_label({label}); - label_value_source[label] = alternative_source; + alternative_source.get_tensor().set_value_symbol({symbol}); + symbol_value_source[symbol] = alternative_source; } } } return alternative_source; } -void optimize_value_usage(ov::Output& output, LTS_map& label_shape_source, LTS_map& label_value_source) { - auto value_labels = output.get_tensor().get_value_label(); - if (value_labels.size() != 1) +void optimize_value_usage(ov::Output& output, STS_map& symbol_shape_source, STS_map& symbol_value_source) { + auto value_symbols = output.get_tensor().get_value_symbol(); + if (value_symbols.size() != 1) return; - auto label = value_labels[0]; - if (label == ov::no_label) + auto symbol = value_symbols[0]; + if (symbol == nullptr) return; auto pshape = output.get_partial_shape(); if (pshape.is_dynamic() || ov::shape_size(pshape.to_shape()) != 1) return; ov::Output alternative_source = - alternative_source_from_concat_input_sources(label_shape_source, label, output, label_value_source); + alternative_source_from_concat_input_sources(symbol_shape_source, symbol, output, symbol_value_source); if (!alternative_source.get_node_shared_ptr()) alternative_source = - get_alternative_source_from_value_or_shape_source(label_shape_source, label, output, label_value_source); + get_alternative_source_from_value_or_shape_source(symbol_shape_source, symbol, output, symbol_value_source); if (alternative_source.get_node_shared_ptr() != nullptr) { evaluate_both_bounds(alternative_source); output.replace(alternative_source); } else { - // in case we can not optimize it -- it is label which appeared just now on the value path - label_value_source[label] = output; + // in case we can not optimize it -- it is symbol which appeared just now on the value path + symbol_value_source[symbol] = output; } } -void save_shape_sources(const ov::Output& output, LTS_map& label_shape_source) { +void save_shape_sources(const ov::Output& output, STS_map& symbol_shape_source) { for (const auto& d : output.get_partial_shape()) { if (d.is_static()) continue; - auto label = ov::DimensionTracker::get_label(d); - if (label == ov::no_label || label_shape_source.count(label)) + auto symbol = d.get_symbol(); + if (symbol == nullptr) + continue; + if (symbol_shape_source.count(symbol)) continue; - label_shape_source[label] = output; + symbol_shape_source[symbol] = output; } } } // namespace -bool ov::pass::OptimizeLabelsUsedAsValues::run_on_model(const std::shared_ptr& m) { - RUN_ON_FUNCTION_SCOPE(OptimizeLabelsUsedAsValues); - LTS_map label_shape_source; - LTS_map label_value_source; +bool ov::pass::OptimizeSymbolsUsedAsValues::run_on_model(const std::shared_ptr& m) { + RUN_ON_FUNCTION_SCOPE(OptimizeSymbolsUsedAsValues); + STS_map symbol_shape_source; + STS_map symbol_value_source; for (const auto& op : m->get_ordered_ops()) { // Result has output port which has shared (during validate_and_infer_type) tensor with input port. // Transformations may replace input of Result. After replacement and before Result::validate_and_infer_type -- - // output tensor of Result may contain inaccurate shape / labels due to the sharing with tensor which may be + // output tensor of Result may contain inaccurate shape / symbols due to the sharing with tensor which may be // already detached from the model. To avoid creating ShapeOf from Result in these cases we exclude it from this // optimization entirely if (auto result = ov::as_type_ptr(op)) @@ -254,8 +249,8 @@ bool ov::pass::OptimizeLabelsUsedAsValues::run_on_model(const std::shared_ptroutputs()) { - optimize_value_usage(output, label_shape_source, label_value_source); - save_shape_sources(output, label_shape_source); + optimize_value_usage(output, symbol_shape_source, symbol_value_source); + save_shape_sources(output, symbol_shape_source); } } return true; 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 ae0098e8e23ade..1886fb8ab39f7d 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/descriptor_tensor.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" @@ -21,9 +20,9 @@ #include "transformations/common_optimizations/simplify_shape_of_sub_graph.hpp" #include "transformations/symbolic_transformations/chained_maximum.hpp" #include "transformations/symbolic_transformations/dereshape_matmul.hpp" -#include "transformations/symbolic_transformations/label_optimization.hpp" #include "transformations/symbolic_transformations/nop_broadcast.hpp" #include "transformations/symbolic_transformations/reshape_optimizations.hpp" +#include "transformations/symbolic_transformations/symbol_optimization.hpp" #include "transformations/symbolic_transformations/utils.hpp" #include "transformations/utils/utils.hpp" @@ -31,21 +30,21 @@ using namespace ov::pass; using namespace ov::symbol::util; namespace { -void symbolic_set_up_for_shape(ov::DimensionTracker& dt, ov::PartialShape& shape) { +void symbolic_set_up_for_shape(ov::PartialShape& shape) { if (shape.rank().is_dynamic()) return; for (auto& d : shape) { - bool is_static = d.is_static(), has_label = ov::DimensionTracker::has_label(d); - if (is_static && has_label) - dt.reset_tracking_info(d); // remove labels from static dims on shapes to reduce label clutter - if (is_static || has_label) + bool is_static = d.is_static(), has_symbol = d.has_symbol(); + if (is_static && has_symbol) + d.set_symbol(nullptr); // remove symbols from static dims on shapes to reduce symbol clutter + if (is_static || has_symbol) continue; - dt.set_up_for_tracking(d); + d.set_symbol(std::make_shared()); } } -void special_case_range_label_propagation(const std::shared_ptr& node) { - /* Label propagation through specific Range operation +void special_case_range_symbol_propagation(const std::shared_ptr& node) { + /* Symbol propagation through specific Range operation start shift | \ / | Add step == 1 @@ -63,59 +62,51 @@ void special_case_range_label_propagation(const std::shared_ptr& node) if (!step_value || step_value->cast_vector()[0] != 1) return; - auto start_labels = node->get_input_tensor(0).get_value_label(); - if (start_labels.size() != 1 || start_labels[0] == ov::no_label) + auto start_symbols = node->get_input_tensor(0).get_value_symbol(); + if (start_symbols.size() != 1 || start_symbols[0] == nullptr) return; - auto start_label = start_labels[0]; + auto start_symbol = start_symbols[0]; auto stop_node = node->input_value(1).get_node_shared_ptr(); if (!ov::is_type(stop_node)) return; - auto add_in0_labels = stop_node->get_input_tensor(0).get_value_label(); - if (add_in0_labels.size() != 1 || add_in0_labels[0] == ov::no_label) + auto add_in0_symbols = stop_node->get_input_tensor(0).get_value_symbol(); + if (add_in0_symbols.size() != 1 || add_in0_symbols[0] == nullptr) return; - auto add_in0_label = add_in0_labels[0]; + auto add_in0_symbol = add_in0_symbols[0]; - auto add_in1_labels = stop_node->get_input_tensor(1).get_value_label(); - if (add_in1_labels.size() != 1 || add_in1_labels[0] == ov::no_label) + auto add_in1_symbols = stop_node->get_input_tensor(1).get_value_symbol(); + if (add_in1_symbols.size() != 1 || add_in1_symbols[0] == nullptr) return; - auto add_in1_label = add_in1_labels[0]; + auto add_in1_symbol = add_in1_symbols[0]; - if (add_in0_label == start_label) - ov::DimensionTracker::set_label(output_shape[0], add_in1_label); - else if (add_in1_label == start_label) - ov::DimensionTracker::set_label(output_shape[0], add_in0_label); + if (add_in0_symbol == start_symbol) + output_shape[0].set_symbol(add_in1_symbol); + else if (add_in1_symbol == start_symbol) + output_shape[0].set_symbol(add_in0_symbol); node->set_output_type(0, node->get_output_element_type(0), output_shape); } } // namespace -ov::pass::SymbolicPropagation::SymbolicPropagation() { - m_te = std::make_shared(); -} - bool ov::pass::SymbolicPropagation::run_on_model(const std::shared_ptr& m) { RUN_ON_MODEL_SCOPE(SymbolicPropagation); - auto te = m_te; - ov::set_up_symbolic_info(m, te); - ov::DimensionTracker dt(te); - for (const auto& op : m->get_ordered_ops()) { // since we disable invalidation with the following two lines, we have to invalidate manually here op->invalidate_values(); for (auto& output : op->outputs()) - ov::set_up_symbolic_info(output, te); + ov::skip_invalidation(output); op->revalidate_and_infer_types(); // Recursively apply transformation for sub-graph based operations ov::op::util::process_subgraph(*this, op); - // additional label propagation rules must be triggered here - special_case_range_label_propagation(op); - // additional label propagation rules must be triggered here + // additional symbol propagation rules must be triggered here + special_case_range_symbol_propagation(op); + // additional symbol propagation rules must be triggered here for (auto& output : op->outputs()) { auto shape = output.get_partial_shape(); - symbolic_set_up_for_shape(dt, shape); + symbolic_set_up_for_shape(shape); ov::descriptor::set_tensor_type(output.get_tensor(), output.get_element_type(), shape); } } @@ -136,21 +127,21 @@ ov::pass::LabelResolvingThroughSelect::LabelResolvingThroughSelect() { ov::matcher_pass_callback matcher_pass_callback = [=](pattern::Matcher& m) { const auto& value_map = m.get_pattern_value_map(); - ov::TensorLabel reshape_labels, add_0_labels, add_1_labels; - if (!get_labels(value_map.at(reshape).get_partial_shape(), reshape_labels)) + ov::TensorSymbol reshape_symbols, add_0_symbols, add_1_symbols; + if (!get_symbols(value_map.at(reshape).get_partial_shape(), reshape_symbols)) return false; auto add_node = value_map.at(add).get_node_shared_ptr(); auto add_0_pshape = add_node->input_value(0).get_partial_shape(); auto add_1_pshape = add_node->input_value(1).get_partial_shape(); - if (!get_labels(add_0_pshape, add_0_labels) && !get_labels(add_1_pshape, add_1_labels)) + if (!get_symbols(add_0_pshape, add_0_symbols) && !get_symbols(add_1_pshape, add_1_symbols)) return false; - if (are_unique_and_equal_labels(reshape_labels, add_0_labels)) { - // we detected that no broadcasting was done during binary elementwise and select, propagating labels + if (are_unique_and_equal_symbols(reshape_symbols, add_0_symbols)) { + // we detected that no broadcasting was done during binary elementwise and select, propagating symbols // through add_node->set_output_type(0, add_node->get_output_element_type(0), add_0_pshape); - } else if (are_unique_and_equal_labels(reshape_labels, add_1_labels)) { - // we detected that no broadcasting was done during binary elementwise and select, propagating labels + } else if (are_unique_and_equal_symbols(reshape_symbols, add_1_symbols)) { + // we detected that no broadcasting was done during binary elementwise and select, propagating symbols // through add_node->set_output_type(0, add_node->get_output_element_type(0), add_1_pshape); } else { @@ -191,10 +182,10 @@ ov::pass::SymbolicOptimizations::SymbolicOptimizations(bool full_run) { REGISTER_SYMBOLIC(NopElimination) // Broadcast (Tile) Ones + Remove Slice Before GatherElements REGISTER_SYMBOLIC(SharedOpOptimization) // Shared GatherElements } - // transformations which use labels for optimizations - REGISTER_SYMBOLIC(ApplyTableOfEquivalence) + // transformations which use symbols for optimizations + REGISTER_SYMBOLIC(ApplySymbolEquivalence) if (full_run) { - REGISTER_SYMBOLIC(OptimizeLabelsUsedAsValues) // reduce shape sub-graphs + REGISTER_SYMBOLIC(OptimizeSymbolsUsedAsValues) // reduce shape sub-graphs REGISTER_SYMBOLIC(LabelResolvingThroughSelect) // figures out that broadcasting didn't happen through Select op REGISTER_SYMBOLIC(DeReshapeMatMul) REGISTER_SYMBOLIC(DeReshapeFullyConnected) @@ -206,6 +197,6 @@ ov::pass::SymbolicOptimizations::SymbolicOptimizations(bool full_run) { bool ov::pass::SymbolicOptimizations::run_on_model(const std::shared_ptr& m) { RUN_ON_FUNCTION_SCOPE(SymbolicOptimizations); m_manager->run_passes(m); - ov::remove_symbolic_info(m); + ov::remove_skip_invalidation_rti(m); return true; } diff --git a/src/common/transformations/src/transformations/symbolic_transformations/utils.cpp b/src/common/transformations/src/transformations/symbolic_transformations/utils.cpp index e30babe38271e6..6568a77fbe6a2e 100644 --- a/src/common/transformations/src/transformations/symbolic_transformations/utils.cpp +++ b/src/common/transformations/src/transformations/symbolic_transformations/utils.cpp @@ -4,31 +4,30 @@ #include "transformations/symbolic_transformations/utils.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/node.hpp" #include "transformations/utils/utils.hpp" -bool ov::symbol::util::get_labels(const ov::PartialShape& shape, ov::TensorLabel& labels) { +bool ov::symbol::util::get_symbols(const ov::PartialShape& shape, ov::TensorSymbol& symbols) { if (shape.rank().is_dynamic()) return false; - labels.clear(); - labels.reserve(shape.size()); + symbols.clear(); + symbols.reserve(shape.size()); for (const auto& d : shape) - labels.push_back((d.is_dynamic() ? ov::DimensionTracker::get_label(d) : ov::no_label)); + symbols.push_back((d.is_dynamic() ? d.get_symbol() : nullptr)); return true; } -bool ov::symbol::util::get_labels(const ov::Output& output, ov::TensorLabel& labels) { +bool ov::symbol::util::get_symbols(const ov::Output& output, ov::TensorSymbol& symbols) { const auto& tensor = output.get_tensor(); - labels = tensor.get_value_label(); - return !labels.empty(); + symbols = tensor.get_value_symbol(); + return !symbols.empty(); } -bool ov::symbol::util::are_unique_and_equal_labels(const ov::TensorLabel& lhs, const ov::TensorLabel& rhs) { +bool ov::symbol::util::are_unique_and_equal_symbols(const ov::TensorSymbol& lhs, const ov::TensorSymbol& rhs) { if (rhs.size() != lhs.size() || rhs.empty()) return false; for (size_t i = 0; i < lhs.size(); ++i) - if (lhs[i] != rhs[i] || lhs[i] == ov::no_label) + if (!symbol::are_equal(lhs[i], rhs[i])) return false; return true; } @@ -36,15 +35,5 @@ bool ov::symbol::util::are_unique_and_equal_labels(const ov::TensorLabel& lhs, c bool ov::symbol::util::dims_are_equal(const ov::Dimension& lhs, const ov::Dimension& rhs) { if (lhs.is_static() && lhs == rhs) return true; - auto lhs_label = ov::DimensionTracker::get_label(lhs); - auto rhs_label = ov::DimensionTracker::get_label(rhs); - if (lhs_label == ov::no_label || rhs_label == ov::no_label) - return false; - if (lhs_label == rhs_label) - return true; - if (auto table_l = ov::DimensionTracker::get_table_of_equivalence(lhs)) - return table_l->are_equal(lhs, rhs); - if (auto table_r = ov::DimensionTracker::get_table_of_equivalence(rhs)) - return table_r->are_equal(lhs, rhs); - return false; + return symbol::are_equal(lhs.get_symbol(), rhs.get_symbol()); } diff --git a/src/common/transformations/tests/common_optimizations/dimension_tracking.cpp b/src/common/transformations/tests/common_optimizations/dimension_tracking.cpp index 35440c2b62b788..74c51c8f3bcfe1 100644 --- a/src/common/transformations/tests/common_optimizations/dimension_tracking.cpp +++ b/src/common/transformations/tests/common_optimizations/dimension_tracking.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2021 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -12,7 +12,7 @@ #include "common_test_utils/ov_test_utils.hpp" #include "common_test_utils/subgraph_builders/detection_output.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/model.hpp" #include "openvino/opsets/opset1.hpp" #include "openvino/pass/manager.hpp" @@ -25,7 +25,9 @@ using namespace testing; TEST(TransformationTests, AutoBatch_LabelPropagation_Transpose) { auto batch = ov::Dimension(5); - ov::DimensionTracker::set_label(batch, 7); + auto A = std::make_shared(); + + batch.set_symbol(A); auto p_shape = ov::PartialShape{batch, 4, 6, 8}; auto arg = std::make_shared(ov::element::f32, p_shape); @@ -35,12 +37,14 @@ TEST(TransformationTests, AutoBatch_LabelPropagation_Transpose) { EXPECT_EQ(r->get_output_element_type(0), ov::element::f32); EXPECT_EQ(r->get_output_partial_shape(0), ov::PartialShape({6, 4, batch, 8})); - EXPECT_EQ(ov::DimensionTracker::get_label(r->get_output_partial_shape(0)[2]), 7); + EXPECT_EQ(r->get_output_partial_shape(0)[2].get_symbol(), A); } TEST(TransformationTests, AutoBatch_LabelPropagation_Convolution) { auto batch = ov::Dimension(5); - ov::DimensionTracker::set_label(batch, 7); + auto A = std::make_shared(); + + batch.set_symbol(A); auto p_shape = ov::PartialShape{batch, 4, 6, 8}; auto arg = std::make_shared(ov::element::f32, p_shape); @@ -55,7 +59,7 @@ TEST(TransformationTests, AutoBatch_LabelPropagation_Convolution) { EXPECT_EQ(conv->get_output_element_type(0), ov::element::f32); EXPECT_EQ(conv->get_output_partial_shape(0), ov::PartialShape({batch, 1, 4, 6})); - EXPECT_EQ(ov::DimensionTracker::get_label(conv->get_output_partial_shape(0)[0]), 7); + EXPECT_EQ(conv->get_output_partial_shape(0)[0].get_symbol(), A); } TEST(TransformationTests, AutoBatch_FindBatch_Transpose_and_Convolution) { @@ -82,16 +86,16 @@ TEST(TransformationTests, AutoBatch_FindBatch_Transpose_and_Convolution) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(!shape[0].get_symbol()) << shape; + ASSERT_TRUE(shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; const auto& out_shape = f->get_results()[0]->get_output_partial_shape(0); - ASSERT_TRUE(ov::DimensionTracker::get_label(out_shape[0])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[1])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[2])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[3])) << out_shape; + ASSERT_TRUE(out_shape[0].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[1].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[2].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[3].get_symbol()) << out_shape; } TEST(TransformationTests, AutoBatch_LabelPropagation_Convolution_Reshape) { @@ -117,15 +121,15 @@ TEST(TransformationTests, AutoBatch_LabelPropagation_Convolution_Reshape) { ASSERT_NO_THROW(check_rt_info(model)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; const auto& out_shape = model->get_results()[0]->get_output_partial_shape(0); - ASSERT_TRUE(ov::DimensionTracker::get_label(out_shape[0])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[1])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[2])) << out_shape; + ASSERT_TRUE(out_shape[0].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[1].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[2].get_symbol()) << out_shape; } TEST(TransformationTests, AutoBatch_FindBatch_SingleMultiply) { @@ -143,10 +147,10 @@ TEST(TransformationTests, AutoBatch_FindBatch_SingleMultiply) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; } TEST(TransformationTests, AutoBatch_FindBatch_Two_Outputs) { @@ -173,10 +177,10 @@ TEST(TransformationTests, AutoBatch_FindBatch_Two_Outputs) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; } TEST(TransformationTests, AutoBatch_FindBatch_TwoOutputsReversed) { @@ -203,10 +207,10 @@ TEST(TransformationTests, AutoBatch_FindBatch_TwoOutputsReversed) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; } TEST(TransformationTests, AutoBatch_FindBatch_IndependentBranchesConcated) { @@ -237,10 +241,10 @@ TEST(TransformationTests, AutoBatch_FindBatch_IndependentBranchesConcated) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; } TEST(TransformationTests, AutoBatch_FindBatch_TwoConvNetwork) { @@ -270,10 +274,10 @@ TEST(TransformationTests, AutoBatch_FindBatch_TwoConvNetwork) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; } TEST(TransformationTests, AutoBatch_FindBatch_NegativeTracking) { @@ -298,13 +302,13 @@ TEST(TransformationTests, AutoBatch_FindBatch_NegativeTracking) { ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; const auto& out_shape = f->get_results()[0]->get_output_partial_shape(0); - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[0])) << out_shape; + ASSERT_TRUE(!out_shape[0].get_symbol()) << out_shape; } TEST(TransformationTests, AutoBatch_FindBatch_AutoBatch_LabelPropagation_DO_detachment) { @@ -318,25 +322,26 @@ TEST(TransformationTests, AutoBatch_FindBatch_AutoBatch_LabelPropagation_DO_deta ASSERT_NO_THROW(check_rt_info(f)); const auto& shape = data->get_partial_shape(); - ASSERT_TRUE(ov::DimensionTracker::get_label(shape[0])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[1])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[2])) << shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(shape[3])) << shape; + ASSERT_TRUE(shape[0].get_symbol()) << shape; + ASSERT_TRUE(!shape[1].get_symbol()) << shape; + ASSERT_TRUE(!shape[2].get_symbol()) << shape; + ASSERT_TRUE(!shape[3].get_symbol()) << shape; ASSERT_EQ(f->get_results().size(), 3); for (const auto& result : f->get_results()) { const auto& out_shape = result->get_output_partial_shape(0); - ASSERT_TRUE(ov::DimensionTracker::get_label(out_shape[0])) << out_shape; - ASSERT_TRUE(!ov::DimensionTracker::get_label(out_shape[1])) << out_shape; + ASSERT_TRUE(out_shape[0].get_symbol()) << out_shape; + ASSERT_TRUE(!out_shape[1].get_symbol()) << out_shape; } } TEST(partial_shape, cout_with_label) { ov::Dimension a = 5; - ov::DimensionTracker::set_label(a, 100500); + auto A = std::make_shared(); + a.set_symbol(A); ov::PartialShape shape{1, 2, 3, a}; std::stringstream stream; stream << shape; - ASSERT_EQ(stream.str(), "[1,2,3,<100500>5]"); + ASSERT_EQ(stream.str(), "[1,2,3,5]"); } TEST(partial_shape, cout_without_label) { diff --git a/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp b/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp index 7e4553fb5f9226..030619cf14bb92 100644 --- a/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp +++ b/src/common/transformations/tests/symbolic_transformations/chained_maximum.cpp @@ -7,7 +7,6 @@ #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/model.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/maximum.hpp" diff --git a/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp b/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp index 56f022dfda9254..a04736a88f3da7 100644 --- a/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp +++ b/src/common/transformations/tests/symbolic_transformations/dereshape_fullyconnected.cpp @@ -5,7 +5,7 @@ #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "common_test_utils/type_prop.hpp" #include "openvino/core/model.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/convert.hpp" @@ -19,19 +19,11 @@ using namespace ov; using namespace ov::op; using namespace std; -namespace { -void label_shape(ov::PartialShape& shape) { - auto table = std::make_shared(42); - auto tracker = ov::DimensionTracker(table); - tracker.set_up_for_tracking(shape); -} -} // namespace - TEST_F(TransformationTestsF, DeReshapeFC) { - { - auto shape = PartialShape{-1, -1, 40}; - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 + auto shape = PartialShape{-1, -1, 40}; + set_shape_symbols(shape); // we label shape with consecutive labels: A, B, C + { auto data = make_shared(element::f32, shape); auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); auto second_input = make_shared(element::f32, Shape{40, 80}); @@ -47,9 +39,6 @@ TEST_F(TransformationTestsF, DeReshapeFC) { manager.register_pass(); } { - auto shape = PartialShape{-1, -1, 40}; - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 - auto data = make_shared(element::f32, shape); auto second_input = make_shared(element::f32, Shape{40, 80}); auto matmul = make_shared(data, second_input); @@ -59,10 +48,9 @@ TEST_F(TransformationTestsF, DeReshapeFC) { } TEST_F(TransformationTestsF, DeReshapeFCWithConvert) { + auto shape = PartialShape{-1, -1, 40}; + set_shape_symbols(shape); // we label shape with consecutive labels: A, B, C { - auto shape = PartialShape{-1, -1, 40}; - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 - auto data = make_shared(element::f16, shape); auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); auto convert = make_shared(in_reshape, element::f32); @@ -79,9 +67,6 @@ TEST_F(TransformationTestsF, DeReshapeFCWithConvert) { manager.register_pass(); } { - auto shape = PartialShape{-1, -1, 40}; - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 - auto data = make_shared(element::f16, shape); auto convert = make_shared(data, element::f32); auto second_input = make_shared(element::f32, Shape{40, 80}); @@ -92,10 +77,9 @@ TEST_F(TransformationTestsF, DeReshapeFCWithConvert) { } TEST_F(TransformationTestsF, DeReshapeFCNegative) { + auto shape = PartialShape{-1, -1, 40}; + set_shape_symbols(shape); // we label shape with consecutive labels: A, B, C { - auto shape = PartialShape{-1, -1, 40}; - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44 - auto data = make_shared(element::f16, shape); auto in_reshape = make_shared(data, v0::Constant::create(element::i64, {2}, {-1, 40}), true); auto convert = make_shared(in_reshape, element::f32); diff --git a/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp b/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp index b48f8c11ae119f..16d21d3fa4e1fe 100644 --- a/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp +++ b/src/common/transformations/tests/symbolic_transformations/dereshape_matmul.cpp @@ -7,7 +7,7 @@ #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "common_test_utils/type_prop.hpp" #include "openvino/core/model.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/matmul.hpp" @@ -22,7 +22,7 @@ using namespace std; namespace { /* Helps to organize dimension representation in the following tests: * 1. Creates requested amount of dimensions - * 2. Labels them automatically + * 2. Sets unique symbols for them automatically * 3. Creates value representation of the dimension via creating Parameter->Shape->Gather subgraph * 4. Gives access to dimension and its value representation via operator[] * 5. Gives access to utility Parameter via get_parameter -- only used for ov::Model creation in tests @@ -35,10 +35,8 @@ class DimensionTestHelper { }; explicit DimensionTestHelper(const size_t& num_dims) { - auto te = make_shared(); - auto dt = ov::DimensionTracker(te); auto dimensions = PartialShape::dynamic(Rank(num_dims)); - dt.set_up_for_tracking(dimensions); + set_shape_symbols(dimensions); parameter = make_shared(element::f32, dimensions); for (size_t i = 0; i < num_dims; ++i) m_map[i] = {dimensions[i], op::util::node_to_get_shape_value_of_indices_from_shape_source(parameter, {i})}; diff --git a/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp b/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp index cdff47d01e4cc0..881d02b20d295a 100644 --- a/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp +++ b/src/common/transformations/tests/symbolic_transformations/label_optimization.cpp @@ -2,18 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "transformations/symbolic_transformations/label_optimization.hpp" - #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/add.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/gather.hpp" #include "openvino/op/reshape.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/pass/manager.hpp" +#include "openvino/pass/visualize_tree.hpp" +#include "transformations/symbolic_transformations/symbol_optimization.hpp" #include "transformations/symbolic_transformations/symbolic_optimizations.hpp" #include "transformations/symbolic_transformations/utils.hpp" @@ -21,15 +20,7 @@ using namespace ov; using namespace ov::op; using namespace std; -#define TEST_SHAPE(source, ...) \ - { \ - auto expected_labels = ov::TensorLabel({__VA_ARGS__}); \ - ov::TensorLabel labels; \ - EXPECT_TRUE(ov::symbol::util::get_labels(source->get_output_partial_shape(0), labels)); \ - EXPECT_EQ(labels, expected_labels); \ - } - -TEST(TransformationTests, ApplyTableOfEquivalence_Concat) { +TEST(TransformationTests, ApplySymbolEquivalence_Concat) { auto input_1 = make_shared(element::f32, PartialShape::dynamic(4)); auto input_2 = make_shared(element::f32, PartialShape::dynamic(4)); auto concat = make_shared(OutputVector{input_1, input_2}, -1); @@ -39,15 +30,24 @@ TEST(TransformationTests, ApplyTableOfEquivalence_Concat) { pass::Manager manager; manager.set_per_pass_validation(false); manager.register_pass(); - manager.register_pass(); + manager.register_pass(); manager.run_passes(model); - TEST_SHAPE(input_1, {1, 2, 3, 4}); - TEST_SHAPE(input_2, {1, 2, 3, 8}); - TEST_SHAPE(concat, {1, 2, 3, 9}); + const auto& pshape_1 = input_1->get_output_partial_shape(0); + const auto& pshape_2 = input_2->get_output_partial_shape(0); + const auto& pshape_3 = concat->get_output_partial_shape(0); + + for (size_t i = 0; i < 3; ++i) { + EXPECT_TRUE(symbol::are_equal(pshape_1[i].get_symbol(), pshape_2[i].get_symbol())); + EXPECT_TRUE(symbol::are_equal(pshape_2[i].get_symbol(), pshape_3[i].get_symbol())); + EXPECT_TRUE(symbol::are_equal(pshape_1[i].get_symbol(), pshape_3[i].get_symbol())); + } + EXPECT_FALSE(symbol::are_equal(pshape_1[3].get_symbol(), pshape_2[3].get_symbol())); + EXPECT_FALSE(symbol::are_equal(pshape_2[3].get_symbol(), pshape_3[3].get_symbol())); + EXPECT_FALSE(symbol::are_equal(pshape_1[3].get_symbol(), pshape_3[3].get_symbol())); } -TEST_F(TransformationTestsF, ApplyTableOfEquivalence_Concat_Values) { +TEST_F(TransformationTestsF, ApplySymbolEquivalence_Concat_Values) { { auto input_1 = make_shared(element::f32, PartialShape::dynamic(4)); auto input_2 = make_shared(element::f32, PartialShape::dynamic(4)); @@ -67,8 +67,8 @@ TEST_F(TransformationTestsF, ApplyTableOfEquivalence_Concat_Values) { manager.set_per_pass_validation(false); manager.register_pass(); - manager.register_pass(); - manager.register_pass(); + manager.register_pass(); + manager.register_pass(); } { auto input_1 = make_shared(element::f32, PartialShape::dynamic(4)); diff --git a/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp b/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp index 6e0c9f0bcaf5c8..48a927ac9ea1fc 100644 --- a/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp +++ b/src/common/transformations/tests/symbolic_transformations/nop_broadcast.cpp @@ -7,7 +7,7 @@ #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "common_test_utils/type_prop.hpp" #include "openvino/core/model.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/maximum.hpp" @@ -19,92 +19,78 @@ using namespace ov; using namespace ov::op; using namespace std; -namespace { -void label_shape(ov::PartialShape& shape) { - auto table = std::make_shared(42); - auto tracker = ov::DimensionTracker(table); - tracker.set_up_for_tracking(shape); -} -} // namespace - TEST_F(TransformationTestsF, NopBroadcastOpset1) { - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + { auto data = make_shared(element::f32, shape); - auto labeled_input = make_shared(element::f32, shape); - auto shape_of = make_shared(labeled_input); + auto symbol_input = make_shared(element::f32, shape); + auto shape_of = make_shared(symbol_input); auto ones = ov::op::v0::Constant::create(element::i64, {}, {1}); auto maximum = make_shared(shape_of, ones); auto broadcast = make_shared(data, maximum); auto relu = make_shared(broadcast); - model = make_shared(NodeVector{relu}, ParameterVector{data, labeled_input}); + model = make_shared(NodeVector{relu}, ParameterVector{data, symbol_input}); manager.register_pass(); } { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 - auto data = make_shared(element::f32, shape); auto relu = make_shared(data); - auto labeled_input = make_shared(element::f32, shape); + auto symbol_input = make_shared(element::f32, shape); - model_ref = make_shared(NodeVector{relu}, ParameterVector{data, labeled_input}); + model_ref = make_shared(NodeVector{relu}, ParameterVector{data, symbol_input}); } } TEST_F(TransformationTestsF, NopBroadcastOpset3) { - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + { auto data = make_shared(element::f32, shape); - auto labeled_input = make_shared(element::f32, shape); - auto shape_of = make_shared(labeled_input); + auto symbol_input = make_shared(element::f32, shape); + auto shape_of = make_shared(symbol_input); auto ones = ov::op::v0::Constant::create(element::i64, {4}, {1, 1, 1, 1}); auto maximum = make_shared(shape_of, ones); auto broadcast = make_shared(data, maximum); auto relu = make_shared(broadcast); - model = make_shared(NodeVector{relu}, ParameterVector{data, labeled_input}); + model = make_shared(NodeVector{relu}, ParameterVector{data, symbol_input}); manager.register_pass(); } { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 - auto data = make_shared(element::f32, shape); auto relu = make_shared(data); - auto labeled_input = make_shared(element::f32, shape); + auto symbol_input = make_shared(element::f32, shape); - model_ref = make_shared(NodeVector{relu}, ParameterVector{data, labeled_input}); + model_ref = make_shared(NodeVector{relu}, ParameterVector{data, symbol_input}); } } TEST_F(TransformationTestsF, NopBroadcastNegative) { { auto shape = PartialShape::dynamic(1); - label_shape(shape); // we label shape with consecutive labels: 42 + shape[0].set_symbol(std::make_shared()); auto data = make_shared(element::f32, shape); - auto labeled_input = make_shared(element::f32, shape); - auto shape_of = make_shared(labeled_input); + auto symbol_input = make_shared(element::f32, shape); + auto shape_of = make_shared(symbol_input); auto ones = ov::op::v0::Constant::create(element::i64, {2}, {1, 1}); auto maximum = make_shared(shape_of, ones); auto broadcast = make_shared(data, maximum); auto relu = make_shared(broadcast); - model = make_shared(NodeVector{relu}, ParameterVector{data, labeled_input}); + model = make_shared(NodeVector{relu}, ParameterVector{data, symbol_input}); manager.register_pass(); } } diff --git a/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp b/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp index 089090aa0ed823..2f1fdba8dc285c 100644 --- a/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp +++ b/src/common/transformations/tests/symbolic_transformations/reshape_optimizations.cpp @@ -7,7 +7,7 @@ #include #include "common_test_utils/ov_test_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "common_test_utils/type_prop.hpp" #include "openvino/core/model.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/divide.hpp" @@ -21,20 +21,13 @@ using namespace ov; using namespace ov::op; using namespace std; -namespace { -void label_shape(ov::PartialShape& shape) { - auto table = std::make_shared(42); - auto tracker = ov::DimensionTracker(table); - tracker.set_up_for_tracking(shape); -} -} // namespace - TEST_F(TransformationTestsF, FlattenOptimization) { // [A, B, C, D] -> [A, B, C*D] - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + + { auto data = make_shared(element::f32, shape); auto shape_of = make_shared(data); @@ -55,9 +48,6 @@ TEST_F(TransformationTestsF, FlattenOptimization) { manager.register_pass(); } { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 - auto data = make_shared(element::f32, shape); auto pattern = ov::op::v0::Constant::create(element::i64, {3}, {0, 0, -1}); @@ -69,10 +59,11 @@ TEST_F(TransformationTestsF, FlattenOptimization) { TEST_F(TransformationTestsF, LastDimSplitStaticLast) { // [A, B, C, D] -> [A, B, C, D/8, 8] - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + + { auto data = make_shared(element::f32, shape); auto shape_of = make_shared(data); @@ -90,9 +81,6 @@ TEST_F(TransformationTestsF, LastDimSplitStaticLast) { manager.register_pass(); } { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 - auto data = make_shared(element::f32, shape); auto pattern = ov::op::v0::Constant::create(element::i64, {5}, {0, 0, 0, -1, 8}); @@ -104,10 +92,11 @@ TEST_F(TransformationTestsF, LastDimSplitStaticLast) { TEST_F(TransformationTestsF, LastDimSplitDymanicLast) { // [A, B, C, D] -> [A, B, C, 8, D/8] - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + + { auto data = make_shared(element::f32, shape); auto shape_of = make_shared(data); @@ -125,9 +114,6 @@ TEST_F(TransformationTestsF, LastDimSplitDymanicLast) { manager.register_pass(); } { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 - auto data = make_shared(element::f32, shape); auto pattern = ov::op::v0::Constant::create(element::i64, {5}, {0, 0, 0, 8, -1}); @@ -139,10 +125,10 @@ TEST_F(TransformationTestsF, LastDimSplitDymanicLast) { TEST_F(TransformationTestsF, NegativeTest) { // [A, B, C, D] -> [A, B, C, D/2, D/3, 6] - { - auto shape = PartialShape::dynamic(4); - label_shape(shape); // we label shape with consecutive labels: 42, 43, 44, 45 + auto shape = PartialShape::dynamic(4); + set_shape_symbols(shape); // we set unique symbols to the shape: A, B, C, D + { auto data = make_shared(element::f32, shape); auto shape_of = make_shared(data); diff --git a/src/core/dev_api/openvino/core/dimension_tracker.hpp b/src/core/dev_api/openvino/core/dimension_tracker.hpp deleted file mode 100644 index 612ab4a01f8318..00000000000000 --- a/src/core/dev_api/openvino/core/dimension_tracker.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "openvino/core/dimension.hpp" -#include "openvino/core/partial_shape.hpp" -#include "openvino/core/type/element_type.hpp" - -namespace ov { -/// \brief Special label value indicate no label set. -constexpr label_t no_label = 0; - -/// \brief Friend class of Dimension to set, get and track dimensions and their equivalence -class OPENVINO_API DimensionTracker { -public: - DimensionTracker() = delete; - explicit DimensionTracker(const std::shared_ptr& table) : m_table_of_equivalence(table) { - OPENVINO_ASSERT(table != nullptr, - "Can not set nullptr as table of equivalence shared pointer for DimensionTracker"); - }; - - static void set_label(ov::Dimension& d, label_t label); - static bool has_label(const ov::Dimension& d); - static label_t get_label(const ov::Dimension& d); - - void set_table_of_equivalence(ov::Dimension& d) const; - static const std::shared_ptr& get_table_of_equivalence(const ov::Dimension& d); - - void set_up_for_tracking(ov::PartialShape& shape); - void set_up_for_tracking(ov::Dimension& d); - void set_up_for_tracking(ov::Dimension& d, label_t label) const; - static void reset_tracking_info(ov::Dimension& d); - -private: - std::shared_ptr m_table_of_equivalence; -}; - -using EqualitySoup = std::shared_ptr>; -using EqTable = std::unordered_map; -using ValTable = std::unordered_map; - -class OPENVINO_API TableOfEquivalence { -public: - explicit TableOfEquivalence(label_t label = 1) : current_label(label){}; - void set_as_equal(const ov::Dimension& lhs, const ov::Dimension& rhs); - bool are_equal(const ov::Dimension& lhs, const ov::Dimension& rhs); - - const EqTable& get_equivalence_table() const; - const ValTable& get_value_equivalence_table() const; - label_t get_next_label(); - -private: - label_t current_label; - EqTable dimension_table_of_equivalence; - ValTable value_table_of_equivalence; -}; - -} // namespace ov diff --git a/src/core/dev_api/openvino/core/validation_util.hpp b/src/core/dev_api/openvino/core/validation_util.hpp index 5825518c264f47..56aa4ae8e7a92c 100644 --- a/src/core/dev_api/openvino/core/validation_util.hpp +++ b/src/core/dev_api/openvino/core/validation_util.hpp @@ -93,15 +93,15 @@ OPENVINO_API bool is_rank_compatible_any_of(const Rank& r, std::initializer_list /// \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 +/// \brief Propagates value sumbol 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 +/// \param output_symbols Vector of TensorSymbol objects representing resulting value symbols /// -/// \return True if label evaluation was successful, false otherwise. -OPENVINO_API bool default_label_evaluator(const Node* node, TensorLabelVector& output_labels); +/// \return True if symbol evaluation was successful, false otherwise. +OPENVINO_API bool default_symbol_evaluator(const Node* node, TensorSymbolVector& output_symbols); /// \brief Generates default order of axes transposition at the end of input vector. /// @@ -121,11 +121,11 @@ OPENVINO_API void generate_transpose_default_order(std::vector& axes_or /// \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. +/// \brief Checks whether symbol tensor has no symbols. /// -/// \param labels Label tensor to check. -/// \return True if there are no labels, false otherwise. -OPENVINO_API bool has_no_labels(const TensorLabel& labels); +/// \param symbols Symbol tensor to check. +/// \return True if there are no symbols, false otherwise. +OPENVINO_API bool has_no_symbols(const TensorSymbol& symbols); /// \brief Handles out of range axis. /// diff --git a/src/core/include/openvino/core/descriptor/tensor.hpp b/src/core/include/openvino/core/descriptor/tensor.hpp index 28d04f36c9c5a7..f9666d8cd57f31 100644 --- a/src/core/include/openvino/core/descriptor/tensor.hpp +++ b/src/core/include/openvino/core/descriptor/tensor.hpp @@ -20,10 +20,11 @@ namespace ov { class Node; -/// \brief Alias for label tensor. -using TensorLabel = std::vector; -/// \brief Alias for vector of label tensors. -using TensorLabelVector = std::vector; +/// \brief Alias for symbol tensor. +using TensorSymbol = std::vector>; +/// \brief Alias for vector of symbol tensors. + +using TensorSymbolVector = std::vector; namespace pass { class ReverseShapeAndTypeInfer; @@ -52,8 +53,8 @@ class OPENVINO_API Tensor { void set_lower_value(const ov::Tensor& value); /// \brief sets upper bound value description void set_upper_value(const ov::Tensor& value); - /// \brief sets value label description - void set_value_label(const TensorLabel& value_label); + /// \brief sets value symbol description + void set_value_symbol(const TensorSymbol& value_symbol); /// \brief unsets bound value descriptions void invalidate_values(); @@ -72,9 +73,9 @@ class OPENVINO_API Tensor { const ov::Tensor& get_upper_value() const { return m_upper_value; } - /// \brief gets upper bound value description - TensorLabel get_value_label() const { - return m_value_label; + /// \brief gets symbol value description + TensorSymbol get_value_symbol() const { + return m_value_symbol; } /// \brief checks if lower and upper bound are set and point to the same Tensor bool has_and_set_bound() const { @@ -111,7 +112,7 @@ class OPENVINO_API Tensor { PartialShape m_partial_shape; ov::Tensor m_lower_value, m_upper_value; - TensorLabel m_value_label; + TensorSymbol m_value_symbol; std::string m_legacy_name; std::unordered_set m_names; diff --git a/src/core/include/openvino/core/dimension.hpp b/src/core/include/openvino/core/dimension.hpp index 7c7d13f3e4ed0f..45c5913f2763ab 100644 --- a/src/core/include/openvino/core/dimension.hpp +++ b/src/core/include/openvino/core/dimension.hpp @@ -11,12 +11,9 @@ #include "openvino/core/attribute_adapter.hpp" #include "openvino/core/core_visibility.hpp" #include "openvino/core/interval.hpp" +#include "openvino/core/symbol.hpp" namespace ov { -class TableOfEquivalence; -/// \brief Alias for dimension label type. -using label_t = uint32_t; - /// \brief Class representing a dimension, which may be dynamic (undetermined until runtime), /// in a shape or shape-like object. /// @@ -179,23 +176,25 @@ class OPENVINO_API Dimension { friend void swap(Dimension& a, Dimension& b) { using std::swap; swap(a.m_dimension, b.m_dimension); - swap(a.m_label, b.m_label); - swap(a.m_table_of_equivalence, b.m_table_of_equivalence); + swap(a.m_symbol, b.m_symbol); } /// \brief String representation of Dimension std::string to_string() const; + /// \brief Indicates if meaningful symbol was set to the Dimension + bool has_symbol() const; + /// \brief Returns symbol of the Dimension + std::shared_ptr get_symbol() const; + /// \brief Sets symbol of the Dimension + void set_symbol(const std::shared_ptr& s); + private: Dimension(const Interval& interval) : m_dimension(interval) {} // The actual numerical value of the dimension. Interval m_dimension{}; - - // private fields for dimension tracking - friend class DimensionTracker; - label_t m_label{0}; - std::shared_ptr m_table_of_equivalence = nullptr; + std::shared_ptr m_symbol = nullptr; }; /// \brief Insert a human-readable representation of a dimension into an output stream. diff --git a/src/core/include/openvino/core/node.hpp b/src/core/include/openvino/core/node.hpp index e0e027a3bf194a..f5a63911abc502 100644 --- a/src/core/include/openvino/core/node.hpp +++ b/src/core/include/openvino/core/node.hpp @@ -205,7 +205,7 @@ class OPENVINO_API Node : public std::enable_shared_from_this { const ov::EvaluationContext& evaluationContext) const; virtual bool evaluate_lower(ov::TensorVector& output_values) const; virtual bool evaluate_upper(ov::TensorVector& output_values) const; - virtual bool evaluate_label(TensorLabelVector& output_labels) const; + virtual bool evaluate_symbol(TensorSymbolVector& output_symbols) const; virtual bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values); /// \brief Decomposes the FusedOp into a sub-graph consisting of core openvino ops diff --git a/src/core/include/openvino/core/symbol.hpp b/src/core/include/openvino/core/symbol.hpp new file mode 100644 index 00000000000000..9157a2df1a2abd --- /dev/null +++ b/src/core/include/openvino/core/symbol.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +#include "openvino/core/core_visibility.hpp" + +namespace ov { + +class Symbol; + +namespace symbol { +/// \brief If both symbols are valid, sets them as equal +void OPENVINO_API set_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +/// \brief Returns true if both symbols are valid and are equal otherwise returns false +bool OPENVINO_API are_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +/// \brief Returns a representative (the most distant parent) of an equality group of this symbol +std::shared_ptr OPENVINO_API ancestor_of(const std::shared_ptr& x); +} // namespace symbol + +/// \brief Class representing unique symbol for the purpose of symbolic shape inference. Equality of symbols is being +/// tracked by Disjoint-set data structure +/// \ingroup ov_model_cpp_api +class OPENVINO_API Symbol : public std::enable_shared_from_this { +public: + /// \brief Default constructs a unique symbol + Symbol() = default; + +private: + /// \brief Returns immediate parent of the Symbol, in case parent is unknown sets this as a parent for itself + std::shared_ptr parent(); + + friend std::shared_ptr ov::symbol::ancestor_of(const std::shared_ptr& x); + friend void ov::symbol::set_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); + friend bool ov::symbol::are_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); + + std::shared_ptr m_parent = nullptr; +}; + +} // namespace ov diff --git a/src/core/include/openvino/op/concat.hpp b/src/core/include/openvino/op/concat.hpp index 4ca09de2a884d3..5fa76967326a53 100644 --- a/src/core/include/openvino/op/concat.hpp +++ b/src/core/include/openvino/op/concat.hpp @@ -54,7 +54,7 @@ class OPENVINO_API Concat : public Op { bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbol) const override; protected: /// \ brief m_axis stores default value for all iterations diff --git a/src/core/include/openvino/op/convert.hpp b/src/core/include/openvino/op/convert.hpp index e4eeb8250b2a9a..c82c2a84c71011 100644 --- a/src/core/include/openvino/op/convert.hpp +++ b/src/core/include/openvino/op/convert.hpp @@ -44,7 +44,7 @@ class OPENVINO_API Convert : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; protected: ov::element::Type m_destination_type; diff --git a/src/core/include/openvino/op/reshape.hpp b/src/core/include/openvino/op/reshape.hpp index 4bf54c5562266b..f3a9e7aa8e59c1 100644 --- a/src/core/include/openvino/op/reshape.hpp +++ b/src/core/include/openvino/op/reshape.hpp @@ -50,7 +50,7 @@ class OPENVINO_API Reshape : public Op { bool has_evaluate() const override; bool evaluate_upper(TensorVector& outputs) const override; bool evaluate_lower(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; protected: diff --git a/src/core/include/openvino/op/scatter_nd_update.hpp b/src/core/include/openvino/op/scatter_nd_update.hpp index 41b74ae2a044d2..653a6857f69d23 100644 --- a/src/core/include/openvino/op/scatter_nd_update.hpp +++ b/src/core/include/openvino/op/scatter_nd_update.hpp @@ -25,7 +25,7 @@ class OPENVINO_API ScatterNDUpdate : public util::ScatterNDBase { bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool has_evaluate() const override; }; } // namespace v3 diff --git a/src/core/include/openvino/op/scatter_update.hpp b/src/core/include/openvino/op/scatter_update.hpp index 81b1f60d30d424..6be01fb5ed2fe9 100644 --- a/src/core/include/openvino/op/scatter_update.hpp +++ b/src/core/include/openvino/op/scatter_update.hpp @@ -35,7 +35,7 @@ class OPENVINO_API ScatterUpdate : public util::ScatterBase { bool evaluate(TensorVector& outputs, const TensorVector& inputs) const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool has_evaluate() const override; }; } // namespace v3 diff --git a/src/core/include/openvino/op/shape_of.hpp b/src/core/include/openvino/op/shape_of.hpp index cd54f12a56f397..c8245d91069ed0 100644 --- a/src/core/include/openvino/op/shape_of.hpp +++ b/src/core/include/openvino/op/shape_of.hpp @@ -36,7 +36,7 @@ class OPENVINO_API ShapeOf : public util::ShapeOfBase { bool evaluate(TensorVector& output_values, const TensorVector& input_values) const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& input_values) override; private: @@ -62,7 +62,7 @@ class OPENVINO_API ShapeOf : public util::ShapeOfBase { bool evaluate(TensorVector& output_values, const TensorVector& input_values) const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& input_values) override; }; } // namespace v0 diff --git a/src/core/include/openvino/op/slice.hpp b/src/core/include/openvino/op/slice.hpp index d8bedcaa361b8b..923f84521d8500 100644 --- a/src/core/include/openvino/op/slice.hpp +++ b/src/core/include/openvino/op/slice.hpp @@ -47,7 +47,7 @@ class OPENVINO_API Slice : public Op { bool evaluate(TensorVector&, const TensorVector&) const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; std::shared_ptr get_default_const_axes(const Output& start) const; }; diff --git a/src/core/include/openvino/op/split.hpp b/src/core/include/openvino/op/split.hpp index 97fa56e4f0b534..0a7fd401a9d4ac 100644 --- a/src/core/include/openvino/op/split.hpp +++ b/src/core/include/openvino/op/split.hpp @@ -44,7 +44,7 @@ class OPENVINO_API Split : public Op { bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; bool has_evaluate() const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; protected: size_t m_num_splits; diff --git a/src/core/include/openvino/op/squeeze.hpp b/src/core/include/openvino/op/squeeze.hpp index 2481029609a03b..f7cb41f974db2f 100644 --- a/src/core/include/openvino/op/squeeze.hpp +++ b/src/core/include/openvino/op/squeeze.hpp @@ -25,7 +25,7 @@ class OPENVINO_API Squeeze : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/src/core/include/openvino/op/strided_slice.hpp b/src/core/include/openvino/op/strided_slice.hpp index d76c6419018280..2ba4f84c0936bf 100644 --- a/src/core/include/openvino/op/strided_slice.hpp +++ b/src/core/include/openvino/op/strided_slice.hpp @@ -112,7 +112,7 @@ class OPENVINO_API StridedSlice : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; private: diff --git a/src/core/include/openvino/op/tile.hpp b/src/core/include/openvino/op/tile.hpp index c880ae72bec622..cf4f41be1d9085 100644 --- a/src/core/include/openvino/op/tile.hpp +++ b/src/core/include/openvino/op/tile.hpp @@ -31,7 +31,7 @@ class OPENVINO_API Tile : public Op { bool evaluate_upper(TensorVector& outputs) const override; bool has_evaluate() const override; bool evaluate(ov::TensorVector& outputs, const ov::TensorVector& inputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; }; } // namespace v0 } // namespace op diff --git a/src/core/include/openvino/op/transpose.hpp b/src/core/include/openvino/op/transpose.hpp index a0380ac29da94c..8c5ba62d503004 100644 --- a/src/core/include/openvino/op/transpose.hpp +++ b/src/core/include/openvino/op/transpose.hpp @@ -35,7 +35,7 @@ class OPENVINO_API Transpose : public Op { bool evaluate_upper(TensorVector& output_values) const override; bool evaluate_lower(TensorVector& output_values) const override; bool has_evaluate() const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; /// \brief Inputs indexes and count. enum Ins : size_t { ARG, ORDER, IN_COUNT }; diff --git a/src/core/include/openvino/op/unsqueeze.hpp b/src/core/include/openvino/op/unsqueeze.hpp index 71939fef2d09a6..d9839c7d68d719 100644 --- a/src/core/include/openvino/op/unsqueeze.hpp +++ b/src/core/include/openvino/op/unsqueeze.hpp @@ -27,7 +27,7 @@ class OPENVINO_API Unsqueeze : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; diff --git a/src/core/include/openvino/op/util/gather_base.hpp b/src/core/include/openvino/op/util/gather_base.hpp index f9125c4c13e66e..f7846b83cfe465 100644 --- a/src/core/include/openvino/op/util/gather_base.hpp +++ b/src/core/include/openvino/op/util/gather_base.hpp @@ -31,7 +31,7 @@ class OPENVINO_API GatherBase : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; bool constant_fold(OutputVector& output_values, const OutputVector& inputs_values) override; const int64_t& get_batch_dims() const; diff --git a/src/core/include/openvino/op/util/pad_base.hpp b/src/core/include/openvino/op/util/pad_base.hpp index 6efb4aa8efcb41..1f6d6dc173d5d2 100644 --- a/src/core/include/openvino/op/util/pad_base.hpp +++ b/src/core/include/openvino/op/util/pad_base.hpp @@ -64,7 +64,7 @@ class OPENVINO_API PadBase : public Op { bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; protected: PadMode m_pad_mode{PadMode::CONSTANT}; diff --git a/src/core/include/openvino/op/util/scatter_elements_update_base.hpp b/src/core/include/openvino/op/util/scatter_elements_update_base.hpp index 7bfc8e29c93bd5..bcf6ae11f455bf 100644 --- a/src/core/include/openvino/op/util/scatter_elements_update_base.hpp +++ b/src/core/include/openvino/op/util/scatter_elements_update_base.hpp @@ -31,7 +31,7 @@ class OPENVINO_API ScatterElementsUpdateBase : public Op { bool has_evaluate() const override; bool evaluate_lower(TensorVector& output_values) const override; bool evaluate_upper(TensorVector& output_values) const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; protected: bool is_supported_index_input_element_type() const; diff --git a/src/core/include/openvino/op/util/symbolic_info.hpp b/src/core/include/openvino/op/util/symbolic_info.hpp index 1291ec578ed61a..0b2f5d089689b0 100644 --- a/src/core/include/openvino/op/util/symbolic_info.hpp +++ b/src/core/include/openvino/op/util/symbolic_info.hpp @@ -12,43 +12,26 @@ namespace ov { -OPENVINO_API void set_up_symbolic_info(const std::shared_ptr& model, - const std::shared_ptr& table); -OPENVINO_API void set_up_symbolic_info(const ov::Output& output, - const std::shared_ptr& table); - -OPENVINO_API void populate_tensor_with_missing_labels(ov::descriptor::Tensor& tensor); +OPENVINO_API void skip_invalidation(const ov::Output& output); OPENVINO_API bool skip_invalidation(const ov::descriptor::Tensor& tensor); -OPENVINO_API std::shared_ptr table_of_equivalence(const std::shared_ptr& model); -OPENVINO_API std::shared_ptr table_of_equivalence(const ov::descriptor::Tensor& tensor); -OPENVINO_API void remove_symbolic_info(const std::shared_ptr& model, bool outermost_model = true); +OPENVINO_API void remove_skip_invalidation_rti(const std::shared_ptr& model, bool outermost_model = true); + +OPENVINO_API void populate_tensor_with_missing_symbols(ov::descriptor::Tensor& tensor); /** * @ingroup ov_runtime_attr_api - * @brief SymbolicInfo class represents runtime info attribute that instructs ov::Output objects to skip invalidation of - * partial values and labels during partial value propagation and keeps shared_ptr to TableOfEquivalence. + * @brief SkipInvalidation class represents runtime info attribute that instructs ov::Output objects to skip + * invalidation of partial values and symbols during partial value propagation. */ -class OPENVINO_API SymbolicInfo : public RuntimeAttribute { +class OPENVINO_API SkipInvalidation : public RuntimeAttribute { public: - OPENVINO_RTTI("SymbolicInfo", "0"); - explicit SymbolicInfo(bool skip_invalidation, const std::shared_ptr& table) - : m_skip_invalidation{skip_invalidation}, - m_table{table} {}; + OPENVINO_RTTI("SkipInvalidation", "0"); + SkipInvalidation() = default; bool is_copyable() const override { return false; } - bool get_skip_invalidation() const { - return m_skip_invalidation; - } - std::shared_ptr get_table() const { - return m_table; - } - -private: - bool m_skip_invalidation; - std::shared_ptr m_table; }; } // namespace ov diff --git a/src/core/include/openvino/op/variadic_split.hpp b/src/core/include/openvino/op/variadic_split.hpp index 6219527f120242..4cfff60d53fdf6 100644 --- a/src/core/include/openvino/op/variadic_split.hpp +++ b/src/core/include/openvino/op/variadic_split.hpp @@ -39,7 +39,7 @@ class OPENVINO_API VariadicSplit : public Op { bool evaluate_lower(TensorVector& outputs) const override; bool evaluate_upper(TensorVector& outputs) const override; bool has_evaluate() const override; - bool evaluate_label(TensorLabelVector& output_labels) const override; + bool evaluate_symbol(TensorSymbolVector& output_symbols) const override; }; } // namespace v1 } // namespace op diff --git a/src/core/include/openvino/pass/visualize_tree.hpp b/src/core/include/openvino/pass/visualize_tree.hpp index 0436dba3a14712..065cec96e27220 100644 --- a/src/core/include/openvino/pass/visualize_tree.hpp +++ b/src/core/include/openvino/pass/visualize_tree.hpp @@ -56,6 +56,7 @@ class OPENVINO_API VisualizeTree : public ModelPass { node_modifiers_t m_node_modifiers = nullptr; bool m_dot_only; static constexpr int max_jump_distance = 20; + std::unordered_map, size_t> m_symbol_to_name; }; } // namespace pass } // namespace ov diff --git a/src/core/reference/src/op/einsum.cpp b/src/core/reference/src/op/einsum.cpp index 639d93b6c3c716..c28c031d1f6e34 100644 --- a/src/core/reference/src/op/einsum.cpp +++ b/src/core/reference/src/op/einsum.cpp @@ -103,8 +103,8 @@ std::string generate_grouping_subscript(const std::string& input_subscript, return required_subscript; } -std::unordered_map compute_label_dim_map(const Rank& input_rank, - const std::string& input_subscript) { +std::unordered_map> compute_label_dim_map(const Rank& input_rank, + const std::string& input_subscript) { constexpr char ellipsis[] = "..."; auto labels = ov::op::v7::Einsum::extract_labels(input_subscript); size_t input_rank_length = labels.size(); @@ -113,25 +113,25 @@ std::unordered_map compute_label_dim_map(const Ran if (input_rank.is_static()) { input_rank_length = input_rank.get_length(); } - std::unordered_map resulted_map; + std::unordered_map> resulted_map; OPENVINO_ASSERT(input_rank_length >= labels.size()); size_t num_broadcasted_dims = input_rank_length - labels.size() + 1; size_t current_dim = 0; for (const auto& label : labels) { if (label == ellipsis) { - ov::TensorLabel label_dims; + std::vector label_dims; for (size_t ind = 0; ind < num_broadcasted_dims; ++ind) { - label_dims.push_back(static_cast(current_dim + ind)); + label_dims.push_back(static_cast(current_dim + ind)); } resulted_map[label] = label_dims; current_dim += num_broadcasted_dims; } else if (resulted_map.find(label) != resulted_map.end()) { - resulted_map[label].push_back(static_cast(current_dim)); + resulted_map[label].push_back(static_cast(current_dim)); ++current_dim; } else { - ov::TensorLabel label_dims; - label_dims.push_back(static_cast(current_dim)); + std::vector label_dims; + label_dims.push_back(static_cast(current_dim)); resulted_map[label] = label_dims; ++current_dim; } @@ -460,7 +460,7 @@ void broadcast_input(ov::TensorVector& inputs, /// identity /// template -ov::Tensor build_identity(const ov::Tensor& input, const ov::TensorLabel& repeated_label_dims) { +ov::Tensor build_identity(const ov::Tensor& input, const std::vector& repeated_label_dims) { // allocate Tensor for building identity tensor OPENVINO_ASSERT(repeated_label_dims.size() > 1); Shape input_shape = input.get_shape(); @@ -504,7 +504,7 @@ ov::Tensor build_identity(const ov::Tensor& input, const ov::TensorLabel& repeat template ov::Tensor build_multi_identity(const ov::Tensor& input, const std::vector& repeated_labels, - std::unordered_map& label_dim_map) { + std::unordered_map>& label_dim_map) { Shape input_shape = input.get_shape(); // initially set multi-identity with identity for the first repeated label diff --git a/src/core/shape_inference/include/fft_base_shape_inference.hpp b/src/core/shape_inference/include/fft_base_shape_inference.hpp index b4a195c733dc73..1012794a28ce47 100644 --- a/src/core/shape_inference/include/fft_base_shape_inference.hpp +++ b/src/core/shape_inference/include/fft_base_shape_inference.hpp @@ -6,7 +6,7 @@ #include "dimension_util.hpp" #include "fft_common_validation.hpp" #include "openvino/core/axis_vector.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/util/fft_base.hpp" #include "utils.hpp" @@ -25,15 +25,15 @@ void apply_dims_from_sizes(const util::FFTBase* op, if (const auto output_bounds = get_input_bounds(op, 2, ta)) { const auto minus_one_bound = std::make_pair(dim::inf_bound, dim::inf_bound); const auto num_of_axes = axes.size(); - const auto labels = - op->get_input_size() > 2 ? op->get_input_source_output(2).get_tensor().get_value_label() : TensorLabel(); - const bool propagate_labels = num_of_axes <= labels.size(); + const auto symbols = + op->get_input_size() > 2 ? op->get_input_source_output(2).get_tensor().get_value_symbol() : TensorSymbol(); + const bool propagate_symbols = num_of_axes <= symbols.size(); for (size_t i = 0; i < num_of_axes; ++i) { if ((*output_bounds)[i] != minus_one_bound) { auto& out_dim = output_shape[(axes)[i]]; out_dim = DimType((*output_bounds)[i].first, (*output_bounds)[i].second); - if (propagate_labels && labels[i] != ov::no_label) { - DimensionTracker::set_label(out_dim, labels[i]); + if (propagate_symbols && symbols[i] != nullptr) { + out_dim.set_symbol(symbols[i]); } } } diff --git a/src/core/shape_inference/include/reshape_shape_inference.hpp b/src/core/shape_inference/include/reshape_shape_inference.hpp index 5da89e773beadb..273d803ca8c82d 100644 --- a/src/core/shape_inference/include/reshape_shape_inference.hpp +++ b/src/core/shape_inference/include/reshape_shape_inference.hpp @@ -5,7 +5,6 @@ #include "compare.hpp" #include "dimension_util.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/reshape.hpp" #include "utils.hpp" @@ -83,8 +82,9 @@ struct Product::value>::ty void calculate() { // dimensions compare to remove same from product calculation auto dim_full_eq = [](const T& lhs, const T& rhs) -> bool { - return (lhs == rhs) && DimensionTracker::get_label(lhs) == DimensionTracker::get_label(rhs) && - (lhs.is_static() || DimensionTracker::has_label(lhs)); + bool symbols_equal_or_both_null = + ov::symbol::are_equal(lhs.get_symbol(), rhs.get_symbol()) || (!lhs.has_symbol() && !rhs.has_symbol()); + return (lhs == rhs) && symbols_equal_or_both_null && (lhs.is_static() || lhs.has_symbol()); }; auto outs = outputs; @@ -154,7 +154,7 @@ TDim resolve_minus_one_dim(const Product& product) { } if (product_out.get_min_length() != 1 || product_out.get_max_length() != 1) { - DimensionTracker::reset_tracking_info(minus_one_dim); + minus_one_dim.set_symbol(nullptr); } } return minus_one_dim; @@ -215,31 +215,29 @@ std::pair get_pattern_and_minus_one_idx(const Node* const op, } /** - * @brief Set the pattern labels on pattern shape if this input is labeled. + * @brief Set the pattern symbols on pattern shape if this input has symbols. * * @param op Pointer to reshape node. - * @param shape Pointer to shape for labels set. + * @param shape Pointer to shape for symbols set. */ template ::value>::type* = nullptr> -void set_pattern_labels(const Node* const op, TShape& shape) { +void set_pattern_symbols(const Node* const op, TShape& shape) { if (op->get_input_size() > 0) { - auto labels = op->get_input_source_output(1).get_tensor().get_value_label(); + auto symbols = op->get_input_source_output(1).get_tensor().get_value_symbol(); - if (!labels.empty()) { - auto label_iter = labels.begin(); + if (!symbols.empty()) { + auto symbol_iter = symbols.begin(); for (auto& d : shape) { - if (*label_iter != no_label) { - DimensionTracker::set_label(d, *label_iter); - } - ++label_iter; + d.set_symbol(*symbol_iter); + ++symbol_iter; } } } } -/** @brief Shapes other than PartialShape have no labels. */ +/** @brief Shapes other than PartialShape have no symbols. */ template ::value>::type* = nullptr> -void set_pattern_labels(const Node* const, TShape&) {} +void set_pattern_symbols(const Node* const, TShape&) {} } // namespace reshape @@ -271,7 +269,7 @@ std::vector shape_infer(const Reshape* op, auto& output_pattern = pattern_and_minus_one_idx.first; const auto minus_one_idx = pattern_and_minus_one_idx.second; - reshape::set_pattern_labels(op, output_pattern); + reshape::set_pattern_symbols(op, output_pattern); if (pattern_shape_rank.get_max_length() == 0) { NODE_VALIDATION_CHECK(op, diff --git a/src/core/src/bound_evaluate.cpp b/src/core/src/bound_evaluate.cpp index c9b5cd3fb421ed..6ffbb3a07e5710 100644 --- a/src/core/src/bound_evaluate.cpp +++ b/src/core/src/bound_evaluate.cpp @@ -4,7 +4,8 @@ #include "bound_evaluate.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "compare.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/rt_info.hpp" #include "openvino/core/shape_util.hpp" #include "openvino/core/validation_util.hpp" @@ -96,7 +97,7 @@ ov::Tensor evaluate_bound(const Output& output, bool is_upper, bool invali if (is_upper ? node->evaluate_upper(outputs) : node->evaluate_lower(outputs)) { const auto& input_values = node->input_values(); - TensorLabelVector output_labels(outputs.size()); + TensorSymbolVector output_symbols(outputs.size()); bool same_inputs = std::all_of(input_values.begin(), input_values.end(), [](const Output& input) { auto& t = input.get_tensor(); @@ -118,15 +119,15 @@ ov::Tensor evaluate_bound(const Output& output, bool is_upper, bool invali } } - bool labels_evaluated = node->evaluate_label(output_labels); + bool symbols_evaluated = node->evaluate_symbol(output_symbols); for (size_t i = 0; i < outputs.size(); ++i) { auto& out_tensor = node->get_output_tensor(i); - if (!out_tensor.get_value_label().empty()) + if (!out_tensor.get_value_symbol().empty()) continue; - if (labels_evaluated) - out_tensor.set_value_label(output_labels[i]); + if (symbols_evaluated) + out_tensor.set_value_symbol(output_symbols[i]); if (outputs[i]) - ov::populate_tensor_with_missing_labels(out_tensor); + ov::populate_tensor_with_missing_symbols(out_tensor); } for (const auto& input : input_values) { @@ -330,8 +331,8 @@ std::pair ov::evaluate_both_bounds(const Output& o auto& t = input.get_tensor(); return t.has_and_set_bound() || are_equal(t.get_lower_value(), t.get_upper_value()); }); - TensorLabelVector output_labels(node->get_output_size()); - bool labels_evaluated = node->evaluate_label(output_labels); + TensorSymbolVector output_symbols(node->get_output_size()); + bool symbols_evaluated = node->evaluate_symbol(output_symbols); for (size_t i = 0; i < node->get_output_size(); ++i) { auto& out_tensor = node->get_output_tensor(i); @@ -342,11 +343,11 @@ std::pair ov::evaluate_both_bounds(const Output& o out_tensor.set_upper_value(outputs_upper[i]); } - if (!out_tensor.get_value_label().empty()) + if (!out_tensor.get_value_symbol().empty()) continue; - if (labels_evaluated) - out_tensor.set_value_label(output_labels[i]); - ov::populate_tensor_with_missing_labels(node->get_output_tensor(i)); + if (symbols_evaluated) + out_tensor.set_value_symbol(output_symbols[i]); + ov::populate_tensor_with_missing_symbols(node->get_output_tensor(i)); } for (const auto& input : node->input_values()) { auto& tensor = input.get_tensor(); @@ -565,29 +566,96 @@ bool ov::have_node_inputs_bounds_set(const Node* const node, const size_t first_ return have_bound_set; } -bool ov::default_label_evaluator(const Node* node, - std::initializer_list labeled_inputs, - TensorLabelVector& output_labels) { - bool has_any_input_labels = false; +namespace { +/// \brief Encodes tensor symbol vector as tensor integer vector for the purpose of evaluation. Provides the key for +/// decoding back. +/// +/// \param symbols All symbols that are planned for evaluation +/// \param integer_representations Container representing resulting encodings +/// \param key Map representing resulting key for decoding +void symbols_to_integer_and_key(const TensorSymbolVector& symbols, + std::vector>& integer_representations, + std::unordered_map>& key) { + int32_t x = 0; + std::unordered_map, int32_t> key_for_encoding; + + key_for_encoding[nullptr] = 0; + key[0] = nullptr; + + for (const auto& container : symbols) { + for (const auto& symbol : container) { + if (symbol == nullptr) + continue; + const auto& root = symbol::ancestor_of(symbol); + if (key_for_encoding.find(root) == key_for_encoding.end()) { + x += 1; + key_for_encoding[root] = x; + key[x] = root; + } + } + } + integer_representations.resize(symbols.size()); + for (size_t i = 0; i < symbols.size(); ++i) { + integer_representations[i].resize(symbols[i].size()); + for (size_t j = 0; j < symbols[i].size(); ++j) { + const auto& symbol = symbols[i][j]; + const auto& root = (symbol ? symbol::ancestor_of(symbol) : nullptr); + integer_representations[i][j] = key_for_encoding[root]; + } + } +} + +/// \brief Decodes tensor integer vector to tensor symbol vector after the evaluation. Uses provided key for decoding. +/// +/// \param integer_representations Container representing encodings +/// \param key Map representing key for decoding +/// \param symbols Tensor symbol vector representing resulting symbols after evaluation +void integer_and_key_to_symbols(const std::vector& integer_representations, + const std::unordered_map>& key, + TensorSymbol& symbols) { + symbols.resize(integer_representations.size()); + for (size_t i = 0; i < integer_representations.size(); ++i) { + if (key.count(integer_representations[i])) + symbols[i] = key.at(integer_representations[i]); + else + symbols[i] = nullptr; + } +} +} // namespace + +bool ov::default_symbol_evaluator(const Node* node, + std::initializer_list symbol_inputs, + TensorSymbolVector& output_symbols) { + TensorSymbolVector input_symbols; + for (const auto& input : node->input_values()) + input_symbols.push_back(input.get_tensor().get_value_symbol()); + + /// turn Symbol objects to int32 to put them through evaluate + std::vector> integer_representation; + std::unordered_map> key; + symbols_to_integer_and_key(input_symbols, integer_representation, key); + + bool has_any_input_symbols = false; const auto& inputs_count = node->get_input_size(); TensorVector inputs; inputs.reserve(inputs_count); 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(); - if (!ov::util::has_no_labels(labels) && !has_any_input_labels) { - has_any_input_labels = true; - } - - if (node->get_input_partial_shape(i).is_static()) { - labels.resize(shape_size(node->get_input_shape(i)), no_label); - inputs.emplace_back(element::from(), node->get_input_shape(i)); - std::copy(labels.begin(), labels.end(), inputs.back().data()); - } else { + if (!symbol_inputs.size() || std::find(symbol_inputs.begin(), symbol_inputs.end(), i) != symbol_inputs.end()) { + const auto& pshape = node->get_input_partial_shape(i); + if (pshape.is_dynamic()) return false; - } + + auto& representation = integer_representation[i]; + if (std::any_of(representation.begin(), representation.end(), [](int32_t& s) { + return s > 0; + })) + has_any_input_symbols = true; + + representation.resize(shape_size(pshape.to_shape()), 0); + inputs.emplace_back(element::from(), node->get_input_shape(i)); + std::copy(representation.begin(), representation.end(), inputs.back().data()); } else { if (node->get_input_tensor(i).has_and_set_bound()) { inputs.push_back(node->get_input_tensor(i).get_lower_value()); @@ -597,7 +665,7 @@ bool ov::default_label_evaluator(const Node* node, } } - if (has_any_input_labels) { + if (has_any_input_symbols) { const auto& outputs_count = node->get_output_size(); TensorVector outputs; outputs.reserve(outputs_count); @@ -606,13 +674,20 @@ bool ov::default_label_evaluator(const Node* node, const auto& partial_shape = node->get_output_partial_shape(i); // Set shape for static or special dynamic if partial shape is dynamic. const auto& shape = partial_shape.is_static() ? partial_shape.to_shape() : Shape{0}; - outputs.emplace_back(element::from(), shape); + outputs.emplace_back(element::from(), shape); } if (node->evaluate(outputs, inputs)) { - std::transform(outputs.cbegin(), outputs.cend(), output_labels.begin(), [](const Tensor& t) { - // Return empty label tensor if input tensor not valid (can have Shape{0}) - return t ? TensorLabel(t.data(), t.data() + t.get_size()) : TensorLabel(); + std::transform(outputs.cbegin(), outputs.cend(), output_symbols.begin(), [&](const Tensor& t) { + // Return empty symbol tensor if input tensor not valid (can have Shape{0}) + if (t) { + TensorSymbol output_symbol; + std::vector integer_output_data(t.data(), t.data() + t.get_size()); + integer_and_key_to_symbols(integer_output_data, key, output_symbol); + return output_symbol; + } else { + return TensorSymbol(); + } }); return true; } diff --git a/src/core/src/bound_evaluate.hpp b/src/core/src/bound_evaluate.hpp index 458918d971d1f4..872aea4e83aa04 100644 --- a/src/core/src/bound_evaluate.hpp +++ b/src/core/src/bound_evaluate.hpp @@ -59,15 +59,16 @@ bool has_and_set_equal_bounds(const Output& source); /// greater than node's inputs count. bool have_node_inputs_bounds_set(const ov::Node* const node, const size_t first_idx, const size_t last_idx); -/// \brief Propagates value label from given inputs list to the only output through an operation. +/// \brief Propagates value symbol from given inputs list 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 labeled_inputs List of node inputs to propagate labels. -/// \param output_labels Vector of TensorLabel objects representing resulting value labels -/// \return boolean status if label evaluation was successful. -bool default_label_evaluator(const Node* node, - std::initializer_list labeled_inputs, - TensorLabelVector& output_labels); +/// \param symbol_inputs List of node input indices to propagate symbols. If empty all inputs are considered for +/// propagation \param output_symbols Vector of TensorSymbol objects representing resulting value symbols \return +/// boolean status if symbol evaluation was successful. +bool default_symbol_evaluator(const Node* node, + std::initializer_list symbol_inputs, + TensorSymbolVector& output_symbols); + } // namespace ov diff --git a/src/core/src/descriptor/tensor.cpp b/src/core/src/descriptor/tensor.cpp index 9f68fbfd7d2b52..07b9737d07c19f 100644 --- a/src/core/src/descriptor/tensor.cpp +++ b/src/core/src/descriptor/tensor.cpp @@ -33,7 +33,7 @@ void ov::descriptor::Tensor::invalidate_values() { return; m_upper_value = {}; m_lower_value = {}; - m_value_label.clear(); + m_value_symbol.clear(); } void ov::descriptor::Tensor::set_lower_value(const ov::Tensor& value) { @@ -50,14 +50,14 @@ void ov::descriptor::Tensor::set_upper_value(const ov::Tensor& value) { m_upper_value = value; } -void ov::descriptor::Tensor::set_value_label(const TensorLabel& value_label) { - const auto& labels_size = value_label.size(); - if (labels_size == 0) { - m_value_label.clear(); +void ov::descriptor::Tensor::set_value_symbol(const TensorSymbol& value_symbol) { + const auto& symbols_size = value_symbol.size(); + if (symbols_size == 0) { + m_value_symbol.clear(); } else { OPENVINO_ASSERT(m_partial_shape.is_static()); - OPENVINO_ASSERT(shape_size(m_partial_shape.to_shape()) == labels_size); - m_value_label = value_label; + OPENVINO_ASSERT(shape_size(m_partial_shape.to_shape()) == symbols_size); + m_value_symbol = value_symbol; } } @@ -121,7 +121,7 @@ void ov::descriptor::Tensor::clone_from(const ov::descriptor::Tensor& old) { m_partial_shape = old.get_partial_shape(); m_lower_value = old.get_lower_value(); m_upper_value = old.get_upper_value(); - m_value_label = old.get_value_label(); + m_value_symbol = old.get_value_symbol(); m_legacy_name = old.m_legacy_name; m_rt_info = old.get_rt_info(); m_shape_changed = true; diff --git a/src/core/src/dimension.cpp b/src/core/src/dimension.cpp index 918880fd15cbef..454207c24377e4 100644 --- a/src/core/src/dimension.cpp +++ b/src/core/src/dimension.cpp @@ -7,38 +7,38 @@ #include #include #include -#include #include -#include "openvino/core/dimension_tracker.hpp" #include "openvino/util/common_util.hpp" using namespace ov; namespace { /** - * \brief Merges two labels. + * \brief Merges two symbols. * - * | label_a | label_b | result | - * |----------|----------|----------| - * | X | X | X | - * | X | no label | X | - * | no label | X | X | - * | X | Y | Y | (if merge_unequal == true) - * | X | Y | no label | (if merge_unequal == false) + * | lhs | rhs | result | + * |-----------|-----------|-----------| + * | X | X | X | + * | X | no symbol | X | + * | no symbol | X | X | + * | X | Y | Y | (if merge_unequal == true) + * | X | Y | no symbol | (if merge_unequal == false) * - * \param label_a First input label. - * \param label_b Second input label. + * \param lhs First input symbol. + * \param lhs Second input symbol. * - * \return ov::label_t Merged label value + * \return Merged symbol shared pointer */ -ov::label_t merge_labels(const ov::label_t label_a, const ov::label_t label_b, bool merge_unequal = true) { - if (label_a == label_b || label_b == ov::no_label) - return label_a; - else if (merge_unequal || label_a == ov::no_label) - return label_b; +std::shared_ptr merge_symbols(std::shared_ptr lhs, + std::shared_ptr rhs, + bool merge_unequal = true) { + if (ov::symbol::are_equal(lhs, rhs) || rhs == nullptr) + return lhs; + else if (merge_unequal || lhs == nullptr) + return rhs; else - return ov::no_label; + return nullptr; } int64_t stringToInt64(const std::string& valStr) { @@ -196,14 +196,8 @@ bool Dimension::merge(Dimension& dst, const Dimension& d1, const Dimension& d2) } else { dst = Dimension(result_interval); } - - if (auto& t = d1.m_table_of_equivalence) - t->set_as_equal(d1, d2); - else if (auto& t = d2.m_table_of_equivalence) - t->set_as_equal(d1, d2); - - dst.m_label = merge_labels(d1.m_label, d2.m_label); - + ov::symbol::set_equal(d1.m_symbol, d2.m_symbol); + dst.m_symbol = merge_symbols(d1.m_symbol, d2.m_symbol); return true; } @@ -216,7 +210,7 @@ bool Dimension::broadcast_merge(Dimension& dst, const Dimension& d1, const Dimen if (result.empty()) return false; dst = Dimension(result); - dst.m_label = merge_labels(d1.m_label, d2.m_label, dst.is_static()); + dst.m_symbol = merge_symbols(d1.m_symbol, d2.m_symbol, dst.is_static()); return true; } else if (d1_has_1) { dst = d2; @@ -242,3 +236,15 @@ Dimension::value_type Dimension::get_max_length() const { Dimension::value_type Dimension::get_min_length() const { return dimension_length(m_dimension.get_min_val()); } + +bool Dimension::has_symbol() const { + return m_symbol != nullptr; +} + +std::shared_ptr Dimension::get_symbol() const { + return m_symbol; +} + +void Dimension::set_symbol(const std::shared_ptr& s) { + m_symbol = s; +} diff --git a/src/core/src/dimension_tracker.cpp b/src/core/src/dimension_tracker.cpp deleted file mode 100644 index 4de869ead861e9..00000000000000 --- a/src/core/src/dimension_tracker.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "openvino/core/dimension_tracker.hpp" - -using namespace ov; - -void TableOfEquivalence::set_as_equal(const Dimension& lhs, const Dimension& rhs) { - const auto &l_label = DimensionTracker::get_label(lhs), r_label = DimensionTracker::get_label(rhs); - if (l_label == ov::no_label || r_label == ov::no_label) - // TODO after value restriction enabling: non labeled dim propagates restriction (if any) to labeled dim - return; - - auto get_soup = [](const label_t& label, EqTable& table) -> EqualitySoup { - if (!table.count(label) || !table.at(label)) - table[label] = std::make_shared>(std::set{label}); - return table.at(label); - }; - - auto l_soup = get_soup(l_label, dimension_table_of_equivalence); - auto r_soup = get_soup(r_label, dimension_table_of_equivalence); - if (r_soup->size() > l_soup->size()) // we would like to minimize number of iterations in the following for-loop - std::swap(l_soup, r_soup); - l_soup->insert(r_soup->begin(), r_soup->end()); - for (const auto& label : *r_soup) - dimension_table_of_equivalence[label] = l_soup; -} - -const ValTable& TableOfEquivalence::get_value_equivalence_table() const { - return value_table_of_equivalence; -} - -const EqTable& TableOfEquivalence::get_equivalence_table() const { - return dimension_table_of_equivalence; -} - -label_t TableOfEquivalence::get_next_label() { - return current_label++; -} - -bool TableOfEquivalence::are_equal(const Dimension& lhs, const Dimension& rhs) { - if (!DimensionTracker::has_label(lhs) || !DimensionTracker::has_label(rhs)) - return false; - const auto &l_label = DimensionTracker::get_label(lhs), &r_label = DimensionTracker::get_label(rhs); - if (l_label == r_label) - return true; - if (dimension_table_of_equivalence.count(l_label) && dimension_table_of_equivalence[l_label]) - return dimension_table_of_equivalence[l_label]->count(r_label); - return false; -} - -void DimensionTracker::set_label(Dimension& d, label_t label) { - OPENVINO_ASSERT(label != no_label, "Can not set zero as label for dimension -- it is reserved for no label"); - d.m_label = label; -} - -bool DimensionTracker::has_label(const Dimension& d) { - return d.m_label != no_label; -} - -label_t DimensionTracker::get_label(const Dimension& d) { - return d.m_label; -} - -const std::shared_ptr& DimensionTracker::get_table_of_equivalence(const Dimension& d) { - return d.m_table_of_equivalence; -} - -void DimensionTracker::set_table_of_equivalence(Dimension& d) const { - OPENVINO_ASSERT(d.m_table_of_equivalence == nullptr, "Dimension is already being tracked"); - OPENVINO_ASSERT(m_table_of_equivalence != nullptr, "Can not set nullptr as table of equivalence shared pointer"); - d.m_table_of_equivalence = m_table_of_equivalence; -} - -void DimensionTracker::reset_tracking_info(Dimension& d) { - d.m_label = no_label; - d.m_table_of_equivalence = nullptr; -} - -void DimensionTracker::set_up_for_tracking(Dimension& d) { - set_up_for_tracking(d, m_table_of_equivalence->get_next_label()); -} - -void DimensionTracker::set_up_for_tracking(Dimension& d, label_t label) const { - set_label(d, label); - set_table_of_equivalence(d); -} - -void DimensionTracker::set_up_for_tracking(ov::PartialShape& shape) { - for (auto& d : shape) - set_up_for_tracking(d); -} diff --git a/src/core/src/node.cpp b/src/core/src/node.cpp index f2d5f603c3b46d..d8af922982d6fe 100644 --- a/src/core/src/node.cpp +++ b/src/core/src/node.cpp @@ -692,7 +692,7 @@ bool ov::Node::evaluate_upper(ov::TensorVector& output_values) const { return all_have_bounds && ov::default_upper_bound_evaluator(this, output_values); } -bool ov::Node::evaluate_label(TensorLabelVector& output_labels) const { +bool ov::Node::evaluate_symbol(TensorSymbolVector& output_symbols) const { return false; } diff --git a/src/core/src/op/concat.cpp b/src/core/src/op/concat.cpp index 37a8099feb2f47..ccccb7c4f4bdcd 100644 --- a/src/core/src/op/concat.cpp +++ b/src/core/src/op/concat.cpp @@ -7,7 +7,7 @@ #include "bound_evaluate.hpp" #include "concat_shape_inference.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/reference/concat.hpp" @@ -98,38 +98,8 @@ bool Concat::evaluate_upper(TensorVector& output_values) const { return default_upper_bound_evaluator(this, output_values); } -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(); - return ov::util::has_no_labels(labels); - })) { - return false; - } - - TensorVector idx_inputs; - idx_inputs.reserve(inputs.size()); - for (const auto& input : inputs) { - auto input_label = input.get_tensor().get_value_label(); - if (input_label.empty()) { - const auto& shape = input.get_partial_shape(); - // sanity check. at this point value propagation was successful - OPENVINO_ASSERT(shape.is_static()); - const auto& num_elements = shape_size(shape.to_shape()); - input_label.resize(num_elements, no_label); - } - idx_inputs.emplace_back(element::from(), input.get_shape()); - std::copy_n(input_label.begin(), idx_inputs.back().get_size(), idx_inputs.back().data()); - } - - auto outputs = TensorVector{{element::from(), get_output_shape(0)}}; - if (evaluate(outputs, idx_inputs)) { - output_labels.front() = - TensorLabel(outputs.front().data(), outputs.front().data() + outputs.front().get_size()); - return true; - } else { - return false; - } +bool Concat::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return default_symbol_evaluator(this, {}, output_symbols); } } // namespace v0 } // namespace op diff --git a/src/core/src/op/convert.cpp b/src/core/src/op/convert.cpp index 0ba495058713ba..74358812337991 100644 --- a/src/core/src/op/convert.cpp +++ b/src/core/src/op/convert.cpp @@ -193,12 +193,12 @@ bool Convert::evaluate_upper(TensorVector& output_values) const { return convert::evaluate_bound(this, output_values, get_input_tensor(0).get_upper_value()); } -bool Convert::evaluate_label(TensorLabelVector& output_labels) const { - const auto input_labels = get_input_tensor(0).get_value_label(); - if (input_labels.empty()) { +bool Convert::evaluate_symbol(TensorSymbolVector& output_symbols) const { + const auto input_symbols = get_input_tensor(0).get_value_symbol(); + if (input_symbols.empty()) { return false; } else { - output_labels[0] = input_labels; + output_symbols[0] = input_symbols; return true; } } diff --git a/src/core/src/op/reshape.cpp b/src/core/src/op/reshape.cpp index 0382c7b3a92fed..ab0e0a0c17cbde 100644 --- a/src/core/src/op/reshape.cpp +++ b/src/core/src/op/reshape.cpp @@ -8,7 +8,7 @@ #include "bound_evaluate.hpp" #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/util/precision_sensitive_attribute.hpp" #include "openvino/reference/reshape.hpp" @@ -92,8 +92,8 @@ bool Reshape::evaluate_upper(ov::TensorVector& output_values) const { return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool Reshape::evaluate_label(TensorLabelVector& output_labels) const { - return get_input_tensor(1).has_and_set_bound() && default_label_evaluator(this, {0}, output_labels); +bool Reshape::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return get_input_tensor(1).has_and_set_bound() && default_symbol_evaluator(this, {0}, output_symbols); } bool Reshape::constant_fold(OutputVector& output_values, const OutputVector& inputs_values) { diff --git a/src/core/src/op/scatter_nd_update.cpp b/src/core/src/op/scatter_nd_update.cpp index d18092212b352d..a1cc302f2af4b9 100644 --- a/src/core/src/op/scatter_nd_update.cpp +++ b/src/core/src/op/scatter_nd_update.cpp @@ -135,9 +135,9 @@ bool ScatterNDUpdate::evaluate_upper(TensorVector& output_values) const { return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool ScatterNDUpdate::evaluate_label(TensorLabelVector& output_labels) const { - OV_OP_SCOPE(v3_ScatterNDUpdate_evaluate_label); - return default_label_evaluator(this, {0, 2}, output_labels); +bool ScatterNDUpdate::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OV_OP_SCOPE(v3_ScatterNDUpdate_evaluate_symbol); + return default_symbol_evaluator(this, {0, 2}, output_symbols); } } // namespace v3 } // namespace op diff --git a/src/core/src/op/scatter_update.cpp b/src/core/src/op/scatter_update.cpp index ec2c92990f1963..a10b7bba131350 100644 --- a/src/core/src/op/scatter_update.cpp +++ b/src/core/src/op/scatter_update.cpp @@ -106,9 +106,9 @@ bool ScatterUpdate::has_evaluate() const { } } -bool ScatterUpdate::evaluate_label(TensorLabelVector& output_labels) const { - OV_OP_SCOPE(v3_ScatterUpdate_evaluate_label); - return default_label_evaluator(this, {0, 2}, output_labels); +bool ScatterUpdate::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OV_OP_SCOPE(v3_ScatterUpdate_evaluate_symbol); + return default_symbol_evaluator(this, {0, 2}, output_symbols); } } // namespace v3 } // namespace op diff --git a/src/core/src/op/shape_of.cpp b/src/core/src/op/shape_of.cpp index 183c9bc3e78344..07138610a4cc12 100644 --- a/src/core/src/op/shape_of.cpp +++ b/src/core/src/op/shape_of.cpp @@ -8,7 +8,7 @@ #include #include "itt.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/select.hpp" #include "openvino/reference/shape_of.hpp" @@ -91,20 +91,20 @@ bool evaluate_bound(const Node* const node, ov::TensorVector& outputs, const boo } } -bool evaluate_label(const Node* shape_of_node, TensorLabelVector& output_labels) { +bool evaluate_symbol(const Node* shape_of_node, TensorSymbolVector& output_symbols) { const auto& shape = shape_of_node->get_input_partial_shape(0); OPENVINO_ASSERT(shape.rank().is_static()); // sanity check. at this point value propagation was successful - auto common_label = ov::no_label; - auto& labels = output_labels[0]; - labels.reserve(shape.size()); + bool at_least_one_symbol_set = false; + auto& symbols = output_symbols[0]; + symbols.reserve(shape.size()); for (const auto& d : shape) { - const auto label = ov::DimensionTracker::get_label(d); - labels.emplace_back(label); - common_label |= label; + const auto symbol = d.get_symbol(); + symbols.emplace_back(symbol); + at_least_one_symbol_set |= (symbol != nullptr); } - return common_label != ov::no_label; + return at_least_one_symbol_set; } } // namespace } // namespace shape_of @@ -165,8 +165,8 @@ bool ShapeOf::evaluate_upper(ov::TensorVector& output_values) const { return shape_of::evaluate_bound(this, output_values, true); } -bool ShapeOf::evaluate_label(TensorLabelVector& output_labels) const { - return shape_of::evaluate_label(this, output_labels); +bool ShapeOf::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return shape_of::evaluate_symbol(this, output_symbols); } bool ShapeOf::constant_fold(OutputVector& output_values, const OutputVector& input_values) { @@ -239,8 +239,8 @@ bool ShapeOf::evaluate_upper(ov::TensorVector& output_values) const { return shape_of::evaluate_bound(this, output_values, true); } -bool ShapeOf::evaluate_label(TensorLabelVector& output_labels) const { - return shape_of::evaluate_label(this, output_labels); +bool ShapeOf::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return shape_of::evaluate_symbol(this, output_symbols); } } // namespace v0 } // namespace op diff --git a/src/core/src/op/slice.cpp b/src/core/src/op/slice.cpp index f9d2b58d304466..a1143da2afa5ae 100644 --- a/src/core/src/op/slice.cpp +++ b/src/core/src/op/slice.cpp @@ -146,8 +146,8 @@ bool Slice::evaluate_upper(ov::TensorVector& output_values) const { return slice_bound_check(this) && default_upper_bound_evaluator(this, output_values); } -bool Slice::evaluate_label(TensorLabelVector& output_labels) const { - return slice_bound_check(this) && ov::util::default_label_evaluator(this, output_labels); +bool Slice::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return slice_bound_check(this) && ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace v8 } // namespace op diff --git a/src/core/src/op/split.cpp b/src/core/src/op/split.cpp index 3bcd4309f6030b..ee93aa34d30e18 100644 --- a/src/core/src/op/split.cpp +++ b/src/core/src/op/split.cpp @@ -117,10 +117,10 @@ bool Split::evaluate_upper(ov::TensorVector& output_values) const { return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool Split::evaluate_label(TensorLabelVector& output_labels) const { - OPENVINO_ASSERT(output_labels.size() == get_num_splits()); +bool Split::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OPENVINO_ASSERT(output_symbols.size() == get_num_splits()); - return get_input_tensor(1).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); + return get_input_tensor(1).has_and_set_bound() && ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace v1 } // namespace op diff --git a/src/core/src/op/squeeze.cpp b/src/core/src/op/squeeze.cpp index b13c26ebcb453c..3abc0a773192d2 100644 --- a/src/core/src/op/squeeze.cpp +++ b/src/core/src/op/squeeze.cpp @@ -100,8 +100,8 @@ bool Squeeze::evaluate_upper(TensorVector& output_values) const { return validate::axes_has_and_set_bound(*this) && default_upper_bound_evaluator(this, output_values); } -bool Squeeze::evaluate_label(TensorLabelVector& output_labels) const { - return validate::axes_has_and_set_bound(*this) && ov::util::default_label_evaluator(this, output_labels); +bool Squeeze::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return validate::axes_has_and_set_bound(*this) && ov::util::default_symbol_evaluator(this, output_symbols); } bool Squeeze::constant_fold(OutputVector& output_values, const OutputVector& inputs_values) { diff --git a/src/core/src/op/strided_slice.cpp b/src/core/src/op/strided_slice.cpp index 74ee1e525d2b83..62049ba8938f8a 100644 --- a/src/core/src/op/strided_slice.cpp +++ b/src/core/src/op/strided_slice.cpp @@ -277,10 +277,10 @@ bool StridedSlice::evaluate_upper(TensorVector& output_values) const { default_upper_bound_evaluator(this, output_values); } -bool StridedSlice::evaluate_label(TensorLabelVector& output_labels) const { +bool StridedSlice::evaluate_symbol(TensorSymbolVector& output_symbols) const { return indices_input_has_and_set_bounds(1, get_begin_mask()) && indices_input_has_and_set_bounds(2, get_end_mask()) && get_input_tensor(3).has_and_set_bound() && - default_label_evaluator(this, {0}, output_labels); + default_symbol_evaluator(this, {0}, output_symbols); } bool StridedSlice::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 6cbaa53e409269..71c7fdac777cb9 100644 --- a/src/core/src/op/tile.cpp +++ b/src/core/src/op/tile.cpp @@ -82,11 +82,11 @@ bool Tile::evaluate_upper(TensorVector& output_values) const { return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool Tile::evaluate_label(TensorLabelVector& output_labels) const { - OV_OP_SCOPE(v0_Tile_evaluate_label); - OPENVINO_ASSERT(output_labels.size() == 1); +bool Tile::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OV_OP_SCOPE(v0_Tile_evaluate_symbol); + OPENVINO_ASSERT(output_symbols.size() == 1); - return get_input_tensor(1).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); + return get_input_tensor(1).has_and_set_bound() && ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace v0 } // namespace op diff --git a/src/core/src/op/transpose.cpp b/src/core/src/op/transpose.cpp index 80139eed27891f..f0675b2a9912db 100644 --- a/src/core/src/op/transpose.cpp +++ b/src/core/src/op/transpose.cpp @@ -77,8 +77,8 @@ bool Transpose::evaluate_upper(ov::TensorVector& output_values) const { return get_input_tensor(ORDER).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool Transpose::evaluate_label(TensorLabelVector& output_labels) const { - return get_input_tensor(ORDER).has_and_set_bound() && ov::util::default_label_evaluator(this, output_labels); +bool Transpose::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return get_input_tensor(ORDER).has_and_set_bound() && ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace v1 } // namespace op diff --git a/src/core/src/op/unsqueeze.cpp b/src/core/src/op/unsqueeze.cpp index 7d4c7beb4c1106..d199c43a2479b5 100644 --- a/src/core/src/op/unsqueeze.cpp +++ b/src/core/src/op/unsqueeze.cpp @@ -71,10 +71,10 @@ bool ov::op::v0::Unsqueeze::evaluate_upper(ov::TensorVector& output_values) cons return get_input_tensor(1).has_and_set_bound() && default_upper_bound_evaluator(this, output_values); } -bool ov::op::v0::Unsqueeze::evaluate_label(TensorLabelVector& output_labels) const { +bool ov::op::v0::Unsqueeze::evaluate_symbol(TensorSymbolVector& output_symbols) const { if (!get_input_tensor(1).has_and_set_bound()) return false; - return ov::util::default_label_evaluator(this, output_labels); + return ov::util::default_symbol_evaluator(this, output_symbols); } bool ov::op::v0::Unsqueeze::constant_fold(OutputVector& output_values, const OutputVector& inputs_values) { diff --git a/src/core/src/op/util/gather_base.cpp b/src/core/src/op/util/gather_base.cpp index 0843399590d4f6..8e7b9fe4531343 100644 --- a/src/core/src/op/util/gather_base.cpp +++ b/src/core/src/op/util/gather_base.cpp @@ -258,8 +258,8 @@ bool GatherBase::evaluate_upper(TensorVector& output_values) const { return gather::have_indices_and_axis_bound_set(this) && default_upper_bound_evaluator(this, output_values); } -bool GatherBase::evaluate_label(TensorLabelVector& output_labels) const { - return gather::have_indices_and_axis_bound_set(this) && ov::util::default_label_evaluator(this, output_labels); +bool GatherBase::evaluate_symbol(TensorSymbolVector& output_symbols) const { + return gather::have_indices_and_axis_bound_set(this) && ov::util::default_symbol_evaluator(this, output_symbols); } bool GatherBase::constant_fold(OutputVector& output_values, const OutputVector& input_values) { diff --git a/src/core/src/op/util/pad_base.cpp b/src/core/src/op/util/pad_base.cpp index df7ef5fff93b87..a6e3fec67fe1da 100644 --- a/src/core/src/op/util/pad_base.cpp +++ b/src/core/src/op/util/pad_base.cpp @@ -150,9 +150,9 @@ bool op::util::PadBase::evaluate_upper(TensorVector& output_values) const { return have_node_inputs_bounds_set(this, 1, 2) && default_upper_bound_evaluator(this, output_values); } -bool op::util::PadBase::evaluate_label(TensorLabelVector& output_labels) const { - OV_OP_SCOPE(util_PadBase_evaluate_label); - return ov::util::default_label_evaluator(this, output_labels); +bool op::util::PadBase::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OV_OP_SCOPE(util_PadBase_evaluate_symbol); + return ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace ov 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 db4fdf0515de47..9126e5cda930b4 100644 --- a/src/core/src/op/util/scatter_elements_update_base.cpp +++ b/src/core/src/op/util/scatter_elements_update_base.cpp @@ -98,10 +98,10 @@ bool util::ScatterElementsUpdateBase::evaluate_upper(ov::TensorVector& output_va return get_input_tensor(1).has_and_set_bound() && ov::default_upper_bound_evaluator(this, output_values); } -bool util::ScatterElementsUpdateBase::evaluate_label(TensorLabelVector& output_labels) const { - OV_OP_SCOPE(util_ScatterNDUpdate_evaluate_label); +bool util::ScatterElementsUpdateBase::evaluate_symbol(TensorSymbolVector& output_symbols) const { + OV_OP_SCOPE(util_ScatterNDUpdate_evaluate_symbol); - return ov::default_label_evaluator(this, {0, 2}, output_labels); + return ov::default_symbol_evaluator(this, {0, 2}, output_symbols); } int64_t util::ScatterElementsUpdateBase::get_normalized_axis(const TensorVector& inputs) const { diff --git a/src/core/src/op/util/symbolic_info.cpp b/src/core/src/op/util/symbolic_info.cpp index fe0854a4f50a3e..51d917ab256979 100644 --- a/src/core/src/op/util/symbolic_info.cpp +++ b/src/core/src/op/util/symbolic_info.cpp @@ -6,72 +6,39 @@ #include -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/util/multi_subgraph_base.hpp" -namespace { -std::shared_ptr get_table(const ov::RTMap& rt_info) { - const auto& type = ov::SymbolicInfo::get_type_info_static(); - if (!rt_info.count(type)) - return nullptr; - return rt_info.at(type).as().get_table(); -} -} // namespace - -void ov::set_up_symbolic_info(const std::shared_ptr& model, - const std::shared_ptr& table) { - auto& rt_info = model->get_rt_info(); - rt_info[ov::SymbolicInfo::get_type_info_static()] = ov::SymbolicInfo(true, table); -} - -void ov::set_up_symbolic_info(const ov::Output& output, - const std::shared_ptr& table) { - auto& rt_info = output.get_tensor().get_rt_info(); - rt_info[ov::SymbolicInfo::get_type_info_static()] = ov::SymbolicInfo(true, table); +void ov::skip_invalidation(const ov::Output& output) { + output.get_tensor().get_rt_info()[ov::SkipInvalidation::get_type_info_static()] = nullptr; } bool ov::skip_invalidation(const ov::descriptor::Tensor& tensor) { - const auto& rt_info = tensor.get_rt_info(); - const auto& type = ov::SymbolicInfo::get_type_info_static(); - return rt_info.count(type) && rt_info.at(type).as().get_skip_invalidation(); -} - -std::shared_ptr ov::table_of_equivalence(const ov::descriptor::Tensor& tensor) { - const auto& rt_info = tensor.get_rt_info(); - return get_table(rt_info); -} - -std::shared_ptr ov::table_of_equivalence(const std::shared_ptr& model) { - const auto& rt_info = model->get_rt_info(); - return get_table(rt_info); -} - -void ov::populate_tensor_with_missing_labels(ov::descriptor::Tensor& tensor) { - if (auto table = ov::table_of_equivalence(tensor)) { - auto label_values = tensor.get_value_label(); - if (label_values.empty()) { - const auto& pshape = tensor.get_partial_shape(); - if (pshape.is_dynamic()) - return; - label_values.resize(ov::shape_size(pshape.to_shape()), ov::no_label); - } - for (auto& label : label_values) - if (label == ov::no_label) - label = table->get_next_label(); - tensor.set_value_label(label_values); + return tensor.get_rt_info().count(ov::SkipInvalidation::get_type_info_static()); +} + +void ov::populate_tensor_with_missing_symbols(ov::descriptor::Tensor& tensor) { + if (!tensor.get_rt_info().count(ov::SkipInvalidation::get_type_info_static())) + return; + auto symbol_values = tensor.get_value_symbol(); + if (symbol_values.empty()) { + const auto& pshape = tensor.get_partial_shape(); + if (pshape.is_dynamic()) + return; + symbol_values.resize(ov::shape_size(pshape.to_shape()), nullptr); } + for (auto& symbol : symbol_values) + if (symbol == nullptr) + symbol = std::make_shared(); + tensor.set_value_symbol(symbol_values); } -void ov::remove_symbolic_info(const std::shared_ptr& model, bool outermost_model) { - const auto& type = ov::SymbolicInfo::get_type_info_static(); - auto& model_rt_info = model->get_rt_info(); - if (model_rt_info.count(type)) - model_rt_info.erase(type); +void ov::remove_skip_invalidation_rti(const std::shared_ptr& model, bool outermost_model) { + const auto& type = ov::SkipInvalidation::get_type_info_static(); for (const auto& op : model->get_ops()) { if (auto multi_subgraph_op = std::dynamic_pointer_cast(op)) for (const auto& sub_graph : multi_subgraph_op->get_functions()) if (sub_graph) - remove_symbolic_info(sub_graph, false); + remove_skip_invalidation_rti(sub_graph, false); for (auto& output : op->outputs()) { auto& rt_info = output.get_tensor().get_rt_info(); if (rt_info.count(type)) diff --git a/src/core/src/op/variadic_split.cpp b/src/core/src/op/variadic_split.cpp index 3484a889792e52..3f638ce2034162 100644 --- a/src/core/src/op/variadic_split.cpp +++ b/src/core/src/op/variadic_split.cpp @@ -120,9 +120,9 @@ bool VariadicSplit::evaluate_upper(TensorVector& output_values) const { return variadic_split::has_axis_and_splits_bound_set(this) && default_upper_bound_evaluator(this, output_values); } -bool VariadicSplit::evaluate_label(TensorLabelVector& output_labels) const { +bool VariadicSplit::evaluate_symbol(TensorSymbolVector& output_symbols) const { return variadic_split::has_axis_and_splits_bound_set(this) && - ov::util::default_label_evaluator(this, output_labels); + ov::util::default_symbol_evaluator(this, output_symbols); } } // namespace v1 } // namespace op diff --git a/src/core/src/partial_shape.cpp b/src/core/src/partial_shape.cpp index 34039f48910fb7..6f503aa608833f 100644 --- a/src/core/src/partial_shape.cpp +++ b/src/core/src/partial_shape.cpp @@ -8,7 +8,7 @@ #include #include -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/shape_util.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/util/common_util.hpp" @@ -158,8 +158,6 @@ std::ostream& ov::operator<<(std::ostream& str, const PartialShape& shape) { if (!first) { str << ","; } - if (const auto& l = ov::DimensionTracker::get_label(d)) - str << "<" << l << ">"; str << d; first = false; } diff --git a/src/core/src/pass/visualize_tree.cpp b/src/core/src/pass/visualize_tree.cpp index bf9e040683e102..7b6ec278086bfd 100644 --- a/src/core/src/pass/visualize_tree.cpp +++ b/src/core/src/pass/visualize_tree.cpp @@ -179,6 +179,38 @@ static std::string name_of_subgraph_file(const std::shared_ptr op, return file_name; } +static void collect_symbol_print_values(const std::shared_ptr& m, + std::unordered_map, size_t>& symbol_to_number) { + size_t n = symbol_to_number.size() + 1; + for (const auto& node : m->get_ops()) { + if (auto multi_subgraph_op = std::dynamic_pointer_cast(node)) + for (size_t i = 0; i < multi_subgraph_op->get_internal_subgraphs_size(); ++i) + if (const auto& sub_graph = multi_subgraph_op->get_function(i)) + collect_symbol_print_values(sub_graph, symbol_to_number); + + for (const auto& output : node->outputs()) { + const auto& shape = output.get_partial_shape(); + if (shape.rank().is_dynamic()) + continue; + for (const auto& dim : shape) + if (auto symbol = dim.get_symbol()) { + const auto& root = ov::symbol::ancestor_of(symbol); + if (symbol_to_number.count(root)) + continue; + symbol_to_number[root] = n++; + } + const auto& value_symbols = output.get_tensor().get_value_symbol(); + for (const auto& value_symbol : value_symbols) + if (value_symbol) { + const auto& root = ov::symbol::ancestor_of(value_symbol); + if (symbol_to_number.count(root)) + continue; + symbol_to_number[root] = n++; + } + } + } +} + bool ov::pass::VisualizeTree::run_on_model(const std::shared_ptr& f) { RUN_ON_MODEL_SCOPE(VisualizeTree); std::unordered_map height_maps; @@ -193,6 +225,8 @@ bool ov::pass::VisualizeTree::run_on_model(const std::shared_ptr& f) auto nodes = topological_sort(f->get_ops()); + collect_symbol_print_values(f, m_symbol_to_name); + for (auto it = nodes.rbegin(); it != nodes.rend(); ++it) { auto& node = *it; if (auto multi_subgraph_op = std::dynamic_pointer_cast(node)) { @@ -298,10 +332,32 @@ std::string ov::pass::VisualizeTree::add_attributes(std::shared_ptr node) return rc; } -static std::string pretty_partial_shape(const ov::PartialShape& shape) { - std::stringstream ss; - ss << shape; - return ss.str(); +static std::string pretty_partial_shape( + const ov::PartialShape& shape, + const std::unordered_map, size_t>& symbol_map = {}) { + std::stringstream str; + if (shape.rank().is_static()) { + str << "["; + bool first = true; + for (auto& d : shape) { + if (!first) { + str << ","; + } + if (const auto& symbol = d.get_symbol()) { + const auto& root = ov::symbol::ancestor_of(symbol); + if (symbol_map.count(root)) + str << "<" << symbol_map.at(root) << ">"; + else + str << ""; + } + str << d; + first = false; + } + str << "]"; + } else { + str << "[...]"; + } + return str.str(); } template @@ -417,23 +473,41 @@ static std::string get_value(const std::shared_ptr& consta return ss.str(); } -static std::string get_bounds_and_label_info(const ov::Output output) { +static std::string pretty_symbol_value(const ov::TensorSymbol& symbols, + const std::unordered_map, size_t>& symbol_map = {}) { + std::vector mapped_symbols; + for (const auto& symbol : symbols) { + if (symbol) { + const auto& root = ov::symbol::ancestor_of(symbol); + if (symbol_map.count(root)) { + mapped_symbols.push_back(symbol_map.at(root)); + continue; + } + } + mapped_symbols.push_back(0); + } + return pretty_value(mapped_symbols); +} + +static std::string get_bounds_and_label_info( + const ov::Output output, + const std::unordered_map, size_t>& symbol_map = {}) { const auto& tensor = output.get_tensor(); const auto& lower = tensor.get_lower_value(); const auto& upper = tensor.get_upper_value(); - const auto& value_label = tensor.get_value_label(); + const auto& value_symbol = tensor.get_value_symbol(); - if (!lower && !upper && value_label.empty()) + if (!lower && !upper && value_symbol.empty()) return ""; std::stringstream label; - size_t size = lower ? lower.get_size() : upper ? upper.get_size() : value_label.size(); + size_t size = lower ? lower.get_size() : upper ? upper.get_size() : value_symbol.size(); if (size == 0) { label << "empty"; } else { label << " lower: " << (lower ? get_value(std::make_shared(lower), true) : "NONE"); label << " upper: " << (upper ? get_value(std::make_shared(upper), true) : "NONE"); - label << " label: " << (value_label.empty() ? "NONE" : pretty_value(value_label)); + label << " symbl: " << (value_symbol.empty() ? "NONE" : pretty_symbol_value(value_symbol, symbol_map)); } return label.str(); } @@ -441,7 +515,7 @@ static std::string get_bounds_and_label_info(const ov::Output output) std::string ov::pass::VisualizeTree::get_constant_value(std::shared_ptr node, size_t max_elements) { std::stringstream ss; ss << "{" << node->get_element_type().to_string() << "}"; - ss << pretty_partial_shape(node->get_output_partial_shape(0)); + ss << pretty_partial_shape(node->get_output_partial_shape(0), m_symbol_to_name); if (const auto& constant = ov::as_type_ptr(node)) { std::string value; @@ -486,7 +560,7 @@ std::string ov::pass::VisualizeTree::get_attributes(std::shared_ptr node) if (nvtot) label << "{" << input.get_element_type().to_string() << "}"; if (nvtos) - label << pretty_partial_shape(input.get_partial_shape()); + label << pretty_partial_shape(input.get_partial_shape(), m_symbol_to_name); label << ": " << node->get_input_node_ptr(input.get_index())->get_name() << ": out" << input.get_source_output().get_index(); @@ -501,13 +575,13 @@ std::string ov::pass::VisualizeTree::get_attributes(std::shared_ptr node) if (nvtot) label << "{" << output.get_element_type().to_string() << "}"; if (nvtos) - label << pretty_partial_shape(output.get_partial_shape()); + label << pretty_partial_shape(output.get_partial_shape(), m_symbol_to_name); // TODO if (nvtrti) { label << get_attribute_values(output.get_rt_info()); } if (ovpvl) - label << get_bounds_and_label_info(output); + label << get_bounds_and_label_info(output, m_symbol_to_name); // TODO } } diff --git a/src/core/src/symbol.cpp b/src/core/src/symbol.cpp new file mode 100644 index 00000000000000..5fba28d3a5cbda --- /dev/null +++ b/src/core/src/symbol.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/core/symbol.hpp" + +std::shared_ptr ov::symbol::ancestor_of(const std::shared_ptr& symbol) { + auto x = symbol; + while (x->parent().get() != x.get()) { + x->m_parent = x->parent()->parent(); + x = x->parent(); + } + return x; +} + +bool ov::symbol::are_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { + if (lhs == nullptr || rhs == nullptr) + return false; + return ov::symbol::ancestor_of(lhs).get() == ov::symbol::ancestor_of(rhs).get(); +} + +void ov::symbol::set_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { + if (lhs == nullptr || rhs == nullptr) + return; + auto lhs_root = ov::symbol::ancestor_of(lhs), rhs_root = ov::symbol::ancestor_of(rhs); + if (lhs_root.get() == rhs_root.get()) + return; // already are equal + lhs->m_parent = rhs; +} + +std::shared_ptr ov::Symbol::parent() { + if (!m_parent) + m_parent = shared_from_this(); + return m_parent; +} diff --git a/src/core/src/validation_util.cpp b/src/core/src/validation_util.cpp index d009b6632e36f7..9e26a546124659 100644 --- a/src/core/src/validation_util.cpp +++ b/src/core/src/validation_util.cpp @@ -10,7 +10,7 @@ #include "bound_evaluate.hpp" #include "compare.hpp" #include "openvino/core/constant_fold_utils.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/gather.hpp" #include "openvino/op/negative.hpp" @@ -284,8 +284,8 @@ bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialSh 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()); + const TensorSymbol& symbols = output.get_tensor().get_value_symbol(); + OPENVINO_ASSERT(symbols.empty() || lower_bound.size() == symbols.size()); std::vector resulting_pshape(lower_bound.size()); for (size_t i = 0; i < lower_bound.size(); ++i) { @@ -298,8 +298,8 @@ bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialSh low = std::numeric_limits::max(); } resulting_pshape[i] = {low, up}; - if (!labels.empty() && labels[i]) - DimensionTracker::set_label(resulting_pshape[i], labels[i]); + if (!symbols.empty()) + resulting_pshape[i].set_symbol(symbols[i]); } pshape = ov::PartialShape(resulting_pshape); shape_defined = true; @@ -307,8 +307,8 @@ bool evaluate_as_partial_shape(const ov::Output& output, ov::PartialSh return shape_defined; } -bool default_label_evaluator(const ov::Node* node, TensorLabelVector& output_labels) { - return default_label_evaluator(node, {0}, output_labels); +bool default_symbol_evaluator(const ov::Node* node, TensorSymbolVector& output_symbols) { + return default_symbol_evaluator(node, {0}, output_symbols); } void generate_transpose_default_order(std::vector& axes_order, const size_t length) { @@ -321,8 +321,8 @@ bool is_valid_axes_order(const std::vector& axes_order, const size_t si 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)); +bool has_no_symbols(const ov::TensorSymbol& symbols) { + return std::all_of(symbols.cbegin(), symbols.cend(), cmp::Equal>(nullptr)); } std::vector normalize_axes(const std::string& node_description, diff --git a/src/core/tests/dimension.cpp b/src/core/tests/dimension.cpp index 30aa8816731ce6..359191d2ca0d9e 100644 --- a/src/core/tests/dimension.cpp +++ b/src/core/tests/dimension.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "openvino/core/dimension.hpp" - +#include "common_test_utils/type_prop.hpp" #include "gtest/gtest.h" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/partial_shape.hpp" +#include "openvino/core/symbol.hpp" using namespace std; using namespace ov; @@ -123,42 +123,38 @@ TEST(dimension, division_of_static_dims) { } TEST(dimension, dimension_equality) { - auto te = make_shared(); - DimensionTracker dt(te); - // labeling dimensions PartialShape dimensions = PartialShape::dynamic(5); // A, B, C, D, E - for (auto& dimension : dimensions) - dt.set_up_for_tracking(dimension); + auto symbols = set_shape_symbols(dimensions); - // checking labels are unique + // checking symbols are unique for (const auto& dimension : dimensions) - EXPECT_NE(DimensionTracker::get_label(dimension), no_label); + EXPECT_NE(dimension.get_symbol(), nullptr); for (const auto& lhs : dimensions) { for (const auto& rhs : dimensions) { if (&lhs == &rhs) continue; - EXPECT_NE(DimensionTracker::get_label(lhs), DimensionTracker::get_label(rhs)); - EXPECT_FALSE(te->are_equal(lhs, rhs)); + EXPECT_NE(lhs.get_symbol(), rhs.get_symbol()); + EXPECT_FALSE(ov::symbol::are_equal(lhs.get_symbol(), rhs.get_symbol())); } } - te->set_as_equal(dimensions[0], dimensions[1]); // A == B - te->set_as_equal(dimensions[3], dimensions[4]); // D == E - te->set_as_equal(dimensions[2], dimensions[3]); // C == D - te->set_as_equal(dimensions[1], dimensions[2]); // B == C + ov::symbol::set_equal(dimensions[0].get_symbol(), dimensions[1].get_symbol()); // A == B + ov::symbol::set_equal(dimensions[3].get_symbol(), dimensions[4].get_symbol()); // D == E + ov::symbol::set_equal(dimensions[2].get_symbol(), dimensions[3].get_symbol()); // C == D + ov::symbol::set_equal(dimensions[1].get_symbol(), dimensions[2].get_symbol()); // B == C // expected to see A == B == C == D == E for (const auto& lhs : dimensions) for (const auto& rhs : dimensions) - EXPECT_TRUE(te->are_equal(lhs, rhs)); + EXPECT_TRUE(ov::symbol::are_equal(lhs.get_symbol(), rhs.get_symbol())); // clear up all the tracking info for (auto& dimension : dimensions) - DimensionTracker::reset_tracking_info(dimension); + dimension.set_symbol(nullptr); - // checking labels are unique + // checking labels are nullified for (const auto& dimension : dimensions) - EXPECT_EQ(DimensionTracker::get_label(dimension), no_label); + EXPECT_EQ(dimension.get_symbol(), nullptr); } diff --git a/src/core/tests/evaluate_bound/concat.cpp b/src/core/tests/evaluate_bound/concat.cpp deleted file mode 100644 index 81143031b14893..00000000000000 --- a/src/core/tests/evaluate_bound/concat.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "gmock/gmock.h" -#include "openvino/core/dimension.hpp" -#include "openvino/core/dimension_tracker.hpp" -#include "openvino/core/node.hpp" -#include "openvino/core/partial_shape.hpp" -#include "openvino/opsets/opset9.hpp" -#include "openvino/pass/graph_rewrite.hpp" - -using namespace ov::opset9; -using namespace testing; - -using ShapeVector = std::vector; -using LabeledShape = std::tuple; -using LabeledShapeVector = std::vector; -using TestParams = std::tuple; - -class EvaluateLabelTest : public Test { -protected: - bool exp_evaluate_status; - ov::TensorLabelVector out_labels; - ov::TensorVector exp_result, inputs; -}; - -class ConcatEvaluateLabelTest : public EvaluateLabelTest, public WithParamInterface { -protected: - void SetUp() override { - const auto& labeled_shapes = std::get<1>(GetParam()); - - exp_evaluate_status = - std::any_of(labeled_shapes.cbegin(), labeled_shapes.cend(), [](const LabeledShape& l_shape) { - return std::get<1>(l_shape); - }); - - for (const auto& labeled_shape : labeled_shapes) { - ov::PartialShape shape; - bool add_labels; - std::tie(shape, add_labels) = labeled_shape; - - auto param = params.make(ov::element::from(), shape); - - if (exp_evaluate_status) { - auto min_shape = shape.get_min_shape(); - ov::TensorLabel labels(ov::shape_size(min_shape), ov::no_label); - - if (add_labels) { - std::iota(labels.begin(), labels.end(), 1); - param->get_default_output().get_tensor().set_value_label(labels); - } - - inputs.emplace_back(ov::element::from(), min_shape); - std::copy_n(labels.begin(), labels.size(), inputs.back().data()); - } - } - } - - std::shared_ptr concat; - ov::pass::NodeRegistry params; -}; - -const auto shape1 = ov::PartialShape({3, 2, 1}); -const auto shape2 = ov::PartialShape({3, 4, 1}); - -const auto contactable_shapes_axis_1 = Values( - LabeledShapeVector{std::make_tuple(shape1, false)}, - LabeledShapeVector{std::make_tuple(shape2, false)}, - LabeledShapeVector{std::make_tuple(shape2, false), std::make_tuple(shape1, false)}, - LabeledShapeVector{std::make_tuple(shape1, true), std::make_tuple(shape2, false)}, - LabeledShapeVector{std::make_tuple(shape2, false), std::make_tuple(shape1, true)}, - LabeledShapeVector{std::make_tuple(shape1, true), std::make_tuple(shape2, false), std::make_tuple(shape1, false)}, - LabeledShapeVector{std::make_tuple(shape1, true), std::make_tuple(shape2, false), std::make_tuple(shape2, true)}, - LabeledShapeVector{std::make_tuple(shape1, true), - std::make_tuple(shape2, true), - std::make_tuple(shape2, true), - std::make_tuple(shape1, true)}); - -INSTANTIATE_TEST_SUITE_P(evaluate_bound_contactable_axis_1, - ConcatEvaluateLabelTest, - Combine(Values(1), contactable_shapes_axis_1), - PrintToStringParamName()); - -const auto contactable_shapes = Values( - LabeledShapeVector{std::make_tuple(shape1, false)}, - LabeledShapeVector{std::make_tuple(shape1, false), std::make_tuple(shape1, false)}, - LabeledShapeVector{std::make_tuple(shape2, false), std::make_tuple(shape2, false), std::make_tuple(shape2, true)}, - LabeledShapeVector{std::make_tuple(shape2, true), std::make_tuple(shape2, false), std::make_tuple(shape2, true)}, - LabeledShapeVector{std::make_tuple(shape1, true), std::make_tuple(shape1, true), std::make_tuple(shape1, true)}); - -INSTANTIATE_TEST_SUITE_P(evaluate_bound, - ConcatEvaluateLabelTest, - Combine(testing::Range(-3, 3), contactable_shapes), - PrintToStringParamName()); - -/** \brief Test evaluate label for combination of different shapes and each shape may be labeled. */ -TEST_P(ConcatEvaluateLabelTest, evaluate_label) { - const auto concat = std::make_shared(params.get(), std::get<0>(GetParam())); - out_labels.resize(concat->get_output_size()); - exp_result.emplace_back(ov::element::from(), concat->get_shape()); - - ASSERT_EQ(concat->evaluate_label(out_labels), exp_evaluate_status); - - if (exp_evaluate_status) { - concat->evaluate(exp_result, inputs); - - ASSERT_THAT(out_labels.front(), - ElementsAreArray(exp_result.front().data(), exp_result.front().get_size())); - } -} diff --git a/src/core/tests/evaluate_bound/transpose.cpp b/src/core/tests/evaluate_bound/transpose.cpp deleted file mode 100644 index 3c79d54169032d..00000000000000 --- a/src/core/tests/evaluate_bound/transpose.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "openvino/op/transpose.hpp" - -#include "common_test_utils/type_prop.hpp" -#include "gmock/gmock.h" -#include "openvino/opsets/opset9.hpp" -#include "sequnce_generator.hpp" -#include "transpose_shape_inference.hpp" - -namespace { -template -std::vector tensor_to_vector(const ov::Tensor& tensor) { - std::vector rc(tensor.data(), tensor.data() + tensor.get_size()); - return rc; -} -} // namespace - -using namespace ov; -using namespace ov::opset9; -using namespace testing; - -using TestParam = std::tuple, Shape>; - -class TransposeEvalBoundTest : public TestWithParam { -protected: - void SetUp() override { - std::tie(axes_order, shape) = GetParam(); - - std::generate_n(std::back_inserter(lower_values), shape_size(shape), SeqGen(-10)); - std::generate_n(std::back_inserter(upper_values), shape_size(shape), SeqGen(20)); - - lower_v_tensor = ov::Tensor(dtype, shape, lower_values.data()); - upper_v_tensor = ov::Tensor(dtype, shape, upper_values.data()); - axes_v_tensor = ov::Tensor(dtype, Shape{axes_order.size()}, axes_order.data()); - - arg = std::make_shared(dtype, shape); - order = std::make_shared(dtype, Shape{axes_order.size()}); - transpose = std::make_shared(arg, order); - - // prepare result tensors for evaluation - auto a = std::vector(axes_order.begin(), axes_order.end()); - result = exp_result = TensorVector{Tensor(dtype, op::v1::calc_output_shape(transpose.get(), shape, a))}; - } - - void node_set_lower_and_upper(Node* node, const ov::Tensor& lower, const ov::Tensor& upper) { - if (lower) { - node->get_output_tensor(0).set_lower_value(lower); - } - - if (upper) { - node->get_output_tensor(0).set_upper_value(upper); - } - } - - Shape shape; - element::Type dtype{element::from()}; - element::Type label_dtype{element::from()}; - - std::vector axes_order, lower_values, upper_values; - ov::Tensor lower_v_tensor, upper_v_tensor, axes_v_tensor; - TensorVector result, exp_result; - std::shared_ptr transpose; - std::shared_ptr arg, order; - - TensorLabel labels; - TensorLabelVector out_labels = TensorLabelVector(Transpose::OUT_COUNT); -}; - -INSTANTIATE_TEST_SUITE_P(evaluate_bound, - TransposeEvalBoundTest, - Values(std::make_tuple(std::vector{0}, Shape{4}), - std::make_tuple(std::vector{0, 1}, Shape{2, 5}), - std::make_tuple(std::vector{1, 0}, Shape{2, 5}), - std::make_tuple(std::vector{0, 1, 2}, Shape{2, 3, 1}), - std::make_tuple(std::vector{1, 2, 0}, Shape{2, 3, 1}), - std::make_tuple(std::vector{1, 3, 2, 0}, Shape{2, 3, 1, 5})), - PrintToStringParamName()); - -TEST_P(TransposeEvalBoundTest, evaluate_lower) { - node_set_lower_and_upper(arg.get(), lower_v_tensor, upper_v_tensor); - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - const auto inputs = TensorVector{Tensor(dtype, shape, lower_values.data()), - Tensor(dtype, Shape{axes_order.size()}, axes_order.data())}; - // evaluate expected values - const auto exp_evaluate = transpose->evaluate(exp_result, inputs); - - ASSERT_EQ(transpose->evaluate_lower(result), exp_evaluate); - ASSERT_EQ(tensor_to_vector(result[Transpose::ARG_T]), - tensor_to_vector(exp_result[Transpose::ARG_T])); -} - -TEST_P(TransposeEvalBoundTest, evaluate_lower_but_arg_lower_values_not_set) { - node_set_lower_and_upper(arg.get(), ov::Tensor(), upper_v_tensor); - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - ASSERT_FALSE(transpose->evaluate_lower(result)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_lower_but_order_has_no_bounds_set) { - node_set_lower_and_upper(arg.get(), lower_v_tensor, upper_v_tensor); - - ASSERT_FALSE(transpose->evaluate_lower(result)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_upper) { - node_set_lower_and_upper(arg.get(), lower_v_tensor, upper_v_tensor); - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - auto inputs = TensorVector{Tensor(dtype, shape, upper_values.data()), - Tensor(dtype, Shape{axes_order.size()}, axes_order.data())}; - // evaluate expected values - transpose->evaluate(exp_result, inputs); - - ASSERT_TRUE(transpose->evaluate_upper(result)); - ASSERT_EQ(tensor_to_vector(result[Transpose::ARG_T]), - tensor_to_vector(exp_result[Transpose::ARG_T])); -} - -TEST_P(TransposeEvalBoundTest, evaluate_upper_but_arg_upper_values_not_set) { - node_set_lower_and_upper(arg.get(), upper_v_tensor, ov::Tensor()); - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - ASSERT_FALSE(transpose->evaluate_upper(result)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_upper_but_order_has_no_bounds_set) { - node_set_lower_and_upper(arg.get(), lower_v_tensor, upper_v_tensor); - - ASSERT_FALSE(transpose->evaluate_upper(result)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_label_but_empty_label_set) { - exp_result = TensorVector{Tensor(label_dtype, exp_result.front().get_shape())}; - - labels.resize(shape_size(shape), 0); - arg->get_default_output().get_tensor().set_value_label(labels); - - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - ASSERT_FALSE(transpose->evaluate_label(out_labels)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_label_but_order_has_no_bound_set) { - exp_result = TensorVector{Tensor(label_dtype, exp_result.front().get_shape())}; - - std::generate_n(std::back_inserter(labels), shape_size(shape), SeqGen(30)); - arg->get_default_output().get_tensor().set_value_label(labels); - - ASSERT_FALSE(transpose->evaluate_label(out_labels)); -} - -TEST_P(TransposeEvalBoundTest, evaluate_label) { - exp_result = TensorVector{Tensor(label_dtype, exp_result.front().get_shape())}; - - std::generate_n(std::back_inserter(labels), shape_size(shape), SeqGen(5)); - arg->get_default_output().get_tensor().set_value_label(labels); - - node_set_lower_and_upper(order.get(), axes_v_tensor, axes_v_tensor); - - auto inputs = TensorVector{Tensor(label_dtype, shape, labels.data()), - Tensor(dtype, Shape{axes_order.size()}, axes_order.data())}; - - auto exp_eval_result = transpose->evaluate(exp_result, inputs); - - ASSERT_EQ(transpose->evaluate_label(out_labels), exp_eval_result); - ASSERT_THAT( - out_labels[Transpose::ARG_T], - ElementsAreArray(exp_result[Transpose::ARG_T].data(), exp_result[Transpose::ARG_T].get_size())); -} diff --git a/src/core/tests/type_prop/adaptive_avg_pool.cpp b/src/core/tests/type_prop/adaptive_avg_pool.cpp index 956d2841d93ed6..44dddd2a52f93f 100644 --- a/src/core/tests/type_prop/adaptive_avg_pool.cpp +++ b/src/core/tests/type_prop/adaptive_avg_pool.cpp @@ -31,7 +31,7 @@ TEST_F(AdaptiveAvgPoolV8Test, default_ctor) { TEST_F(AdaptiveAvgPoolV8Test, static_dim_shape_prop) { auto data_shape = PartialShape{1, 6, 8, 9}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); @@ -39,12 +39,13 @@ TEST_F(AdaptiveAvgPoolV8Test, static_dim_shape_prop) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, 6, 5, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST_F(AdaptiveAvgPoolV8Test, dynamic_batch) { PartialShape data_shape{Dimension::dynamic(), 6, 8, 9}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); @@ -52,31 +53,35 @@ TEST_F(AdaptiveAvgPoolV8Test, dynamic_batch) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 6, 5, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST_F(AdaptiveAvgPoolV8Test, dynamic_channel) { PartialShape data_shape{1, Dimension::dynamic(), {10, 20}, 9}; - set_shape_labels(data_shape, 20); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); const auto op = make_op(data, out_shape); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, -1, 5, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 21, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST_F(AdaptiveAvgPoolV8Test, dynamic_spatial) { PartialShape data_shape{1, 6, -1, -1}; - set_shape_labels(data_shape, 20); + + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); const auto op = make_op(data, out_shape); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, 6, 5, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 21, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST_F(AdaptiveAvgPoolV8Test, dynamic_output_shape) { @@ -103,18 +108,19 @@ TEST_F(AdaptiveAvgPoolV8Test, data_dynamic_rank) { EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic()); } -TEST_F(AdaptiveAvgPoolV8Test, preserve_partial_values_and_labels_on_output_shape_input) { +TEST_F(AdaptiveAvgPoolV8Test, preserve_partial_values_and_symbols_on_output_shape_input) { auto data_shape = PartialShape{{1, 2}, {2, 4}, 5, {10, 20}, -1}; - set_shape_labels(data_shape, 10); + auto d_symbols = set_shape_symbols(data_shape); auto out_shape = PartialShape{{2, 6}, 3, {12, 13}}; - set_shape_labels(out_shape, 20); + auto o_symbols = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, data_shape); const auto spatial_dim_shape = make_shared(make_shared(element::i64, out_shape)); const auto op = make_op(data, spatial_dim_shape); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{1, 2}, {2, 4}, {2, 6}, 3, {12, 13}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 20, 21, 22)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], d_symbols[1], o_symbols[0], o_symbols[1], o_symbols[2])); } TEST_F(AdaptiveAvgPoolV8Test, out_spatial_shape_size_not_match_data_spatial_dimensions) { diff --git a/src/core/tests/type_prop/adaptive_max_pool.cpp b/src/core/tests/type_prop/adaptive_max_pool.cpp index b4c53ff21d8882..d7d602bb6c462d 100644 --- a/src/core/tests/type_prop/adaptive_max_pool.cpp +++ b/src/core/tests/type_prop/adaptive_max_pool.cpp @@ -48,7 +48,7 @@ TEST_F(AdaptiveMaxPoolV8Test, shape_infer) { TEST_F(AdaptiveMaxPoolV8Test, i32_indices) { auto data_shape = PartialShape{2, 6, 2, 10}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f64, data_shape); const auto out_shape = Constant::create(element::i32, Shape{2}, {7, 1}); @@ -62,12 +62,12 @@ TEST_F(AdaptiveMaxPoolV8Test, i32_indices) { Each(Property("PartialShape", &Output::get_partial_shape, PartialShape({2, 6, 7, 1})))); EXPECT_THAT(op->outputs(), Each(Property(&Output::get_partial_shape, - ResultOf(get_shape_labels, ElementsAre(10, 11, ov::no_label, ov::no_label))))); + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], nullptr, nullptr))))); } TEST_F(AdaptiveMaxPoolV8Test, dynamic_batch) { PartialShape data_shape{Dimension::dynamic(), 6, 8, 9}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {9, 9}); @@ -77,12 +77,12 @@ TEST_F(AdaptiveMaxPoolV8Test, dynamic_batch) { Each(Property("PartialShape", &Output::get_partial_shape, PartialShape({-1, 6, 9, 9})))); EXPECT_THAT(op->outputs(), Each(Property(&Output::get_partial_shape, - ResultOf(get_shape_labels, ElementsAre(10, 11, ov::no_label, ov::no_label))))); + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], nullptr, nullptr))))); } TEST_F(AdaptiveMaxPoolV8Test, dynamic_channel) { PartialShape data_shape{2, Dimension::dynamic(), {10, 20}, 9}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); @@ -92,12 +92,12 @@ TEST_F(AdaptiveMaxPoolV8Test, dynamic_channel) { Each(Property("PartialShape", &Output::get_partial_shape, PartialShape({2, -1, 5, 7})))); EXPECT_THAT(op->outputs(), Each(Property(&Output::get_partial_shape, - ResultOf(get_shape_labels, ElementsAre(10, 11, ov::no_label, ov::no_label))))); + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], nullptr, nullptr))))); } TEST_F(AdaptiveMaxPoolV8Test, dynamic_spatial) { PartialShape data_shape{2, 6, -1, -1}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::f32, data_shape); const auto out_shape = Constant::create(element::i64, Shape{2}, {5, 7}); @@ -107,7 +107,7 @@ TEST_F(AdaptiveMaxPoolV8Test, dynamic_spatial) { Each(Property("PartialShape", &Output::get_partial_shape, PartialShape({2, 6, 5, 7})))); EXPECT_THAT(op->outputs(), Each(Property(&Output::get_partial_shape, - ResultOf(get_shape_labels, ElementsAre(10, 11, ov::no_label, ov::no_label))))); + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], nullptr, nullptr))))); } TEST_F(AdaptiveMaxPoolV8Test, dynamic_output_shape) { @@ -146,11 +146,11 @@ TEST_F(AdaptiveMaxPoolV8Test, out_spatial_shape_size_not_match_data_spatial_dime HasSubstr("Output shape for spatial dimension not compatible with data shape.")); } -TEST_F(AdaptiveMaxPoolV8Test, preserve_partial_values_and_labels_on_output_shape_input) { +TEST_F(AdaptiveMaxPoolV8Test, preserve_partial_values_and_symbols_on_output_shape_input) { auto data_shape = PartialShape{{1, 2}, {2, 4}, 5, {10, 20}, -1}; - set_shape_labels(data_shape, 10); + auto symbols_in = set_shape_symbols(data_shape); auto out_shape = PartialShape{{2, 6}, -1, {12, 13}}; - set_shape_labels(out_shape, 20); + auto symbols_out = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, data_shape); const auto spatial_dim_shape = make_shared(make_shared(element::i64, out_shape)); @@ -162,7 +162,10 @@ TEST_F(AdaptiveMaxPoolV8Test, preserve_partial_values_and_labels_on_output_shape PartialShape({{1, 2}, {2, 4}, {2, 6}, -1, {12, 13}})))); EXPECT_THAT( op->outputs(), - Each(Property(&Output::get_partial_shape, ResultOf(get_shape_labels, ElementsAre(10, 11, 20, 21, 22))))); + Each(Property( + &Output::get_partial_shape, + ResultOf(get_shape_symbols, + ElementsAre(symbols_in[0], symbols_in[1], symbols_out[0], symbols_out[1], symbols_out[2]))))); } TEST_F(AdaptiveMaxPoolV8Test, unsupported_input_shape) { diff --git a/src/core/tests/type_prop/arithmetic_ops.hpp b/src/core/tests/type_prop/arithmetic_ops.hpp index ef9a1b0225a0ae..04992bd9040b93 100644 --- a/src/core/tests/type_prop/arithmetic_ops.hpp +++ b/src/core/tests/type_prop/arithmetic_ops.hpp @@ -7,7 +7,7 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/symbol.hpp" #include "openvino/op/util/attr_types.hpp" using namespace ov; @@ -501,15 +501,18 @@ TYPED_TEST_P(ArithmeticOperator, dynamic_shape_intervals_broadcast_pdpd) { } } -TYPED_TEST_P(ArithmeticOperator, labels_a_dynamic_mixed_dims_broadcast_numpy) { - // All dimensions of A have labels, B without labels +TYPED_TEST_P(ArithmeticOperator, symbols_a_dynamic_mixed_dims_broadcast_numpy) { + // All dimensions of A have symbols, B without symbols ov::PartialShape pshape_A{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(1), ov::Dimension(2, 128)}; ov::PartialShape pshape_B{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1)}; ov::PartialShape expected_shape = {-1, 3, ov::Dimension(2, 224), ov::Dimension(2, 128)}; - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(expected_shape, {10, 11, 0, 13}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, nullptr, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -519,18 +522,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_a_dynamic_mixed_dims_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_b_dynamic_mixed_dims_broadcast_numpy) { - // All dimensions of B have labels, A without labels +TYPED_TEST_P(ArithmeticOperator, symbols_b_dynamic_mixed_dims_broadcast_numpy) { + // All dimensions of B have symbols, A without symbols ov::PartialShape pshape_A{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(1), ov::Dimension(2, 128)}; ov::PartialShape pshape_B{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1)}; ov::PartialShape expected_shape = {-1, 3, ov::Dimension(2, 224), ov::Dimension(2, 128)}; - set_shape_labels(pshape_B, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 0}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + + set_shape_symbols(pshape_B, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, nullptr}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -540,19 +546,24 @@ TYPED_TEST_P(ArithmeticOperator, labels_b_dynamic_mixed_dims_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_interval_mixed_dims_broadcast_numpy) { - // Both params have dimensions with different labels +TYPED_TEST_P(ArithmeticOperator, symbols_different_interval_mixed_dims_broadcast_numpy) { + // Both params have dimensions with different symbols ov::PartialShape pshape_A{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(1), ov::Dimension(2, 128)}; ov::PartialShape pshape_B{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1)}; ov::PartialShape expected_shape = {-1, 3, ov::Dimension(2, 224), ov::Dimension(2, 128)}; - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {0, 21, 22, 13}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {E, F, G, H}); + set_shape_symbols(expected_shape, {nullptr, B, G, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -562,20 +573,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_interval_mixed_dims_broadcast_ const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_interval_b_and_fully_dyn_a_broadcast_numpy) { - // Both params have dimension labels, output has label B +TYPED_TEST_P(ArithmeticOperator, symbols_different_interval_b_and_fully_dyn_a_broadcast_numpy) { + // Both params have dimension symbols, output has symbol B ov::Dimension dim_0_A = ov::Dimension(-1); ov::Dimension dim_0_B = ov::Dimension(2, 4); - ov::DimensionTracker::set_label(dim_0_A, 10); - ov::DimensionTracker::set_label(dim_0_B, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_A.set_symbol(A); + dim_0_B.set_symbol(B); ov::PartialShape pshape_A = {dim_0_A, 3, 224, 1}, pshape_B = {dim_0_B, 3, 1, 224}; ov::PartialShape expected_shape = {ov::Dimension(2, 4), 3, 224, 224}; - ov::TensorLabel expected_labels{20, 0, 0, 0}; + ov::TensorSymbol expected_symbols{B, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -585,20 +597,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_interval_b_and_fully_dyn_a_bro const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_different_interval_a_and_fully_dyn_b_broadcast_numpy) { - // Both params have dimension labels, output has label A +TYPED_TEST_P(ArithmeticOperator, symbols_different_interval_a_and_fully_dyn_b_broadcast_numpy) { + // Both params have dimension symbols, output has symbol A ov::Dimension dim_0_A = ov::Dimension(2, 4); ov::Dimension dim_0_B = ov::Dimension(-1); - ov::DimensionTracker::set_label(dim_0_A, 10); - ov::DimensionTracker::set_label(dim_0_B, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_A.set_symbol(A); + dim_0_B.set_symbol(B); ov::PartialShape pshape_A = {dim_0_A, 3, 224, 1}, pshape_B = {dim_0_B, 3, 1, 224}; ov::PartialShape expected_shape = {ov::Dimension(2, 4), 3, 224, 224}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -608,19 +621,22 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_interval_a_and_fully_dyn_b_bro const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_equal_interval_dims_without_one_broadcast_numpy) { - // Both params have dynamic interval dimension the same labels +TYPED_TEST_P(ArithmeticOperator, symbols_equal_interval_dims_without_one_broadcast_numpy) { + // Both params have dynamic interval dimension the same symbols ov::PartialShape pshape_A{ov::Dimension(2, 4), ov::Dimension(8, 16), ov::Dimension(8, 16), ov::Dimension(8, 16)}; ov::PartialShape pshape_B{ov::Dimension(2, 4), ov::Dimension(4, 12), ov::Dimension(10, 12), ov::Dimension(16, 24)}; ov::PartialShape expected_shape = {ov::Dimension(2, 4), ov::Dimension(8, 12), ov::Dimension(10, 12), 16}; - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {10, 11, 12, 13}); - set_shape_labels(expected_shape, {10, 11, 12, 13}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -630,19 +646,22 @@ TYPED_TEST_P(ArithmeticOperator, labels_equal_interval_dims_without_one_broadcas const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_interval_dims_without_one_broadcast_numpy) { - // Both params have dynamic interval dimension different labels +TYPED_TEST_P(ArithmeticOperator, symbols_different_interval_dims_without_one_broadcast_numpy) { + // Both params have dynamic interval dimension different symbols ov::PartialShape pshape_A{ov::Dimension(2, 4), ov::Dimension(8, 16), ov::Dimension(8, 16), ov::Dimension(8, 16)}; ov::PartialShape pshape_B{ov::Dimension(2, 4), ov::Dimension(4, 12), ov::Dimension(10, 12), ov::Dimension(16, 24)}; ov::PartialShape expected_shape = {ov::Dimension(2, 4), ov::Dimension(8, 12), ov::Dimension(10, 12), 16}; - ov::TensorLabel expected_labels{20, 21, 22, 23}; - - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + ov::TensorSymbol expected_symbols{A, B, C, D}; + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {E, F, G, H}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -652,19 +671,19 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_interval_dims_without_one_broa const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_different_interval_batch_without_one_equivalence_table_broadcast_numpy) { - // Both params have dynamic interval dimension different labels, use table of equivalence - auto table_of_equivalence = std::make_shared(); - ov::DimensionTracker dim_tracker(table_of_equivalence); +TYPED_TEST_P(ArithmeticOperator, symbols_different_interval_batch_without_one_equivalence_table_broadcast_numpy) { + // Both params have dynamic interval dimension different symbols, use table of equivalence ov::Dimension dim_0_A = ov::Dimension(2, 4); - ov::Dimension dim_0_B = ov::Dimension(2, 4); + auto A = std::make_shared(); + dim_0_A.set_symbol(A); - dim_tracker.set_up_for_tracking(dim_0_A, 10); - dim_tracker.set_up_for_tracking(dim_0_B, 20); + ov::Dimension dim_0_B = ov::Dimension(2, 4); + auto B = std::make_shared(); + dim_0_B.set_symbol(B); ov::PartialShape pshape_A = {dim_0_A, 3, 224, 1}, pshape_B = {dim_0_B, 3, 1, 224}; @@ -676,27 +695,26 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_interval_batch_without_one_equ const auto out_shape = op->get_output_partial_shape(0); ov::PartialShape expected_shape = {ov::Dimension(2, 4), 3, 224, 224}; - ov::TensorLabel expected_labels{20, 0, 0, 0}; - - auto eq_table = table_of_equivalence->get_equivalence_table(); - EXPECT_EQ(*eq_table[ov::DimensionTracker::get_label(dim_0_A)], std::set({10, 20})); - EXPECT_EQ(*eq_table[ov::DimensionTracker::get_label(dim_0_B)], std::set({10, 20})); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_TRUE(ov::symbol::are_equal(out_shape[0].get_symbol(), A)); + EXPECT_TRUE(ov::symbol::are_equal(out_shape[0].get_symbol(), B)); + EXPECT_TRUE(ov::symbol::are_equal(A, B)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_fully_dynamic_batch_broadcast_numpy) { - // Both params have fully dynamic dimension and different labels +TYPED_TEST_P(ArithmeticOperator, symbols_different_fully_dynamic_batch_broadcast_numpy) { + // Both params have fully dynamic dimension and different symbols ov::Dimension dim_0_A = ov::Dimension(-1); - ov::Dimension dim_0_B = ov::Dimension(-1); + auto A = std::make_shared(); + dim_0_A.set_symbol(A); - ov::DimensionTracker::set_label(dim_0_A, 10); - ov::DimensionTracker::set_label(dim_0_B, 20); + ov::Dimension dim_0_B = ov::Dimension(-1); + auto B = std::make_shared(); + dim_0_B.set_symbol(B); ov::PartialShape pshape_A = {dim_0_A, 3, 224, 1}, pshape_B = {dim_0_B, 3, 1, 224}; ov::PartialShape expected_shape = {-1, 3, 224, 224}; - ov::TensorLabel expected_labels{0, 0, 0, 0}; + ov::TensorSymbol expected_symbols{nullptr, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -706,20 +724,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_fully_dynamic_batch_broadcast_ const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_equal_fully_dynamic_batch_broadcast_numpy) { - // Both params have fully dynamic dimension and the same labels +TYPED_TEST_P(ArithmeticOperator, symbols_equal_fully_dynamic_batch_broadcast_numpy) { + // Both params have fully dynamic dimension and the same symbols + auto A = std::make_shared(); + ov::Dimension dim_0_A = ov::Dimension(-1); + dim_0_A.set_symbol(A); ov::Dimension dim_0_B = ov::Dimension(-1); - - ov::DimensionTracker::set_label(dim_0_A, 10); - ov::DimensionTracker::set_label(dim_0_B, 10); + dim_0_B.set_symbol(A); ov::PartialShape pshape_A = {dim_0_A, 3, 224, 1}, pshape_B = {dim_0_B, 3, 1, 224}; ov::PartialShape expected_shape = {-1, 3, 224, 224}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -729,16 +748,17 @@ TYPED_TEST_P(ArithmeticOperator, labels_equal_fully_dynamic_batch_broadcast_nump const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_a_broadcast_numpy) { +TYPED_TEST_P(ArithmeticOperator, symbols_dyn_batch_a_broadcast_numpy) { + auto S = std::make_shared(); ov::Dimension b = -1; - ov::DimensionTracker::set_label(b, 10); + b.set_symbol(S); ov::PartialShape A = {b, 3, 224, 224}, B = {1, 3, 1, 1}; ov::PartialShape expected_shape{b, 3, 224, 224}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{S, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f64, A); auto param_B = std::make_shared(element::f64, B); @@ -748,16 +768,17 @@ TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_a_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_b_broadcast_numpy) { +TYPED_TEST_P(ArithmeticOperator, symbols_dyn_batch_b_broadcast_numpy) { + auto S = std::make_shared(); ov::Dimension b = -1; - ov::DimensionTracker::set_label(b, 10); + b.set_symbol(S); ov::PartialShape B = {b, 3, 224, 224}, A = {1, 3, 1, 1}; ov::PartialShape expected_shape{b, 3, 224, 224}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{S, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f64, A); auto param_B = std::make_shared(element::f64, B); @@ -767,18 +788,19 @@ TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_b_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_and_higher_rank_a_broadcast_numpy) { +TYPED_TEST_P(ArithmeticOperator, symbols_dyn_batch_and_higher_rank_a_broadcast_numpy) { + auto S = std::make_shared(); ov::Dimension b = -1; - ov::DimensionTracker::set_label(b, 10); + b.set_symbol(S); ov::PartialShape pshape_A{b, -1, -1, -1}; ov::PartialShape pshape_B{3, 1, 1}; ov::PartialShape expected_shape{b, 3, -1, -1}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{S, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f64, pshape_A); auto param_B = std::make_shared(element::f64, pshape_B); @@ -788,18 +810,19 @@ TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_and_higher_rank_a_broadcast_nu const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_and_higher_rank_b_broadcast_numpy) { +TYPED_TEST_P(ArithmeticOperator, symbols_dyn_batch_and_higher_rank_b_broadcast_numpy) { + auto S = std::make_shared(); ov::Dimension b = -1; - ov::DimensionTracker::set_label(b, 10); + b.set_symbol(S); ov::PartialShape pshape_A{3, 1, 1}; ov::PartialShape pshape_B{b, -1, -1, -1}; ov::PartialShape expected_shape{b, 3, -1, -1}; - ov::TensorLabel expected_labels{10, 0, 0, 0}; + ov::TensorSymbol expected_symbols{S, nullptr, nullptr, nullptr}; auto param_A = std::make_shared(element::f64, pshape_A); auto param_B = std::make_shared(element::f64, pshape_B); @@ -809,19 +832,24 @@ TYPED_TEST_P(ArithmeticOperator, labels_dyn_batch_and_higher_rank_b_broadcast_nu const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(ArithmeticOperator, labels_different_static_shape_broadcast_numpy) { - // Static shape, different labels +TYPED_TEST_P(ArithmeticOperator, symbols_different_static_shape_broadcast_numpy) { + // Static shape, different symbols ov::PartialShape pshape_A{ov::Dimension(2), ov::Dimension(1), ov::Dimension(224), ov::Dimension(1)}; ov::PartialShape pshape_B{ov::Dimension(2), ov::Dimension(1), ov::Dimension(1), ov::Dimension(128)}; ov::PartialShape expected_shape{2, 1, 224, 128}; - // Different labels - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 12, 23}); + // Different symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {E, F, G, H}); + set_shape_symbols(expected_shape, {A, F, C, H}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -830,19 +858,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_static_shape_broadcast_numpy) const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_equal_static_shape_broadcast_numpy) { - // Static shape, the same labels +TYPED_TEST_P(ArithmeticOperator, symbols_equal_static_shape_broadcast_numpy) { + // Static shape, the same symbols ov::PartialShape pshape_A{2, 1, 224, 1}; ov::PartialShape pshape_B{2, 1, 1, 128}; ov::PartialShape expected_shape{2, 1, 224, 128}; - // Equal labels - set_shape_labels(pshape_A, {30, 31, 32, 33}); - set_shape_labels(pshape_B, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -851,19 +881,19 @@ TYPED_TEST_P(ArithmeticOperator, labels_equal_static_shape_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_static_shape_broadcast_none) { +TYPED_TEST_P(ArithmeticOperator, symbols_different_static_shape_broadcast_none) { // Static shape ov::PartialShape pshape_A{2, 3, 224, 128}; ov::PartialShape pshape_B{2, 3, 224, 128}; ov::PartialShape expected_shape{2, 3, 224, 128}; - // Different labels - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 23}); + // Different symbols + auto symbols = set_shape_symbols(pshape_A); + set_shape_symbols(pshape_B); + set_shape_symbols(expected_shape, symbols); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -872,19 +902,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_static_shape_broadcast_none) { auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_equal_static_shape_broadcast_none) { +TYPED_TEST_P(ArithmeticOperator, symbols_equal_static_shape_broadcast_none) { // Static shape ov::PartialShape pshape_A{2, 3, 224, 128}; ov::PartialShape pshape_B{2, 3, 224, 128}; ov::PartialShape expected_shape{2, 3, 224, 128}; - // Equal labels - set_shape_labels(pshape_A, {30, 31, 32, 33}); - set_shape_labels(pshape_B, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -893,19 +925,19 @@ TYPED_TEST_P(ArithmeticOperator, labels_equal_static_shape_broadcast_none) { auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_different_dynamic_shape_broadcast_none) { +TYPED_TEST_P(ArithmeticOperator, symbols_different_dynamic_shape_broadcast_none) { // Dynamic shape ov::PartialShape pshape_A{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1, 128)}; ov::PartialShape pshape_B{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1, 128)}; ov::PartialShape expected_shape{-1, 3, ov::Dimension(2, 224), ov::Dimension(1, 128)}; // Different labels - set_shape_labels(pshape_A, {10, 11, 12, 13}); - set_shape_labels(pshape_B, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 23}); + auto symbols = set_shape_symbols(pshape_A); + set_shape_symbols(pshape_B); + set_shape_symbols(expected_shape, symbols); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -914,19 +946,21 @@ TYPED_TEST_P(ArithmeticOperator, labels_different_dynamic_shape_broadcast_none) const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(ArithmeticOperator, labels_equal_dynamic_shape_broadcast_none) { +TYPED_TEST_P(ArithmeticOperator, symbols_equal_dynamic_shape_broadcast_none) { // Dynamic shape ov::PartialShape pshape_A{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1, 128)}; ov::PartialShape pshape_B{ov::Dimension(-1), ov::Dimension(3), ov::Dimension(2, 224), ov::Dimension(1, 128)}; ov::PartialShape expected_shape{-1, 3, ov::Dimension(2, 224), ov::Dimension(1, 128)}; - // Equal labels - set_shape_labels(pshape_A, {30, 31, 32, 33}); - set_shape_labels(pshape_B, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_A, {A, B, C, D}); + set_shape_symbols(pshape_B, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto param_A = std::make_shared(element::f32, pshape_A); auto param_B = std::make_shared(element::f32, pshape_B); @@ -935,7 +969,7 @@ TYPED_TEST_P(ArithmeticOperator, labels_equal_dynamic_shape_broadcast_none) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } REGISTER_TYPED_TEST_SUITE_P(ArithmeticOperator, @@ -974,24 +1008,24 @@ REGISTER_TYPED_TEST_SUITE_P(ArithmeticOperator, dynamic_shape_intervals_b_rank_smaller_broadcast_numpy, dynamic_shape_intervals_broadcast_pdpd, - // Dimension labels (static and dynamic) - labels_a_dynamic_mixed_dims_broadcast_numpy, - labels_b_dynamic_mixed_dims_broadcast_numpy, - labels_different_interval_mixed_dims_broadcast_numpy, - labels_different_interval_b_and_fully_dyn_a_broadcast_numpy, - labels_different_interval_a_and_fully_dyn_b_broadcast_numpy, - labels_equal_interval_dims_without_one_broadcast_numpy, - labels_different_interval_dims_without_one_broadcast_numpy, - labels_different_interval_batch_without_one_equivalence_table_broadcast_numpy, - labels_different_fully_dynamic_batch_broadcast_numpy, - labels_equal_fully_dynamic_batch_broadcast_numpy, - labels_dyn_batch_a_broadcast_numpy, - labels_dyn_batch_b_broadcast_numpy, - labels_dyn_batch_and_higher_rank_a_broadcast_numpy, - labels_dyn_batch_and_higher_rank_b_broadcast_numpy, - labels_different_static_shape_broadcast_numpy, - labels_equal_static_shape_broadcast_numpy, - labels_different_static_shape_broadcast_none, - labels_equal_static_shape_broadcast_none, - labels_different_dynamic_shape_broadcast_none, - labels_equal_dynamic_shape_broadcast_none); + // Dimension symbols (static and dynamic) + symbols_a_dynamic_mixed_dims_broadcast_numpy, + symbols_b_dynamic_mixed_dims_broadcast_numpy, + symbols_different_interval_mixed_dims_broadcast_numpy, + symbols_different_interval_b_and_fully_dyn_a_broadcast_numpy, + symbols_different_interval_a_and_fully_dyn_b_broadcast_numpy, + symbols_equal_interval_dims_without_one_broadcast_numpy, + symbols_different_interval_dims_without_one_broadcast_numpy, + symbols_different_interval_batch_without_one_equivalence_table_broadcast_numpy, + symbols_different_fully_dynamic_batch_broadcast_numpy, + symbols_equal_fully_dynamic_batch_broadcast_numpy, + symbols_dyn_batch_a_broadcast_numpy, + symbols_dyn_batch_b_broadcast_numpy, + symbols_dyn_batch_and_higher_rank_a_broadcast_numpy, + symbols_dyn_batch_and_higher_rank_b_broadcast_numpy, + symbols_different_static_shape_broadcast_numpy, + symbols_equal_static_shape_broadcast_numpy, + symbols_different_static_shape_broadcast_none, + symbols_equal_static_shape_broadcast_none, + symbols_different_dynamic_shape_broadcast_none, + symbols_equal_dynamic_shape_broadcast_none); diff --git a/src/core/tests/type_prop/avg_pool.cpp b/src/core/tests/type_prop/avg_pool.cpp index 52b5fd3727a87d..8ce34875558275 100644 --- a/src/core/tests/type_prop/avg_pool.cpp +++ b/src/core/tests/type_prop/avg_pool.cpp @@ -19,7 +19,7 @@ TYPED_TEST_SUITE_P(AvgPoolOperator); TYPED_TEST_P(AvgPoolOperator, avg_pool_default_ctor) { ov::PartialShape arg_shape{1, 3, 32}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); auto arg = make_shared(ov::element::f32, arg_shape); auto mp = this->make_op(); @@ -37,7 +37,7 @@ TYPED_TEST_P(AvgPoolOperator, avg_pool_default_ctor) { EXPECT_EQ(mp->get_output_size(), 1); EXPECT_EQ(mp->get_output_element_type(0), ov::element::f32); EXPECT_EQ(mp->get_output_partial_shape(0), ov::PartialShape({1, 3, 32})); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], nullptr)); EXPECT_EQ(mp->get_pads_begin(), (ov::Shape{1})); EXPECT_EQ(mp->get_pads_end(), (ov::Shape{0})); } diff --git a/src/core/tests/type_prop/batch_to_space.cpp b/src/core/tests/type_prop/batch_to_space.cpp index 66d992e08ec68a..33d13979f172b0 100644 --- a/src/core/tests/type_prop/batch_to_space.cpp +++ b/src/core/tests/type_prop/batch_to_space.cpp @@ -366,7 +366,7 @@ TEST(type_prop, batch_to_space_output_dynamic_shape_5D_when_batch_is_static) { TEST(type_prop, batch_to_space_output_dynamic_shape_5D_when_batch_is_dynamic) { auto data_shape = ov::PartialShape{{959, 962}, {2, 34}, {9, 21}, {100, 162}, {1, 1999}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(ov::element::f32, data_shape); auto block_shape = make_shared(ov::element::i32, ov::Shape{5}, vector{1, 6, 5, 1, 16}); @@ -381,13 +381,13 @@ TEST(type_prop, batch_to_space_output_dynamic_shape_5D_when_batch_is_dynamic) { {9 * 5 - 1, 21 * 5 - 1}, {100, 162}, {1 * 16, 1999 * 16}})); - EXPECT_THAT(get_shape_labels(batch_to_space->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, 13, ov::no_label)); + EXPECT_THAT(get_shape_symbols(batch_to_space->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, symbols[3], nullptr)); } TEST(type_prop, batch_to_space_input_interval_shape_block_one) { auto data_shape = ov::PartialShape{{959, 962}, {2, 34}, {9, 21}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(ov::element::f32, data_shape); auto block_shape = make_shared(ov::element::i32, ov::Shape{3}, vector{1, 1, 1}); auto crops_begin = make_shared(ov::element::i32, ov::Shape{3}, vector{0, 0, 0}); @@ -396,7 +396,8 @@ TEST(type_prop, batch_to_space_input_interval_shape_block_one) { EXPECT_EQ(batch_to_space->get_output_partial_shape(0), ov::PartialShape({{959, 962}, {2, 34}, {9 * 1 - 1, 21 * 1 - 1}})); - EXPECT_THAT(get_shape_labels(batch_to_space->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label)); + EXPECT_THAT(get_shape_symbols(batch_to_space->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr)); } TEST(type_prop, batch_to_space_and_space_to_batch) { diff --git a/src/core/tests/type_prop/binary_convolution.cpp b/src/core/tests/type_prop/binary_convolution.cpp index 1d5ace4b7ac7b0..487aa8cdd5360f 100644 --- a/src/core/tests/type_prop/binary_convolution.cpp +++ b/src/core/tests/type_prop/binary_convolution.cpp @@ -16,8 +16,8 @@ using namespace testing; TEST(type_prop, bin_convolution_auto_padding_same) { ov::PartialShape data_batch_shape{1, 1, 5, 5}; ov::PartialShape filters_shape{1, 1, 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto a_symbols = set_shape_symbols(data_batch_shape); + auto w_symbols = set_shape_symbols(filters_shape); ov::Strides strides{1, 1}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -39,7 +39,8 @@ TEST(type_prop, bin_convolution_auto_padding_same) { pad_value, auto_pad); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(a_symbols[0], w_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_output_partial_shape(0), (ov::PartialShape{1, 1, 5, 5})); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{1, 1})); EXPECT_EQ(conv->get_pads_end(), (ov::CoordinateDiff{1, 1})); @@ -48,8 +49,8 @@ TEST(type_prop, bin_convolution_auto_padding_same) { TEST(type_prop, bin_convolution_auto_padding_same_lower_spatial_dims_static) { ov::PartialShape data_batch_shape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 5, 5}; ov::PartialShape filters_shape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto a_symbols = set_shape_symbols(data_batch_shape); + auto w_symbols = set_shape_symbols(filters_shape); ov::Strides strides{1, 1}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -71,7 +72,8 @@ TEST(type_prop, bin_convolution_auto_padding_same_lower_spatial_dims_static) { pad_value, auto_pad); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(a_symbols[0], w_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_output_partial_shape(0), (ov::PartialShape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 5, 5})); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{1, 1})); @@ -111,8 +113,8 @@ TEST(type_prop, bin_convolution_auto_padding_same_upper_spatial_dims_static) { TEST(type_prop, bin_convolution_auto_padding_same_data_batch_spatial_dims_dynamic) { ov::PartialShape data_batch_shape{1, 1, ov::Dimension::dynamic(), 5}; ov::PartialShape filters_shape{ov::Dimension::dynamic(), 1, 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto a_symbols = set_shape_symbols(data_batch_shape); + auto w_symbols = set_shape_symbols(filters_shape); ov::Strides strides{1, 1}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -134,7 +136,8 @@ TEST(type_prop, bin_convolution_auto_padding_same_data_batch_spatial_dims_dynami pad_value, auto_pad); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(a_symbols[0], w_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_output_partial_shape(0), (ov::PartialShape{1, ov::Dimension::dynamic(), ov::Dimension::dynamic(), 5})); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{0, 1})); @@ -415,8 +418,8 @@ TEST_F(TypePropBinaryConvolutionV1Test, default_ctor) { TEST_F(TypePropBinaryConvolutionV1Test, interval_shapes) { ov::PartialShape data_batch_pshape{{1, 3}, 1, {1, 5}, {3, 10}}; ov::PartialShape filters_pshape{2, {1, 3}, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto a_symbols = set_shape_symbols(data_batch_pshape); + auto w_symbols = set_shape_symbols(filters_pshape); constexpr auto et = ov::element::f32; constexpr auto auto_pad = ov::op::PadType::EXPLICIT; @@ -435,7 +438,8 @@ TEST_F(TypePropBinaryConvolutionV1Test, interval_shapes) { pad_value, auto_pad); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(a_symbols[0], w_symbols[0], nullptr, nullptr)); EXPECT_EQ(op->get_output_partial_shape(0), ov::PartialShape({{1, 3}, 2, {1, 3}, {1, 8}})); EXPECT_EQ(op->get_pads_begin(), (ov::CoordinateDiff{0, 0})); EXPECT_EQ(op->get_pads_end(), (ov::CoordinateDiff{0, 0})); diff --git a/src/core/tests/type_prop/binary_elementwise.cpp b/src/core/tests/type_prop/binary_elementwise.cpp index 661da925bc3bb2..ef2e174019d5ae 100644 --- a/src/core/tests/type_prop/binary_elementwise.cpp +++ b/src/core/tests/type_prop/binary_elementwise.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" @@ -161,7 +160,7 @@ TYPED_TEST_P(BinaryElementwiseCmpTest, argument_shapes_are_inconsistent) { TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_static_partial_shape_no_broadcast) { auto shape = ov::PartialShape{2, 4, 5}; - set_shape_labels(shape, 3); + auto symbols = set_shape_symbols(shape); const auto a = make_shared(ov::element::f32, shape); const auto b = make_shared(ov::element::f32, ov::PartialShape({2, 4, 5})); @@ -171,9 +170,9 @@ TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_static_partial_shape_no_broadca EXPECT_EQ(op->get_element_type(), ov::element::boolean); EXPECT_EQ(op->get_output_partial_shape(0), shape); EXPECT_EQ(op->get_shape(), shape.get_shape()); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(3, 4, 5)); - EXPECT_THAT(get_shape_labels(a->get_output_partial_shape(0)), ElementsAre(3, 4, 5)); - EXPECT_THAT(get_shape_labels(b->get_output_partial_shape(0)), Each(0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], symbols[2])); + EXPECT_THAT(get_shape_symbols(a->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], symbols[2])); + EXPECT_THAT(get_shape_symbols(b->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_static_partial_shape_numpy_broadcast) { @@ -264,64 +263,74 @@ TYPED_TEST_P(BinaryElementwiseCmpTest, not_allowed_mixed_input_types) { ASSERT_ANY_THROW({ this->make_op_with_types(ov::element::boolean, ov::element::i32); }); } -TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_labels_from_one_input_only_no_broadcast) { +TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_symbols_from_one_input_only_no_broadcast) { constexpr auto et = ov::element::f64; - auto labeled_shape = ov::PartialShape{2, 4, 5}; - set_shape_labels(labeled_shape, 3); - const auto exp_labels = get_shape_labels(labeled_shape); + auto symboled_shape = ov::PartialShape{2, 4, 5}; + const auto exp_symbols = set_shape_symbols(symboled_shape); - const auto a = make_shared(et, labeled_shape); + const auto a = make_shared(et, symboled_shape); const auto b = make_shared(et, ov::PartialShape({2, 4, 5})); - EXPECT_EQ(get_shape_labels(this->make_op(a, b, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0)), - exp_labels); - EXPECT_EQ(get_shape_labels(this->make_op(b, a, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0)), - exp_labels); + EXPECT_EQ(get_shape_symbols(this->make_op(a, b, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0)), + exp_symbols); + EXPECT_EQ(get_shape_symbols(this->make_op(b, a, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0)), + exp_symbols); } -TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_labels_from_both_inputs_no_broadcast) { +TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_symbols_from_both_inputs_no_broadcast) { constexpr auto et = ov::element::f64; - const auto labels_a = ov::TensorLabel{10, ov::no_label, 12, 13, 14, 15}; + auto A = std::make_shared(), B = std::make_shared(); + auto C = std::make_shared(), D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(); + auto G = std::make_shared(), H = std::make_shared(); + auto I = std::make_shared(), J = std::make_shared(); + + const auto symbols_a = ov::TensorSymbol{A, nullptr, B, C, D, E}; auto shape_a = ov::PartialShape{2, 4, 5, -1, {4, 5}, {-1, 6}}; - set_shape_labels(shape_a, labels_a); + set_shape_symbols(shape_a, symbols_a); const auto a = make_shared(et, shape_a); - const auto labels_b = ov::TensorLabel{20, 21, ov::no_label, 23, 24, 25}; + const auto symbols_b = ov::TensorSymbol{F, G, nullptr, H, I, J}; auto shape_b = ov::PartialShape{2, 4, 5, 5, -1, {4, -1}}; - set_shape_labels(shape_b, labels_b); + set_shape_symbols(shape_b, symbols_b); const auto b = make_shared(et, shape_b); EXPECT_THAT(this->make_op(a, b, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0), AllOf(Eq(ov::PartialShape({2, 4, 5, 5, {4, 5}, {4, 6}})), - ResultOf(get_shape_labels, ElementsAre(20, 21, 12, 23, 24, 25)))); + ResultOf(get_shape_symbols, ElementsAre(A, G, B, C, D, E)))); EXPECT_THAT(this->make_op(b, a, ov::op::AutoBroadcastType::NONE)->get_output_partial_shape(0), AllOf(Eq(ov::PartialShape({2, 4, 5, 5, {4, 5}, {4, 6}})), - ResultOf(get_shape_labels, ElementsAre(10, 21, 12, 13, 14, 15)))); + ResultOf(get_shape_symbols, ElementsAre(F, G, B, H, I, J)))); } -TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_labels_from_both_inputs_numpy_broadcast) { +TYPED_TEST_P(BinaryElementwiseCmpTest, propagate_symbols_from_both_inputs_numpy_broadcast) { constexpr auto et = ov::element::f64; - const auto labels_a = ov::TensorLabel{10, ov::no_label, 12, 13, ov::no_label, 15}; + auto A = std::make_shared(), B = std::make_shared(); + auto C = std::make_shared(), D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(); + auto G = std::make_shared(), H = std::make_shared(); + + const auto symbols_a = ov::TensorSymbol{A, nullptr, B, C, nullptr, D}; auto shape_a = ov::PartialShape{2, {2, 4}, -1, {4, 5}, {-1, 6}, 1}; - set_shape_labels(shape_a, labels_a); + set_shape_symbols(shape_a, symbols_a); const auto a = make_shared(et, shape_a); - const auto labels_b = ov::TensorLabel{20, 21, ov::no_label, 23}; + const auto symbols_b = ov::TensorSymbol{E, F, nullptr, G}; auto shape_b = ov::PartialShape{2, {4, -1}, 5, {4, -1}}; - set_shape_labels(shape_b, labels_b); + set_shape_symbols(shape_b, symbols_b); const auto b = make_shared(et, shape_b); EXPECT_THAT(this->make_op(a, b, ov::op::AutoBroadcastType::NUMPY)->get_output_partial_shape(0), AllOf(Eq(ov::PartialShape({2, {2, 4}, 2, {4, 5}, 5, {4, -1}})), - ResultOf(get_shape_labels, ElementsAre(10, ov::no_label, 20, 21, ov::no_label, 23)))); + ResultOf(get_shape_symbols, ElementsAre(A, nullptr, E, C, nullptr, G)))); EXPECT_THAT(this->make_op(b, a, ov::op::AutoBroadcastType::NUMPY)->get_output_partial_shape(0), AllOf(Eq(ov::PartialShape({2, {2, 4}, 2, {4, 5}, 5, {4, -1}})), - ResultOf(get_shape_labels, ElementsAre(10, ov::no_label, 20, 13, ov::no_label, 23)))); + ResultOf(get_shape_symbols, ElementsAre(A, nullptr, E, F, nullptr, G)))); } TYPED_TEST_P(BinaryElementwiseCmpTest, use_default_ctor) { @@ -353,9 +362,9 @@ REGISTER_TYPED_TEST_SUITE_P(BinaryElementwiseCmpTest, propagate_one_input_is_dynamic_rank_shape, allowed_mixed_input_types, not_allowed_mixed_input_types, - propagate_labels_from_one_input_only_no_broadcast, - propagate_labels_from_both_inputs_no_broadcast, - propagate_labels_from_both_inputs_numpy_broadcast, + propagate_symbols_from_one_input_only_no_broadcast, + propagate_symbols_from_both_inputs_no_broadcast, + propagate_symbols_from_both_inputs_numpy_broadcast, use_default_ctor); using BinaryOpTypes = Typesget_output_partial_shape(0), exp_shape); } -TEST_P(BitwiseNotTest, propagate_labels) { +TEST_P(BitwiseNotTest, propagate_symbols) { if (exp_shape.rank().is_static()) { - set_shape_labels(exp_shape, 10); + set_shape_symbols(exp_shape); } - const auto exp_labels = get_shape_labels(exp_shape); + const auto exp_symbols = get_shape_symbols(exp_shape); const auto input = std::make_shared(exp_type, exp_shape); const auto op = make_op(input); - EXPECT_EQ(get_shape_labels(op->get_output_partial_shape(0)), exp_labels); + EXPECT_EQ(get_shape_symbols(op->get_output_partial_shape(0)), exp_symbols); } TEST_P(BitwiseNotTest, default_ctor) { diff --git a/src/core/tests/type_prop/bitwise_ops.hpp b/src/core/tests/type_prop/bitwise_ops.hpp index 75bc80300059dd..63a5237ded6b9a 100644 --- a/src/core/tests/type_prop/bitwise_ops.hpp +++ b/src/core/tests/type_prop/bitwise_ops.hpp @@ -8,7 +8,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/util/attr_types.hpp" using namespace ov; @@ -440,15 +439,17 @@ TYPED_TEST_P(BitwiseOperator, dynamic_shape_intervals_broadcast_pdpd) { } } -TYPED_TEST_P(BitwiseOperator, labels_a_dynamic_mixed_dims_broadcast_numpy) { - // All dimensions of lhs have labels, rhs without labels +TYPED_TEST_P(BitwiseOperator, symbols_a_dynamic_mixed_dims_broadcast_numpy) { + // All dimensions of lhs have symbols, rhs without symbols PartialShape pshape_lhs{{-1}, {3}, {1}, {2, 128}}; PartialShape pshape_rhs{{-1}, {3}, {2, 224}, {1}}; PartialShape expected_shape = {-1, 3, {2, 224}, {2, 128}}; - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(expected_shape, {10, 11, 0, 13}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, nullptr, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -458,18 +459,20 @@ TYPED_TEST_P(BitwiseOperator, labels_a_dynamic_mixed_dims_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_b_dynamic_mixed_dims_broadcast_numpy) { - // All dimensions of rhs have labels, lhs without labels +TYPED_TEST_P(BitwiseOperator, symbols_b_dynamic_mixed_dims_broadcast_numpy) { + // All dimensions of rhs have symbols, lhs without symbols PartialShape pshape_lhs{{-1}, {3}, {1}, {2, 128}}; PartialShape pshape_rhs{{-1}, {3}, {2, 224}, {1}}; PartialShape expected_shape = {-1, 3, {2, 224}, {2, 128}}; - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 0}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_rhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, nullptr}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -479,19 +482,23 @@ TYPED_TEST_P(BitwiseOperator, labels_b_dynamic_mixed_dims_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_different_interval_mixed_dims_broadcast_numpy) { - // Both params have dimensions with different labels +TYPED_TEST_P(BitwiseOperator, symbols_different_interval_mixed_dims_broadcast_numpy) { + // Both params have dimensions with different symbols PartialShape pshape_lhs{{-1}, {3}, {1}, {2, 128}}; PartialShape pshape_rhs{{-1}, {3}, {2, 224}, {1}}; PartialShape expected_shape = {-1, 3, {2, 224}, {2, 128}}; + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {0, 21, 22, 13}); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {E, F, G, H}); + set_shape_symbols(expected_shape, {nullptr, B, G, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -501,20 +508,20 @@ TYPED_TEST_P(BitwiseOperator, labels_different_interval_mixed_dims_broadcast_num const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_different_interval_b_and_fully_dyn_a_broadcast_numpy) { - // Both params have dimension labels, output has label rhs +TYPED_TEST_P(BitwiseOperator, symbols_different_interval_b_and_fully_dyn_a_broadcast_numpy) { + // Both params have dimension symbols, output has symbol rhs Dimension dim_0_lhs = {-1}; Dimension dim_0_rhs = {2, 4}; - - DimensionTracker::set_label(dim_0_lhs, 10); - DimensionTracker::set_label(dim_0_rhs, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_lhs.set_symbol(A); + dim_0_rhs.set_symbol(B); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 1}, pshape_rhs = {dim_0_rhs, 3, 1, 224}; PartialShape expected_shape = {{2, 4}, 3, 224, 224}; - TensorLabel expected_labels{20, 0, 0, 0}; + TensorSymbol expected_symbols{B, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -524,20 +531,20 @@ TYPED_TEST_P(BitwiseOperator, labels_different_interval_b_and_fully_dyn_a_broadc const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_different_interval_a_and_fully_dyn_b_broadcast_numpy) { - // Both params have dimension labels, output has label lhs +TYPED_TEST_P(BitwiseOperator, symbols_different_interval_a_and_fully_dyn_b_broadcast_numpy) { + // Both params have dimension symbols, output has symbol lhs Dimension dim_0_lhs = {2, 4}; Dimension dim_0_rhs = {-1}; - - DimensionTracker::set_label(dim_0_lhs, 10); - DimensionTracker::set_label(dim_0_rhs, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_lhs.set_symbol(A); + dim_0_rhs.set_symbol(B); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 1}, pshape_rhs = {dim_0_rhs, 3, 1, 224}; PartialShape expected_shape = {{2, 4}, 3, 224, 224}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -547,19 +554,21 @@ TYPED_TEST_P(BitwiseOperator, labels_different_interval_a_and_fully_dyn_b_broadc const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_equal_interval_dims_without_one_broadcast_numpy) { - // Both params have dynamic interval dimension the same labels +TYPED_TEST_P(BitwiseOperator, symbols_equal_interval_dims_without_one_broadcast_numpy) { + // Both params have dynamic interval dimension the same symbols PartialShape pshape_lhs{{2, 4}, {8, 16}, {8, 16}, {8, 16}}; PartialShape pshape_rhs{{2, 4}, {4, 12}, {10, 12}, {16, 24}}; PartialShape expected_shape = {{2, 4}, {8, 12}, {10, 12}, 16}; - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {10, 11, 12, 13}); - set_shape_labels(expected_shape, {10, 11, 12, 13}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -569,20 +578,24 @@ TYPED_TEST_P(BitwiseOperator, labels_equal_interval_dims_without_one_broadcast_n const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_different_interval_dims_without_one_broadcast_numpy) { - // Both params have dynamic interval dimension different labels +TYPED_TEST_P(BitwiseOperator, symbols_different_interval_dims_without_one_broadcast_numpy) { + // Both params have dynamic interval dimension different symbols PartialShape pshape_lhs{{2, 4}, {8, 16}, {8, 16}, {8, 16}}; PartialShape pshape_rhs{{2, 4}, {4, 12}, {10, 12}, {16, 24}}; - PartialShape expected_shape = {{2, 4}, {8, 12}, {10, 12}, 16}; - TensorLabel expected_labels{20, 21, 22, 23}; + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); + PartialShape expected_shape = {{2, 4}, {8, 12}, {10, 12}, 16}; + auto symbols = set_shape_symbols(pshape_lhs); + set_shape_symbols(pshape_rhs); + auto expected_symbols = symbols; auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -591,19 +604,16 @@ TYPED_TEST_P(BitwiseOperator, labels_different_interval_dims_without_one_broadca const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_different_interval_batch_without_one_equivalence_table_broadcast_numpy) { - // Both params have dynamic interval dimension different labels, use table of equivalence - auto table_of_equivalence = std::make_shared(); - DimensionTracker dim_tracker(table_of_equivalence); - +TYPED_TEST_P(BitwiseOperator, symbols_different_interval_batch_without_one_equivalence_table_broadcast_numpy) { + // Both params have dynamic interval dimension different symbols Dimension dim_0_lhs = {2, 4}; Dimension dim_0_rhs = {2, 4}; - - dim_tracker.set_up_for_tracking(dim_0_lhs, 10); - dim_tracker.set_up_for_tracking(dim_0_rhs, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_lhs.set_symbol(A); + dim_0_rhs.set_symbol(B); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 1}, pshape_rhs = {dim_0_rhs, 3, 1, 224}; @@ -615,27 +625,25 @@ TYPED_TEST_P(BitwiseOperator, labels_different_interval_batch_without_one_equiva const auto out_shape = op->get_output_partial_shape(0); PartialShape expected_shape = {{2, 4}, 3, 224, 224}; - TensorLabel expected_labels{20, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; - auto eq_table = table_of_equivalence->get_equivalence_table(); - EXPECT_EQ(*eq_table[DimensionTracker::get_label(dim_0_lhs)], std::set({10, 20})); - EXPECT_EQ(*eq_table[DimensionTracker::get_label(dim_0_rhs)], std::set({10, 20})); + EXPECT_TRUE(symbol::are_equal(dim_0_lhs.get_symbol(), dim_0_rhs.get_symbol())); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_different_fully_dynamic_batch_broadcast_numpy) { - // Both params have fully dynamic dimension and different labels +TYPED_TEST_P(BitwiseOperator, symbols_different_fully_dynamic_batch_broadcast_numpy) { + // Both params have fully dynamic dimension and different symbols Dimension dim_0_lhs = {-1}; Dimension dim_0_rhs = {-1}; - - DimensionTracker::set_label(dim_0_lhs, 10); - DimensionTracker::set_label(dim_0_rhs, 20); + auto A = std::make_shared(), B = std::make_shared(); + dim_0_lhs.set_symbol(A); + dim_0_rhs.set_symbol(B); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 1}, pshape_rhs = {dim_0_rhs, 3, 1, 224}; PartialShape expected_shape = {-1, 3, 224, 224}; - TensorLabel expected_labels{0, 0, 0, 0}; + TensorSymbol expected_symbols{nullptr, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -645,20 +653,20 @@ TYPED_TEST_P(BitwiseOperator, labels_different_fully_dynamic_batch_broadcast_num const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_equal_fully_dynamic_batch_broadcast_numpy) { - // Both params have fully dynamic dimension and the same labels +TYPED_TEST_P(BitwiseOperator, symbols_equal_fully_dynamic_batch_broadcast_numpy) { + // Both params have fully dynamic dimension and the same symbols Dimension dim_0_lhs = {-1}; Dimension dim_0_rhs = {-1}; - - DimensionTracker::set_label(dim_0_lhs, 10); - DimensionTracker::set_label(dim_0_rhs, 10); + auto A = std::make_shared(); + dim_0_lhs.set_symbol(A); + dim_0_rhs.set_symbol(A); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 1}, pshape_rhs = {dim_0_rhs, 3, 1, 224}; PartialShape expected_shape = {-1, 3, 224, 224}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -668,16 +676,17 @@ TYPED_TEST_P(BitwiseOperator, labels_equal_fully_dynamic_batch_broadcast_numpy) const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_a_broadcast_numpy) { +TYPED_TEST_P(BitwiseOperator, symbols_dyn_batch_a_broadcast_numpy) { Dimension dim_0_lhs = -1; - DimensionTracker::set_label(dim_0_lhs, 10); + auto A = std::make_shared(); + dim_0_lhs.set_symbol(A); PartialShape pshape_lhs = {dim_0_lhs, 3, 224, 224}, pshape_rhs = {1, 3, 1, 1}; PartialShape expected_shape{dim_0_lhs, 3, 224, 224}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i64, pshape_lhs); auto rhs = std::make_shared(element::i64, pshape_rhs); @@ -687,16 +696,17 @@ TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_a_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_b_broadcast_numpy) { +TYPED_TEST_P(BitwiseOperator, symbols_dyn_batch_b_broadcast_numpy) { Dimension dim_0_rhs = -1; - DimensionTracker::set_label(dim_0_rhs, 10); + auto A = std::make_shared(); + dim_0_rhs.set_symbol(A); PartialShape pshape_rhs = {dim_0_rhs, 3, 224, 224}, pshape_lhs = {1, 3, 1, 1}; PartialShape expected_shape{dim_0_rhs, 3, 224, 224}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i64, pshape_lhs); auto rhs = std::make_shared(element::i64, pshape_rhs); @@ -706,18 +716,19 @@ TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_b_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_and_higher_rank_a_broadcast_numpy) { +TYPED_TEST_P(BitwiseOperator, symbols_dyn_batch_and_higher_rank_a_broadcast_numpy) { Dimension dim_0_lhs = -1; - DimensionTracker::set_label(dim_0_lhs, 10); + auto A = std::make_shared(); + dim_0_lhs.set_symbol(A); PartialShape pshape_lhs{dim_0_lhs, -1, -1, -1}; PartialShape pshape_rhs{3, 1, 1}; PartialShape expected_shape{dim_0_lhs, 3, -1, -1}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i64, pshape_lhs); auto rhs = std::make_shared(element::i64, pshape_rhs); @@ -727,18 +738,19 @@ TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_and_higher_rank_a_broadcast_numpy const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_and_higher_rank_b_broadcast_numpy) { +TYPED_TEST_P(BitwiseOperator, symbols_dyn_batch_and_higher_rank_b_broadcast_numpy) { Dimension dim_0_rhs = -1; - DimensionTracker::set_label(dim_0_rhs, 10); + auto A = std::make_shared(); + dim_0_rhs.set_symbol(A); PartialShape pshape_lhs{3, 1, 1}; PartialShape pshape_rhs{dim_0_rhs, -1, -1, -1}; PartialShape expected_shape{dim_0_rhs, 3, -1, -1}; - TensorLabel expected_labels{10, 0, 0, 0}; + TensorSymbol expected_symbols{A, nullptr, nullptr, nullptr}; auto lhs = std::make_shared(element::i64, pshape_lhs); auto rhs = std::make_shared(element::i64, pshape_rhs); @@ -748,19 +760,23 @@ TYPED_TEST_P(BitwiseOperator, labels_dyn_batch_and_higher_rank_b_broadcast_numpy const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TYPED_TEST_P(BitwiseOperator, labels_different_static_shape_broadcast_numpy) { - // Static shape, different labels +TYPED_TEST_P(BitwiseOperator, symbols_different_static_shape_broadcast_numpy) { + // Static shape, different symbols PartialShape pshape_lhs{{2}, {1}, {224}, {1}}; PartialShape pshape_rhs{{2}, {1}, {1}, {128}}; PartialShape expected_shape{2, 1, 224, 128}; - // Different labels - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 12, 23}); + // Different symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {E, F, G, H}); + set_shape_symbols(expected_shape, {A, F, C, H}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -769,19 +785,21 @@ TYPED_TEST_P(BitwiseOperator, labels_different_static_shape_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_equal_static_shape_broadcast_numpy) { - // Static shape, the same labels +TYPED_TEST_P(BitwiseOperator, symbols_equal_static_shape_broadcast_numpy) { + // Static shape, the same symbols PartialShape pshape_lhs{2, 1, 224, 1}; PartialShape pshape_rhs{2, 1, 1, 128}; PartialShape expected_shape{2, 1, 224, 128}; - // Equal labels - set_shape_labels(pshape_lhs, {30, 31, 32, 33}); - set_shape_labels(pshape_rhs, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -790,19 +808,19 @@ TYPED_TEST_P(BitwiseOperator, labels_equal_static_shape_broadcast_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_different_static_shape_broadcast_none) { +TYPED_TEST_P(BitwiseOperator, symbols_different_static_shape_broadcast_none) { // Static shape PartialShape pshape_lhs{2, 3, 224, 128}; PartialShape pshape_rhs{2, 3, 224, 128}; PartialShape expected_shape{2, 3, 224, 128}; - // Different labels - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 23}); + // Different symbols + auto symbols = set_shape_symbols(pshape_lhs); + set_shape_symbols(pshape_rhs); + set_shape_symbols(expected_shape, symbols); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -811,19 +829,21 @@ TYPED_TEST_P(BitwiseOperator, labels_different_static_shape_broadcast_none) { auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_equal_static_shape_broadcast_none) { +TYPED_TEST_P(BitwiseOperator, symbols_equal_static_shape_broadcast_none) { // Static shape PartialShape pshape_lhs{2, 3, 224, 128}; PartialShape pshape_rhs{2, 3, 224, 128}; PartialShape expected_shape{2, 3, 224, 128}; - // Equal labels - set_shape_labels(pshape_lhs, {30, 31, 32, 33}); - set_shape_labels(pshape_rhs, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -832,19 +852,19 @@ TYPED_TEST_P(BitwiseOperator, labels_equal_static_shape_broadcast_none) { auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_different_dynamic_shape_broadcast_none) { +TYPED_TEST_P(BitwiseOperator, symbols_different_dynamic_shape_broadcast_none) { // Dynamic shape PartialShape pshape_lhs{{-1}, {3}, {2, 224}, {1, 128}}; PartialShape pshape_rhs{{-1}, {3}, {2, 224}, {1, 128}}; PartialShape expected_shape{-1, 3, {2, 224}, {1, 128}}; - // Different labels - set_shape_labels(pshape_lhs, {10, 11, 12, 13}); - set_shape_labels(pshape_rhs, {20, 21, 22, 23}); - set_shape_labels(expected_shape, {20, 21, 22, 23}); + // Different symbols + auto symbols = set_shape_symbols(pshape_lhs); + set_shape_symbols(pshape_rhs); + set_shape_symbols(expected_shape, symbols); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -853,19 +873,21 @@ TYPED_TEST_P(BitwiseOperator, labels_different_dynamic_shape_broadcast_none) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } -TYPED_TEST_P(BitwiseOperator, labels_equal_dynamic_shape_broadcast_none) { +TYPED_TEST_P(BitwiseOperator, symbols_equal_dynamic_shape_broadcast_none) { // Dynamic shape PartialShape pshape_lhs{{-1}, {3}, {2, 224}, {1, 128}}; PartialShape pshape_rhs{{-1}, {3}, {2, 224}, {1, 128}}; PartialShape expected_shape{-1, 3, {2, 224}, {1, 128}}; - // Equal labels - set_shape_labels(pshape_lhs, {30, 31, 32, 33}); - set_shape_labels(pshape_rhs, {30, 31, 32, 33}); - set_shape_labels(expected_shape, {30, 31, 32, 33}); + // Equal symbols + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + set_shape_symbols(pshape_lhs, {A, B, C, D}); + set_shape_symbols(pshape_rhs, {A, B, C, D}); + set_shape_symbols(expected_shape, {A, B, C, D}); auto lhs = std::make_shared(element::i32, pshape_lhs); auto rhs = std::make_shared(element::i32, pshape_rhs); @@ -874,7 +896,7 @@ TYPED_TEST_P(BitwiseOperator, labels_equal_dynamic_shape_broadcast_none) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), get_shape_labels(expected_shape)); + EXPECT_EQ(get_shape_symbols(out_shape), get_shape_symbols(expected_shape)); } REGISTER_TYPED_TEST_SUITE_P(BitwiseOperator, @@ -913,24 +935,24 @@ REGISTER_TYPED_TEST_SUITE_P(BitwiseOperator, dynamic_shape_intervals_b_rank_smaller_broadcast_numpy, dynamic_shape_intervals_broadcast_pdpd, - // Dimension labels (static and dynamic) - labels_a_dynamic_mixed_dims_broadcast_numpy, - labels_b_dynamic_mixed_dims_broadcast_numpy, - labels_different_interval_mixed_dims_broadcast_numpy, - labels_different_interval_b_and_fully_dyn_a_broadcast_numpy, - labels_different_interval_a_and_fully_dyn_b_broadcast_numpy, - labels_equal_interval_dims_without_one_broadcast_numpy, - labels_different_interval_dims_without_one_broadcast_numpy, - labels_different_interval_batch_without_one_equivalence_table_broadcast_numpy, - labels_different_fully_dynamic_batch_broadcast_numpy, - labels_equal_fully_dynamic_batch_broadcast_numpy, - labels_dyn_batch_a_broadcast_numpy, - labels_dyn_batch_b_broadcast_numpy, - labels_dyn_batch_and_higher_rank_a_broadcast_numpy, - labels_dyn_batch_and_higher_rank_b_broadcast_numpy, - labels_different_static_shape_broadcast_numpy, - labels_equal_static_shape_broadcast_numpy, - labels_different_static_shape_broadcast_none, - labels_equal_static_shape_broadcast_none, - labels_different_dynamic_shape_broadcast_none, - labels_equal_dynamic_shape_broadcast_none); + // Dimension symbols (static and dynamic) + symbols_a_dynamic_mixed_dims_broadcast_numpy, + symbols_b_dynamic_mixed_dims_broadcast_numpy, + symbols_different_interval_mixed_dims_broadcast_numpy, + symbols_different_interval_b_and_fully_dyn_a_broadcast_numpy, + symbols_different_interval_a_and_fully_dyn_b_broadcast_numpy, + symbols_equal_interval_dims_without_one_broadcast_numpy, + symbols_different_interval_dims_without_one_broadcast_numpy, + symbols_different_interval_batch_without_one_equivalence_table_broadcast_numpy, + symbols_different_fully_dynamic_batch_broadcast_numpy, + symbols_equal_fully_dynamic_batch_broadcast_numpy, + symbols_dyn_batch_a_broadcast_numpy, + symbols_dyn_batch_b_broadcast_numpy, + symbols_dyn_batch_and_higher_rank_a_broadcast_numpy, + symbols_dyn_batch_and_higher_rank_b_broadcast_numpy, + symbols_different_static_shape_broadcast_numpy, + symbols_equal_static_shape_broadcast_numpy, + symbols_different_static_shape_broadcast_none, + symbols_equal_static_shape_broadcast_none, + symbols_different_dynamic_shape_broadcast_none, + symbols_equal_dynamic_shape_broadcast_none); diff --git a/src/core/tests/type_prop/broadcast.cpp b/src/core/tests/type_prop/broadcast.cpp index 86ff62ec53e6b5..74d2169a019cbb 100644 --- a/src/core/tests/type_prop/broadcast.cpp +++ b/src/core/tests/type_prop/broadcast.cpp @@ -8,7 +8,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -29,7 +28,8 @@ TYPED_TEST_SUITE_P(BroadcastTests); TYPED_TEST_P(BroadcastTests, broadcast_dynamic_value_propagation) { ov::Dimension marked = ov::Dimension(3); - ov::DimensionTracker::set_label(marked, 10); + auto A = std::make_shared(); + marked.set_symbol(A); ov::PartialShape target = ov::PartialShape{1, 2, marked, 4}; auto param = make_shared(ov::element::f32, ov::Shape{1, 1}); @@ -47,7 +47,7 @@ TYPED_TEST_P(BroadcastTests, broadcast_dynamic_value_propagation) { auto bc = make_shared(param, target_shape); ASSERT_EQ(bc->get_element_type(), ov::element::f32); ASSERT_EQ(bc->get_shape(), (ov::Shape{3, 5})); - ASSERT_EQ(ov::DimensionTracker::get_label(bc->get_output_partial_shape(0)[0]), 10); + ASSERT_TRUE(ov::symbol::are_equal(bc->get_output_partial_shape(0)[0].get_symbol(), A)); } TYPED_TEST_P(BroadcastTests, broadcast_numpy) { @@ -987,15 +987,23 @@ TEST(type_prop, broadcast_v3_bidirectional_data_bigger_rank_numpy) { HasSubstr("Broadcast target_shape has smaller rank")); } -TEST(type_prop, broadcast_v3_labels_in0_dynamic_mixed_dims_bidirectional) { - // All dimensions of A have labels, B without labels +TEST(type_prop, broadcast_v3_symbols_in0_dynamic_mixed_dims_bidirectional) { + // All dimensions of A have symbols, B without symbols ov::PartialShape pshape_a{-1, 2, 1, {4, 8}, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, 1, {3, 9}, -1, {1, 9}, -1, {3, 19}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 8}, {3, 9}, {4, 8}, -1, -1, {3, 19}, {4, 18}}; - ov::TensorLabel expected_labels{10, 11, ov::no_label, 13, ov::no_label, 15, 16, 17, ov::no_label, 19}; - set_shape_labels(pshape_a, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + auto I = std::make_shared(), J = std::make_shared(); + const std::shared_ptr NO = nullptr; + + ov::TensorSymbol expected_symbols{A, B, NO, D, NO, F, G, H, NO, J}; + + set_shape_symbols(pshape_a, {A, B, C, D, E, F, G, H, I, J}); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1006,18 +1014,25 @@ TEST(type_prop, broadcast_v3_labels_in0_dynamic_mixed_dims_bidirectional) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_labels_in1_dynamic_mixed_dims_bidirectional) { - // All dimensions of B have labels, A without labels +TEST(type_prop, broadcast_v3_symbols_in1_dynamic_mixed_dims_bidirectional) { + // All dimensions of B have symbols, A without symbols ov::PartialShape pshape_a{-1, 2, 1, {4, 8}, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, 1, {3, 9}, -1, {1, 9}, -1, {3, 19}, {1, 10}}; + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + auto I = std::make_shared(), J = std::make_shared(); + const std::shared_ptr NO = nullptr; + ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 8}, {3, 9}, {4, 8}, -1, -1, {3, 19}, {4, 18}}; - ov::TensorLabel expected_labels{10, 11, 12, ov::no_label, 14, ov::no_label, 16, 17, 18, ov::no_label}; + ov::TensorSymbol expected_symbols{A, B, C, NO, E, NO, G, H, I, NO}; - set_shape_labels(pshape_b, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}); + set_shape_symbols(pshape_b, {A, B, C, D, E, F, G, H, I, J}); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1028,19 +1043,31 @@ TEST(type_prop, broadcast_v3_labels_in1_dynamic_mixed_dims_bidirectional) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_labels_different_dynamic_mixed_dims_broadcast_bidirectional) { - // Both params have dimensions with different labels +TEST(type_prop, broadcast_v3_symbols_different_dynamic_mixed_dims_broadcast_bidirectional) { + // Both params have dimensions with different symbols ov::PartialShape pshape_a{-1, 2, 1, {4, 8}, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, 1, {3, 9}, -1, {1, 9}, -1, {3, 19}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 8}, {3, 9}, {4, 8}, -1, -1, {3, 19}, {4, 18}}; - ov::TensorLabel expected_labels{ov::no_label, 21, 22, 13, 24, 15, ov::no_label, ov::no_label, 28, 19}; - set_shape_labels(pshape_a, {10, 11, 12, 13, 14, 15, 16, 17, 18, 19}); - set_shape_labels(pshape_b, {20, 21, 22, 23, 24, 25, 26, 27, 28, 29}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(), + H = std::make_shared(); + auto I = std::make_shared(), J = std::make_shared(), K = std::make_shared(), + L = std::make_shared(); + auto M = std::make_shared(), N = std::make_shared(), O = std::make_shared(), + P = std::make_shared(); + auto Q = std::make_shared(), R = std::make_shared(), S = std::make_shared(), + T = std::make_shared(); + const std::shared_ptr NO = nullptr; + ov::TensorSymbol expected_symbols{NO, B, M, D, O, F, NO, NO, S, J}; + + set_shape_symbols(pshape_a, {A, B, C, D, E, F, G, H, I, J}); + set_shape_symbols(pshape_b, {K, L, M, N, O, P, Q, R, S, T}); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1051,19 +1078,19 @@ TEST(type_prop, broadcast_v3_labels_different_dynamic_mixed_dims_broadcast_bidir const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_labels_same_dynamic_mixed_dims_broadcast_bidirectional) { - // Both params have dimensions with the same labels +TEST(type_prop, broadcast_v3_symbols_same_dynamic_mixed_dims_broadcast_bidirectional) { + // Both params have dimensions with the same symbols ov::PartialShape pshape_a{-1, 2, 1, {4, 8}, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, 1, {3, 9}, -1, {1, 9}, -1, {3, 19}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 8}, {3, 9}, {4, 8}, -1, -1, {3, 19}, {4, 18}}; - ov::TensorLabel expected_labels{10, 11, 12, 13, 14, 15, 16, 17, 18, 19}; + auto expected_symbols = set_shape_symbols(expected_shape); - set_shape_labels(pshape_a, expected_labels); - set_shape_labels(pshape_b, expected_labels); + set_shape_symbols(pshape_a, expected_symbols); + set_shape_symbols(pshape_b, expected_symbols); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1074,7 +1101,7 @@ TEST(type_prop, broadcast_v3_labels_same_dynamic_mixed_dims_broadcast_bidirectio const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, broadcast_v3_in0_interval_in1_param_rank_bigger_bidirectional) { @@ -1095,12 +1122,12 @@ TEST(type_prop, broadcast_v3_in0_interval_in1_param_rank_smaller_bidirectional) EXPECT_EQ(broadcast->get_output_partial_shape(0), (ov::PartialShape{-1, 2, -1, {4, 8}, -1})); } -TEST(type_prop, broadcast_v3_labels_in0_dims_in1_param_bidirectional) { +TEST(type_prop, broadcast_v3_symbols_in0_dims_in1_param_bidirectional) { ov::PartialShape pshape_a{-1, 2, 1, {4, 8}, {1, 10}}; ov::PartialShape expected_shape{-1, 2, -1, {4, 8}, -1}; - ov::TensorLabel expected_labels{10, 11, 12, 13, 14}; - set_shape_labels(pshape_a, expected_labels); + auto expected_symbols = set_shape_symbols(expected_shape); + set_shape_symbols(pshape_a, expected_symbols); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape_param = std::make_shared(ov::element::i32, ov::Shape{5}); @@ -1109,7 +1136,7 @@ TEST(type_prop, broadcast_v3_labels_in0_dims_in1_param_bidirectional) { const auto& out_shape = broadcast->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, broadcast_v3_non_broadcastable_dims_numpy) { @@ -1130,15 +1157,15 @@ TEST(type_prop, broadcast_v3_non_broadcastable_dims_numpy) { EXPECT_EQ(out_shape, expected_shape); } -TEST(type_prop, broadcast_v3_labels_in0_dynamic_mixed_dims_numpy) { +TEST(type_prop, broadcast_v3_symbols_in0_dynamic_mixed_dims_numpy) { // Numpy mode for v3::Broadcast mode is one directional - // All dimensions of A have labels, B without labels + // All dimensions of A have symbols, B without symbols ov::PartialShape pshape_a{-1, 2, 1, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; - set_shape_labels(pshape_a, {10, 11, 12, 13, 14, 15, 16, 17, 18}); + set_shape_symbols(pshape_a); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1148,21 +1175,20 @@ TEST(type_prop, broadcast_v3_labels_in0_dynamic_mixed_dims_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - // Output shape is a copy of the target shape value, the `A` labels are not propagated - EXPECT_THAT(get_shape_labels(out_shape), Each(ov::no_label)); + // Output shape is a copy of the target shape value, the `A` symbols are not propagated + EXPECT_THAT(get_shape_symbols(out_shape), Each(nullptr)); } -TEST(type_prop, broadcast_v3_labels_in1_dynamic_mixed_dims_numpy) { +TEST(type_prop, broadcast_v3_symbols_in1_dynamic_mixed_dims_numpy) { // Numpy mode for v3::Broadcast mode is one directional - // All dimensions of B have labels, A without labels + // All dimensions of B have symbols, A without symbols ov::PartialShape pshape_a{-1, 2, 1, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; - // Output shape is a copy of the target shape, `B` labels are propagated - ov::TensorLabel expected_labels{10, 11, 12, 13, 14, 15, 16, 17, 18}; - - set_shape_labels(pshape_b, expected_labels); + // Output shape is a copy of the target shape, `B` symbols are propagated + auto expected_symbols = set_shape_symbols(expected_shape); + set_shape_symbols(pshape_b, expected_symbols); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1173,21 +1199,20 @@ TEST(type_prop, broadcast_v3_labels_in1_dynamic_mixed_dims_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_labels_both_inputs_dynamic_mixed_dims_numpy) { +TEST(type_prop, broadcast_v3_symbols_both_inputs_dynamic_mixed_dims_numpy) { // Numpy mode for v3::Broadcast mode is one directional - // All dimensions of A and B have labels + // All dimensions of A and B have symbols ov::PartialShape pshape_a{-1, 2, 1, -1, {4, 8}, -1, {1, 8}, {1, 10}, {4, 18}}; ov::PartialShape pshape_b{-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; ov::PartialShape expected_shape = {-1, 2, {3, 9}, {4, 10}, -1, {5, 11}, -1, {6, 20}, {1, 10}}; - // Output shape is a copy of the target shape, `B` labels are propagated - ov::TensorLabel expected_labels{20, 21, 22, 23, 24, 25, 26, 27, 28}; + // Output shape is a copy of the target shape, `B` symbols are propagated - set_shape_labels(pshape_a, {10, 11, 12, 13, 14, 15, 16, 17, 18}); - set_shape_labels(pshape_b, {20, 21, 22, 23, 24, 25, 26, 27, 28}); + set_shape_symbols(pshape_a); + auto expected_symbols = set_shape_symbols(pshape_b); auto data = std::make_shared(ov::element::f32, pshape_a); auto target_shape = std::make_shared(ov::element::f32, pshape_b); @@ -1198,17 +1223,16 @@ TEST(type_prop, broadcast_v3_labels_both_inputs_dynamic_mixed_dims_numpy) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_labels_dynamic_mixed_dims_explicit) { +TEST(type_prop, broadcast_v3_symbols_dynamic_mixed_dims_explicit) { ov::PartialShape pshape_a{2, {6, 8}, -1}; ov::PartialShape pshape_b{2, -1, {6, 8}, -1, 5}; ov::PartialShape expected_shape = {2, -1, {6, 8}, -1, 5}; - ov::TensorLabel expected_labels{21, 22, 23, 24, 25}; - set_shape_labels(pshape_b, {21, 22, 23, 24, 25}); + auto expected_symbols = set_shape_symbols(pshape_b); auto axis_map = std::make_shared(ov::element::i32, ov::Shape{3}, std::vector{0, 2, 3}); @@ -1221,20 +1245,19 @@ TEST(type_prop, broadcast_v3_labels_dynamic_mixed_dims_explicit) { const auto out_shape = op->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_eval_labels_static_dims_numpy) { +TEST(type_prop, broadcast_v3_eval_symbols_static_dims_numpy) { // Numpy mode for v3::Broadcast mode is one directional - // All dimensions of A have labels, B without labels + // All dimensions of A have symbols, B without symbols ov::PartialShape pshape_a{1, 1}; ov::PartialShape pshape_b{2, 3}; ov::PartialShape pshape_c{1, 3}; ov::PartialShape expected_shape = {2, 3}; - ov::TensorLabel expected_labels{22, 23}; - set_shape_labels(pshape_b, {22, 23}); + auto expected_symbols = set_shape_symbols(pshape_b); auto a = std::make_shared(ov::element::f32, pshape_a); auto b = std::make_shared(ov::element::f32, pshape_b); @@ -1250,20 +1273,24 @@ TEST(type_prop, broadcast_v3_eval_labels_static_dims_numpy) { const auto out_shape = broadcast_c->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, broadcast_v3_eval_labels_static_dims_bidirectional) { +TEST(type_prop, broadcast_v3_eval_symbols_static_dims_bidirectional) { ov::PartialShape pshape_a{1, 3}; ov::PartialShape pshape_b{2, 1}; ov::PartialShape pshape_c{1, 1}; ov::PartialShape expected_shape = {2, 3}; - ov::TensorLabel expected_labels{22, 13}; - set_shape_labels(pshape_a, {12, 13}); - set_shape_labels(pshape_b, {22, 23}); - set_shape_labels(pshape_c, {33, 33}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(); + ov::TensorSymbol expected_symbols{C, B}; + + set_shape_symbols(pshape_a, {A, B}); + set_shape_symbols(pshape_b, {C, D}); + set_shape_symbols(pshape_c, {E, F}); auto a = std::make_shared(ov::element::f32, pshape_a); auto b = std::make_shared(ov::element::f32, pshape_b); @@ -1279,7 +1306,7 @@ TEST(type_prop, broadcast_v3_eval_labels_static_dims_bidirectional) { const auto out_shape = broadcast_c->get_output_partial_shape(0); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, broadcast_v3_bidirectional_tricky_partial_value_case_and_equal_partial_value_propagation) { diff --git a/src/core/tests/type_prop/bucketize.cpp b/src/core/tests/type_prop/bucketize.cpp index a6b0c00c8d8065..de330a528ac49d 100644 --- a/src/core/tests/type_prop/bucketize.cpp +++ b/src/core/tests/type_prop/bucketize.cpp @@ -82,14 +82,14 @@ TEST_F(TypePropBucketizeV3Test, dynamic_buckets) { TEST_F(TypePropBucketizeV3Test, interval_dimensions) { auto data_shape = PartialShape{{10, 30}, {12, -1}, -1, {0, 30}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::f16, data_shape); auto buckets = make_shared(element::f32, PartialShape{{2, 4}}); auto bucketize = make_op(data, buckets); EXPECT_EQ(bucketize->get_element_type(), element::i64); EXPECT_EQ(bucketize->get_output_partial_shape(0), data_shape); - EXPECT_THAT(get_shape_labels(bucketize->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(bucketize->get_output_partial_shape(0)), symbols); } TEST_F(TypePropBucketizeV3Test, invalid_data_element_type) { diff --git a/src/core/tests/type_prop/concat.cpp b/src/core/tests/type_prop/concat.cpp index 92e7de526549c1..294c82fca967f7 100644 --- a/src/core/tests/type_prop/concat.cpp +++ b/src/core/tests/type_prop/concat.cpp @@ -8,7 +8,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/shape_of.hpp" @@ -260,14 +259,15 @@ TEST(type_prop, concat_partial_negative_axis_incorrect) { HasSubstr("Concat Parameter axis -4 out of the tensor rank range")); } -/** \brief Test uses evaluate lower/upper and label of concat op. */ -TEST(type_prop, concat_dynamic_value_and_label_propagation) { +/** \brief Test uses evaluate lower/upper and symbol of concat op. */ +TEST(type_prop, concat_dynamic_value_and_symbol_propagation) { ov::Dimension marked_0 = ov::Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto A = std::make_shared(), B = std::make_shared(); + marked_0.set_symbol(A); ov::PartialShape target_0 = ov::PartialShape{marked_0, 4}; ov::Dimension marked_1 = ov::Dimension(5); - ov::DimensionTracker::set_label(marked_1, 15); + marked_1.set_symbol(B); ov::PartialShape target_1 = ov::PartialShape{4, marked_1, 9}; auto param = make_shared(ov::element::f32, ov::Shape{1}); @@ -284,18 +284,19 @@ TEST(type_prop, concat_dynamic_value_and_label_propagation) { EXPECT_EQ(bc->get_shape(), (ov::Shape{3, 4, 5, 4, 5, 9})); const auto& output_shape = bc->get_output_partial_shape(0); - const auto labels = get_shape_labels(output_shape); - ASSERT_THAT(labels, ElementsAre(10, 0, 0, 0, 15, 0)); + const auto symbols = get_shape_symbols(output_shape); + ASSERT_THAT(symbols, ElementsAre(A, nullptr, nullptr, nullptr, B, nullptr)); } -/** \brief Test uses evaluate lower/upper and label of concat op. */ -TEST(type_prop, concat_dynamic_value_and_label_propagation_1) { +/** \brief Test uses evaluate lower/upper and symbol of concat op. */ +TEST(type_prop, concat_dynamic_value_and_symbol_propagation_1) { ov::Dimension marked_0 = ov::Dimension(3); - ov::DimensionTracker::set_label(marked_0, 1000); + auto A = std::make_shared(), B = std::make_shared(); + marked_0.set_symbol(A); ov::PartialShape target_0 = ov::PartialShape{marked_0, 4}; ov::Dimension marked_1 = ov::Dimension(5); - ov::DimensionTracker::set_label(marked_1, 1500); + marked_1.set_symbol(B); ov::PartialShape target_1 = ov::PartialShape{4, marked_1, 9}; auto param = make_shared(ov::element::f32, ov::Shape{1}); @@ -316,8 +317,8 @@ TEST(type_prop, concat_dynamic_value_and_label_propagation_1) { EXPECT_EQ(bc->get_shape(), (ov::Shape{3, 4, 5, 4, 5, 9})); const auto& output_shape = bc->get_output_partial_shape(0); - const auto labels = get_shape_labels(output_shape); - ASSERT_THAT(labels, ElementsAre(1000, 0, 0, 0, 1500, 0)); + const auto symbols = get_shape_symbols(output_shape); + ASSERT_THAT(symbols, ElementsAre(A, nullptr, nullptr, nullptr, B, nullptr)); } TEST(type_prop, concat_interval_dimensions) { diff --git a/src/core/tests/type_prop/convert.cpp b/src/core/tests/type_prop/convert.cpp index d71eb87b38d4ef..50aa8885668eca 100644 --- a/src/core/tests/type_prop/convert.cpp +++ b/src/core/tests/type_prop/convert.cpp @@ -7,7 +7,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/shape_of.hpp" @@ -21,9 +20,10 @@ TEST(type_prop, convert_deduce) { ASSERT_EQ(c->get_shape(), (ov::Shape{2, 3, 4})); } -TEST(type_prop, convert_dynamic_value_and_label_propagation) { +TEST(type_prop, convert_dynamic_value_and_symbol_propagation) { ov::Dimension marked_0 = ov::Dimension(3); - ov::DimensionTracker::set_label(marked_0, 500); + auto A = std::make_shared(); + marked_0.set_symbol(A); ov::PartialShape target_0 = ov::PartialShape{marked_0, 4}; auto param = make_shared(ov::element::f32, ov::Shape{1}); @@ -37,6 +37,6 @@ TEST(type_prop, convert_dynamic_value_and_label_propagation) { ASSERT_EQ(bc->get_shape(), (ov::Shape{3, 4})); const auto& output_shape = bc->get_output_partial_shape(0); - ASSERT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 500); - ASSERT_EQ(ov::DimensionTracker::get_label(output_shape[1]), 0); + ASSERT_EQ(output_shape[0].get_symbol(), A); + ASSERT_EQ(output_shape[1].get_symbol(), nullptr); } diff --git a/src/core/tests/type_prop/convert_color_i420_base.hpp b/src/core/tests/type_prop/convert_color_i420_base.hpp index dd6bc0a7a9f45d..f7d8a7efd82ec3 100644 --- a/src/core/tests/type_prop/convert_color_i420_base.hpp +++ b/src/core/tests/type_prop/convert_color_i420_base.hpp @@ -21,7 +21,7 @@ TYPED_TEST_SUITE_P(ConvertI420BaseTest); TYPED_TEST_P(ConvertI420BaseTest, shape_inference_default_ctor_single_plane) { auto param_shape = PartialShape{5, 3, 2, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{5, 2, 2, 3}; auto param = std::make_shared(element::f32, param_shape); @@ -31,18 +31,20 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_default_ctor_single_plane) { EXPECT_EQ(op->output(0).get_element_type(), element::f32); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertI420BaseTest, shape_inference_single_tensor) { auto param_shape = PartialShape{5, 3, 2, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{5, 2, 2, 3}; auto param = std::make_shared(element::f32, param_shape); auto op = std::make_shared(param); EXPECT_EQ(op->output(0).get_element_type(), element::f32); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertI420BaseTest, shape_inference_single_tensor_dynamic) { @@ -72,15 +74,16 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_single_tensor_dynamic_height) EXPECT_EQ(op->output(0).get_element_type(), element::u8); } -TYPED_TEST_P(ConvertI420BaseTest, shape_inference_interval_dims_and_labels) { +TYPED_TEST_P(ConvertI420BaseTest, shape_inference_interval_dims_and_symbols) { auto param_shape = PartialShape{{2, 20}, {5, 10}, 8, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{{2, 20}, {4, 6}, 8, 3}; auto param = std::make_shared(element::u8, param_shape); auto op = std::make_shared(param); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), element::u8); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertI420BaseTest, shape_inference_single_tensor_dynamic_type) { @@ -195,8 +198,8 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_uv_dynamic) { TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_dynamic_types) { auto param_shape_y = PartialShape{1, 4, 4, 1}; auto param_shape_uv = PartialShape{1, 2, 2, 1}; - set_shape_labels(param_shape_y, 10); - set_shape_labels(param_shape_uv, 20); + auto y_symbols = set_shape_symbols(param_shape_y); + auto uv_symbols = set_shape_symbols(param_shape_uv); auto out_shape = PartialShape{1, 4, 4, 3}; auto y_type = element::dynamic; @@ -208,13 +211,14 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_dynamic_types) { auto op = std::make_shared(param_y, param_u, param_v); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), out_type); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(y_symbols[0], y_symbols[1], y_symbols[2], nullptr)); } TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_uv_type) { auto param_shape_y = PartialShape{1, 4, 4, 1}; auto param_shape_uv = PartialShape{1, 2, 2, 1}; - set_shape_labels(param_shape_uv, 20); + auto uv_symbols = set_shape_symbols(param_shape_uv); auto out_shape = PartialShape{1, 4, 4, 3}; auto y_type = element::dynamic; auto uv_type = element::f64; @@ -225,8 +229,8 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_uv_type) { auto op = std::make_shared(param_y, param_u, param_v); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), out_type); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(uv_symbols[0], nullptr, nullptr, nullptr)); } TYPED_TEST_P(ConvertI420BaseTest, shape_inference_3_plane_error_type_mismatch_y) { @@ -356,11 +360,11 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_error_2_planes) { EXPECT_THROW(empty->constructor_validate_and_infer_types(), ov::AssertFailure); } -TYPED_TEST_P(ConvertI420BaseTest, shape_inference_2_plane_interval_dims_and_labels) { +TYPED_TEST_P(ConvertI420BaseTest, shape_inference_2_plane_interval_dims_and_symbols) { auto param_shape_y = PartialShape{{2, 5}, {2, 20}, -1, 1}; auto param_shape_uv = PartialShape{{2, 3}, {2, 12}, 2, -1}; - set_shape_labels(param_shape_y, 10); - set_shape_labels(param_shape_uv, 20); + auto y_symbols = set_shape_symbols(param_shape_y); + auto uv_symbols = set_shape_symbols(param_shape_uv); auto param_y = std::make_shared(element::f32, param_shape_y); auto param_u = std::make_shared(element::f32, param_shape_uv); @@ -369,7 +373,8 @@ TYPED_TEST_P(ConvertI420BaseTest, shape_inference_2_plane_interval_dims_and_labe EXPECT_EQ(op->output(0).get_partial_shape(), PartialShape({{2, 3}, {4, 20}, 4, 3})); EXPECT_EQ(op->output(0).get_element_type(), element::f32); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(y_symbols[0], y_symbols[1], y_symbols[2], nullptr)); } REGISTER_TYPED_TEST_SUITE_P(ConvertI420BaseTest, @@ -379,7 +384,7 @@ REGISTER_TYPED_TEST_SUITE_P(ConvertI420BaseTest, shape_inference_single_tensor_dynamic_dims, shape_inference_single_tensor_dynamic_height, shape_inference_single_tensor_dynamic_type, - shape_inference_interval_dims_and_labels, + shape_inference_interval_dims_and_symbols, shape_inference_single_tensor_error_channels, shape_inference_single_tensor_error_dims_5, shape_inference_single_tensor_error_dims_3, @@ -407,4 +412,4 @@ REGISTER_TYPED_TEST_SUITE_P(ConvertI420BaseTest, shape_inference_3_plane_error_width_odd, shape_inference_3_plane_error_channels, shape_inference_error_2_planes, - shape_inference_2_plane_interval_dims_and_labels); + shape_inference_2_plane_interval_dims_and_symbols); diff --git a/src/core/tests/type_prop/convert_color_nv12_base.hpp b/src/core/tests/type_prop/convert_color_nv12_base.hpp index 7ccef7ee5d8fef..99f22fc289e5fb 100644 --- a/src/core/tests/type_prop/convert_color_nv12_base.hpp +++ b/src/core/tests/type_prop/convert_color_nv12_base.hpp @@ -20,7 +20,7 @@ TYPED_TEST_SUITE_P(ConvertNV12BaseTest); TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_default_ctor_single_plane) { auto param_shape = PartialShape{5, 3, 2, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{5, 2, 2, 3}; auto param = std::make_shared(element::f32, param_shape); @@ -30,18 +30,20 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_default_ctor_single_plane) { EXPECT_EQ(op->output(0).get_element_type(), element::f32); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_single_tensor) { auto param_shape = PartialShape{5, 3, 2, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{5, 2, 2, 3}; auto param = std::make_shared(element::f32, param_shape); auto op = std::make_shared(param); EXPECT_EQ(op->output(0).get_element_type(), element::f32); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_single_tensor_dynamic) { @@ -116,15 +118,16 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_single_tensor_error_i8) { EXPECT_THROW(std::ignore = std::make_shared(param), ov::AssertFailure); } -TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_single_interval_dims_and_labels) { +TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_single_interval_dims_and_symbols) { auto param_shape = PartialShape{{2, 20}, {5, 10}, 8, 1}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto out_shape = PartialShape{{2, 20}, {4, 6}, 8, 3}; auto param = std::make_shared(element::u8, param_shape); auto op = std::make_shared(param); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), element::u8); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, no_label, 12, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], nullptr)); } TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_default_ctor_2_planes) { @@ -188,8 +191,8 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_uv_dynamic) { TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_dynamic_types) { auto param_shape_y = PartialShape{1, 4, 4, 1}; auto param_shape_uv = PartialShape{1, 2, 2, 2}; - set_shape_labels(param_shape_y, 10); - set_shape_labels(param_shape_uv, 20); + auto y_symbols = set_shape_symbols(param_shape_y); + auto uv_symbols = set_shape_symbols(param_shape_uv); auto out_shape = PartialShape{1, 4, 4, 3}; auto y_type = element::dynamic; @@ -200,13 +203,14 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_dynamic_types) { auto op = std::make_shared(param_y, param_uv); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), out_type); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(y_symbols[0], y_symbols[1], y_symbols[2], nullptr)); } TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_uv_type) { auto param_shape_y = PartialShape{1, 4, 4, 1}; auto param_shape_uv = PartialShape{1, 2, 2, 2}; - set_shape_labels(param_shape_uv, 20); + auto symbols = set_shape_symbols(param_shape_uv); auto out_shape = PartialShape{1, 4, 4, 3}; auto y_type = element::dynamic; @@ -217,8 +221,7 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_uv_type) { auto op = std::make_shared(param_y, param_uv); EXPECT_EQ(op->output(0).get_partial_shape(), out_shape); EXPECT_EQ(op->output(0).get_element_type(), out_type); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_error_type_mismatch) { @@ -307,11 +310,11 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_error_many_types) { EXPECT_THROW(empty->constructor_validate_and_infer_types(), ov::AssertFailure); } -TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_interval_dims_and_labels) { +TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_interval_dims_and_symbols) { auto param_shape_y = PartialShape{{2, 5}, {2, 20}, -1, 1}; auto param_shape_uv = PartialShape{{2, 3}, {2, 12}, 2, -1}; - set_shape_labels(param_shape_y, 10); - set_shape_labels(param_shape_uv, 20); + auto y_symbols = set_shape_symbols(param_shape_y); + auto uv_symbols = set_shape_symbols(param_shape_uv); auto param_y = std::make_shared(element::f32, param_shape_y); auto param_uv = std::make_shared(element::f32, param_shape_uv); @@ -319,7 +322,8 @@ TYPED_TEST_P(ConvertNV12BaseTest, shape_inference_2_plane_interval_dims_and_labe EXPECT_EQ(op->output(0).get_partial_shape(), PartialShape({{2, 3}, {4, 20}, 4, 3})); EXPECT_EQ(op->output(0).get_element_type(), element::f32); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(y_symbols[0], y_symbols[1], y_symbols[2], nullptr)); } REGISTER_TYPED_TEST_SUITE_P(ConvertNV12BaseTest, @@ -335,7 +339,7 @@ REGISTER_TYPED_TEST_SUITE_P(ConvertNV12BaseTest, shape_inference_single_tensor_error_height, shape_inference_single_tensor_error_width_odd, shape_inference_single_tensor_error_i8, - shape_inference_single_interval_dims_and_labels, + shape_inference_single_interval_dims_and_symbols, shape_inference_default_ctor_2_planes, shape_inference_2_plane_simple, shape_inference_2_plane_dynamic, @@ -354,4 +358,4 @@ REGISTER_TYPED_TEST_SUITE_P(ConvertNV12BaseTest, shape_inference_2_plane_error_width_odd, shape_inference_2_plane_error_channels, shape_inference_error_many_types, - shape_inference_2_plane_interval_dims_and_labels); + shape_inference_2_plane_interval_dims_and_symbols); diff --git a/src/core/tests/type_prop/convert_promote_types.cpp b/src/core/tests/type_prop/convert_promote_types.cpp index f26961149c1de5..cbcd6cb9d31b87 100644 --- a/src/core/tests/type_prop/convert_promote_types.cpp +++ b/src/core/tests/type_prop/convert_promote_types.cpp @@ -42,11 +42,11 @@ TEST_P(ConvertPromoteTypesTest, suite) { auto& params = this->GetParam(); auto in0_shape = params.in0_shape; if (!in0_shape.is_dynamic()) { - set_shape_labels(in0_shape, 10); + set_shape_symbols(in0_shape); } auto in1_shape = params.in1_shape; if (!in1_shape.is_dynamic()) { - set_shape_labels(in1_shape, 100); + set_shape_symbols(in1_shape); } auto in0 = std::make_shared(params.in0_type, in0_shape); @@ -56,8 +56,8 @@ TEST_P(ConvertPromoteTypesTest, suite) { ASSERT_EQ(c->get_output_element_type(0), params.expected_type); ASSERT_EQ(c->get_output_partial_shape(0), (in0_shape)); ASSERT_EQ(c->get_output_partial_shape(1), (in1_shape)); - ASSERT_EQ(get_shape_labels(c->get_output_partial_shape(0)), get_shape_labels(in0_shape)); - ASSERT_EQ(get_shape_labels(c->get_output_partial_shape(1)), get_shape_labels(in1_shape)); + ASSERT_EQ(get_shape_symbols(c->get_output_partial_shape(0)), get_shape_symbols(in0_shape)); + ASSERT_EQ(get_shape_symbols(c->get_output_partial_shape(1)), get_shape_symbols(in1_shape)); } INSTANTIATE_TEST_SUITE_P(type_prop, diff --git a/src/core/tests/type_prop/convolution.cpp b/src/core/tests/type_prop/convolution.cpp index 2561f8e0523543..f39e139a755a6e 100644 --- a/src/core/tests/type_prop/convolution.cpp +++ b/src/core/tests/type_prop/convolution.cpp @@ -35,8 +35,8 @@ TEST(type_prop, convolution_v1_partial_rank) { TEST(type_prop, convolution_v1_partial_auto_padding_same) { ov::PartialShape data_batch_shape{1, 1, 5, 5}; ov::PartialShape filters_shape{1, 1, 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto d_symbols = set_shape_symbols(data_batch_shape); + auto f_symbols = set_shape_symbols(filters_shape); ov::Strides strides{1, 1}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -50,7 +50,8 @@ TEST(type_prop, convolution_v1_partial_auto_padding_same) { make_shared(data_batch, filters, strides, pads_begin, pads_end, dilations, auto_pad); EXPECT_EQ(conv->get_output_partial_shape(0), (ov::PartialShape{1, 1, 5, 5})); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{1, 1})); EXPECT_EQ(conv->get_pads_end(), (ov::CoordinateDiff{1, 1})); } @@ -58,8 +59,8 @@ TEST(type_prop, convolution_v1_partial_auto_padding_same) { TEST(type_prop, convolution_v1_partial_auto_padding_same_nc_dims_dynamic_same_lower) { ov::PartialShape data_batch_shape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 5, 5}; ov::PartialShape filters_shape{1, 1, 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto d_symbols = set_shape_symbols(data_batch_shape); + auto f_symbols = set_shape_symbols(filters_shape); ov::Strides strides{1, 1}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -73,7 +74,8 @@ TEST(type_prop, convolution_v1_partial_auto_padding_same_nc_dims_dynamic_same_lo make_shared(data_batch, filters, strides, pads_begin, pads_end, dilations, auto_pad); EXPECT_EQ(conv->get_output_partial_shape(0), ov::PartialShape({ov::Dimension::dynamic(), 1, 5, 5})); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{1, 1})); EXPECT_EQ(conv->get_pads_end(), (ov::CoordinateDiff{1, 1})); } @@ -101,8 +103,8 @@ TEST(type_prop, convolution_v1_partial_auto_padding_same_nc_dims_dynamic_same_up TEST(type_prop, convolution_v1_partial_auto_padding_same_spatial_dims_dynamic) { ov::PartialShape data_batch_shape{1, 1, ov::Dimension::dynamic(), {3, 5}}; ov::PartialShape filters_shape{1, 1, 3, 3}; - set_shape_labels(data_batch_shape, 10); - set_shape_labels(filters_shape, 20); + auto d_symbols = set_shape_symbols(data_batch_shape); + auto f_symbols = set_shape_symbols(filters_shape); ov::Strides strides{2, 2}; ov::CoordinateDiff pads_begin{0, 0}; ov::CoordinateDiff pads_end{0, 0}; @@ -116,7 +118,8 @@ TEST(type_prop, convolution_v1_partial_auto_padding_same_spatial_dims_dynamic) { make_shared(data_batch, filters, strides, pads_begin, pads_end, dilations, auto_pad); EXPECT_EQ(conv->get_output_partial_shape(0), ov::PartialShape({1, 1, ov::Dimension::dynamic(), {2, 3}})); - EXPECT_THAT(get_shape_labels(conv->get_output_partial_shape(0)), ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(conv->get_pads_begin(), (ov::CoordinateDiff{0, 0})); EXPECT_EQ(conv->get_pads_end(), (ov::CoordinateDiff{0, 0})); } diff --git a/src/core/tests/type_prop/convolution_backprop_data.cpp b/src/core/tests/type_prop/convolution_backprop_data.cpp index 7dcf37e89e4dd3..b8a87a1da57204 100644 --- a/src/core/tests/type_prop/convolution_backprop_data.cpp +++ b/src/core/tests/type_prop/convolution_backprop_data.cpp @@ -74,8 +74,8 @@ TEST(type_prop, convolution_backprop_data_partial_auto_padding_lower) { TEST(type_prop, convolution_backprop_data_auto_pad_explicit_with_output_padding) { ov::PartialShape data_pshape{1, 16, 2, 2}; ov::PartialShape filters_pshape{16, 6, 3, 3}; - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto d_symbols = set_shape_symbols(data_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); const ov::Strides strides{2, 2}; const ov::Strides dilations{1, 1}; const ov::CoordinateDiff padding_begin{1, 1}; @@ -95,8 +95,8 @@ TEST(type_prop, convolution_backprop_data_auto_pad_explicit_with_output_padding) auto_pad, output_padding); - EXPECT_THAT(get_shape_labels(conv_backprop->get_output_partial_shape(0)), - ElementsAre(10, 21, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv_backprop->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[1], nullptr, nullptr)); ASSERT_EQ(conv_backprop->get_output_partial_shape(0), ov::PartialShape(ov::PartialShape{1, 6, 4, 4})); ASSERT_EQ(conv_backprop->get_pads_begin(), (ov::CoordinateDiff{1, 1})); ASSERT_EQ(conv_backprop->get_pads_end(), (ov::CoordinateDiff{1, 1})); @@ -229,8 +229,8 @@ TEST(type_prop, convolution_backprop_data_with_output_shape_dyn_static_ranks_fil TEST(type_prop, convolution_backprop_data_with_output_shape_dyn_static_ranks_filters_cin_cout_dyn) { ov::PartialShape data_pshape{ov::Dimension::dynamic(), 16, 5, 5}; ov::PartialShape filters_pshape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 3, 3}; - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto d_symbols = set_shape_symbols(data_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); const ov::element::Type_t et = ov::element::f32; auto data = make_shared(et, data_pshape); @@ -245,8 +245,8 @@ TEST(type_prop, convolution_backprop_data_with_output_shape_dyn_static_ranks_fil ov::Strides{}, ov::op::PadType::SAME_UPPER); - EXPECT_THAT(get_shape_labels(conv_backprop->get_output_partial_shape(0)), - ElementsAre(10, 21, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(conv_backprop->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[1], nullptr, nullptr)); ASSERT_EQ(conv_backprop->get_output_partial_shape(0), ov::PartialShape(ov::PartialShape{ov::Dimension::dynamic(), ov::Dimension::dynamic(), 3, 3})); } @@ -874,9 +874,9 @@ TEST(type_prop, convolution_back_prop_data_interval_shapes_output_shape_as_shape ov::PartialShape filters_pshape{{2, 3}, {1, 3}, 3, 3, 3}; ov::PartialShape out_spatial_pshape{3, {2, 4}, 3}; - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); - set_shape_labels(out_spatial_pshape, 30); + auto d_symbols = set_shape_symbols(data_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); + auto output_symbols = set_shape_symbols(out_spatial_pshape); const ov::element::Type_t et = ov::element::f32; ov::Strides strides{1, 2, 1}; @@ -898,7 +898,8 @@ TEST(type_prop, convolution_back_prop_data_interval_shapes_output_shape_as_shape pads_end, dilations, auto_pad); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 21, 30, 31, 32)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(d_symbols[0], f_symbols[1], output_symbols[0], output_symbols[1], output_symbols[2])); EXPECT_EQ(op->get_output_partial_shape(0), ov::PartialShape({{1, 3}, {1, 3}, 3, {2, 4}, 3})); EXPECT_EQ(op->get_pads_begin(), (ov::CoordinateDiff{0, 0, 0})); EXPECT_EQ(op->get_pads_end(), (ov::CoordinateDiff{0, 0, 0})); diff --git a/src/core/tests/type_prop/ctc_greedy_decoder.cpp b/src/core/tests/type_prop/ctc_greedy_decoder.cpp index 0c3ee4b09174a1..05424fd036bfb6 100644 --- a/src/core/tests/type_prop/ctc_greedy_decoder.cpp +++ b/src/core/tests/type_prop/ctc_greedy_decoder.cpp @@ -7,7 +7,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" using namespace std; using namespace ov; @@ -47,13 +46,13 @@ TEST(type_prop, ctc_greedy_decoder_static_shapes) { EXPECT_EQ(op->get_shape(), out_shape); } -TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_all) { +TEST(type_prop, ctc_greedy_decoder_interval_symboled_dims_all) { PartialShape data_shape{{1, 100}, {2, 6}, {600, 1200}}; PartialShape seq_mask_shape{{10, 1000}, {4, 8}}; PartialShape expected_shape{{4, 6}, {10, 100}, 1, 1}; - set_shape_labels(data_shape, 10); - set_shape_labels(seq_mask_shape, 20); + auto symbols = set_shape_symbols(data_shape); + set_shape_symbols(seq_mask_shape); auto data = make_shared(element::f32, data_shape); auto seq_mask = make_shared(element::f32, seq_mask_shape); @@ -62,15 +61,15 @@ TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_all) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(21, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[1], symbols[0], nullptr, nullptr)); } -TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_data) { +TEST(type_prop, ctc_greedy_decoder_interval_symboled_dims_data) { PartialShape data_shape{{1, 100}, {2, 6}, {600, 1200}}; PartialShape seq_mask_shape{{10, 1000}, {4, 8}}; PartialShape expected_shape{{4, 6}, {10, 100}, 1, 1}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::f32, data_shape); auto seq_mask = make_shared(element::f32, seq_mask_shape); @@ -79,15 +78,15 @@ TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_data) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(11, 10, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[1], symbols[0], nullptr, nullptr)); } -TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_mask) { +TEST(type_prop, ctc_greedy_decoder_interval_symboled_dims_mask) { PartialShape data_shape{{1, 100}, {2, 6}, {600, 1200}}; PartialShape seq_mask_shape{{10, 1000}, {4, 8}}; PartialShape expected_shape{{4, 6}, {10, 100}, 1, 1}; - set_shape_labels(seq_mask_shape, 20); + auto symbols = set_shape_symbols(seq_mask_shape); auto data = make_shared(element::f32, data_shape); auto seq_mask = make_shared(element::f32, seq_mask_shape); @@ -96,7 +95,7 @@ TEST(type_prop, ctc_greedy_decoder_interval_labeled_dims_mask) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(21, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[1], symbols[0], nullptr, nullptr)); } TEST(type_prop, ctc_greedy_decoder_output_static_shape1) { diff --git a/src/core/tests/type_prop/ctc_greedy_decoder_seq_len.cpp b/src/core/tests/type_prop/ctc_greedy_decoder_seq_len.cpp index 263ad1e7225417..2b2ed1bc460868 100644 --- a/src/core/tests/type_prop/ctc_greedy_decoder_seq_len.cpp +++ b/src/core/tests/type_prop/ctc_greedy_decoder_seq_len.cpp @@ -5,7 +5,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/ops.hpp" using namespace std; @@ -144,12 +143,12 @@ TEST(type_prop, ctc_greedy_decoder_seq_len_dynamic_ranks2) { EXPECT_TRUE(op->get_output_partial_shape(1).same_scheme(out_shape2)); } -TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_all) { +TEST(type_prop, ctc_greedy_decoder_seq_len_interval_symboled_dims_all) { PartialShape logits_shape{{2, 6}, {10, 100}, {600, 1200}}; PartialShape seq_len_shape{{4, 8}}; - set_shape_labels(logits_shape, 10); - set_shape_labels(seq_len_shape, 20); + auto l_symbols = set_shape_symbols(logits_shape); + auto s_symbols = set_shape_symbols(seq_len_shape); auto logits_param = make_shared(element::f32, logits_shape); auto seq_len_param = make_shared(element::f32, seq_len_shape); @@ -158,19 +157,19 @@ TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_all) { // Output 0 EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{4, 6}, {10, 100}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(l_symbols[0], l_symbols[1])); // Output 1 EXPECT_EQ(op->get_output_element_type(1), element::i32); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{{4, 6}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(l_symbols[0])); } -TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_in0) { +TEST(type_prop, ctc_greedy_decoder_seq_len_interval_symboled_dims_in0) { PartialShape logits_shape{{2, 6}, {10, 100}, {600, 1200}}; PartialShape seq_len_shape{{4, 8}}; - set_shape_labels(logits_shape, 10); + auto symbols = set_shape_symbols(logits_shape); auto logits_param = make_shared(element::f32, logits_shape); auto seq_len_param = make_shared(element::f32, seq_len_shape); @@ -179,19 +178,19 @@ TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_in0) { // Output 0 EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{4, 6}, {10, 100}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1])); // Output 1 EXPECT_EQ(op->get_output_element_type(1), element::i32); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{{4, 6}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(symbols[0])); } -TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_in1) { +TEST(type_prop, ctc_greedy_decoder_seq_len_interval_symboled_dims_in1) { PartialShape logits_shape{{2, 6}, {10, 100}, {600, 1200}}; PartialShape seq_len_shape{{4, 8}}; - set_shape_labels(seq_len_shape, 20); + auto symbols = set_shape_symbols(seq_len_shape); auto logits_param = make_shared(element::f32, logits_shape); auto seq_len_param = make_shared(element::f32, seq_len_shape); @@ -200,12 +199,12 @@ TEST(type_prop, ctc_greedy_decoder_seq_len_interval_labeled_dims_in1) { // Output 0 EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{4, 6}, {10, 100}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); // Output 1 EXPECT_EQ(op->get_output_element_type(1), element::i32); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{{4, 6}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(symbols[0])); } TEST(type_prop, ctc_greedy_decoder_seq_len_incorrect_rank) { diff --git a/src/core/tests/type_prop/ctc_loss.cpp b/src/core/tests/type_prop/ctc_loss.cpp index f611e31902e077..131fb9e4206bd8 100644 --- a/src/core/tests/type_prop/ctc_loss.cpp +++ b/src/core/tests/type_prop/ctc_loss.cpp @@ -18,7 +18,7 @@ class TypePropCTCLossV4Test : public TypePropOpTest {}; TEST_F(TypePropCTCLossV4Test, with_blank_index) { // create inputs auto logits_shape = PartialShape{10, 120, 28}; - set_shape_labels(logits_shape, 10); + auto symbols = set_shape_symbols(logits_shape); auto logits = make_shared(element::f32, logits_shape); auto logit_length = make_shared(element::i32, Shape{10}); @@ -32,7 +32,7 @@ TEST_F(TypePropCTCLossV4Test, with_blank_index) { // check type and shape infer EXPECT_EQ(ctc_loss->get_element_type(), element::f32); EXPECT_EQ(ctc_loss->get_output_partial_shape(0), PartialShape({10})); - EXPECT_THAT(get_shape_labels(ctc_loss->get_output_partial_shape(0)), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(ctc_loss->get_output_partial_shape(0)), ElementsAre(symbols[0])); } TEST_F(TypePropCTCLossV4Test, no_blank_index) { @@ -41,7 +41,7 @@ TEST_F(TypePropCTCLossV4Test, no_blank_index) { auto logit_length = make_shared(element::i32, Shape{10}); auto labels_shape = PartialShape{10, 120}; - set_shape_labels(labels_shape, 20); + auto symbols = set_shape_symbols(labels_shape); auto labels = make_shared(element::i32, labels_shape); auto label_length = make_shared(element::i32, Shape{10}); @@ -51,7 +51,7 @@ TEST_F(TypePropCTCLossV4Test, no_blank_index) { // check type and shape infer EXPECT_EQ(ctc_loss->get_element_type(), element::f32); EXPECT_EQ(ctc_loss->get_output_partial_shape(0), PartialShape({10})); - EXPECT_THAT(get_shape_labels(ctc_loss->get_output_partial_shape(0)), ElementsAre(20)); + EXPECT_THAT(get_shape_symbols(ctc_loss->get_output_partial_shape(0)), ElementsAre(symbols[0])); } TEST_F(TypePropCTCLossV4Test, output_type_f64) { @@ -61,7 +61,7 @@ TEST_F(TypePropCTCLossV4Test, output_type_f64) { auto labels = make_shared(element::i32, Shape{10, 120}); auto label_len_shape = PartialShape{10}; - set_shape_labels(label_len_shape, 30); + auto symbols = set_shape_symbols(label_len_shape); auto label_length = make_shared(element::i32, label_len_shape); auto blank_index = make_shared(element::i32, Shape{}); @@ -71,7 +71,7 @@ TEST_F(TypePropCTCLossV4Test, output_type_f64) { // check type and shape infer EXPECT_EQ(ctc_loss->get_element_type(), element::f64); EXPECT_EQ(ctc_loss->get_output_partial_shape(0), PartialShape({10})); - EXPECT_THAT(get_shape_labels(ctc_loss->get_output_partial_shape(0)), ElementsAre(30)); + EXPECT_THAT(get_shape_symbols(ctc_loss->get_output_partial_shape(0)), ElementsAre(symbols[0])); } TEST_F(TypePropCTCLossV4Test, non_default_parameters) { @@ -111,9 +111,9 @@ TEST_F(TypePropCTCLossV4Test, partly_dynamic_input) { auto logits_shape = PartialShape{{2, 20}, {100, 130}, 28}; auto logits_len_shape = PartialShape{{5, 10}}; auto labels_shape = PartialShape{-1, 120}; - set_shape_labels(logits_shape, 10); - set_shape_labels(logits_len_shape, 20); - set_shape_labels(labels_shape, 30); + auto symbols = set_shape_symbols(logits_shape); + set_shape_symbols(logits_len_shape); + set_shape_symbols(labels_shape); auto logits = make_shared(element::f32, logits_shape); auto logit_length = make_shared(element::i32, logits_len_shape); @@ -127,7 +127,7 @@ TEST_F(TypePropCTCLossV4Test, partly_dynamic_input) { // check type and shape infer EXPECT_EQ(ctc_loss->get_element_type(), element::f32); EXPECT_EQ(ctc_loss->get_output_partial_shape(0), PartialShape({{5, 10}})); - EXPECT_THAT(get_shape_labels(ctc_loss->get_output_partial_shape(0)), ElementsAre(30)); + EXPECT_THAT(get_shape_symbols(ctc_loss->get_output_partial_shape(0)), ElementsAre(symbols[0])); } TEST_F(TypePropCTCLossV4Test, fail_inputs_dim) { @@ -227,9 +227,9 @@ TEST_F(TypePropCTCLossV4Test, default_ctor) { auto logits_shape = PartialShape{{2, 20}, {100, 130}, 28}; auto logits_len_shape = PartialShape{{5, 10}}; auto labels_shape = PartialShape{-1, 120}; - set_shape_labels(logits_shape, 10); - set_shape_labels(logits_len_shape, 20); - set_shape_labels(labels_shape, 30); + auto symbols = set_shape_symbols(logits_shape); + set_shape_symbols(logits_len_shape); + set_shape_symbols(labels_shape); auto logits = make_shared(element::f32, logits_shape); auto logit_length = make_shared(element::i32, logits_len_shape); @@ -245,5 +245,5 @@ TEST_F(TypePropCTCLossV4Test, default_ctor) { // check type and shape infer EXPECT_EQ(ctc_loss->get_element_type(), element::f32); EXPECT_EQ(ctc_loss->get_output_partial_shape(0), PartialShape({{5, 10}})); - EXPECT_THAT(get_shape_labels(ctc_loss->get_output_partial_shape(0)), ElementsAre(30)); + EXPECT_THAT(get_shape_symbols(ctc_loss->get_output_partial_shape(0)), ElementsAre(symbols[0])); } diff --git a/src/core/tests/type_prop/deformable_convolution.cpp b/src/core/tests/type_prop/deformable_convolution.cpp index c4c3d29eefc5e2..643fb7c9a6afc0 100644 --- a/src/core/tests/type_prop/deformable_convolution.cpp +++ b/src/core/tests/type_prop/deformable_convolution.cpp @@ -17,9 +17,9 @@ TEST(type_prop, deformable_convolution_partial_auto_padding_same) { PartialShape data_batch_pshape{1, 4, 5, 5}; PartialShape offsets_pshape{1, 36, 5, 5}; PartialShape filters_pshape{4, 1, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(offsets_pshape, 20); - set_shape_labels(filters_pshape, 30); + set_shape_symbols(data_batch_pshape); + auto o_symbols = set_shape_symbols(offsets_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; Strides strides{1, 1}; @@ -44,8 +44,8 @@ TEST(type_prop, deformable_convolution_partial_auto_padding_same) { group, deformable_group); - EXPECT_THAT(get_shape_labels(deformable_conv->get_output_partial_shape(0)), - ElementsAre(10, 30, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(deformable_conv->get_output_partial_shape(0)), + ElementsAre(o_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(deformable_conv->get_output_partial_shape(0), (PartialShape{1, 4, 5, 5})); EXPECT_EQ(deformable_conv->get_pads_begin(), (CoordinateDiff{1, 1})); EXPECT_EQ(deformable_conv->get_pads_end(), (CoordinateDiff{1, 1})); @@ -154,8 +154,8 @@ TEST(type_prop, deformable_convolution_data_batch_dynamic) { PartialShape data_batch_pshape{PartialShape::dynamic()}; PartialShape offsets_pshape{2, 36, 5, 5}; PartialShape filters_pshape{4, 4, 3, 3}; - set_shape_labels(offsets_pshape, 20); - set_shape_labels(filters_pshape, 30); + auto o_symbols = set_shape_symbols(offsets_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::EXPLICIT; @@ -182,8 +182,8 @@ TEST(type_prop, deformable_convolution_data_batch_dynamic) { EXPECT_EQ(deformable_conv->get_pads_begin(), (CoordinateDiff{0, 0})); EXPECT_EQ(deformable_conv->get_pads_end(), (CoordinateDiff{0, 0})); EXPECT_EQ(deformable_conv->get_output_partial_shape(0), (PartialShape{2, 4, {1, -1}, {1, -1}})); - EXPECT_THAT(get_shape_labels(deformable_conv->get_output_partial_shape(0)), - ElementsAre(20, 30, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(deformable_conv->get_output_partial_shape(0)), + ElementsAre(o_symbols[0], f_symbols[0], nullptr, nullptr)); } TEST(type_prop, deformable_convolution_offsets_dynamic) { @@ -1063,9 +1063,9 @@ TEST_F(TypePropDeformableConvolutionV1Test, interval_shapes) { PartialShape data_batch_pshape{{1, 3}, {2, 6}, {1, 5}, {3, 10}}; PartialShape offsets_shape{1, 36, 4, 5}; PartialShape filters_pshape{{2, 5}, {1, 3}, {2, 3}, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(offsets_shape, 20); - set_shape_labels(filters_pshape, 30); + set_shape_symbols(data_batch_pshape); + auto o_symbols = set_shape_symbols(offsets_shape); + auto f_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::EXPLICIT; @@ -1075,7 +1075,8 @@ TEST_F(TypePropDeformableConvolutionV1Test, interval_shapes) { const auto filters = make_shared(et, filters_pshape); const auto op = make_op(data_batch, offsets, filters, Strides{}, empty_pad, empty_pad, Strides{}, auto_pad, 4, 2); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 30, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(o_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, {2, 5}, {1, 4}, {1, 8}})); EXPECT_EQ(op->get_pads_begin(), (CoordinateDiff{0, 0})); EXPECT_EQ(op->get_pads_end(), (CoordinateDiff{0, 0})); diff --git a/src/core/tests/type_prop/deformable_convolution_opset8.cpp b/src/core/tests/type_prop/deformable_convolution_opset8.cpp index e1fded3bc56b33..7563f4efeb6243 100644 --- a/src/core/tests/type_prop/deformable_convolution_opset8.cpp +++ b/src/core/tests/type_prop/deformable_convolution_opset8.cpp @@ -16,9 +16,9 @@ TEST(type_prop, deformable_convolution_opset8_partial_auto_padding_same) { PartialShape data_batch_pshape{1, 4, 5, 5}; PartialShape offsets_pshape{1, 36, 5, 5}; PartialShape filters_pshape{4, 1, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(offsets_pshape, 20); - set_shape_labels(filters_pshape, 30); + set_shape_symbols(data_batch_pshape); + auto o_symbols = set_shape_symbols(offsets_pshape); + auto f_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; Strides strides{1, 1}; @@ -43,8 +43,8 @@ TEST(type_prop, deformable_convolution_opset8_partial_auto_padding_same) { group, deformable_group); - EXPECT_THAT(get_shape_labels(deformable_conv->get_output_partial_shape(0)), - ElementsAre(10, 30, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(deformable_conv->get_output_partial_shape(0)), + ElementsAre(o_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(deformable_conv->get_output_partial_shape(0), (PartialShape{1, 4, 5, 5})); EXPECT_EQ(deformable_conv->get_pads_begin(), (CoordinateDiff{1, 1})); EXPECT_EQ(deformable_conv->get_pads_end(), (CoordinateDiff{1, 1})); @@ -1270,9 +1270,9 @@ TEST_F(TypePropDeformableConvolutionV8Test, interval_shapes) { PartialShape data_batch_pshape{{1, 3}, {2, 6}, {1, 5}, {3, 10}}; PartialShape offsets_shape{1, 36, 4, 5}; PartialShape filters_pshape{{2, 5}, {1, 3}, {2, 3}, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(offsets_shape, 20); - set_shape_labels(filters_pshape, 30); + set_shape_symbols(data_batch_pshape); + auto o_symbols = set_shape_symbols(offsets_shape); + auto f_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::EXPLICIT; @@ -1284,7 +1284,8 @@ TEST_F(TypePropDeformableConvolutionV8Test, interval_shapes) { const auto op = make_op(data_batch, offsets, filters, masks, Strides{}, empty_pad, empty_pad, Strides{}, auto_pad, 4, 2); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 30, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(o_symbols[0], f_symbols[0], nullptr, nullptr)); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, {2, 5}, {1, 4}, {1, 8}})); EXPECT_EQ(op->get_pads_begin(), (CoordinateDiff{0, 0})); EXPECT_EQ(op->get_pads_end(), (CoordinateDiff{0, 0})); diff --git a/src/core/tests/type_prop/deformable_psroi_pooling.cpp b/src/core/tests/type_prop/deformable_psroi_pooling.cpp index 858a16e886c11b..5de181e02af76a 100644 --- a/src/core/tests/type_prop/deformable_psroi_pooling.cpp +++ b/src/core/tests/type_prop/deformable_psroi_pooling.cpp @@ -43,7 +43,7 @@ TEST(type_prop, deformable_psroi_pooling_interval_labels) { auto input_data = make_shared(element::f32, PartialShape{2, 4, 64, 56}); auto coords_shape = PartialShape{rois_dim, 5}; - set_shape_labels(coords_shape, 20); + auto symbols = set_shape_symbols(coords_shape); auto input_coords = make_shared(element::f32, coords_shape); auto op = @@ -51,8 +51,7 @@ TEST(type_prop, deformable_psroi_pooling_interval_labels) { const PartialShape expected_output{rois_dim, output_dim, group_size, group_size}; EXPECT_EQ(op->get_output_partial_shape(0), expected_output); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, deformable_psroi_pooling_no_offsets_group_size_3) { diff --git a/src/core/tests/type_prop/depth_to_space.cpp b/src/core/tests/type_prop/depth_to_space.cpp index 138d384aa643f7..081819cd961b09 100644 --- a/src/core/tests/type_prop/depth_to_space.cpp +++ b/src/core/tests/type_prop/depth_to_space.cpp @@ -15,7 +15,7 @@ using namespace testing; TEST(type_prop, depth_to_space_input_interval_shape_block_first_5D_when_depth_is_static) { auto a_shape = PartialShape{{2, 10}, 24, {3, 7}, {423, 3000}, {235, 1345}}; - set_shape_labels(a_shape, 10); + auto symbols = set_shape_symbols(a_shape); auto A = make_shared(element::f32, a_shape); auto depth_to_space = make_shared(A, ov::op::v0::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, 2); @@ -23,20 +23,20 @@ TEST(type_prop, depth_to_space_input_interval_shape_block_first_5D_when_depth_is EXPECT_EQ(depth_to_space->get_output_element_type(0), element::f32); EXPECT_EQ(depth_to_space->get_output_partial_shape(0), (PartialShape{{2, 10}, 3, {3 * 2, 7 * 2}, {423 * 2, 3000 * 2}, {235 * 2, 1345 * 2}})); - EXPECT_THAT(get_shape_labels(depth_to_space->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(depth_to_space->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr, nullptr)); } TEST(type_prop, depth_to_space_input_interval_shape_default_block_size) { auto a_shape = PartialShape{{2, 10}, 24, {3, 7}, {423, 3000}, {235, 1345}}; - set_shape_labels(a_shape, 10); + auto symbols = set_shape_symbols(a_shape); auto A = make_shared(element::f32, a_shape); auto depth_to_space = make_shared(A, ov::op::v0::DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST); EXPECT_EQ(depth_to_space->get_output_element_type(0), element::f32); EXPECT_EQ(depth_to_space->get_output_partial_shape(0), a_shape); - EXPECT_THAT(get_shape_labels(depth_to_space->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13, 14)); + EXPECT_THAT(get_shape_symbols(depth_to_space->get_output_partial_shape(0)), symbols); } TEST(type_prop, depth_to_space_output_dynamicshape_block_first_5D_when_depth_is_dynamic) { diff --git a/src/core/tests/type_prop/detection_output.cpp b/src/core/tests/type_prop/detection_output.cpp index ee15bde9c20caf..bf7aeabde2940c 100644 --- a/src/core/tests/type_prop/detection_output.cpp +++ b/src/core/tests/type_prop/detection_output.cpp @@ -10,7 +10,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/util/common_util.hpp" using namespace std; @@ -27,15 +26,15 @@ static std::shared_ptr create_detection_output( const ov::op::v0::DetectionOutput::Attributes& attrs, element::Type input_type, element::Type proposals_type, - bool set_labels = false) { - if (set_labels) { - // The labels are set for all of the shapes, - // but the output dimension is always a product of multiplication, so labels are not preserved - set_shape_labels(box_logits_shape, 10); - set_shape_labels(class_preds_shape, 20); - set_shape_labels(proposals_shape, 30); - set_shape_labels(aux_class_preds_shape, 40); - set_shape_labels(aux_box_preds_shape, 50); + bool set_symbols = false) { + if (set_symbols) { + // The symbols are set for all of the shapes, + // but the output dimension is always a product of multiplication, so symbols are not preserved + set_shape_symbols(box_logits_shape); + set_shape_symbols(class_preds_shape); + set_shape_symbols(proposals_shape); + set_shape_symbols(aux_class_preds_shape); + set_shape_symbols(aux_box_preds_shape); } auto box_logits = make_shared(input_type, box_logits_shape); @@ -102,7 +101,7 @@ TEST(type_prop_layers, detection_output_basic) { EXPECT_EQ(op->get_element_type(), element::f32); } -TEST(type_prop_layers, detection_output_interval_labeled_keep_top_k) { +TEST(type_prop_layers, detection_output_interval_symboled_keep_top_k) { ov::op::v0::DetectionOutput::Attributes attrs; attrs.keep_top_k = {60}; attrs.num_classes = 3; @@ -115,15 +114,15 @@ TEST(type_prop_layers, detection_output_interval_labeled_keep_top_k) { attrs, element::f32, element::f32, - true); // set labels + true); // set symbols // [1, 1, N * keep_top_k[0], 7] EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{1, 1, {120, 240}, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } -TEST(type_prop_layers, detection_output_interval_labeled_top_k) { +TEST(type_prop_layers, detection_output_interval_symboled_top_k) { ov::op::v0::DetectionOutput::Attributes attrs; attrs.keep_top_k = {-1}; attrs.top_k = 80; @@ -137,15 +136,15 @@ TEST(type_prop_layers, detection_output_interval_labeled_top_k) { attrs, element::f32, element::f32, - true); // set labels + true); // set symbols // [1, 1, N * top_k * num_classes, 7] EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{1, 1, {480, 960}, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } -TEST(type_prop_layers, detection_output_interval_labeled_negative_both_topk) { +TEST(type_prop_layers, detection_output_interval_symboled_negative_both_topk) { ov::op::v0::DetectionOutput::Attributes attrs; attrs.keep_top_k = {-1}; attrs.top_k = -1; @@ -159,11 +158,11 @@ TEST(type_prop_layers, detection_output_interval_labeled_negative_both_topk) { attrs, element::f32, element::f32, - true); // set labels + true); // set symbols // [1, 1, N * num_classes * num_prior_boxes, 7] // num_prior_boxex = 5 EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{1, 1, {30, 60}, 7})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } @@ -809,13 +808,13 @@ std::shared_ptr create_detection_output_v8(PartialShape PartialShape proposals_shape, const op::v8::DetectionOutput::Attributes& attrs, element::Type input_type, - bool set_labels = false) { - if (set_labels) { - // The labels are set for all of the shapes, - // but the output dimension is always a product of multiplication, so labels are not preserved - set_shape_labels(box_logits_shape, 10); - set_shape_labels(class_preds_shape, 20); - set_shape_labels(proposals_shape, 30); + bool set_symbols = false) { + if (set_symbols) { + // The symbols are set for all of the shapes, + // but the output dimension is always a product of multiplication, so symbols are not preserved + set_shape_symbols(box_logits_shape); + set_shape_symbols(class_preds_shape); + set_shape_symbols(proposals_shape); } auto box_logits = make_shared(input_type, box_logits_shape); @@ -831,15 +830,15 @@ std::shared_ptr create_detection_output2_v8(PartialShap PartialShape aux_box_preds_shape, const op::v8::DetectionOutput::Attributes& attrs, element::Type input_type, - bool set_labels = false) { - if (set_labels) { - // The labels are set for all of the shapes, - // but the output dimension is always a product of multiplication, so labels are not preserved - set_shape_labels(box_logits_shape, 10); - set_shape_labels(class_preds_shape, 20); - set_shape_labels(proposals_shape, 30); - set_shape_labels(aux_class_preds_shape, 40); - set_shape_labels(aux_box_preds_shape, 50); + bool set_symbols = false) { + if (set_symbols) { + // The symbols are set for all of the shapes, + // but the output dimension is always a product of multiplication, so symbols are not preserved + set_shape_symbols(box_logits_shape); + set_shape_symbols(class_preds_shape); + set_shape_symbols(proposals_shape); + set_shape_symbols(aux_class_preds_shape); + set_shape_symbols(aux_box_preds_shape); } auto box_logits = make_shared(input_type, box_logits_shape); @@ -1051,7 +1050,7 @@ TEST(type_prop_layers, detection_output_v8_intervals_3in) { EXPECT_EQ(op->get_output_partial_shape(0), output_shape_reference) << "Failed for keep_top_k=" << ov::util::vector_to_string(attrs.keep_top_k) << " top_k=" << attrs.top_k << " and variance_encoded_in_target=" << attrs.variance_encoded_in_target << std::endl; - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } } @@ -1081,7 +1080,7 @@ TEST(type_prop_layers, detection_output_v8_interval_batch_3in) { EXPECT_EQ(op->get_output_partial_shape(0), output_shape_reference) << "Failed for keep_top_k=" << ov::util::vector_to_string(attrs.keep_top_k) << " top_k=" << attrs.top_k << " and variance_encoded_in_target=" << attrs.variance_encoded_in_target << std::endl; - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } } @@ -1112,7 +1111,7 @@ TEST(type_prop_layers, detection_output_v8_interval_batch_5in) { EXPECT_EQ(op->get_output_partial_shape(0), output_shape_reference) << "Failed for keep_top_k=" << ov::util::vector_to_string(attrs.keep_top_k) << " top_k=" << attrs.top_k << " and variance_encoded_in_target=" << attrs.variance_encoded_in_target << std::endl; - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_element_type(), element::f32); } } diff --git a/src/core/tests/type_prop/einsum.cpp b/src/core/tests/type_prop/einsum.cpp index 906b5af5f11fad..9fbb04fcc1b610 100644 --- a/src/core/tests/type_prop/einsum.cpp +++ b/src/core/tests/type_prop/einsum.cpp @@ -8,7 +8,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/pass/graph_rewrite.hpp" using namespace std; @@ -144,14 +143,16 @@ TEST_F(TypePropEinsumTest, static_shape_ellipsis) { EXPECT_EQ(o->get_shape(), Shape({11, 11, 7, 4})); } -// Dynamic shapes test also label propagation as each Einsum tests different equation +// Dynamic shapes test also symbol propagation as each Einsum tests different equation TEST_F(TypePropEinsumTest, dynamic_shape_dot_product) { constexpr auto et = element::f64; const auto equation = std::string("a,ab->ab"); auto input_shapes = PartialShapes{{{2, 7}}, {{3, 10}, 3}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[1], {ov::no_label, 21}); + + auto A = std::make_shared(), B = std::make_shared(); + input_shapes[0][0].set_symbol(A); + input_shapes[1][1].set_symbol(B); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -160,14 +161,14 @@ TEST_F(TypePropEinsumTest, dynamic_shape_dot_product) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({{3, 7}, 3})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(10, 21)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), ElementsAre(A, B)); } TEST_F(TypePropEinsumTest, dynamic_shape_diag_extraction) { const std::string equation = "xyzxy->xyz"; constexpr auto et = element::i32; auto input_shape = PartialShape{{2, 7}, {1, 5}, 4, {3, 5}, 3}; - set_shape_labels(input_shape, 10); + auto symbols = set_shape_symbols(input_shape); const auto input = make_shared(et, input_shape); const auto o = make_op(OutputVector{input}, equation); @@ -176,15 +177,16 @@ TEST_F(TypePropEinsumTest, dynamic_shape_diag_extraction) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({{3, 5}, 3, 4})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(13, 14, 12)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], symbols[2])); } TEST_F(TypePropEinsumTest, dynamic_shape_ellipsis) { const std::string equation = "a...b,b...->a..."; constexpr auto et = element::f32; auto input_shapes = PartialShapes{{11, 1, {3, 5}, 3}, {3, 11, 7, {1, 3}}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[1], 20); + + auto symbols_a = set_shape_symbols(input_shapes[0]); + auto symbols_b = set_shape_symbols(input_shapes[1]); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -193,7 +195,8 @@ TEST_F(TypePropEinsumTest, dynamic_shape_ellipsis) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({11, 11, 7, {3, 5}})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(10, 21, 22, 12)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), + ElementsAre(symbols_a[0], symbols_b[1], symbols_b[2], symbols_a[2])); } TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters) { @@ -201,7 +204,7 @@ TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters) { const std::string equation = "AbC"; constexpr auto et = element::i32; auto input_shape = PartialShape{1, {2, 3}, {4, 5}}; - set_shape_labels(input_shape, 10); + auto symbols = set_shape_symbols(input_shape); const auto input = make_shared(et, input_shape); const auto o = make_op(OutputVector{input}, equation); @@ -210,7 +213,7 @@ TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({1, {4, 5}, {2, 3}})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(10, 12, 11)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[2], symbols[1])); } TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters_ellipsis) { @@ -218,8 +221,8 @@ TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters_ellipsis) { const std::string equation = "a...b,B..."; constexpr auto et = element::f32; auto input_shapes = PartialShapes{{{3, 5}, 11, 1, 3}, {{1, 3}, 3, 1, 7}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[1], 20); + auto symbols_a = set_shape_symbols(input_shapes[0]); + auto symbols_b = set_shape_symbols(input_shapes[1]); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -228,16 +231,17 @@ TEST_F(TypePropEinsumTest, implicit_mode_mixed_case_letters_ellipsis) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({3, 11, 7, {1, 3}, {3, 5}, 3})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(21, 11, 23, 20, 10, 13)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), + ElementsAre(symbols_b[1], symbols_a[1], symbols_b[3], symbols_b[0], symbols_a[0], symbols_a[3])); } -TEST_F(TypePropEinsumTest, implicit_mode_repeated_labels) { +TEST_F(TypePropEinsumTest, implicit_mode_repeated_symbols) { // the following equation is equivalent to "a...b,b...->...a" const std::string equation = "a...b,b..."; constexpr auto et = element::f32; auto input_shapes = PartialShapes{{{3, 5}, 11, 1, 3}, {{1, 3}, 3, 1, 7}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[1], 20); + auto symbols_a = set_shape_symbols(input_shapes[0]); + auto symbols_b = set_shape_symbols(input_shapes[1]); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -246,7 +250,8 @@ TEST_F(TypePropEinsumTest, implicit_mode_repeated_labels) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({3, 11, 7, {3, 5}})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(21, 11, 23, 10)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), + ElementsAre(symbols_b[1], symbols_a[1], symbols_b[3], symbols_a[0])); } TEST_F(TypePropEinsumTest, dynamic_shape_implict_mode_inner_prod) { @@ -255,8 +260,8 @@ TEST_F(TypePropEinsumTest, dynamic_shape_implict_mode_inner_prod) { constexpr auto et = element::f16; auto input_shapes = PartialShapes{{11}, {{1, 20}}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[1], 20); + auto symbols_a = set_shape_symbols(input_shapes[0]); + auto symbols_b = set_shape_symbols(input_shapes[1]); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -265,7 +270,7 @@ TEST_F(TypePropEinsumTest, dynamic_shape_implict_mode_inner_prod) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({})); - EXPECT_TRUE(get_shape_labels(o->get_output_partial_shape(0)).empty()); + EXPECT_TRUE(get_shape_symbols(o->get_output_partial_shape(0)).empty()); } TEST_F(TypePropEinsumTest, dynamic_rank_multi_matmul) { @@ -273,8 +278,8 @@ TEST_F(TypePropEinsumTest, dynamic_rank_multi_matmul) { constexpr auto et = element::i32; auto input_shapes = PartialShapes{{2, 5}, PartialShape::dynamic(), {5, 3}}; - set_shape_labels(input_shapes[0], 10); - set_shape_labels(input_shapes[2], 30); + auto symbols_a = set_shape_symbols(input_shapes[0]); + auto symbols_b = set_shape_symbols(input_shapes[2]); const auto inputs = make_inputs(et, input_shapes); const auto o = make_op(inputs, equation); @@ -283,7 +288,7 @@ TEST_F(TypePropEinsumTest, dynamic_rank_multi_matmul) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({3, 2})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), ElementsAre(31, 10)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), ElementsAre(symbols_b[1], symbols_a[0])); } TEST_F(TypePropEinsumTest, all_dynamic_rank_multi_matmul) { @@ -298,7 +303,7 @@ TEST_F(TypePropEinsumTest, all_dynamic_rank_multi_matmul) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({-1, -1})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropEinsumTest, default_ctor) { @@ -317,7 +322,7 @@ TEST_F(TypePropEinsumTest, default_ctor) { EXPECT_EQ(o->get_element_type(), et); EXPECT_EQ(o->get_output_size(), exp_einsum_outputs_count); EXPECT_EQ(o->get_output_partial_shape(0), PartialShape({-1, -1})); - EXPECT_THAT(get_shape_labels(o->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(o->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropEinsumTest, incorrect_equation_subscript_number) { @@ -332,7 +337,7 @@ TEST_F(TypePropEinsumTest, incorrect_equation_subscript_number) { "number of Einsum inputs.")); } -TEST_F(TypePropEinsumTest, incorrect_equation_invalid_labels) { +TEST_F(TypePropEinsumTest, incorrect_equation_invalid_symbols) { const std::string equation = "a$,Bc->ac"; const auto input_shapes = Shapes{{2, 3}, {3, 4}}; diff --git a/src/core/tests/type_prop/embedding_segments_sum.cpp b/src/core/tests/type_prop/embedding_segments_sum.cpp index 2d5adf48ed1ad7..172421c1d164e7 100644 --- a/src/core/tests/type_prop/embedding_segments_sum.cpp +++ b/src/core/tests/type_prop/embedding_segments_sum.cpp @@ -460,9 +460,9 @@ TEST(type_prop, ess_num_segment_const) { TEST(type_prop, ess_num_segment_interval_label_propagation) { auto emb_shape = PartialShape{{5, 10}, {2, 4}, {1, 3}}; - set_shape_labels(emb_shape, 10); + auto emb_symbols = set_shape_symbols(emb_shape); auto num_segm_shape = PartialShape{{6, 8}}; - set_shape_labels(num_segm_shape, 20); + auto num_segm_symbols = set_shape_symbols(num_segm_shape); auto num_segments = make_shared(element::i64, num_segm_shape); auto shape_of = make_shared(num_segments); @@ -475,5 +475,6 @@ TEST(type_prop, ess_num_segment_interval_label_propagation) { auto op = make_shared(emb_table, indices, segment_ids, num_segm_squeeze); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{6, 8}, {2, 4}, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(num_segm_symbols[0], emb_symbols[1], emb_symbols[2])); } diff --git a/src/core/tests/type_prop/embeddingbag_offsetssum.cpp b/src/core/tests/type_prop/embeddingbag_offsetssum.cpp index 03b0033098750b..1345769240dd8d 100644 --- a/src/core/tests/type_prop/embeddingbag_offsetssum.cpp +++ b/src/core/tests/type_prop/embeddingbag_offsetssum.cpp @@ -29,9 +29,9 @@ TEST(type_prop, ebos_default_ctor) { TEST(type_prop, ebos_labeled_interval_dims) { auto emb_shape = PartialShape{{5, 10}, {2, 4}, {1, 3}}; - set_shape_labels(emb_shape, 10); + auto emb_symbols = set_shape_symbols(emb_shape); auto off_shape = PartialShape{{6, 8}}; - set_shape_labels(off_shape, 20); + auto off_symbols = set_shape_symbols(off_shape); auto emb_table = make_shared(element::f32, emb_shape); auto indices = make_shared(element::i64, PartialShape{{3, 4}}); @@ -43,7 +43,8 @@ TEST(type_prop, ebos_labeled_interval_dims) { make_shared(emb_table, indices, offsets, default_index, per_sample_weights); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{6, 8}, {2, 4}, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(off_symbols[0], emb_symbols[1], emb_symbols[2])); } TEST(type_prop, ebos) { diff --git a/src/core/tests/type_prop/embeddingbag_packedsum.cpp b/src/core/tests/type_prop/embeddingbag_packedsum.cpp index 3b7f846b1c40f4..07759a449675d1 100644 --- a/src/core/tests/type_prop/embeddingbag_packedsum.cpp +++ b/src/core/tests/type_prop/embeddingbag_packedsum.cpp @@ -28,9 +28,9 @@ TEST(type_prop, ebps_default_ctor) { TEST(type_prop, ebps_labeled_interval_dims_2in) { auto emb_shape = PartialShape{{5, 10}, {2, 4}, {1, 3}}; - set_shape_labels(emb_shape, 10); + auto emb_symbols = set_shape_symbols(emb_shape); auto ind_shape = PartialShape{{6, 8}, 4}; - set_shape_labels(ind_shape, 20); + auto ind_symbols = set_shape_symbols(ind_shape); auto emb_table = make_shared(element::f32, emb_shape); auto indices = make_shared(element::i64, ind_shape); @@ -38,16 +38,17 @@ TEST(type_prop, ebps_labeled_interval_dims_2in) { auto op = make_shared(emb_table, indices); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{6, 8}, {2, 4}, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(ind_symbols[0], emb_symbols[1], emb_symbols[2])); } TEST(type_prop, ebps_labeled_interval_dims_3in) { auto emb_shape = PartialShape{{5, 10}, {2, 4}, {1, 3}}; - set_shape_labels(emb_shape, 10); + auto emb_symbols = set_shape_symbols(emb_shape); auto ind_shape = PartialShape{{2, 6}, 4}; - set_shape_labels(ind_shape, 20); + auto ind_symbols = set_shape_symbols(ind_shape); auto sample_shape = PartialShape{{4, 8}, 4}; - set_shape_labels(sample_shape, 30); + auto sample_symbols = set_shape_symbols(sample_shape); auto emb_table = make_shared(element::f32, emb_shape); auto indices = make_shared(element::i64, ind_shape); @@ -56,7 +57,8 @@ TEST(type_prop, ebps_labeled_interval_dims_3in) { auto op = make_shared(emb_table, indices, per_sample_weights); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{{4, 6}, {2, 4}, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(30, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(ind_symbols[0], emb_symbols[1], emb_symbols[2])); } TEST(type_prop, ebps) { diff --git a/src/core/tests/type_prop/experimental_detectron_detection_output.cpp b/src/core/tests/type_prop/experimental_detectron_detection_output.cpp index 5edef18e78d375..454919737532b3 100644 --- a/src/core/tests/type_prop/experimental_detectron_detection_output.cpp +++ b/src/core/tests/type_prop/experimental_detectron_detection_output.cpp @@ -109,10 +109,10 @@ TEST_F(TypePropExperimentalDetectronDetectionOutputV6Test, interval_shapes) { auto deltas_shape = PartialShape{{1, 12}, {1, 500}}; auto scores_shape = PartialShape{{1, 3}, {10, 90}}; auto im_info_shape = PartialShape{1, {1, 4}}; - set_shape_labels(rois_shape, 10); - set_shape_labels(deltas_shape, 20); - set_shape_labels(scores_shape, 30); - set_shape_labels(im_info_shape, 40); + set_shape_symbols(rois_shape); + set_shape_symbols(deltas_shape); + set_shape_symbols(scores_shape); + set_shape_symbols(im_info_shape); const auto rois = std::make_shared(element::f16, rois_shape); const auto deltas = std::make_shared(element::f16, deltas_shape); @@ -128,13 +128,13 @@ TEST_F(TypePropExperimentalDetectronDetectionOutputV6Test, interval_shapes) { EXPECT_THAT(op->outputs(), ElementsAre(Property("Boxes shape", &Output::get_partial_shape, - AllOf(PartialShape({25, 4}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25, 4}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Classes shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Scores shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))))); + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronDetectionOutputV6Test, all_inputs_dynamic_rank) { @@ -152,13 +152,13 @@ TEST_F(TypePropExperimentalDetectronDetectionOutputV6Test, all_inputs_dynamic_ra EXPECT_THAT(op->outputs(), ElementsAre(Property("Boxes shape", &Output::get_partial_shape, - AllOf(PartialShape({25, 4}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25, 4}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Classes shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Scores shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))))); + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronDetectionOutputV6Test, input_not_floating_point) { @@ -450,11 +450,11 @@ TEST_P(ExperimentalDetectronDetectionOutputV6Test, static_rank_shape_inference) EXPECT_THAT(op->outputs(), ElementsAre(Property("Boxes shape", &Output::get_partial_shape, - AllOf(PartialShape({25, 4}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25, 4}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Classes shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("Scores shape", &Output::get_partial_shape, - AllOf(PartialShape({25}), ResultOf(get_shape_labels, Each(ov::no_label)))))); + AllOf(PartialShape({25}), ResultOf(get_shape_symbols, Each(nullptr)))))); } diff --git a/src/core/tests/type_prop/experimental_detectron_generate_proposals.cpp b/src/core/tests/type_prop/experimental_detectron_generate_proposals.cpp index 4c664037c5d3a6..ea7a7ea5c43633 100644 --- a/src/core/tests/type_prop/experimental_detectron_generate_proposals.cpp +++ b/src/core/tests/type_prop/experimental_detectron_generate_proposals.cpp @@ -94,10 +94,10 @@ TEST_F(TypePropExperimentalDetectronGenerateProposalsSingleImageV6Test, interval auto anchors_shape = PartialShape{{1, 201600}, {1, 4}}; auto deltas_shape = PartialShape{{1, 12}, {1, 200}, {336, -1}}; auto scores_shape = PartialShape{{1, 3}, {100, 200}, {2, 336}}; - set_shape_labels(im_info_shape, 10); - set_shape_labels(anchors_shape, 20); - set_shape_labels(deltas_shape, 30); - set_shape_labels(scores_shape, 40); + set_shape_symbols(im_info_shape); + set_shape_symbols(anchors_shape); + set_shape_symbols(deltas_shape); + set_shape_symbols(scores_shape); const auto im_info = std::make_shared(element::f16, im_info_shape); const auto anchors = std::make_shared(element::f16, anchors_shape); @@ -110,10 +110,10 @@ TEST_F(TypePropExperimentalDetectronGenerateProposalsSingleImageV6Test, interval EXPECT_THAT(op->outputs(), ElementsAre(Property("ROIs shape", &Output::get_partial_shape, - AllOf(PartialShape({44, 4}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({44, 4}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("ROIs Score shape", &Output::get_partial_shape, - AllOf(PartialShape({44}), ResultOf(get_shape_labels, Each(ov::no_label)))))); + AllOf(PartialShape({44}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronGenerateProposalsSingleImageV6Test, all_inputs_dynamic_rank) { @@ -128,10 +128,10 @@ TEST_F(TypePropExperimentalDetectronGenerateProposalsSingleImageV6Test, all_inpu EXPECT_THAT(op->outputs(), ElementsAre(Property("ROIs shape", &Output::get_partial_shape, - AllOf(PartialShape({100, 4}), ResultOf(get_shape_labels, Each(ov::no_label)))), + AllOf(PartialShape({100, 4}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("ROIs Score shape", &Output::get_partial_shape, - AllOf(PartialShape({100}), ResultOf(get_shape_labels, Each(ov::no_label)))))); + AllOf(PartialShape({100}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronGenerateProposalsSingleImageV6Test, input_not_floating_point) { diff --git a/src/core/tests/type_prop/experimental_detectron_prior_grid_generator.cpp b/src/core/tests/type_prop/experimental_detectron_prior_grid_generator.cpp index a4e25ab2d0ffb4..9c85ee5af368d5 100644 --- a/src/core/tests/type_prop/experimental_detectron_prior_grid_generator.cpp +++ b/src/core/tests/type_prop/experimental_detectron_prior_grid_generator.cpp @@ -34,16 +34,16 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, default_ctor_no_fl EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({200, 336, 3, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, static_shape_flatten) { auto priors_shape = PartialShape{3, 4}; auto feat_map_shape = PartialShape{1, 4, 6, 10}; auto im_data_shape = PartialShape{1, 4, 128, 128}; - set_shape_labels(priors_shape, 10); - set_shape_labels(feat_map_shape, 20); - set_shape_labels(im_data_shape, 30); + set_shape_symbols(priors_shape); + set_shape_symbols(feat_map_shape); + set_shape_symbols(im_data_shape); const auto priors = std::make_shared(element::f64, priors_shape); const auto feature_map = std::make_shared(element::f64, feat_map_shape); @@ -53,16 +53,16 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, static_shape_flatt EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({180, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, static_shape_without_flatten) { auto priors_shape = PartialShape{3, 4}; auto feat_map_shape = PartialShape{1, 4, 6, 10}; auto im_data_shape = PartialShape{1, 4, 128, 128}; - set_shape_labels(priors_shape, 10); - set_shape_labels(feat_map_shape, 20); - set_shape_labels(im_data_shape, 30); + auto priors_symbols = set_shape_symbols(priors_shape); + auto feat_symbols = set_shape_symbols(feat_map_shape); + set_shape_symbols(im_data_shape); const auto priors = std::make_shared(element::f16, priors_shape); const auto feature_map = std::make_shared(element::f16, feat_map_shape); @@ -72,16 +72,17 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, static_shape_witho EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({6, 10, 3, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(22, 23, 10, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(feat_symbols[2], feat_symbols[3], priors_symbols[0], nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, interval_shapes_flatten) { auto priors_shape = PartialShape{{2, 5}, {0, 4}}; auto feat_map_shape = PartialShape{1, {3, 4}, {5, 10}, {9, 10}}; auto im_data_shape = PartialShape{1, {2, 4}, {1, 128}, {1, 128}}; - set_shape_labels(priors_shape, 10); - set_shape_labels(feat_map_shape, 20); - set_shape_labels(im_data_shape, 30); + set_shape_symbols(priors_shape); + set_shape_symbols(feat_map_shape); + set_shape_symbols(im_data_shape); const auto priors = std::make_shared(element::bf16, priors_shape); const auto feature_map = std::make_shared(element::bf16, feat_map_shape); @@ -91,16 +92,16 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, interval_shapes_fl EXPECT_EQ(op->get_output_element_type(0), element::bf16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{90, 500}, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, interval_shapes_no_flatten) { auto priors_shape = PartialShape{{2, 5}, {0, 4}}; auto feat_map_shape = PartialShape{1, {3, 4}, {5, 10}, {9, 10}}; auto im_data_shape = PartialShape{1, {2, 4}, {1, 128}, {1, 128}}; - set_shape_labels(priors_shape, 10); - set_shape_labels(feat_map_shape, 20); - set_shape_labels(im_data_shape, 30); + auto priors_symbols = set_shape_symbols(priors_shape); + auto feat_symbols = set_shape_symbols(feat_map_shape); + set_shape_symbols(im_data_shape); const auto priors = std::make_shared(element::bf16, priors_shape); const auto feature_map = std::make_shared(element::bf16, feat_map_shape); @@ -110,7 +111,8 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, interval_shapes_no EXPECT_EQ(op->get_output_element_type(0), element::bf16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{5, 10}, {9, 10}, {2, 5}, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(22, 23, 10, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(feat_symbols[2], feat_symbols[3], priors_symbols[0], nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, all_inputs_dynamic_rank_flatten) { @@ -122,7 +124,7 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, all_inputs_dynamic EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, all_inputs_dynamic_rank_no_flatten) { @@ -134,7 +136,7 @@ TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, all_inputs_dynamic EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, -1, -1, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropExperimentalDetectronPriorGridGeneratorV6Test, all_input_got_dynamic_type) { diff --git a/src/core/tests/type_prop/experimental_detectron_roi_feature_extractor.cpp b/src/core/tests/type_prop/experimental_detectron_roi_feature_extractor.cpp index e4c9214249e46b..809cf7ece5c8c3 100644 --- a/src/core/tests/type_prop/experimental_detectron_roi_feature_extractor.cpp +++ b/src/core/tests/type_prop/experimental_detectron_roi_feature_extractor.cpp @@ -67,10 +67,10 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, dims_and_labels_p auto l1_shape = PartialShape{1, {0, 20}, 32, 32}; auto l2_shape = PartialShape{1, {1, 10}, 16, 16}; - set_shape_labels(in_shape, 10); - set_shape_labels(l0_shape, 20); - set_shape_labels(l1_shape, 30); - set_shape_labels(l2_shape, 40); + auto in_symbols = set_shape_symbols(in_shape); + auto l0_symbols = set_shape_symbols(l0_shape); + set_shape_symbols(l1_shape); + set_shape_symbols(l2_shape); const auto rois = std::make_shared(element::f64, in_shape); const auto pyramid_layer0 = std::make_shared(element::f64, l0_shape); @@ -82,13 +82,15 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, dims_and_labels_p EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output::get_element_type, element::f64))); EXPECT_THAT( op->outputs(), - ElementsAre(Property("ROIs feat shape", - &Output::get_partial_shape, - AllOf(PartialShape({{100, 200}, {2, 10}, 7, 7}), - ResultOf(get_shape_labels, ElementsAre(10, 41, no_label, no_label)))), - Property("ROIs order shape", - &Output::get_partial_shape, - AllOf(PartialShape({{100, 200}, 4}), ResultOf(get_shape_labels, ElementsAre(10, 11)))))); + ElementsAre( + Property("ROIs feat shape", + &Output::get_partial_shape, + AllOf(PartialShape({{100, 200}, {2, 10}, 7, 7}), + ResultOf(get_shape_symbols, ElementsAre(in_symbols[0], l0_symbols[1], nullptr, nullptr)))), + Property("ROIs order shape", + &Output::get_partial_shape, + AllOf(PartialShape({{100, 200}, 4}), + ResultOf(get_shape_symbols, ElementsAre(in_symbols[0], in_symbols[1])))))); } TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, dims_and_labels_propagation_not_all_inputs_labeled) { @@ -97,9 +99,9 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, dims_and_labels_p auto l1_shape = PartialShape{1, {0, 20}, 32, 32}; auto l2_shape = PartialShape{1, {1, 10}, 16, 16}; - set_shape_labels(in_shape, 10); - set_shape_labels(l0_shape, 20); - set_shape_labels(l1_shape, 30); + auto in_symbol = set_shape_symbols(in_shape); + auto l0_symbol = set_shape_symbols(l0_shape); + set_shape_symbols(l1_shape); const auto rois = std::make_shared(element::bf16, in_shape); const auto pyramid_layer0 = std::make_shared(element::bf16, l0_shape); @@ -111,13 +113,15 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, dims_and_labels_p EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output::get_element_type, element::bf16))); EXPECT_THAT( op->outputs(), - ElementsAre(Property("ROIs feat shape", - &Output::get_partial_shape, - AllOf(PartialShape({{100, 200}, 5, 7, 7}), - ResultOf(get_shape_labels, ElementsAre(10, 31, no_label, no_label)))), - Property("ROIs order shape", - &Output::get_partial_shape, - AllOf(PartialShape({{100, 200}, 4}), ResultOf(get_shape_labels, ElementsAre(10, 11)))))); + ElementsAre( + Property("ROIs feat shape", + &Output::get_partial_shape, + AllOf(PartialShape({{100, 200}, 5, 7, 7}), + ResultOf(get_shape_symbols, ElementsAre(in_symbol[0], l0_symbol[1], nullptr, nullptr)))), + Property("ROIs order shape", + &Output::get_partial_shape, + AllOf(PartialShape({{100, 200}, 4}), + ResultOf(get_shape_symbols, ElementsAre(in_symbol[0], in_symbol[1])))))); } TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, all_inputs_dynamic_rank) { @@ -131,10 +135,10 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, all_inputs_dynami EXPECT_THAT(op->outputs(), ElementsAre(Property("ROIs feat shape", &Output::get_partial_shape, - AllOf(PartialShape({-1, -1, 7, 7}), ResultOf(get_shape_labels, Each(no_label)))), + AllOf(PartialShape({-1, -1, 7, 7}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("ROIs order shape", &Output::get_partial_shape, - AllOf(PartialShape({-1, 4}), ResultOf(get_shape_labels, Each(no_label)))))); + AllOf(PartialShape({-1, 4}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, all_inputs_static_rank_but_dynamic_dims) { @@ -153,10 +157,10 @@ TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, all_inputs_static EXPECT_THAT(op->outputs(), ElementsAre(Property("ROIs feat shape", &Output::get_partial_shape, - AllOf(PartialShape({-1, -1, 7, 7}), ResultOf(get_shape_labels, Each(no_label)))), + AllOf(PartialShape({-1, -1, 7, 7}), ResultOf(get_shape_symbols, Each(nullptr)))), Property("ROIs order shape", &Output::get_partial_shape, - AllOf(PartialShape({-1, 4}), ResultOf(get_shape_labels, Each(no_label)))))); + AllOf(PartialShape({-1, 4}), ResultOf(get_shape_symbols, Each(nullptr)))))); } TEST_F(TypePropExperimentalDetectronROIFeatureExtractorV6Test, input_not_floating_point) { diff --git a/src/core/tests/type_prop/experimental_detectron_topkrois.cpp b/src/core/tests/type_prop/experimental_detectron_topkrois.cpp index ba475d36dd6566..f713ae86a9744f 100644 --- a/src/core/tests/type_prop/experimental_detectron_topkrois.cpp +++ b/src/core/tests/type_prop/experimental_detectron_topkrois.cpp @@ -63,8 +63,8 @@ TEST_F(TypePropExperimentalDetectronTopKROIsV6, static_rank_rois_and_probabiliti TEST_F(TypePropExperimentalDetectronTopKROIsV6, interval_num_of_rois_and_dynamic_probabilities) { auto input_rois_shape = PartialShape{{20, 30}, 4}; auto rois_prop_shape = PartialShape{-1}; - set_shape_labels(input_rois_shape, 10); - set_shape_labels(input_rois_shape, 20); + set_shape_symbols(input_rois_shape); + set_shape_symbols(rois_prop_shape); const auto input_rois = std::make_shared(element::dynamic, input_rois_shape); const auto rois_probs = std::make_shared(element::dynamic, rois_prop_shape); @@ -72,14 +72,14 @@ TEST_F(TypePropExperimentalDetectronTopKROIsV6, interval_num_of_rois_and_dynamic EXPECT_EQ(op->get_output_element_type(0), element::dynamic); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({20, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(nullptr, nullptr)); } TEST_F(TypePropExperimentalDetectronTopKROIsV6, interval_num_of_rois_and_probabilities) { auto input_rois_shape = PartialShape{{20, 30}, 4}; auto rois_prop_shape = PartialShape{{10, 35}}; - set_shape_labels(input_rois_shape, 10); - set_shape_labels(input_rois_shape, 20); + set_shape_symbols(input_rois_shape); + set_shape_symbols(rois_prop_shape); const auto input_rois = std::make_shared(element::dynamic, input_rois_shape); const auto rois_probs = std::make_shared(element::dynamic, rois_prop_shape); @@ -87,14 +87,14 @@ TEST_F(TypePropExperimentalDetectronTopKROIsV6, interval_num_of_rois_and_probabi EXPECT_EQ(op->get_output_element_type(0), element::dynamic); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({20, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(nullptr, nullptr)); } TEST_F(TypePropExperimentalDetectronTopKROIsV6, dynamic_num_rois_and_interval_probabilities) { auto input_rois_shape = PartialShape{-1, 4}; auto rois_prop_shape = PartialShape{{10, 15}}; - set_shape_labels(input_rois_shape, 10); - set_shape_labels(input_rois_shape, 20); + set_shape_symbols(input_rois_shape); + set_shape_symbols(rois_prop_shape); const auto input_rois = std::make_shared(element::dynamic, input_rois_shape); const auto rois_probs = std::make_shared(element::dynamic, rois_prop_shape); @@ -102,7 +102,7 @@ TEST_F(TypePropExperimentalDetectronTopKROIsV6, dynamic_num_rois_and_interval_pr EXPECT_EQ(op->get_output_element_type(0), element::dynamic); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({200, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(nullptr, nullptr)); } TEST_F(TypePropExperimentalDetectronTopKROIsV6, element_type_of_inputs_are_not_same) { diff --git a/src/core/tests/type_prop/extractimagepatches.cpp b/src/core/tests/type_prop/extractimagepatches.cpp index 15345d7870e5f2..4cd0ae5c6eb1ea 100644 --- a/src/core/tests/type_prop/extractimagepatches.cpp +++ b/src/core/tests/type_prop/extractimagepatches.cpp @@ -68,7 +68,7 @@ TEST(type_prop, extractimagepatches_rates_change) { TEST(type_prop, extractimagepatches_input_shape_change) { auto data_shape = PartialShape{64, 3, 9, 9}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::i32, data_shape); auto sizes = Shape{3, 3}; auto strides = Strides{5, 5}; @@ -78,12 +78,13 @@ TEST(type_prop, extractimagepatches_input_shape_change) { EXPECT_EQ(extractimagepatches->get_output_element_type(0), element::i32); EXPECT_EQ(extractimagepatches->get_output_shape(0), (Shape{64, 27, 1, 1})); - EXPECT_THAT(get_shape_labels(extractimagepatches->get_output_partial_shape(0)), ElementsAre(10, 0, 0, 0)); + EXPECT_THAT(get_shape_symbols(extractimagepatches->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, extractimagepatches_dynamic_shape) { auto data_shape = PartialShape::dynamic(4); - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::i32, data_shape); auto sizes = Shape{3, 3}; @@ -94,7 +95,8 @@ TEST(type_prop, extractimagepatches_dynamic_shape) { EXPECT_EQ(extractimagepatches->get_output_element_type(0), element::i32); EXPECT_EQ(extractimagepatches->get_output_partial_shape(0), PartialShape::dynamic(4)); - EXPECT_THAT(get_shape_labels(extractimagepatches->get_output_partial_shape(0)), ElementsAre(10, 0, 0, 0)); + EXPECT_THAT(get_shape_symbols(extractimagepatches->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, extractimagepatches_dynamic_batch_shape) { @@ -111,7 +113,7 @@ TEST(type_prop, extractimagepatches_dynamic_batch_shape) { TEST(type_prop, extractimagepatches_interval_shape_and_labels) { auto data_shape = PartialShape{{1, 10}, {3, 4}, {10, 51}, {13, 71}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::i32, data_shape); auto sizes = Shape{3, 3}; auto strides = Strides{5, 5}; @@ -121,7 +123,8 @@ TEST(type_prop, extractimagepatches_interval_shape_and_labels) { EXPECT_EQ(extractimagepatches->get_output_element_type(0), element::i32); EXPECT_EQ(extractimagepatches->get_output_partial_shape(0), PartialShape({{1, 10}, {27, 36}, {2, 10}, {3, 14}})); - EXPECT_THAT(get_shape_labels(extractimagepatches->get_output_partial_shape(0)), ElementsAre(10, 0, 0, 0)); + EXPECT_THAT(get_shape_symbols(extractimagepatches->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, extractimagepatches_padding_same_lower1) { @@ -221,7 +224,7 @@ TEST(type_prop, extractimagepatches_dyn) { TEST(type_prop, extractimagepatches_interval_shape_and_labels_padding_same_upper) { auto data_shape = PartialShape{{1, 10}, {3, 4}, {10, 51}, {13, 71}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::i32, data_shape); auto sizes = Shape{1, 1}; auto strides = Strides{5, 5}; @@ -231,7 +234,8 @@ TEST(type_prop, extractimagepatches_interval_shape_and_labels_padding_same_upper EXPECT_EQ(extractimagepatches->get_output_element_type(0), element::i32); EXPECT_EQ(extractimagepatches->get_output_partial_shape(0), PartialShape({{1, 10}, {3, 4}, {2, 11}, {3, 15}})); - EXPECT_THAT(get_shape_labels(extractimagepatches->get_output_partial_shape(0)), ElementsAre(10, 11, 0, 0)); + EXPECT_THAT(get_shape_symbols(extractimagepatches->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST(type_prop, extractimagepatches_data_not_rank_4d) { diff --git a/src/core/tests/type_prop/eye.cpp b/src/core/tests/type_prop/eye.cpp index 70e40f1d534f37..41def046dd4c10 100644 --- a/src/core/tests/type_prop/eye.cpp +++ b/src/core/tests/type_prop/eye.cpp @@ -7,7 +7,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" #include "eye_shape_inference.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/opsets/opset10.hpp" using namespace std; @@ -40,9 +39,8 @@ TEST(type_prop, eye_batch_shape_constant) { } TEST(type_prop, eye_rows_param) { - constexpr label_t row_label = 2; auto rows_dim = Dimension{0, 1}; - DimensionTracker::set_label(rows_dim, row_label); + rows_dim.set_symbol(std::make_shared()); auto num_rows = make_shared(element::i64, PartialShape{rows_dim}); auto num_columns = op::v0::Constant::create(element::i64, Shape{}, {10}); @@ -52,13 +50,12 @@ TEST(type_prop, eye_rows_param) { EXPECT_EQ(eye->get_output_element_type(0), element::f32); EXPECT_EQ(eye->get_output_partial_shape(0), PartialShape({Dimension::dynamic(), 10})); - EXPECT_THAT(get_shape_labels(eye->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(eye->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, eye_rows_const) { - constexpr label_t columns_label = 2; auto columns_dim = Dimension{0, 1}; - DimensionTracker::set_label(columns_dim, columns_label); + columns_dim.set_symbol(std::make_shared()); auto num_rows = op::v0::Constant::create(element::i64, Shape{}, {10}); auto num_columns = make_shared(element::i64, PartialShape{columns_dim}); @@ -68,13 +65,12 @@ TEST(type_prop, eye_rows_const) { EXPECT_EQ(eye->get_output_element_type(0), element::f32); EXPECT_EQ(eye->get_output_partial_shape(0), PartialShape({10, Dimension::dynamic()})); - EXPECT_THAT(get_shape_labels(eye->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(eye->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, eye_batch_shape_const) { - constexpr label_t batch_label = 2; auto batch_dim = Dimension{2}; - DimensionTracker::set_label(batch_dim, batch_label); + batch_dim.set_symbol(std::make_shared()); auto num_rows = make_shared(element::i64, PartialShape{1}); auto num_columns = num_rows; @@ -85,7 +81,7 @@ TEST(type_prop, eye_batch_shape_const) { EXPECT_EQ(eye->get_output_element_type(0), element::f32); EXPECT_EQ(eye->get_output_partial_shape(0), PartialShape({2, 3, Dimension::dynamic(), Dimension::dynamic()})); - EXPECT_THAT(get_shape_labels(eye->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(eye->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, eye_batch_shape_params) { @@ -102,7 +98,7 @@ TEST(type_prop, eye_batch_shape_params) { TEST(type_prop, eye_batch_shape_shape_of) { auto batch_shape = PartialShape{{1, 10}, {10, 25}}; - set_shape_labels(batch_shape, 10); + auto symbols = set_shape_symbols(batch_shape); auto num_rows = Constant::create(element::i64, Shape{}, {10}); auto num_columns = num_rows; @@ -114,7 +110,8 @@ TEST(type_prop, eye_batch_shape_shape_of) { EXPECT_EQ(eye->get_output_element_type(0), element::f64); EXPECT_EQ(eye->get_output_partial_shape(0), PartialShape({{1, 10}, {10, 25}, 10, 10})); - EXPECT_THAT(get_shape_labels(eye->get_output_partial_shape(0)), ElementsAre(10, 11, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(eye->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST(type_prop, eye_invalid_num_rows_value) { @@ -336,7 +333,7 @@ TEST_F(TypePropEyeV9Test, eye_batch_shape_param_other_ins_const) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, -1, -1, 5, 6})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropEyeV9Test, default_ctor) { @@ -353,7 +350,7 @@ TEST_F(TypePropEyeV9Test, default_ctor) { EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({3, 1, 2, 2, 16})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropEyeV9Test, default_ctor_no_arguments) { @@ -374,20 +371,20 @@ TEST_F(TypePropEyeV9Test, default_ctor_no_arguments) { EXPECT_EQ(output_shapes.front(), PartialShape({2, 4, 1, 8, 5})); } -TEST_F(TypePropEyeV9Test, preserve_partial_values_and_labels) { +TEST_F(TypePropEyeV9Test, preserve_partial_values_and_symbols) { auto rows_shape = PartialShape{{2, 5}}; - set_shape_labels(rows_shape, 30); + auto rows_symbols = set_shape_symbols(rows_shape); auto rows = std::make_shared(element::i64, rows_shape); auto num_rows = make_shared(rows); auto columns_shape = PartialShape{{1, 3}}; - set_shape_labels(columns_shape, 40); + auto col_symbols = set_shape_symbols(columns_shape); auto columns = std::make_shared(element::i64, columns_shape); auto shape_of_columns = make_shared(columns); auto num_columns = std::make_shared(shape_of_columns, Constant::create(element::i64, Shape{}, {0})); auto batch_shape = PartialShape{{1, 10}, {10, 25}}; - set_shape_labels(batch_shape, 10); + auto batch_symbol = set_shape_symbols(batch_shape); auto diagonal_index = make_shared(element::i64, PartialShape{1}); auto batch = make_shared(make_shared(element::i64, batch_shape)); @@ -395,5 +392,6 @@ TEST_F(TypePropEyeV9Test, preserve_partial_values_and_labels) { auto op = make_op(num_rows, num_columns, diagonal_index, batch, element::i32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{1, 10}, {10, 25}, {2, 5}, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 30, 40)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(batch_symbol[0], batch_symbol[1], rows_symbols[0], col_symbols[0])); } diff --git a/src/core/tests/type_prop/fake_convert.cpp b/src/core/tests/type_prop/fake_convert.cpp index ccdaed07a7c758..b96a99467ff7c0 100644 --- a/src/core/tests/type_prop/fake_convert.cpp +++ b/src/core/tests/type_prop/fake_convert.cpp @@ -71,9 +71,9 @@ TEST(type_prop, fake_convert_dynamic_shape) { EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape::dynamic())); } -TEST(type_prop, fake_convert_label) { +TEST(type_prop, fake_convert_symbol) { PartialShape data_shape{2, 1, Dimension::dynamic(), 6}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); const auto scale = std::make_shared(element::f32, PartialShape{}); const auto shift = std::make_shared(element::f32, PartialShape{}); @@ -81,7 +81,7 @@ TEST(type_prop, fake_convert_label) { const auto op = std::make_shared(data, scale, shift); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{2, 1, Dimension::dynamic(), 6})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), testing::ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST(type_prop, fake_convert_example_0) { diff --git a/src/core/tests/type_prop/fft_base_complex.cpp b/src/core/tests/type_prop/fft_base_complex.cpp index 1cb166fa04a16b..d0f6101947a794 100644 --- a/src/core/tests/type_prop/fft_base_complex.cpp +++ b/src/core/tests/type_prop/fft_base_complex.cpp @@ -24,9 +24,24 @@ struct FFTConstantAxesAndConstantSignalSizeTestParams { PartialShape ref_output_shape; std::vector axes; std::vector signal_size; - std::vector expected_labels; + std::vector expected_symbols; }; +namespace { +TensorSymbol from_idx_to_symbol_vector(const std::vector& indices, + const TensorSymbol& initial_symbols, + size_t base = 10) { + TensorSymbol result; + for (const auto& i : indices) { + if (i == 0) + result.push_back(nullptr); + else + result.push_back(initial_symbols[(i >= base ? i - base : i)]); + } + return result; +} +} // namespace + template class FFTConstantAxesAndConstantSignalSizeTest : public TypePropOpTest { public: @@ -136,49 +151,49 @@ class FFTConstantAxesAndConstantSignalSizeTest : public TypePropOpTest { {2, 180, 77, 2}, {1, 2}, {-1, 77}, - {10, 11, ov::no_label, 13}}, + {10, 11, 0, 13}}, FFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180, 2}, {2}, {2}, {87, 180, 390, 2}, {2, 0}, {390, 87}, - {ov::no_label, 11, ov::no_label, 13}}, + {0, 11, 0, 13}}, FFTConstantAxesAndConstantSignalSizeTestParams{{7, 50, 130, 400, 2}, {3}, {3}, {7, 40, 130, 600, 2}, {3, 0, 1}, {600, -1, 40}, - {10, ov::no_label, 12, ov::no_label, 14}}, + {10, 0, 12, 0, 14}}, FFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(0, 200), 180, 2}, {2}, {2}, {2, Dimension(0, 200), 77, 2}, {1, 2}, {-1, 77}, - {10, 11, ov::no_label, 13}}, + {10, 11, 0, 13}}, FFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400), 2}, {2}, {2}, {87, 180, 390, 2}, {2, 0}, {390, 87}, - {ov::no_label, 11, ov::no_label, 13}}, + {0, 11, 0, 13}}, FFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(8, 129), 50, 130, Dimension(0, 500), 2}, {3}, {3}, {Dimension(8, 129), 40, 130, 600, 2}, {3, 0, 1}, {600, -1, 40}, - {10, ov::no_label, 12, ov::no_label, 14}}}; + {10, 0, 12, 0, 14}}}; }; TYPED_TEST_SUITE_P(FFTConstantAxesAndConstantSignalSizeTest); TYPED_TEST_P(FFTConstantAxesAndConstantSignalSizeTest, constant_axes_and_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + auto symbols = set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, params.axes_shape, params.axes); @@ -193,10 +208,11 @@ TYPED_TEST_P(FFTConstantAxesAndConstantSignalSizeTest, constant_axes_and_signal_ EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - if (params.expected_labels.empty()) { - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), get_shape_labels(params.input_shape)); + if (params.expected_symbols.empty()) { + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), get_shape_symbols(params.input_shape)); } else { - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + auto output_symbols = from_idx_to_symbol_vector(params.expected_symbols, symbols); + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), output_symbols); } } } @@ -275,7 +291,7 @@ TYPED_TEST_SUITE_P(FFTNonConstantAxesTest); TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_no_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = std::make_shared(element::i64, params.axes_shape); @@ -284,13 +300,13 @@ TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_no_signal_size) { EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.input_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), get_shape_labels(params.input_shape)); + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), get_shape_symbols(params.input_shape)); } } TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_param_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = std::make_shared(element::i64, params.axes_shape); @@ -301,15 +317,16 @@ TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_param_signal_size) { EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - std::vector expected_labels(params.input_shape.size() - 1, no_label); - expected_labels.push_back(get_shape_labels(params.input_shape).back()); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), expected_labels); + TensorSymbol expected_symbols(params.input_shape.size() - 1, nullptr); + expected_symbols.push_back(get_shape_symbols(params.input_shape).back()); + + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), expected_symbols); } } TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_const_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = std::make_shared(element::i64, params.axes_shape); @@ -320,9 +337,9 @@ TYPED_TEST_P(FFTNonConstantAxesTest, non_constant_axes_const_signal_size) { EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - std::vector expected_labels(params.input_shape.size() - 1, no_label); - expected_labels.push_back(get_shape_labels(params.input_shape).back()); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), expected_labels); + TensorSymbol expected_symbols(params.input_shape.size() - 1, nullptr); + expected_symbols.push_back(get_shape_symbols(params.input_shape).back()); + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), expected_symbols); } } @@ -338,7 +355,7 @@ struct NonConstantSignalSizeTestParams { Shape signal_size_shape; PartialShape ref_output_shape; std::vector axes; - std::vector expected_labels; + std::vector expected_symbols; }; template @@ -350,26 +367,26 @@ class FFTNonConstantSignalSizeTest : public TypePropOpTest { {2}, {2, Dimension::dynamic(), Dimension::dynamic(), 2}, {1, 2}, - {10, no_label, no_label, 13}}, + {10, 0, 0, 13}}, NonConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400), 2}, {2}, {2}, {Dimension::dynamic(), 180, Dimension::dynamic(), 2}, {2, 0}, - {no_label, 11, no_label, 13}}, + {0, 11, 0, 13}}, NonConstantSignalSizeTestParams{{Dimension(8, 129), 50, 130, Dimension(0, 500), 2}, {3}, {3}, {Dimension::dynamic(), Dimension::dynamic(), 130, Dimension::dynamic(), 2}, {3, 0, 1}, - {no_label, no_label, 12, no_label, 14}}}; + {0, 0, 12, 0, 14}}}; }; TYPED_TEST_SUITE_P(FFTNonConstantSignalSizeTest); TYPED_TEST_P(FFTNonConstantSignalSizeTest, non_constant_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + auto symbols = set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, params.axes_shape, params.axes); auto signal_size_input = std::make_shared(element::i64, params.signal_size_shape); @@ -377,7 +394,8 @@ TYPED_TEST_P(FFTNonConstantSignalSizeTest, non_constant_signal_size) { EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + auto output_symbols = from_idx_to_symbol_vector(params.expected_symbols, symbols); + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), output_symbols); } } @@ -479,7 +497,7 @@ struct FFTConstantAxesAndShapeOfSignalSizeTestParams { PartialShape ref_output_shape; std::vector axes; PartialShape signal_size; - std::vector expected_labels; + std::vector expected_symbols; }; template @@ -501,11 +519,11 @@ TYPED_TEST_SUITE_P(FFTConstantAxesAndShapeOfSignalSizeTest); TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size) { for (auto params : this->test_params) { - set_shape_labels(params.input_shape, 10); + auto in_symbols = set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); - set_shape_labels(params.signal_size, 20); + auto signal_symbols = set_shape_symbols(params.signal_size); auto param_of_shape = std::make_shared(element::f32, params.signal_size); auto signal_size_input = std::make_shared(param_of_shape, element::i64); @@ -513,18 +531,25 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + TensorSymbol expected_output_symbols; + for (const auto& i : params.expected_symbols) { + if (i >= 20) { + expected_output_symbols.push_back(signal_symbols[i - 20]); + } else if (i >= 10) { + expected_output_symbols.push_back(in_symbols[i - 10]); + } + } + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), expected_output_symbols); } } -TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_first_input_labels) { +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_first_input_symbols) { auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, {-1, {10, 16}, {6, 8}, 4, 2}, {2, 0, -1}, {{6, 8}, -1, 4}, - {ov::no_label, 11, ov::no_label, ov::no_label, 14}}; - set_shape_labels(params.input_shape, 10); + {0, 11, 0, 0, 14}}; + auto symbols = set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); @@ -536,20 +561,21 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_THAT(get_shape_symbols(dft->get_output_partial_shape(0)), + ElementsAre(nullptr, symbols[1], nullptr, nullptr, symbols[4])); } -TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_second_input_labels) { +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_second_input_symbols) { auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, {-1, {10, 16}, {6, 8}, 4, 2}, {2, 0, -1}, {{6, 8}, -1, 4}, - {21, ov::no_label, 20, 22, ov::no_label}}; + {21, 0, 20, 22, 0}}; auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); - set_shape_labels(params.signal_size, 20); + auto symbols = set_shape_symbols(params.signal_size); auto param_of_shape = std::make_shared(element::f32, params.signal_size); auto signal_size_input = std::make_shared(param_of_shape, element::i64); @@ -558,21 +584,23 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_THAT(get_shape_symbols(dft->get_output_partial_shape(0)), + ElementsAre(symbols[1], nullptr, symbols[0], symbols[2], nullptr)); } -TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_single_label) { +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_single_symbol) { auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, {-1, {10, 16}, {6, 8}, 4, 2}, {2, 0, -1}, {{6, 8}, -1, 4}, - {ov::no_label, 11, 22, ov::no_label, ov::no_label}}; - ov::DimensionTracker::set_label(params.input_shape[1], 11); + {0, 11, 22, 0, 0}}; + auto A = make_shared(), B = make_shared(); + params.input_shape[1].set_symbol(A); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); - ov::DimensionTracker::set_label(params.signal_size[0], 22); + params.signal_size[0].set_symbol(B); auto param_of_shape = std::make_shared(element::f32, params.signal_size); auto signal_size_input = std::make_shared(param_of_shape, element::i64); @@ -582,16 +610,15 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_THAT(get_shape_symbols(dft->get_output_partial_shape(0)), ElementsAre(nullptr, A, B, nullptr, nullptr)); } -TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_no_labels) { - auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{ - {3, {10, 16}, 18, 20, 2}, - {-1, {10, 16}, {6, 8}, 4, 2}, - {2, 0, -1}, - {{6, 8}, -1, 4}, - {ov::no_label, ov::no_label, ov::no_label, ov::no_label, ov::no_label}}; +TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size_no_symbols) { + auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{3, {10, 16}, 18, 20, 2}, + {-1, {10, 16}, {6, 8}, 4, 2}, + {2, 0, -1}, + {{6, 8}, -1, 4}, + {0, 0, 0, 0, 0}}; auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); @@ -603,20 +630,20 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), + TensorSymbol({nullptr, nullptr, nullptr, nullptr, nullptr})); } TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_concat_signal_size) { auto params = FFTConstantAxesAndShapeOfSignalSizeTestParams{{4, {8, 16}, 24, -1, 2}, {{5, 10}, {8, 16}, -1, 40, 2}, {1, 0, -2, 3}, - {{5, 10}, -1, 40}, - {20, 11, 21, 22, 14}}; - set_shape_labels(params.input_shape, 10); + {{5, 10}, -1, 40}}; + auto input_symbols = set_shape_symbols(params.input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes); - set_shape_labels(params.signal_size, 20); + auto signal_symbols = set_shape_symbols(params.signal_size); auto param_of_shape = std::make_shared(element::f32, params.signal_size); auto shape_of = std::make_shared(param_of_shape, element::i64); auto minus_one = op::v0::Constant::create(element::i64, Shape{1}, {-1}); @@ -627,15 +654,17 @@ TYPED_TEST_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of EXPECT_EQ(dft->get_element_type(), element::f32); EXPECT_EQ(dft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(dft->get_output_partial_shape(0)), params.expected_labels); + auto output_symbols = + TensorSymbol{signal_symbols[0], input_symbols[1], signal_symbols[1], signal_symbols[2], input_symbols[4]}; + EXPECT_EQ(get_shape_symbols(dft->get_output_partial_shape(0)), output_symbols); } REGISTER_TYPED_TEST_SUITE_P(FFTConstantAxesAndShapeOfSignalSizeTest, constant_axes_and_shape_of_signal_size, - constant_axes_and_shape_of_signal_size_first_input_labels, - constant_axes_and_shape_of_signal_size_second_input_labels, - constant_axes_and_shape_of_signal_size_single_label, - constant_axes_and_shape_of_signal_size_no_labels, + constant_axes_and_shape_of_signal_size_first_input_symbols, + constant_axes_and_shape_of_signal_size_second_input_symbols, + constant_axes_and_shape_of_signal_size_single_symbol, + constant_axes_and_shape_of_signal_size_no_symbols, constant_axes_and_shape_of_concat_signal_size); INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, FFTConstantAxesAndShapeOfSignalSizeTest, FFTBaseTypes); diff --git a/src/core/tests/type_prop/gather.cpp b/src/core/tests/type_prop/gather.cpp index 3f075d3682c111..8570b985a969c6 100644 --- a/src/core/tests/type_prop/gather.cpp +++ b/src/core/tests/type_prop/gather.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/add.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" @@ -106,9 +105,10 @@ TEST(type_prop, gather_v1_negative_axis) { EXPECT_EQ(gather_v1->get_axis(), 1); } -TEST(type_prop, gather_1_dynamic_value_and_label_propagation) { +TEST(type_prop, gather_1_dynamic_value_and_symbol_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -125,7 +125,7 @@ TEST(type_prop, gather_1_dynamic_value_and_label_propagation) { EXPECT_EQ(bc->get_shape(), (Shape{3})); const auto& output_shape = bc->get_output_partial_shape(0); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + EXPECT_EQ(output_shape[0].get_symbol(), symbol); } TEST(type_prop, dynamic_value_propagation) { @@ -340,9 +340,10 @@ TEST(type_prop, gather_7_axis_not_set_positive_batch_dims) { EXPECT_EQ(G->get_output_partial_shape(0), out_shape); } -TEST(type_prop, gather_7_dynamic_value_and_label_propagation) { +TEST(type_prop, gather_7_dynamic_value_and_symbol_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -359,7 +360,7 @@ TEST(type_prop, gather_7_dynamic_value_and_label_propagation) { EXPECT_EQ(bc->get_shape(), (Shape{3})); const auto& output_shape = bc->get_output_partial_shape(0); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + EXPECT_EQ(output_shape[0].get_symbol(), symbol); } // --------------------- V7 Negative tests ------------------------------ @@ -667,10 +668,11 @@ TEST(type_prop, gather_v8_axis_not_set_positive_batch_dims) { EXPECT_EQ(G->get_output_partial_shape(0), out_shape); } -/** \brief Check usage of evaluate lower and label on shape inference. */ -TEST(type_prop, gather_v8_dynamic_value_and_label_propagation) { +/** \brief Check usage of evaluate lower and symbol on shape inference. */ +TEST(type_prop, gather_v8_dynamic_value_and_symbol_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -687,13 +689,14 @@ TEST(type_prop, gather_v8_dynamic_value_and_label_propagation) { EXPECT_EQ(bc->get_shape(), (Shape{3})); const auto& output_shape = bc->get_output_partial_shape(0); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + EXPECT_EQ(output_shape[0].get_symbol(), symbol); } -/** \brief Check usage of evaluate lower/upper and label on shape inference. */ -TEST(type_prop, gather_v8_dynamic_value_and_label_propagation_interval_dim) { +/** \brief Check usage of evaluate lower/upper and symbol on shape inference. */ +TEST(type_prop, gather_v8_dynamic_value_and_symbol_propagation_interval_dim) { Dimension marked_0 = Dimension(2, 4); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -710,7 +713,7 @@ TEST(type_prop, gather_v8_dynamic_value_and_label_propagation_interval_dim) { EXPECT_EQ(bc->get_output_partial_shape(0), PartialShape({marked_0})); const auto& output_shape = bc->get_output_partial_shape(0); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + EXPECT_EQ(output_shape[0].get_symbol(), symbol); } TEST(type_prop, gather_v8_use_default_ctor) { diff --git a/src/core/tests/type_prop/gather_elements.cpp b/src/core/tests/type_prop/gather_elements.cpp index 88afe6f459167e..d3ad38e2eb0305 100644 --- a/src/core/tests/type_prop/gather_elements.cpp +++ b/src/core/tests/type_prop/gather_elements.cpp @@ -5,7 +5,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/ops.hpp" using namespace std; @@ -167,12 +166,12 @@ TEST(type_prop, gather_elements_data_pshape_static_indices_rank_dynamic) { EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 7, 5})); } -TEST(type_prop, gather_elements_interval_dims_with_labels_both_inputs) { +TEST(type_prop, gather_elements_interval_dims_with_symbols_both_inputs) { PartialShape data_shape{-1, {2, 4}, {1, 5}, -1, {4, 8}, {2, 4}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{-1, {3, 6}, {6, 10}, {4, 8}, -1, {4, 6}}; - set_shape_labels(indices_shape, 20); + auto ind_symbols = set_shape_symbols(indices_shape); int64_t axis = 2; const auto data = make_shared(element::Type_t::f32, data_shape); @@ -182,12 +181,13 @@ TEST(type_prop, gather_elements_interval_dims_with_labels_both_inputs) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::Type_t::f32); EXPECT_EQ(out_shape, PartialShape({-1, {3, 4}, {6, 10}, {4, 8}, {4, 8}, 4})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, 22, 23, 24, 25)); + EXPECT_THAT(get_shape_symbols(out_shape), + ElementsAre(symbols[0], symbols[1], ind_symbols[2], symbols[3], symbols[4], symbols[5])); } -TEST(type_prop, gather_elements_interval_dims_with_labels_data) { +TEST(type_prop, gather_elements_interval_dims_with_symbols_data) { PartialShape data_shape{-1, {2, 4}, {1, 5}, -1, {4, 8}, {2, 4}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{-1, {3, 6}, {6, 10}, {4, 8}, -1, {4, 6}}; @@ -199,13 +199,14 @@ TEST(type_prop, gather_elements_interval_dims_with_labels_data) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::Type_t::f32); EXPECT_EQ(out_shape, PartialShape({-1, {3, 4}, {6, 10}, {4, 8}, {4, 8}, 4})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, 11, ov::no_label, 13, 14, 15)); + EXPECT_THAT(get_shape_symbols(out_shape), + ElementsAre(symbols[0], symbols[1], nullptr, symbols[3], symbols[4], symbols[5])); } -TEST(type_prop, gather_elements_interval_dims_with_labels_indices) { +TEST(type_prop, gather_elements_interval_dims_with_symbols_indices) { PartialShape data_shape{-1, {2, 4}, {1, 5}, -1, {4, 8}, {2, 4}}; PartialShape indices_shape{-1, {3, 6}, {6, 10}, {4, 8}, -1, {4, 6}}; - set_shape_labels(indices_shape, 20); + auto symbols = set_shape_symbols(indices_shape); int64_t axis = 2; const auto data = make_shared(element::Type_t::f32, data_shape); @@ -215,7 +216,7 @@ TEST(type_prop, gather_elements_interval_dims_with_labels_indices) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::Type_t::f32); EXPECT_EQ(out_shape, PartialShape({-1, {3, 4}, {6, 10}, {4, 8}, {4, 8}, 4})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, 22, 23, 24, 25)); + EXPECT_THAT(get_shape_symbols(out_shape), symbols); } // --------------------- Negative tests ------------------------------ diff --git a/src/core/tests/type_prop/gather_nd.cpp b/src/core/tests/type_prop/gather_nd.cpp index 4a82d2cf7f3a50..5a66f9001f21fe 100644 --- a/src/core/tests/type_prop/gather_nd.cpp +++ b/src/core/tests/type_prop/gather_nd.cpp @@ -5,7 +5,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/ops.hpp" using namespace std; @@ -88,12 +87,12 @@ TYPED_TEST_P(gather_nd_type_prop, static_shape_batch_dims_1_ind_tuple_dynamic) { EXPECT_EQ(op->get_output_partial_shape(0), expected_shape); } -TYPED_TEST_P(gather_nd_type_prop, interval_both_labeled_batch_dims_1_ind_tuple_2) { +TYPED_TEST_P(gather_nd_type_prop, interval_both_symboled_batch_dims_1_ind_tuple_2) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + auto data_symbols = set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 2}; - set_shape_labels(indices_shape, 20); + auto indices_symbols = set_shape_symbols(indices_shape); PartialShape expected_shape{{4, 6}, {6, 10}, {12, 14}}; @@ -106,12 +105,12 @@ TYPED_TEST_P(gather_nd_type_prop, interval_both_labeled_batch_dims_1_ind_tuple_2 const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, 13)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(data_symbols[0], indices_symbols[1], data_symbols[3])); } -TYPED_TEST_P(gather_nd_type_prop, interval_data_labeled_batch_dims_1_ind_tuple_2) { +TYPED_TEST_P(gather_nd_type_prop, interval_data_symboled_batch_dims_1_ind_tuple_2) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 2}; PartialShape expected_shape{{4, 6}, {6, 10}, {12, 14}}; @@ -125,13 +124,13 @@ TYPED_TEST_P(gather_nd_type_prop, interval_data_labeled_batch_dims_1_ind_tuple_2 const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, ov::no_label, 13)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], nullptr, symbols[3])); } -TYPED_TEST_P(gather_nd_type_prop, interval_indices_labeled_batch_dims_1_ind_tuple_2) { +TYPED_TEST_P(gather_nd_type_prop, interval_indices_symboled_batch_dims_1_ind_tuple_2) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; PartialShape indices_shape{{4, 8}, {6, 10}, 2}; - set_shape_labels(indices_shape, 20); + auto symbols = set_shape_symbols(indices_shape); PartialShape expected_shape{{4, 6}, {6, 10}, {12, 14}}; @@ -144,7 +143,7 @@ TYPED_TEST_P(gather_nd_type_prop, interval_indices_labeled_batch_dims_1_ind_tupl const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1], nullptr)); } REGISTER_TYPED_TEST_SUITE_P(gather_nd_type_prop, @@ -152,9 +151,9 @@ REGISTER_TYPED_TEST_SUITE_P(gather_nd_type_prop, static_shape_batch_dims_1_ind_tuple_2, static_shape_batch_dims_1_ind_tuple_3, static_shape_batch_dims_1_ind_tuple_dynamic, - interval_both_labeled_batch_dims_1_ind_tuple_2, - interval_data_labeled_batch_dims_1_ind_tuple_2, - interval_indices_labeled_batch_dims_1_ind_tuple_2); + interval_both_symboled_batch_dims_1_ind_tuple_2, + interval_data_symboled_batch_dims_1_ind_tuple_2, + interval_indices_symboled_batch_dims_1_ind_tuple_2); typedef Types GatherNDTypes; INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, gather_nd_type_prop, GatherNDTypes); @@ -411,12 +410,12 @@ TEST(type_prop, gather_nd_v5_batch_2d_from_3d) { ASSERT_EQ(op->get_shape(), expected_shape); } -TEST(type_prop, gather_nd_v5_interval_both_labeled_batch_dims_2_ind_tuple_2) { +TEST(type_prop, gather_nd_v5_interval_both_symboled_batch_dims_2_ind_tuple_2) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 2}; - set_shape_labels(indices_shape, 20); + set_shape_symbols(indices_shape); PartialShape expected_shape{{24, 42}}; @@ -429,15 +428,15 @@ TEST(type_prop, gather_nd_v5_interval_both_labeled_batch_dims_2_ind_tuple_2) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(nullptr)); } -TEST(type_prop, gather_nd_v5_interval_both_labeled_batch_dims_2_ind_tuple_1) { +TEST(type_prop, gather_nd_v5_interval_both_symboled_batch_dims_2_ind_tuple_1) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 1}; - set_shape_labels(indices_shape, 20); + set_shape_symbols(indices_shape); PartialShape expected_shape{{24, 42}, {12, 14}}; @@ -450,7 +449,7 @@ TEST(type_prop, gather_nd_v5_interval_both_labeled_batch_dims_2_ind_tuple_1) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(ov::no_label, 13)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(nullptr, symbols[3])); } TEST(type_prop, gather_nd_v5_fail_params_rank) { @@ -585,12 +584,12 @@ TEST(type_prop, gather_nd_v8_batch_dim0_with_dyn_ind_dim) { ASSERT_TRUE(op->get_output_partial_shape(0).same_scheme(PartialShape::dynamic())); } -TEST(type_prop, gather_nd_v8_interval_both_labeled_batch_dims_2_ind_tuple_2) { +TEST(type_prop, gather_nd_v8_interval_both_symboled_batch_dims_2_ind_tuple_2) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 2}; - set_shape_labels(indices_shape, 20); + set_shape_symbols(indices_shape); PartialShape expected_shape{{4, 6}, {6, 7}}; @@ -603,15 +602,15 @@ TEST(type_prop, gather_nd_v8_interval_both_labeled_batch_dims_2_ind_tuple_2) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1])); } -TEST(type_prop, gather_nd_v8_interval_both_labeled_batch_dims_2_ind_tuple_1) { +TEST(type_prop, gather_nd_v8_interval_both_symboled_batch_dims_2_ind_tuple_1) { PartialShape data_shape{{2, 6}, {3, 7}, {8, 10}, {12, 14}}; - set_shape_labels(data_shape, 10); + auto data_symbols = set_shape_symbols(data_shape); PartialShape indices_shape{{4, 8}, {6, 10}, 1}; - set_shape_labels(indices_shape, 20); + auto indices_symbols = set_shape_symbols(indices_shape); PartialShape expected_shape{{4, 6}, {6, 7}, {12, 14}}; @@ -624,7 +623,7 @@ TEST(type_prop, gather_nd_v8_interval_both_labeled_batch_dims_2_ind_tuple_1) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, 13)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(data_symbols[0], data_symbols[1], data_symbols[3])); } TEST(type_prop, gather_nd_v8_fail_batch_dims_greater_indices_rank) { diff --git a/src/core/tests/type_prop/gather_tree.cpp b/src/core/tests/type_prop/gather_tree.cpp index 1c2f034836d0e4..dbda6bf1cb533f 100644 --- a/src/core/tests/type_prop/gather_tree.cpp +++ b/src/core/tests/type_prop/gather_tree.cpp @@ -8,7 +8,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/ops.hpp" using namespace std; @@ -316,13 +315,13 @@ TEST(type_prop, gather_tree_invalid_end_token_rank) { TEST(type_prop, gather_tree_interval_labeled_dims_all) { auto step_ids_shape = PartialShape{{2, 5}, {4, 8}, {3, 6}}; - set_shape_labels(step_ids_shape, 10); + auto symbols = set_shape_symbols(step_ids_shape); auto parent_ids_shape = PartialShape{{3, 7}, {3, 7}, {1, 4}}; - set_shape_labels(parent_ids_shape, 20); + set_shape_symbols(parent_ids_shape); auto max_seq_len_shape = PartialShape{{2, 6}}; - set_shape_labels(max_seq_len_shape, 30); + set_shape_symbols(max_seq_len_shape); auto step_ids = std::make_shared(element::i32, step_ids_shape); auto parent_ids = std::make_shared(element::i32, parent_ids_shape); @@ -334,12 +333,12 @@ TEST(type_prop, gather_tree_interval_labeled_dims_all) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(out_shape, (PartialShape{{3, 5}, {4, 6}, {3, 4}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 30, 22)); + EXPECT_THAT(get_shape_symbols(out_shape), symbols); } TEST(type_prop, gather_tree_interval_labeled_dims_step_ids) { auto step_ids_shape = PartialShape{{2, 5}, {4, 8}, {3, 6}}; - set_shape_labels(step_ids_shape, 10); + auto symbols = set_shape_symbols(step_ids_shape); auto parent_ids_shape = PartialShape{{3, 7}, {3, 7}, {1, 4}}; auto max_seq_len_shape = PartialShape{{2, 6}}; @@ -354,13 +353,13 @@ TEST(type_prop, gather_tree_interval_labeled_dims_step_ids) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(out_shape, (PartialShape{{3, 5}, {4, 6}, {3, 4}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(out_shape), symbols); } TEST(type_prop, gather_tree_interval_labeled_dims_parent_ids) { auto step_ids_shape = PartialShape{{2, 5}, {4, 8}, {3, 6}}; auto parent_ids_shape = PartialShape{{3, 7}, {3, 7}, {1, 4}}; - set_shape_labels(parent_ids_shape, 20); + auto symbols = set_shape_symbols(parent_ids_shape); auto max_seq_len_shape = PartialShape{{2, 6}}; @@ -374,14 +373,14 @@ TEST(type_prop, gather_tree_interval_labeled_dims_parent_ids) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(out_shape, (PartialShape{{3, 5}, {4, 6}, {3, 4}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, 21, 22)); + EXPECT_THAT(get_shape_symbols(out_shape), symbols); } TEST(type_prop, gather_tree_interval_labeled_dims_seq_len) { auto step_ids_shape = PartialShape{{2, 5}, {4, 8}, {3, 6}}; auto parent_ids_shape = PartialShape{{3, 7}, {3, 7}, {1, 4}}; auto max_seq_len_shape = PartialShape{{2, 6}}; - set_shape_labels(max_seq_len_shape, 30); + auto symbols = set_shape_symbols(max_seq_len_shape); auto step_ids = std::make_shared(element::i32, step_ids_shape); auto parent_ids = std::make_shared(element::i32, parent_ids_shape); @@ -393,5 +392,5 @@ TEST(type_prop, gather_tree_interval_labeled_dims_seq_len) { const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_output_element_type(0), element::i32); EXPECT_EQ(out_shape, (PartialShape{{3, 5}, {4, 6}, {3, 4}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(ov::no_label, 30, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(nullptr, symbols[0], nullptr)); } diff --git a/src/core/tests/type_prop/generate_proposals.cpp b/src/core/tests/type_prop/generate_proposals.cpp index 0b88c1bc8b1af6..4e259ad361d726 100644 --- a/src/core/tests/type_prop/generate_proposals.cpp +++ b/src/core/tests/type_prop/generate_proposals.cpp @@ -274,18 +274,20 @@ TEST(type_prop, generate_proposals_dynamic) { attrs.pre_nms_count = 1000; if (s.im_info_shape.rank().is_static()) - set_shape_labels(s.im_info_shape, 10); + set_shape_symbols(s.im_info_shape); if (s.anchors_shape.rank().is_static()) - set_shape_labels(s.anchors_shape, 20); + set_shape_symbols(s.anchors_shape); if (s.deltas_shape.rank().is_static()) - set_shape_labels(s.deltas_shape, 30); + set_shape_symbols(s.deltas_shape); if (s.scores_shape.rank().is_static()) - set_shape_labels(s.scores_shape, 40); + set_shape_symbols(s.scores_shape); - ov::label_t expected_batch_label = - s.im_info_shape.rank().is_static() - ? 10 - : s.deltas_shape.rank().is_static() ? 30 : s.scores_shape.rank().is_static() ? 40 : ov::no_label; + auto expected_batch_label = + s.scores_shape.rank().is_static() + ? s.scores_shape[0].get_symbol() + : s.deltas_shape.rank().is_static() + ? s.deltas_shape[0].get_symbol() + : s.im_info_shape.rank().is_static() ? s.im_info_shape[0].get_symbol() : nullptr; auto im_info = std::make_shared(element::f32, s.im_info_shape); auto anchors = std::make_shared(element::f32, s.anchors_shape); @@ -301,8 +303,8 @@ TEST(type_prop, generate_proposals_dynamic) { EXPECT_EQ(proposals->get_output_partial_shape(0), s.expected_shape_0); EXPECT_EQ(proposals->get_output_partial_shape(1), s.expected_shape_1); EXPECT_EQ(proposals->get_output_partial_shape(2), s.expected_shape_2); - EXPECT_THAT(get_shape_labels(proposals->get_output_partial_shape(0)), ElementsAre(ov::no_label, ov::no_label)); - EXPECT_THAT(get_shape_labels(proposals->get_output_partial_shape(1)), ElementsAre(ov::no_label)); - EXPECT_THAT(get_shape_labels(proposals->get_output_partial_shape(2)), ElementsAre(expected_batch_label)); + EXPECT_THAT(get_shape_symbols(proposals->get_output_partial_shape(0)), ElementsAre(nullptr, nullptr)); + EXPECT_THAT(get_shape_symbols(proposals->get_output_partial_shape(1)), ElementsAre(nullptr)); + EXPECT_THAT(get_shape_symbols(proposals->get_output_partial_shape(2)), ElementsAre(expected_batch_label)); } } diff --git a/src/core/tests/type_prop/grid_sample.cpp b/src/core/tests/type_prop/grid_sample.cpp index 15927c178975c0..ccf20b50107129 100644 --- a/src/core/tests/type_prop/grid_sample.cpp +++ b/src/core/tests/type_prop/grid_sample.cpp @@ -5,7 +5,6 @@ #include #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/util/attr_types.hpp" #include "openvino/opsets/opset9.hpp" @@ -62,18 +61,19 @@ TEST(type_prop, grid_sample_dynamic_batch) { TEST(type_prop, grid_sample_interval_dims_and_labels) { auto data_pshape = PartialShape{{2, 4}, {1, 3}, 128, 256}; - set_shape_labels(data_pshape, 10); + auto data_symbols = set_shape_symbols(data_pshape); const auto data = make_shared(element::i32, data_pshape); auto grid_pshape = PartialShape{{3, 8}, {4, 6}, {5, 7}, 2}; - set_shape_labels(grid_pshape, 20); + auto grid_symbols = set_shape_symbols(grid_pshape); const auto grid = make_shared(element::f32, grid_pshape); const auto grid_sample = make_shared(data, grid, opset9::GridSample::Attributes{}); const auto& out_shape = grid_sample->get_output_partial_shape(0); EXPECT_EQ(out_shape, (PartialShape{{3, 4}, {1, 3}, {4, 6}, {5, 7}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, 11, 21, 22)); + EXPECT_THAT(get_shape_symbols(out_shape), + ElementsAre(grid_symbols[0], data_symbols[1], grid_symbols[1], grid_symbols[2])); } TEST(type_prop, grid_sample_static_batch_data_labeled_dynamic_grid_batch) { @@ -81,19 +81,19 @@ TEST(type_prop, grid_sample_static_batch_data_labeled_dynamic_grid_batch) { const auto data = make_shared(element::i32, data_pshape); auto grid_pshape = PartialShape{-1, {4, 6}, {5, 7}, 2}; - set_shape_labels(grid_pshape, 20); + auto symbols = set_shape_symbols(grid_pshape); const auto grid = make_shared(element::f32, grid_pshape); const auto grid_sample = make_shared(data, grid, opset9::GridSample::Attributes{}); const auto& out_shape = grid_sample->get_output_partial_shape(0); EXPECT_EQ(out_shape, (PartialShape{2, {1, 3}, {4, 6}, {5, 7}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, ov::no_label, 21, 22)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], nullptr, symbols[1], symbols[2])); } TEST(type_prop, grid_sample_labeled_dynamic_batch_data_labeled_static_grid_batch) { auto data_pshape = PartialShape{-1, {1, 3}, 224, 224}; - set_shape_labels(data_pshape, 10); + auto symbols = set_shape_symbols(data_pshape); const auto data = make_shared(element::i32, data_pshape); auto grid_pshape = PartialShape{2, Dimension(4, 6), Dimension(5, 7), 2}; @@ -103,12 +103,12 @@ TEST(type_prop, grid_sample_labeled_dynamic_batch_data_labeled_static_grid_batch const auto& out_shape = grid_sample->get_output_partial_shape(0); EXPECT_EQ(out_shape, (PartialShape{2, {1, 3}, {4, 6}, {5, 7}})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST(type_prop, grid_sample_labeled_interval_batch_data_dynamic_grid_batch) { auto data_pshape = PartialShape{{2, 4}, 3, 224, 224}; - set_shape_labels(data_pshape, 10); + auto symbols = set_shape_symbols(data_pshape); const auto data = make_shared(element::i32, data_pshape); auto grid_pshape = PartialShape{-1, 6, 7, 2}; @@ -118,7 +118,7 @@ TEST(type_prop, grid_sample_labeled_interval_batch_data_dynamic_grid_batch) { const auto& out_shape = grid_sample->get_output_partial_shape(0); EXPECT_EQ(out_shape, (PartialShape{{2, 4}, 3, 6, 7})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST(type_prop, grid_sample_dynamic_batch_data_labeled_interval_grid_batch) { @@ -126,14 +126,14 @@ TEST(type_prop, grid_sample_dynamic_batch_data_labeled_interval_grid_batch) { const auto data = make_shared(element::i32, data_pshape); auto grid_pshape = PartialShape{{2, 4}, 6, 7, 2}; - set_shape_labels(grid_pshape, 20); + auto symbols = set_shape_symbols(grid_pshape); const auto grid = make_shared(element::f32, grid_pshape); const auto grid_sample = make_shared(data, grid, opset9::GridSample::Attributes{}); const auto& out_shape = grid_sample->get_output_partial_shape(0); EXPECT_EQ(out_shape, (PartialShape{{2, 4}, 3, 6, 7})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(20, ov::no_label, 21, 22)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], nullptr, symbols[1], symbols[2])); } TEST(type_prop, grid_sample_dynamic_output_spatials) { diff --git a/src/core/tests/type_prop/group_convolution.cpp b/src/core/tests/type_prop/group_convolution.cpp index 09cc4910933a93..cb6f4f69a87c32 100644 --- a/src/core/tests/type_prop/group_convolution.cpp +++ b/src/core/tests/type_prop/group_convolution.cpp @@ -16,8 +16,8 @@ using namespace testing; TEST(type_prop, group_convolution_auto_padding_same_lower) { PartialShape data_batch_pshape{1, 4, 5, 5}; PartialShape filters_pshape{2, 1, 2, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto data_symbols = set_shape_symbols(data_batch_pshape); + auto filter_symbols = set_shape_symbols(filters_pshape); element::Type_t et = element::f32; Strides strides{1, 1}; CoordinateDiff pads_begin{0, 0}; @@ -31,8 +31,8 @@ TEST(type_prop, group_convolution_auto_padding_same_lower) { auto groupConv = make_shared(data_batch, filters, strides, pads_begin, pads_end, dilations, auto_pad); - EXPECT_THAT(get_shape_labels(groupConv->get_output_partial_shape(0)), - ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(groupConv->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], filter_symbols[0], nullptr, nullptr)); ASSERT_EQ(groupConv->get_output_partial_shape(0), PartialShape({1, 2, 5, 5})); ASSERT_EQ(groupConv->get_pads_begin(), (CoordinateDiff{1, 1})); ASSERT_EQ(groupConv->get_pads_end(), (CoordinateDiff{1, 1})); @@ -83,8 +83,8 @@ TEST(type_prop, group_convolution_auto_padding_same_lower_spatial_dims_static) { TEST(type_prop, group_convolution_auto_padding_same_upper_spatial_dims_static) { PartialShape data_batch_pshape{1, Dimension::dynamic(), 5, 5}; PartialShape filters_pshape{Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic(), 2, 2}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto data_symbols = set_shape_symbols(data_batch_pshape); + auto filter_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::SAME_UPPER; @@ -98,8 +98,8 @@ TEST(type_prop, group_convolution_auto_padding_same_upper_spatial_dims_static) { Strides{}, auto_pad); - EXPECT_THAT(get_shape_labels(groupConv->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(groupConv->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], nullptr, nullptr, nullptr)); ASSERT_EQ(groupConv->get_output_partial_shape(0), PartialShape({1, Dimension::dynamic(), 5, 5})); ASSERT_EQ(groupConv->get_pads_begin(), (CoordinateDiff{0, 0})); ASSERT_EQ(groupConv->get_pads_end(), (CoordinateDiff{1, 1})); @@ -108,8 +108,8 @@ TEST(type_prop, group_convolution_auto_padding_same_upper_spatial_dims_static) { TEST(type_prop, group_convolution_static_ranks_filters_groups_dyn) { PartialShape data_batch_pshape{Dimension::dynamic(), 4, 5, 5}; PartialShape filters_pshape{Dimension::dynamic(), 1, 2, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto data_symbols = set_shape_symbols(data_batch_pshape); + auto filter_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::SAME_LOWER; @@ -123,8 +123,8 @@ TEST(type_prop, group_convolution_static_ranks_filters_groups_dyn) { CoordinateDiff{}, Strides{}, auto_pad); - EXPECT_THAT(get_shape_labels(groupConv->get_output_partial_shape(0)), - ElementsAre(10, 20, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(groupConv->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], filter_symbols[0], nullptr, nullptr)); ASSERT_EQ(groupConv->get_output_partial_shape(0), PartialShape({Dimension::dynamic(), 2, 5, 5})); ASSERT_EQ(groupConv->get_pads_begin(), (CoordinateDiff{1, 1})); ASSERT_EQ(groupConv->get_pads_end(), (CoordinateDiff{1, 1})); @@ -513,8 +513,8 @@ TEST(type_prop, group_convolution_invalid_conv_param_spatial_dims) { TEST(type_prop, group_convolution_interval_shapes) { PartialShape data_batch_pshape{{1, 3}, {2, 6}, {1, 5}, {3, 10}, {20, 100}}; PartialShape filters_pshape{{2, 3}, {1, 3}, {2, 3}, 3, 3, 3}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto data_symbols = set_shape_symbols(data_batch_pshape); + set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::EXPLICIT; @@ -528,8 +528,8 @@ TEST(type_prop, group_convolution_interval_shapes) { CoordinateDiff{}, Strides{}, auto_pad); - EXPECT_THAT(get_shape_labels(groupConv->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(groupConv->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], nullptr, nullptr, nullptr, nullptr)); EXPECT_EQ(groupConv->get_output_partial_shape(0), PartialShape({{1, 3}, {2, 9}, {1, 3}, {1, 8}, {18, 98}})); EXPECT_EQ(groupConv->get_pads_begin(), (CoordinateDiff{0, 0, 0})); EXPECT_EQ(groupConv->get_pads_end(), (CoordinateDiff{0, 0, 0})); diff --git a/src/core/tests/type_prop/group_convolution_backprop_data.cpp b/src/core/tests/type_prop/group_convolution_backprop_data.cpp index 2fa75a1ae94156..66a1b35f6d35aa 100644 --- a/src/core/tests/type_prop/group_convolution_backprop_data.cpp +++ b/src/core/tests/type_prop/group_convolution_backprop_data.cpp @@ -159,8 +159,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_with_output_shape_st TEST(type_prop, group_convolution_backprop_data_shape_infer_with_output_shape_static_ranks_filters_group_cout_dyn) { PartialShape data_pshape{Dimension::dynamic(), 16, 5, 5}; // [N, C_IN * GROUPS, H, W] PartialShape filters_pshape{Dimension::dynamic(), 16, Dimension::dynamic(), 3, 3}; // [GROUPS, C_IN, C_OUT, kH, kW] - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto data_symbols = set_shape_symbols(data_pshape); + auto filter_symbols = set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; auto data = make_shared(et, data_pshape); @@ -173,7 +173,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_with_output_shape_st Strides{}, op::PadType::SAME_UPPER); - EXPECT_THAT(get_shape_labels(gcbd->get_output_partial_shape(0)), ElementsAre(10, 22, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(gcbd->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], filter_symbols[2], nullptr, nullptr)); ASSERT_EQ(gcbd->get_output_partial_shape(0), (PartialShape{Dimension::dynamic(), Dimension::dynamic(), 3, 3})); } @@ -272,8 +273,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_data_ci TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_filters_group_cout_dyn) { PartialShape data_pshape{1, 20, 224, 224}; // [N, C_IN * GROUPS, H, W] PartialShape filters_pshape{Dimension::dynamic(), Dimension::dynamic(), 2, 3, 3}; // [GROUPS, C_IN, C_OUT, kH, kW] - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto symbols = set_shape_symbols(data_pshape); + set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const Strides strides{2, 2}; @@ -289,8 +290,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_filters padding_begin, padding_end, dilations); - EXPECT_THAT(get_shape_labels(gcbd->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(gcbd->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); ASSERT_EQ(gcbd->get_output_partial_shape(0), (PartialShape{1, Dimension::dynamic(), 447, 447})); } @@ -319,8 +320,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_data_sp TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_filters_spatial_dim_dyn) { PartialShape data_pshape{Dimension::dynamic(), 20, 224, Dimension::dynamic()}; // [N, C_IN * GROUPS, H, W] PartialShape filters_pshape{4, 5, 2, 3, 3}; // [GROUPS, C_IN, C_OUT, kH, kW] - set_shape_labels(data_pshape, 10); - set_shape_labels(filters_pshape, 20); + auto symbols = set_shape_symbols(data_pshape); + set_shape_symbols(filters_pshape); const element::Type_t et = element::f32; const Strides strides{2, 2}; @@ -337,8 +338,8 @@ TEST(type_prop, group_convolution_backprop_data_shape_infer_static_ranks_filters padding_end, dilations); - EXPECT_THAT(get_shape_labels(gcbd->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(gcbd->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); ASSERT_EQ(gcbd->get_output_partial_shape(0), (PartialShape{Dimension::dynamic(), 8, 447, Dimension(1, -1)})); } @@ -867,9 +868,9 @@ TEST(type_prop, group_convolution_backprop_data_interval_shapes) { PartialShape data_batch_pshape{{1, 3}, {2, 6}, {1, 5}, {3, 10}, {20, 100}}; PartialShape filters_pshape{{2, 3}, {1, 3}, 1, 3, 3, 3}; PartialShape out_spatial_pshape{{2, 3}, -1, 10}; - set_shape_labels(data_batch_pshape, 10); - set_shape_labels(filters_pshape, 20); - set_shape_labels(out_spatial_pshape, 30); + auto data_symbols = set_shape_symbols(data_batch_pshape); + auto filter_symbols = set_shape_symbols(filters_pshape); + auto out_symbols = set_shape_symbols(out_spatial_pshape); const element::Type_t et = element::f32; const auto auto_pad = op::PadType::SAME_LOWER; @@ -887,7 +888,8 @@ TEST(type_prop, group_convolution_backprop_data_interval_shapes) { Strides{}, auto_pad); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 20, 30, 31, 32)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], filter_symbols[0], out_symbols[0], out_symbols[1], out_symbols[2])); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{1, 3}, {2, 3}, {2, 3}, -1, 10})); EXPECT_EQ(op->get_pads_begin(), (CoordinateDiff{0, 0, 0})); EXPECT_EQ(op->get_pads_end(), (CoordinateDiff{0, 0, 0})); diff --git a/src/core/tests/type_prop/group_normalization.cpp b/src/core/tests/type_prop/group_normalization.cpp index 1eaa24d315a1b5..0d0c069e43894a 100644 --- a/src/core/tests/type_prop/group_normalization.cpp +++ b/src/core/tests/type_prop/group_normalization.cpp @@ -22,19 +22,19 @@ TEST(type_prop, group_normalization_basic) { EXPECT_EQ(gn->get_shape(), (Shape{1, 12, 6, 6})); } -TEST(type_prop, group_normalization_labels) { +TEST(type_prop, group_normalization_symbols) { auto data_shape = PartialShape{1, 12, 6, 6}; auto scale_shape = PartialShape{12}; auto bias_shape = PartialShape{12}; - set_shape_labels(data_shape, 43); - set_shape_labels(scale_shape, 100); - set_shape_labels(bias_shape, 200); + auto symbols = set_shape_symbols(data_shape); + set_shape_symbols(scale_shape); + set_shape_symbols(bias_shape); const auto data = std::make_shared(element::f32, data_shape); const auto scale = std::make_shared(element::f32, scale_shape); const auto bias = std::make_shared(element::f32, bias_shape); const auto gn = std::make_shared(data, scale, bias, 4, 0.00001f); - EXPECT_THAT(get_shape_labels(gn->get_output_partial_shape(0)), ElementsAre(43, 44, 45, 46)); + EXPECT_THAT(get_shape_symbols(gn->get_output_partial_shape(0)), symbols); } TEST(type_prop, group_normalization_dynamic_channels) { @@ -101,9 +101,9 @@ TEST(type_prop, group_normalization_dynamic_intervals) { auto data_shape = PartialShape{2, Dimension{10, 20}, 6, 6}; auto scale_shape = PartialShape{Dimension{10, 20}}; auto bias_shape = PartialShape{Dimension{10, 20}}; - set_shape_labels(data_shape, 42); - set_shape_labels(scale_shape, 21); - set_shape_labels(bias_shape, 37); + auto symbols = set_shape_symbols(data_shape); + set_shape_symbols(scale_shape); + set_shape_symbols(bias_shape); const auto data = std::make_shared(element::f32, data_shape); const auto scale = std::make_shared(element::f32, scale_shape); const auto bias = std::make_shared(element::f32, bias_shape); @@ -111,7 +111,7 @@ TEST(type_prop, group_normalization_dynamic_intervals) { const auto gn = std::make_shared(data, scale, bias, 2, 0.00001f); EXPECT_EQ(gn->get_element_type(), element::f32); EXPECT_EQ(gn->get_output_partial_shape(0), (PartialShape{2, Dimension{10, 20}, 6, 6})); - EXPECT_THAT(get_shape_labels(gn->get_output_partial_shape(0)), ElementsAre(42, 43, 44, 45)); + EXPECT_THAT(get_shape_symbols(gn->get_output_partial_shape(0)), symbols); } TEST(type_prop, group_normalization_incorrect_scale_shape) { diff --git a/src/core/tests/type_prop/interpolate.cpp b/src/core/tests/type_prop/interpolate.cpp index 5dded3427f39b9..33fff5250a6e4d 100644 --- a/src/core/tests/type_prop/interpolate.cpp +++ b/src/core/tests/type_prop/interpolate.cpp @@ -36,7 +36,7 @@ TEST(type_prop, interpolate_v0_default_ctor) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_shape(), (Shape{2, 2, 15, 30})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v0_all_inputs_dynamic_rank) { @@ -87,8 +87,8 @@ TEST(type_prop, interpolate_v0_target_shape_not_constant) { TEST(type_prop, interpolate_v0_target_shape_as_shape_of) { auto img_shape = PartialShape{{1, 2}, 10, 10, {5, 30}}; auto out_shape = PartialShape{{2, 4}, -1}; - set_shape_labels(img_shape, 10); - set_shape_labels(out_shape, 20); + auto img_symbols = set_shape_symbols(img_shape); + auto out_symbols = set_shape_symbols(out_shape); auto image = std::make_shared(element::f64, img_shape); auto target_shape = @@ -102,7 +102,8 @@ TEST(type_prop, interpolate_v0_target_shape_as_shape_of) { EXPECT_EQ(interp->get_element_type(), element::f64); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({{1, 2}, {2, 4}, 10, -1})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), ElementsAre(10, 20, 12, 21)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(img_symbols[0], out_symbols[0], img_symbols[2], out_symbols[1])); } // --- v4 --- @@ -129,7 +130,7 @@ TEST(type_prop, interpolate_v4_default_ctor) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_shape(), (Shape{2, 2, 15, 30})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v4) { @@ -151,12 +152,12 @@ TEST(type_prop, interpolate_v4) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_shape(), (Shape{2, 2, 15, 30})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v4_non_constant_axes_scales) { auto img_shape = PartialShape{2, 2, 30, 60}; - set_shape_labels(img_shape, 10); + set_shape_symbols(img_shape); auto image = std::make_shared(element::f16, img_shape); auto target_shape = std::make_shared(element::i64, Shape{}); @@ -176,12 +177,12 @@ TEST(type_prop, interpolate_v4_non_constant_axes_scales) { EXPECT_EQ(interp->get_element_type(), element::f16); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape::dynamic(4)); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v4_non_constant_axes_sizes) { auto img_shape = PartialShape{2, 2, 30, 60}; - set_shape_labels(img_shape, 10); + set_shape_symbols(img_shape); auto image = std::make_shared(element::bf16, img_shape); auto target_shape = std::make_shared(element::i64, Shape{2}); @@ -202,7 +203,7 @@ TEST(type_prop, interpolate_v4_non_constant_axes_sizes) { EXPECT_EQ(interp->get_element_type(), element::bf16); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape::dynamic(4)); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v4_img_dynamic_rank) { @@ -228,7 +229,7 @@ TEST(type_prop, interpolate_v4_img_dynamic_rank) { TEST(type_prop, interpolate_v4_partial_static_rank) { auto img_shape = PartialShape{2, 2, -1, {5, 30}}; - set_shape_labels(img_shape, 10); + auto symbols = set_shape_symbols(img_shape); auto image = std::make_shared(element::f32, img_shape); auto target_shape = std::make_shared(element::i32, Shape{2}); @@ -248,13 +249,13 @@ TEST(type_prop, interpolate_v4_partial_static_rank) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({2, 4, -1, {2, 15}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, interpolate_v4_img_intervals_use_scales) { auto img_shape = PartialShape{{1, 2}, -1, 10, {5, 30}}; - set_shape_labels(img_shape, 10); + set_shape_symbols(img_shape); auto image = std::make_shared(element::f32, img_shape); auto target_shape = std::make_shared(element::i32, Shape{2}); @@ -274,14 +275,14 @@ TEST(type_prop, interpolate_v4_img_intervals_use_scales) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({{2, 3}, {1, -1}, 5, {3, 16}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v4_use_sizes_as_shape_of) { auto img_shape = PartialShape{{1, 2}, 10, 10, {5, 30}}; auto out_shape = PartialShape{{2, 4}, -1}; - set_shape_labels(img_shape, 10); - set_shape_labels(out_shape, 20); + auto img_symbols = set_shape_symbols(img_shape); + auto out_symbols = set_shape_symbols(out_shape); auto image = std::make_shared(element::f32, img_shape); auto target_shape = @@ -302,12 +303,13 @@ TEST(type_prop, interpolate_v4_use_sizes_as_shape_of) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({{1, 2}, -1, 10, {2, 4}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), ElementsAre(10, 21, 12, 20)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(img_symbols[0], out_symbols[1], img_symbols[2], out_symbols[0])); } TEST(type_prop, interpolate_v4_use_scales_interval_shapes) { auto img_shape = PartialShape{2, 2, {12, 800}, {0, -1}, {24, -1}}; - set_shape_labels(img_shape, 10); + auto symbols = set_shape_symbols(img_shape); auto image = std::make_shared(element::f32, img_shape); auto target_shape = std::make_shared(element::i32, Shape{3}); @@ -327,8 +329,8 @@ TEST(type_prop, interpolate_v4_use_scales_interval_shapes) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({2, 2, {6, 400}, -1, {3, -1}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), - ElementsAre(10, 11, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr, nullptr)); } TEST(type_prop, interpolate_v4_target_shapes_gt_axes_number) { @@ -495,7 +497,7 @@ TEST(type_prop, interpolate_v11_default_ctor) { EXPECT_EQ(interp->get_element_type(), element::f32); EXPECT_EQ(interp->get_shape(), (Shape{2, 4, 6, 12})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v11_scales) { @@ -560,7 +562,7 @@ TEST(type_prop, interpolate_v11_sizes_all_inputs_dynamic_rank) { TEST(type_prop, interpolate_v11_intervals_with_scales_mode) { auto img_shape = PartialShape{{1, 3}, 3, {1, 10}, {10, -1}, {10, 20}}; - set_shape_labels(img_shape, 10); + auto symbols = set_shape_symbols(img_shape); const auto image = std::make_shared(element::f32, img_shape); const auto scales = ov::op::v0::Constant::create(element::f32, Shape{3}, {2.0f, 3.0f, 1.0f}); @@ -573,13 +575,13 @@ TEST(type_prop, interpolate_v11_intervals_with_scales_mode) { auto interp = std::make_shared(image, scales, axes, attrs); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({{2, 4}, 6, {4, 22}, {33, -1}, {10, 20}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, ov::no_label, 14)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, nullptr, symbols[4])); } TEST(type_prop, interpolate_v11_intervals_with_sizes_mode) { auto img_shape = PartialShape{{1, 3}, 3, {1, 10}, {10, -1}}; - set_shape_labels(img_shape, 10); + auto symbols = set_shape_symbols(img_shape); const auto image = std::make_shared(element::f32, img_shape); const auto sizes = ov::op::v0::Constant::create(element::i32, Shape{2}, {200, 300}); @@ -592,14 +594,15 @@ TEST(type_prop, interpolate_v11_intervals_with_sizes_mode) { auto interp = std::make_shared(image, sizes, axes, attrs); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape({{1, 3}, 3, 200, 300})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TEST(type_prop, interpolate_v11_sizes_with_shapeof) { auto img_shape = PartialShape{{1, 3}, 3, {1, 10}, {10, -1}}; auto sizes_shape = PartialShape{{12, 37}, {0, 21}}; - set_shape_labels(img_shape, 10); - set_shape_labels(sizes_shape, 20); + auto img_symbols = set_shape_symbols(img_shape); + auto sizes_symbols = set_shape_symbols(sizes_shape); const auto image = std::make_shared(element::f32, img_shape); const auto param = std::make_shared(element::f32, sizes_shape); @@ -613,12 +616,13 @@ TEST(type_prop, interpolate_v11_sizes_with_shapeof) { auto interp = std::make_shared(image, sizes, axes, attrs); EXPECT_EQ(interp->get_output_partial_shape(0), (PartialShape{{1, 3}, {0, 21}, {12, 37}, {10, -1}})); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), ElementsAre(10, 21, 20, 13)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), + ElementsAre(img_symbols[0], sizes_symbols[1], sizes_symbols[0], img_symbols[3])); } TEST(type_prop, interpolate_v11_non_constant_axes_scales) { auto img_shape = PartialShape{2, 2, 30, 60}; - set_shape_labels(img_shape, 10); + set_shape_symbols(img_shape); auto image = std::make_shared(element::f16, img_shape); auto scales = ov::op::v0::Constant::create(element::f32, Shape{2}, {0.5f, 0.5f}); @@ -632,7 +636,7 @@ TEST(type_prop, interpolate_v11_non_constant_axes_scales) { EXPECT_EQ(interp->get_element_type(), element::f16); EXPECT_EQ(interp->get_output_partial_shape(0), PartialShape::dynamic(4)); - EXPECT_THAT(get_shape_labels(interp->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(interp->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, interpolate_v11_scales_incorrect_et) { diff --git a/src/core/tests/type_prop/irdft.cpp b/src/core/tests/type_prop/irdft.cpp index 2792ddeaa83c8a..6464f3f57cba1e 100644 --- a/src/core/tests/type_prop/irdft.cpp +++ b/src/core/tests/type_prop/irdft.cpp @@ -21,9 +21,22 @@ struct IRDFTConstantAxesAndConstantSignalSizeTestParams { PartialShape ref_output_shape; std::vector axes; std::vector signal_size; - std::vector expected_labels; + std::vector expected_symbols; }; +namespace { +TensorSymbol from_idx_to_symbol_vector(const std::vector& indices, const TensorSymbol& initial_symbols) { + TensorSymbol result; + for (const auto& i : indices) { + if (i == 0) + result.push_back(nullptr); + else + result.push_back(initial_symbols[i - 10]); + } + return result; +} +} // namespace + struct IRDFTConstantAxesAndConstantSignalSizeTest : ::testing::TestWithParam {}; @@ -31,7 +44,7 @@ TEST_P(IRDFTConstantAxesAndConstantSignalSizeTest, irdft_constant_axes_and_signa auto params = GetParam(); auto input_shape = params.input_shape; - set_shape_labels(input_shape, 10); + auto symbols = set_shape_symbols(input_shape); auto data = std::make_shared(element::f32, input_shape); auto axes_input = op::v0::Constant::create(element::i64, params.axes_shape, params.axes); @@ -46,7 +59,8 @@ TEST_P(IRDFTConstantAxesAndConstantSignalSizeTest, irdft_constant_axes_and_signa EXPECT_EQ(irdft->get_element_type(), element::f32); EXPECT_EQ(irdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(irdft->get_output_partial_shape(0)), (params.expected_labels)); + auto output_expected_symbols = from_idx_to_symbol_vector(params.expected_symbols, symbols); + EXPECT_EQ(get_shape_symbols(irdft->get_output_partial_shape(0)), output_expected_symbols); } INSTANTIATE_TEST_SUITE_P( @@ -59,126 +73,126 @@ INSTANTIATE_TEST_SUITE_P( {2, 180, 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180, 2}, {2}, Shape{}, {2, 180, 180}, {2, 0}, {}, - {no_label, 11, 12}}, + {0, 11, 12}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{4, 180, 180, 2}, {2}, Shape{}, {6, 180, 180}, {2, 0}, {}, - {no_label, 11, 12}}, + {0, 11, 12}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{16, 500, 180, 369, 2}, {3}, Shape{}, {16, 998, 180, 369}, {0, 3, 1}, {}, - {10, no_label, 12, 13}}, + {10, 0, 12, 13}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180, Dimension(1, 18)}, {2}, Shape{}, {2, 180, 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(7, 500), 2}, {2}, Shape{}, {2, 180, Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(7, 500), Dimension(1, 18)}, {2}, Shape{}, {2, 180, Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), 180, 2}, {2}, Shape{}, {2, Dimension(7, 500), 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), 180, Dimension(1, 18)}, {2}, Shape{}, {2, Dimension(7, 500), 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), Dimension(7, 500), 2}, {2}, Shape{}, {2, Dimension(7, 500), Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), Dimension(7, 500), Dimension(1, 18)}, {2}, Shape{}, {2, Dimension(7, 500), Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, 180, 2}, {2}, Shape{}, {Dimension(0, 2), 180, 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, 180, Dimension(1, 18)}, {2}, Shape{}, {Dimension(0, 2), 180, 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, Dimension(7, 500), 2}, {2}, Shape{}, {Dimension(0, 2), 180, Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, Dimension(7, 500), Dimension(1, 18)}, {2}, Shape{}, {Dimension(0, 2), 180, Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), 180, 2}, {2}, Shape{}, {Dimension(0, 2), Dimension(7, 500), 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), 180, Dimension(1, 18)}, {2}, Shape{}, {Dimension(0, 2), Dimension(7, 500), 358}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), Dimension(7, 500), 2}, {2}, Shape{}, {Dimension(0, 2), Dimension(7, 500), Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{ {Dimension(0, 2), Dimension(7, 500), Dimension(7, 500), Dimension(1, 18)}, {2}, @@ -186,54 +200,54 @@ INSTANTIATE_TEST_SUITE_P( {Dimension(0, 2), Dimension(7, 500), Dimension(12, 998)}, {1, 2}, {}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180, 2}, {2}, {2}, {2, 180, 77}, {1, 2}, {-1, 77}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180, 2}, {2}, {2}, {87, 180, 390}, {2, 0}, {390, 87}, - {no_label, 11, no_label}}, + {0, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{7, 50, 130, 400, 2}, {3}, {3}, {7, 40, 130, 600}, {3, 0, 1}, {600, -1, 40}, - {10, no_label, 12, no_label}}, + {10, 0, 12, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(0, 200), 180, 2}, {2}, {2}, {2, Dimension(0, 200), 77}, {1, 2}, {-1, 77}, - {10, 11, no_label}}, + {10, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400), 2}, {2}, {2}, {87, 180, 390}, {2, 0}, {390, 87}, - {no_label, 11, no_label}}, + {0, 11, 0}}, IRDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(8, 129), 50, 130, Dimension(0, 500), 2}, {3}, {3}, {Dimension(8, 129), 40, 130, 600}, {3, 0, 1}, {600, -1, 40}, - {10, no_label, 12, no_label}}), + {10, 0, 12, 0}}), PrintToDummyParamName()); TEST(type_prop, irdft_dynamic_axes) { auto input_shape = PartialShape{2, 180, 180, Dimension(1, 18)}; - set_shape_labels(input_shape, 10); + auto symbols = set_shape_symbols(input_shape); const auto axes_shape = PartialShape::dynamic(); const auto ref_output_shape = PartialShape{Dimension::dynamic(), Dimension::dynamic(), Dimension::dynamic()}; @@ -243,7 +257,7 @@ TEST(type_prop, irdft_dynamic_axes) { EXPECT_EQ(irdft->get_element_type(), element::f32); EXPECT_EQ(irdft->get_output_partial_shape(0), ref_output_shape); - EXPECT_THAT(get_shape_labels(irdft->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(irdft->get_output_partial_shape(0)), Each(nullptr)); } struct IRDFTNonConstantAxesTestParams { @@ -257,7 +271,7 @@ struct IRDFTNonConstantAxesTest : ::testing::TestWithParam(element::f32, input_shape); auto axes_input = std::make_shared(element::i64, params.axes_shape); @@ -265,7 +279,7 @@ TEST_P(IRDFTNonConstantAxesTest, irdft_non_constant_axes) { EXPECT_EQ(irdft->get_element_type(), element::f32); EXPECT_EQ(irdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_THAT(get_shape_labels(irdft->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(irdft->get_output_partial_shape(0)), Each(nullptr)); } INSTANTIATE_TEST_SUITE_P( @@ -325,7 +339,7 @@ struct IRDFTNonConstantSignalSizeTestParams { Shape signal_size_shape; PartialShape ref_output_shape; std::vector axes; - std::vector expected_labels; + std::vector expected_symbols; }; struct IRDFTNonConstantSignalSizeTest : ::testing::TestWithParam {}; @@ -334,7 +348,7 @@ TEST_P(IRDFTNonConstantSignalSizeTest, irdft_non_constant_signal_size) { auto params = GetParam(); auto input_shape = params.input_shape; - set_shape_labels(input_shape, 10); + set_shape_symbols(input_shape); auto data = std::make_shared(element::f32, params.input_shape); auto axes_input = op::v0::Constant::create(element::i64, params.axes_shape, params.axes); @@ -343,7 +357,8 @@ TEST_P(IRDFTNonConstantSignalSizeTest, irdft_non_constant_signal_size) { EXPECT_EQ(irdft->get_element_type(), element::f32); EXPECT_EQ(irdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(irdft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_EQ(get_shape_symbols(irdft->get_output_partial_shape(0)), + TensorSymbol(params.expected_symbols.size(), nullptr)); } INSTANTIATE_TEST_SUITE_P( @@ -354,20 +369,20 @@ INSTANTIATE_TEST_SUITE_P( {2}, {2, Dimension(0, 200), Dimension::dynamic()}, {1, 2}, - {no_label, no_label, no_label}}, + {0, 0, 0}}, IRDFTNonConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400), 2}, {2}, {2}, {Dimension::dynamic(), 180, Dimension(0, 400)}, {2, 0}, - {no_label, no_label, no_label}}, + {0, 0, 0}}, IRDFTNonConstantSignalSizeTestParams{ {Dimension(8, 129), 50, 130, Dimension(0, 500), 2}, {3}, {3}, {Dimension(8, 129), Dimension::dynamic(), 130, Dimension(0, 500)}, {3, 0, 1}, - {no_label, no_label, no_label, no_label}}), + {0, 0, 0, 0}}), PrintToDummyParamName()); TEST(type_prop, irdft_invalid_input) { diff --git a/src/core/tests/type_prop/logical_not.cpp b/src/core/tests/type_prop/logical_not.cpp index 1f46b1ac88885e..351c3b81d88704 100644 --- a/src/core/tests/type_prop/logical_not.cpp +++ b/src/core/tests/type_prop/logical_not.cpp @@ -55,14 +55,14 @@ TEST_P(LogicalNotTest, propagate_dimensions) { TEST_P(LogicalNotTest, propagate_labels) { if (exp_shape.rank().is_static()) { - set_shape_labels(exp_shape, 10); + set_shape_symbols(exp_shape); } - const auto exp_labels = get_shape_labels(exp_shape); + const auto exp_labels = get_shape_symbols(exp_shape); const auto input = std::make_shared(exp_type, exp_shape); const auto op = make_op(input); - EXPECT_EQ(get_shape_labels(op->get_output_partial_shape(0)), exp_labels); + EXPECT_EQ(get_shape_symbols(op->get_output_partial_shape(0)), exp_labels); } TEST_P(LogicalNotTest, default_ctor) { diff --git a/src/core/tests/type_prop/logical_ops.hpp b/src/core/tests/type_prop/logical_ops.hpp index 3a481d54968f97..5b2aa9ae7c58b4 100644 --- a/src/core/tests/type_prop/logical_ops.hpp +++ b/src/core/tests/type_prop/logical_ops.hpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" template class LogicalOperatorType { @@ -133,18 +132,23 @@ TYPED_TEST_P(LogicalOperatorTypeProp, partial_shape_no_broadcast) { auto shape_a = PartialShape{1, {2, 4}, {2, 5}, 4, -1}; auto shape_b = PartialShape{1, 3, {1, 6}, 4, {-1, 5}}; - set_shape_labels(shape_a, ov::TensorLabel{ov::no_label, 11, 12, ov::no_label, 14}); - set_shape_labels(shape_b, ov::TensorLabel{20, 21, ov::no_label, ov::no_label, ov::no_label}); + + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(); + + set_shape_symbols(shape_a, ov::TensorSymbol{nullptr, A, B, nullptr, C}); + set_shape_symbols(shape_b, ov::TensorSymbol{E, F, nullptr, nullptr, nullptr}); const auto exp_shape = PartialShape{1, 3, {2, 5}, 4, {-1, 5}}; const auto a = std::make_shared(element::boolean, shape_a); const auto b = std::make_shared(element::boolean, shape_b); EXPECT_THAT(this->make_op(a, b, "NONE")->get_output_partial_shape(0), - AllOf(Eq(exp_shape), ResultOf(get_shape_labels, ElementsAre(20, 21, 12, ov::no_label, 14)))); + AllOf(Eq(exp_shape), ResultOf(get_shape_symbols, ElementsAre(E, A, B, nullptr, C)))); EXPECT_THAT(this->make_op(b, a, "NONE")->get_output_partial_shape(0), - AllOf(Eq(exp_shape), ResultOf(get_shape_labels, ElementsAre(20, 11, 12, ov::no_label, 14)))); + AllOf(Eq(exp_shape), ResultOf(get_shape_symbols, ElementsAre(E, F, B, nullptr, C)))); } TYPED_TEST_P(LogicalOperatorTypeProp, partial_shape_numpy_broadcast) { @@ -153,18 +157,22 @@ TYPED_TEST_P(LogicalOperatorTypeProp, partial_shape_numpy_broadcast) { auto shape_a = PartialShape{1, {2, 4}, {2, 5}, 4, -1}; auto shape_b = PartialShape{1, 3, {1, 6}, 4}; - set_shape_labels(shape_a, ov::TensorLabel{ov::no_label, 11, 12, 13, 14}); - set_shape_labels(shape_b, ov::TensorLabel{20, 21, ov::no_label, 23}); + + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(), G = std::make_shared(); + set_shape_symbols(shape_a, ov::TensorSymbol{nullptr, A, B, C, D}); + set_shape_symbols(shape_b, ov::TensorSymbol{E, F, nullptr, G}); const auto exp_shape = PartialShape{1, {2, 4}, 3, 4, 4}; const auto a = std::make_shared(element::boolean, shape_a); const auto b = std::make_shared(element::boolean, shape_b); EXPECT_THAT(this->make_op(a, b, "NUMPY")->get_output_partial_shape(0), - AllOf(Eq(exp_shape), ResultOf(get_shape_labels, ElementsAre(ov::no_label, 11, 21, 13, 23)))); + AllOf(Eq(exp_shape), ResultOf(get_shape_symbols, ElementsAre(nullptr, A, B, C, G)))); EXPECT_THAT(this->make_op(b, a, "NUMPY")->get_output_partial_shape(0), - AllOf(Eq(exp_shape), ResultOf(get_shape_labels, ElementsAre(ov::no_label, 11, 12, 13, 23)))); + AllOf(Eq(exp_shape), ResultOf(get_shape_symbols, ElementsAre(nullptr, A, F, C, G)))); } TYPED_TEST_P(LogicalOperatorTypeProp, default_ctor) { diff --git a/src/core/tests/type_prop/matmul.cpp b/src/core/tests/type_prop/matmul.cpp index 736542db4d1547..1ba1c37f086000 100644 --- a/src/core/tests/type_prop/matmul.cpp +++ b/src/core/tests/type_prop/matmul.cpp @@ -5,7 +5,6 @@ #include "openvino/op/matmul.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" @@ -480,62 +479,74 @@ TEST(type_prop, matmul_incompatible_batch_dim_bounds) { ASSERT_EQ(matmul->get_output_partial_shape(0), expected_output_shape); } -TEST(type_prop, matmul_propagate_labels) { - const auto a_labels = ov::TensorLabel{1, 0, 2, 5, 6}; - const auto b_labels = ov::TensorLabel{0, 1, 3, 7, 9}; +TEST(type_prop, matmul_propagate_symbols) { + auto A = std::make_shared(); + + const auto a_symbols = ov::TensorSymbol{A, + nullptr, + std::make_shared(), + std::make_shared(), + std::make_shared()}; + const auto b_symbols = ov::TensorSymbol{nullptr, + A, + std::make_shared(), + std::make_shared(), + std::make_shared()}; auto a_shape = PartialShape{4, 2, 3, 6, 4}; auto b_shape = PartialShape{4, 2, 3, 4, 2}; - set_shape_labels(a_shape, a_labels); - set_shape_labels(b_shape, b_labels); + set_shape_symbols(a_shape, a_symbols); + set_shape_symbols(b_shape, b_symbols); const auto a = make_shared(element::f32, a_shape); const auto b = make_shared(element::f32, b_shape); const auto matmul = make_shared(a, b, false, false); const auto& output_shape = matmul->get_output_partial_shape(0); - const auto labels = get_shape_labels(output_shape); - - ASSERT_THAT(labels, - ElementsAre(a_labels[0], // use a label, b is not set - b_labels[1], // use b label, a is not set - b_labels[2], // use b label, equal dimension - a_labels[3], // use label from a, b is lost - b_labels[4] // use label from b, a is lost + const auto symbols = get_shape_symbols(output_shape); + + ASSERT_THAT(symbols, + ElementsAre(a_symbols[0], // use a symbol, b is not set + b_symbols[1], // use b symbol, a is not set + a_symbols[2], // use a symbol, equal dimension + a_symbols[3], // use symbol from a, b is lost + b_symbols[4] // use symbol from b, a is lost )); } -TEST(type_prop, matmul_propagate_labels_on_interval_dims) { - const auto a_labels = ov::TensorLabel{1, 0, 3, 4, 5}; - const auto b_labels = ov::TensorLabel{0, 1, 3, 4, 7}; +TEST(type_prop, matmul_propagate_symbols_on_interval_dims) { + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + + const auto a_symbols = ov::TensorSymbol{A, nullptr, B, C, std::make_shared()}; + const auto b_symbols = ov::TensorSymbol{nullptr, A, B, C, std::make_shared()}; auto a_shape = PartialShape{Dimension(1, 3), 1, Dimension(2, 3), Dimension(3, 4), 4}; auto b_shape = PartialShape{1, Dimension(1, 5), Dimension(1, 3), 4, Dimension::dynamic()}; - set_shape_labels(a_shape, a_labels); - set_shape_labels(b_shape, b_labels); + set_shape_symbols(a_shape, a_symbols); + set_shape_symbols(b_shape, b_symbols); const auto a = make_shared(element::f32, a_shape); const auto b = make_shared(element::f32, b_shape); const auto matmul = make_shared(a, b, false, false); const auto& output_shape = matmul->get_output_partial_shape(0); - const auto labels = get_shape_labels(output_shape); - - ASSERT_THAT(labels, - ElementsAre(a_labels[0], // use a label, b is not set - b_labels[1], // use b label, a is not set - a_labels[2], // use a label, b is same - a_labels[3], // use label from a, b is lost - b_labels[4] // use label from a, b is lost + const auto symbols = get_shape_symbols(output_shape); + + ASSERT_THAT(symbols, + ElementsAre(a_symbols[0], // use a symbol, b is not set + b_symbols[1], // use b symbol, a is not set + a_symbols[2], // use a symbol, b is same + a_symbols[3], // use symbol from a, b is lost + b_symbols[4] // use symbol from a, b is lost )); } -TEST(type_prop, matmul_propagate_label_on_b_input_after_reshape) { - constexpr ov::label_t my_label = 2; +TEST(type_prop, matmul_propagate_symbol_on_b_input_after_reshape) { + auto my_symbol = std::make_shared(); auto marked_dim = Dimension(2, 3); - ov::DimensionTracker::set_label(marked_dim, my_label); + marked_dim.set_symbol(my_symbol); const auto a_shape = PartialShape{Dimension::dynamic(), 5, 3}; const auto b_shape = PartialShape{3, marked_dim, 2}; @@ -555,8 +566,8 @@ TEST(type_prop, matmul_propagate_label_on_b_input_after_reshape) { const auto matmul = make_shared(a, reshape_b, false, false); const auto& output_shape = matmul->get_output_partial_shape(0); - const auto labels = get_shape_labels(output_shape); + const auto symbols = get_shape_symbols(output_shape); - ASSERT_THAT(labels, ElementsAre(my_label, 0, 0)); + ASSERT_THAT(symbols, ElementsAre(my_symbol, nullptr, nullptr)); ASSERT_EQ(output_shape, (PartialShape{marked_dim, 5, 8})); } diff --git a/src/core/tests/type_prop/max_pool.cpp b/src/core/tests/type_prop/max_pool.cpp index 19516ebf97b12d..98e5323338fbdf 100644 --- a/src/core/tests/type_prop/max_pool.cpp +++ b/src/core/tests/type_prop/max_pool.cpp @@ -20,7 +20,7 @@ TYPED_TEST_SUITE_P(MaxPoolOperator); TEST(type_prop, max_pool_default_ctor) { PartialShape arg_shape{1, 3, 32}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const Strides strides{1}; const Shape pads_begin{2}; const Shape pads_end{2}; @@ -39,14 +39,14 @@ TEST(type_prop, max_pool_default_ctor) { mp->validate_and_infer_types(); EXPECT_EQ(mp->get_output_partial_shape(0), PartialShape({1, 3, 31})); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], nullptr)); EXPECT_EQ(mp->get_pads_begin(), (Shape{0})); EXPECT_EQ(mp->get_pads_end(), (Shape{0})); } TEST(type_prop, max_pool_valid_auto_padding) { PartialShape arg_shape{1, 3, {10, 32}}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const Strides strides{1}; const Shape pads_begin{2}; const Shape pads_end{2}; @@ -57,7 +57,7 @@ TEST(type_prop, max_pool_valid_auto_padding) { auto arg = make_shared(element::f32, arg_shape); auto mp = make_shared(arg, strides, pads_begin, pads_end, kernel_shape, rounding_mode, auto_pad); EXPECT_EQ(mp->get_output_partial_shape(0), PartialShape({1, 3, {9, 31}})); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], nullptr)); EXPECT_EQ(mp->get_pads_begin(), (Shape{0})); EXPECT_EQ(mp->get_pads_end(), (Shape{0})); } @@ -132,7 +132,7 @@ TEST(type_prop, max_pool_auto_padding_2D_nc_dims_dynamic_same_lower) { TEST(type_prop, max_pool_auto_padding_nc_dims_dynamic_same_upper) { PartialShape arg_shape{Dimension::dynamic(), Dimension::dynamic(), 32, 32}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const Strides strides{1, 1}; const Shape pads_begin{0, 0}; const Shape pads_end{0, 0}; @@ -144,14 +144,15 @@ TEST(type_prop, max_pool_auto_padding_nc_dims_dynamic_same_upper) { auto mp = make_shared(arg, strides, pads_begin, pads_end, kernel_shape, rounding_mode, auto_pad); EXPECT_EQ(mp->get_output_partial_shape(0), PartialShape({Dimension::dynamic(), Dimension::dynamic(), 32, 32})); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); EXPECT_EQ(mp->get_pads_begin(), (Shape{0, 0})); EXPECT_EQ(mp->get_pads_end(), (Shape{1, 1})); } TEST(type_prop, max_pool_auto_padding_interval_dims_same_upper) { PartialShape arg_shape{{1, 2}, {2, 3}, {16, 32}, {11, 32}}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const Strides strides{1, 1}; const Shape pads_begin{0, 0}; const Shape pads_end{0, 0}; @@ -163,7 +164,8 @@ TEST(type_prop, max_pool_auto_padding_interval_dims_same_upper) { auto mp = make_shared(arg, strides, pads_begin, pads_end, kernel_shape, rounding_mode, auto_pad); EXPECT_EQ(mp->get_output_partial_shape(0), PartialShape({{1, 2}, {2, 3}, -1, -1})); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); EXPECT_EQ(mp->get_pads_begin(), (Shape{0, 0})); EXPECT_EQ(mp->get_pads_end(), (Shape{0, 0})); } @@ -351,7 +353,7 @@ TYPED_TEST_P(MaxPoolOperator, max_pool_4D_dynamic_dims_with_non_zero_low_range_c TYPED_TEST_P(MaxPoolOperator, max_pool_4D_interval_dims_with_dilations) { PartialShape arg_shape{{2, 3}, {1, 3}, {2, 13}, {6, 13}}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const Strides strides{1, 1}; const Strides dilations{2, 3}; const Shape pads_begin{0, 0}; @@ -364,7 +366,8 @@ TYPED_TEST_P(MaxPoolOperator, max_pool_4D_interval_dims_with_dilations) { const auto expected_output_shape = PartialShape({{2, 3}, {1, 3}, {1, 11}, {3, 10}}); EXPECT_EQ(mp->get_output_partial_shape(0), expected_output_shape); EXPECT_EQ(mp->get_output_partial_shape(1), expected_output_shape); - EXPECT_THAT(get_shape_labels(mp->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(mp->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, nullptr)); } TYPED_TEST_P(MaxPoolOperator, max_pool_4D_with_dilations_and_auto_pad_same_upper) { diff --git a/src/core/tests/type_prop/multiclass_nms.cpp b/src/core/tests/type_prop/multiclass_nms.cpp index c6739f5990e393..31056fd0361b8d 100644 --- a/src/core/tests/type_prop/multiclass_nms.cpp +++ b/src/core/tests/type_prop/multiclass_nms.cpp @@ -210,8 +210,8 @@ TYPED_TEST(type_prop, multiclass_nms_default_ctor) { TYPED_TEST(type_prop, multiclass_nms_output_shape_1dim_dynamic) { auto boxes_shape = PartialShape{5, 2, 4}; auto scores_shape = PartialShape{5, 3, 2}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + auto symbols = set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -221,9 +221,9 @@ TYPED_TEST(type_prop, multiclass_nms_output_shape_1dim_dynamic) { EXPECT_EQ(nms->get_output_partial_shape(0), (PartialShape{{0, 30}, 6})); EXPECT_EQ(nms->get_output_partial_shape(1), (PartialShape{{0, 30}, 1})); EXPECT_EQ(nms->get_output_partial_shape(2), (PartialShape{5})); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(2)), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(2)), ElementsAre(symbols[0])); } TYPED_TEST(type_prop, multiclass_nms_output_shape_1dim_max_out) { @@ -340,9 +340,9 @@ TEST(type_prop2, multiclass_nms_interval_shapes_and_labels) { auto boxes_shape = PartialShape{2, 7, 4}; auto scores_shape = PartialShape{2, 7}; auto roisnum_shape = PartialShape{4}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); - set_shape_labels(roisnum_shape, 30); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); + auto symbols = set_shape_symbols(roisnum_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -357,9 +357,9 @@ TEST(type_prop2, multiclass_nms_interval_shapes_and_labels) { EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({{0, 56}, 6})); EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({{0, 56}, 1})); EXPECT_EQ(nms->get_output_partial_shape(2), PartialShape({4})); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(nms->get_output_partial_shape(2)), ElementsAre(30)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(nms->get_output_partial_shape(2)), ElementsAre(symbols[0])); } TEST(type_prop2, multiclass_nms_static_shapes) { diff --git a/src/core/tests/type_prop/nms_rotated.cpp b/src/core/tests/type_prop/nms_rotated.cpp index 9efb8571441fb3..e6ea3ad3f07484 100644 --- a/src/core/tests/type_prop/nms_rotated.cpp +++ b/src/core/tests/type_prop/nms_rotated.cpp @@ -166,8 +166,8 @@ TYPED_TEST_P(NMSRotatedDynamicOutputTest, boxes_scores_static_max_out_param) { TYPED_TEST_P(NMSRotatedDynamicOutputTest, num_boxes_gt_max_out_boxes) { auto boxes_shape = PartialShape{2, 7, 5}; auto scores_shape = PartialShape{2, 5, 7}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -185,9 +185,9 @@ TYPED_TEST_P(NMSRotatedDynamicOutputTest, num_boxes_gt_max_out_boxes) { ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({{0, 30}, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({{0, 30}, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSRotatedDynamicOutputTest, num_boxes_lt_max_out_boxes) { @@ -231,8 +231,8 @@ TYPED_TEST_P(NMSRotatedDynamicOutputTest, max_out_boxes_is_zero) { TYPED_TEST_P(NMSRotatedDynamicOutputTest, interval_shapes_labels) { auto boxes_shape = PartialShape{{0, 2}, {0, 7}, 5}; auto scores_shape = PartialShape{{0, 2}, {0, 5}, {1, 7}}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -250,16 +250,16 @@ TYPED_TEST_P(NMSRotatedDynamicOutputTest, interval_shapes_labels) { ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({{0, 70}, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({{0, 70}, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSRotatedDynamicOutputTest, num_box_dynamic_dim_max_boxes_per_class_as_const) { auto boxes_shape = PartialShape{2, -1, 5}; auto scores_shape = PartialShape{2, {0, 5}, {1, 7}}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -273,9 +273,9 @@ TYPED_TEST_P(NMSRotatedDynamicOutputTest, num_box_dynamic_dim_max_boxes_per_clas ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({-1, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({-1, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSRotatedDynamicOutputTest, output_shape_i32) { diff --git a/src/core/tests/type_prop/non_max_suppression.cpp b/src/core/tests/type_prop/non_max_suppression.cpp index f74e7faba17a97..e5c4c79b320356 100644 --- a/src/core/tests/type_prop/non_max_suppression.cpp +++ b/src/core/tests/type_prop/non_max_suppression.cpp @@ -130,11 +130,11 @@ TYPED_TEST_P(NMSNonDynamicOutputTest, num_boxes_lt_max_out_boxes) { EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({1, 3})); } -TYPED_TEST_P(NMSNonDynamicOutputTest, interval_shapes_boxes_and_scores_with_labels) { +TYPED_TEST_P(NMSNonDynamicOutputTest, interval_shapes_boxes_and_scores_with_symbols) { auto boxes_shape = PartialShape{{1, 2}, {2, 5}, {0, 4}}; auto scores_shape = PartialShape{{0, 2}, {1, 2}, {0, 6}}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -146,12 +146,12 @@ TYPED_TEST_P(NMSNonDynamicOutputTest, interval_shapes_boxes_and_scores_with_labe EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::i64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 3})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(NMSNonDynamicOutputTest, interval_boxes_scores_dynamic_rank) { auto boxes_shape = PartialShape{{1, 2}, {2, 5}, {0, 4}}; - set_shape_labels(boxes_shape, 10); + set_shape_symbols(boxes_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, PartialShape::dynamic()); @@ -163,7 +163,7 @@ TYPED_TEST_P(NMSNonDynamicOutputTest, interval_boxes_scores_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::i64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 3})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(NMSNonDynamicOutputTest, dynamic_rank_boxes_and_scores) { @@ -184,7 +184,7 @@ REGISTER_TYPED_TEST_SUITE_P(NMSNonDynamicOutputTest, static_boxes_and_scores_default_others, num_boxes_gt_max_out_boxes, num_boxes_lt_max_out_boxes, - interval_shapes_boxes_and_scores_with_labels, + interval_shapes_boxes_and_scores_with_symbols, interval_boxes_scores_dynamic_rank, dynamic_rank_boxes_and_scores); using NMSNonDynamicOutputTypes = @@ -279,8 +279,8 @@ TYPED_TEST_P(NMSDynamicOutputTest, boxes_scores_static_other_defaults) { TYPED_TEST_P(NMSDynamicOutputTest, num_boxes_gt_max_out_boxes) { auto boxes_shape = PartialShape{2, 7, 4}; auto scores_shape = PartialShape{2, 5, 7}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -298,9 +298,9 @@ TYPED_TEST_P(NMSDynamicOutputTest, num_boxes_gt_max_out_boxes) { ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({{0, 30}, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({{0, 30}, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSDynamicOutputTest, num_boxes_lt_max_out_boxes) { @@ -341,11 +341,11 @@ TYPED_TEST_P(NMSDynamicOutputTest, max_out_boxes_is_zero) { Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); } -TYPED_TEST_P(NMSDynamicOutputTest, interval_shapes_labels) { +TYPED_TEST_P(NMSDynamicOutputTest, interval_shapes_symbols) { auto boxes_shape = PartialShape{{0, 2}, {0, 7}, 4}; auto scores_shape = PartialShape{{0, 2}, {0, 5}, {1, 7}}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -363,16 +363,16 @@ TYPED_TEST_P(NMSDynamicOutputTest, interval_shapes_labels) { ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({{0, 70}, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({{0, 70}, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSDynamicOutputTest, num_box_dynamic_dim_max_boxes_per_class_as_const) { auto boxes_shape = PartialShape{2, -1, 4}; auto scores_shape = PartialShape{2, {0, 5}, {1, 7}}; - set_shape_labels(boxes_shape, 10); - set_shape_labels(scores_shape, 20); + set_shape_symbols(boxes_shape); + set_shape_symbols(scores_shape); const auto boxes = make_shared(element::f32, boxes_shape); const auto scores = make_shared(element::f32, scores_shape); @@ -386,9 +386,9 @@ TYPED_TEST_P(NMSDynamicOutputTest, num_box_dynamic_dim_max_boxes_per_class_as_co ElementsAre(Property("Indicies shape", &Output::get_partial_shape, PartialShape({-1, 3})), Property("Scores shape", &Output::get_partial_shape, PartialShape({-1, 3})), Property("Outputs shape", &Output::get_partial_shape, PartialShape({1})))); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(no_label)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(2)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(2)), Each(nullptr)); } TYPED_TEST_P(NMSDynamicOutputTest, output_shape_i32) { @@ -477,7 +477,7 @@ REGISTER_TYPED_TEST_SUITE_P(NMSDynamicOutputTest, num_boxes_gt_max_out_boxes, num_boxes_lt_max_out_boxes, max_out_boxes_is_zero, - interval_shapes_labels, + interval_shapes_symbols, num_box_dynamic_dim_max_boxes_per_class_as_const, output_shape_i32, dynamic_boxes_and_scores, diff --git a/src/core/tests/type_prop/one_hot.cpp b/src/core/tests/type_prop/one_hot.cpp index 2e1a3f3bfdb52c..3a3092fcc9bf0e 100644 --- a/src/core/tests/type_prop/one_hot.cpp +++ b/src/core/tests/type_prop/one_hot.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" #include "openvino/op/squeeze.hpp" @@ -47,9 +46,9 @@ TEST(type_prop, one_hot_v1_output_shape_2) { ASSERT_EQ(dyn_ont_hot->get_output_partial_shape(0), (PartialShape{1, {3, 5}, 2, 4, 3})); } -TEST(type_prop, one_hot_v1_indices_labels) { +TEST(type_prop, one_hot_v1_indices_symbols) { auto ind_shape = PartialShape{-1, {3, 5}, 2, 3}; - set_shape_labels(ind_shape, {10, 11, 12, 13}); + auto symbols = set_shape_symbols(ind_shape); auto dyn_indices = make_shared(element::i64, ind_shape); auto depth = ov::op::v0::Constant::create(element::i64, Shape{}, {4}); @@ -58,19 +57,19 @@ TEST(type_prop, one_hot_v1_indices_labels) { int64_t axis = 1; PartialShape expected_shape{-1, 4, {3, 5}, 2, 3}; - ov::TensorLabel expected_labels{10, ov::no_label, 11, 12, 13}; + ov::TensorSymbol expected_symbols = {symbols[0], nullptr, symbols[1], symbols[2], symbols[3]}; auto dyn_one_hot = make_shared(dyn_indices, depth, on_value, off_value, axis); const auto& out_shape = dyn_one_hot->get_output_partial_shape(0); EXPECT_EQ(dyn_one_hot->get_output_element_type(0), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, one_hot_v1_depth_shape_of_value) { auto ind_shape = PartialShape{-1, {3, 5}, 2, 3}; - set_shape_labels(ind_shape, {10, 11, 12, 13}); + set_shape_symbols(ind_shape); auto dyn_indices = make_shared(element::i64, ind_shape); @@ -93,16 +92,16 @@ TEST(type_prop, one_hot_v1_depth_shape_of_value) { EXPECT_EQ(out_shape, expected_shape); } -TEST(type_prop, one_hot_v1_depth_value_label) { +TEST(type_prop, one_hot_v1_depth_value_symbol) { auto ind_shape = PartialShape{-1, {3, 5}, 2, 3}; - set_shape_labels(ind_shape, {10, 11, 12, 13}); + auto symbols = set_shape_symbols(ind_shape); auto dyn_indices = make_shared(element::i64, ind_shape); - auto labeled_dim = Dimension(4, 6); - ov::label_t depth_label = 2345664; - ov::DimensionTracker::set_label(labeled_dim, depth_label); - PartialShape shape_for_depth = PartialShape{labeled_dim}; + auto symboled_dim = Dimension(4, 6); + auto depth_symbol = std::make_shared(); + symboled_dim.set_symbol(depth_symbol); + PartialShape shape_for_depth = PartialShape{symboled_dim}; auto data = make_shared(element::i8, shape_for_depth); auto depth_dim = make_shared(data); @@ -113,19 +112,19 @@ TEST(type_prop, one_hot_v1_depth_value_label) { int64_t axis = 1; PartialShape expected_shape{-1, {4, 6}, {3, 5}, 2, 3}; - ov::TensorLabel expected_labels{10, depth_label, 11, 12, 13}; + ov::TensorSymbol expected_symbols{symbols[0], depth_symbol, symbols[1], symbols[2], symbols[3]}; auto dyn_one_hot = make_shared(dyn_indices, depth, on_value, off_value, axis); const auto& out_shape = dyn_one_hot->get_output_partial_shape(0); EXPECT_EQ(dyn_one_hot->get_output_element_type(0), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, one_hot_v1_output_labels) { +TEST(type_prop, one_hot_v1_output_symbols) { auto ind_shape = PartialShape{-1, {3, 5}, 2, 3}; - set_shape_labels(ind_shape, {10, 11, 12, 13}); + auto symbols = set_shape_symbols(ind_shape); auto dyn_indices = make_shared(element::i64, ind_shape); auto depth = ov::op::v0::Constant::create(element::i64, Shape{}, {4}); @@ -134,14 +133,14 @@ TEST(type_prop, one_hot_v1_output_labels) { int64_t axis = 1; PartialShape expected_shape{-1, 4, {3, 5}, 2, 3}; - ov::TensorLabel expected_labels{10, ov::no_label, 11, 12, 13}; + ov::TensorSymbol expected_symbols{symbols[0], nullptr, symbols[1], symbols[2], symbols[3]}; auto dyn_one_hot = make_shared(dyn_indices, depth, on_value, off_value, axis); const auto& out_shape = dyn_one_hot->get_output_partial_shape(0); EXPECT_EQ(dyn_one_hot->get_output_element_type(0), element::f32); EXPECT_EQ(out_shape, expected_shape); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, one_hot_v1_default_constructor) { diff --git a/src/core/tests/type_prop/pad.cpp b/src/core/tests/type_prop/pad.cpp index 62ef27db940f2a..7057c8bd9358f0 100644 --- a/src/core/tests/type_prop/pad.cpp +++ b/src/core/tests/type_prop/pad.cpp @@ -144,7 +144,7 @@ TYPED_TEST_P(PadTest, pad_deduce_too_small_for_reflect) { TYPED_TEST_P(PadTest, pad_pads_end_got_negative_value) { auto arg_shape = PartialShape{-1, {0, 10}, {2, -1}, {2, 8}, {3, 10}, 5}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const auto arg = std::make_shared(element::f32, arg_shape); const auto pads_begin = op::v0::Constant::create(element::i64, Shape{6}, {2, 0, 1, 3, 2, 1}); const auto pads_end = op::v0::Constant::create(element::i64, Shape{6}, {-3, -2, -2, -3, -1, -3}); @@ -152,21 +152,21 @@ TYPED_TEST_P(PadTest, pad_pads_end_got_negative_value) { const auto pad = this->make_op(arg, pads_begin, pads_end, op::PadMode::REFLECT); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({-1, {0, 8}, {1, -1}, {2, 8}, {4, 11}, 3})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, 13, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, symbols[3], nullptr, nullptr)); } TYPED_TEST_P(PadTest, pad_pads_begin_got_negative_value) { auto arg_shape = PartialShape{-1, {0, 10}, {2, -1}, {2, 8}, {3, 10}, 5}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const auto arg = std::make_shared(element::f32, arg_shape); const auto pads_begin = op::v0::Constant::create(element::i64, Shape{6}, {-1, -1, -2, -3, -8, -4}); const auto pads_end = op::v0::Constant::create(element::i64, Shape{6}, {0, 2, 0, 3, 5, 4}); const auto pad = make_shared(arg, pads_begin, pads_end, op::PadMode::REFLECT); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({-1, {1, 11}, {0, -1}, {2, 8}, {0, 7}, 5})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, 13, ov::no_label, 15)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, symbols[3], nullptr, symbols[5])); } TYPED_TEST_P(PadTest, pad_dynamic_output_with_dynamic_rank) { @@ -191,27 +191,28 @@ TYPED_TEST_P(PadTest, pad_dynamic_output_with_static_rank) { TYPED_TEST_P(PadTest, pad_any_dim_for_padding_reflect) { auto arg_shape = PartialShape{1, {23, 48}, {23, 48}, 1}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); auto arg = make_shared(element::f32, arg_shape); auto pads_begin = make_shared(element::i64, Shape{4}, std::vector{0, 1, 1, 0}); auto pads_end = make_shared(element::i64, Shape{4}, std::vector{0, 1, 1, 0}); auto pad = make_shared(arg, pads_begin, pads_end, op::PadMode::REFLECT); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({1, {25, 50}, {25, 50}, 1})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, ov::no_label, 13)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, symbols[3])); } TYPED_TEST_P(PadTest, pad_any_dim_for_padding_edge) { auto arg_shape = PartialShape{1, {0, 48}, -1, {20, -1}, {5, -1}, 10, 12}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); auto arg = make_shared(element::f32, arg_shape); auto pads_begin = make_shared(element::i64, Shape{7}, std::vector{1, 2, 1, 2, 0, 0, 0}); auto pads_end = make_shared(element::i64, Shape{7}, std::vector{0, 3, 0, 1, 0, 5, 0}); auto pad = this->make_op(arg, pads_begin, pads_end, op::PadMode::EDGE); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({2, {5, 53}, {1, -1}, {23, -1}, {5, -1}, 15, 12})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, ov::no_label, 14, ov::no_label, 16)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, nullptr, symbols[4], nullptr, symbols[6])); } TYPED_TEST_P(PadTest, pad_dynamic_input_type_with_static_value) { @@ -225,13 +226,13 @@ TYPED_TEST_P(PadTest, pad_dynamic_input_type_with_static_value) { EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape::dynamic(3)); } -TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_labels_via_evaluates_bounds) { +TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_symbols_via_evaluates_bounds) { auto arg_shape = PartialShape{1, {2, 5}, {1, 3}}; auto begin_shape = PartialShape{{2, 4}, 0, {0, 2}}; auto end_shape = PartialShape{{1, 2}, 0, 1}; - set_shape_labels(arg_shape, 10); - set_shape_labels(begin_shape, 20); - set_shape_labels(end_shape, 30); + auto symbols = set_shape_symbols(arg_shape); + set_shape_symbols(begin_shape); + set_shape_symbols(end_shape); auto arg = make_shared(element::f32, arg_shape); auto s_begin = make_shared(make_shared(element::i64, begin_shape)); @@ -240,12 +241,12 @@ TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_labels_via_evaluates_bound auto pad = this->make_op(arg, s_begin, s_end, op::PadMode::EDGE); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({{4, 7}, {2, 5}, {2, 6}})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), ElementsAre(ov::no_label, 11, ov::no_label)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), ElementsAre(nullptr, symbols[1], nullptr)); } -TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_labels_on_inputs) { +TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_symbols_on_inputs) { auto arg_shape = PartialShape{1, {2, 5}, {1, 3}}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); auto arg = make_shared(element::i32, arg_shape); auto s = make_shared(arg); @@ -257,16 +258,17 @@ TYPED_TEST_P(PadTest, pad_preserve_partial_values_and_labels_on_inputs) { auto bc = std::make_shared(param, pad, op::BroadcastType::BIDIRECTIONAL); EXPECT_EQ(bc->get_output_partial_shape(0), PartialShape({1, 1, {2, 5}, {1, 3}, {1, 3}, {1, 3}})); - EXPECT_THAT(get_shape_labels(bc->get_output_partial_shape(0)), ElementsAre(10, 10, 11, 12, 12, 12)); + EXPECT_THAT(get_shape_symbols(bc->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[0], symbols[1], symbols[2], symbols[2], symbols[2])); } TYPED_TEST_P(PadTest, pad_begin_and_end_has_inf_interval_as_bounds) { auto arg_shape = PartialShape{9, {3, 5}, {3, 5}, {3, 4}, {3, 4}}; auto begin_shape = PartialShape{-1, {0, 2}, -1, -1, {0, 1}}; auto end_shape = PartialShape{-1, -1, {0, 2}, {0, 1}, -1}; - set_shape_labels(arg_shape, 10); - set_shape_labels(begin_shape, 20); - set_shape_labels(end_shape, 30); + set_shape_symbols(arg_shape); + set_shape_symbols(begin_shape); + set_shape_symbols(end_shape); auto arg = make_shared(element::f32, arg_shape); auto s_begin = make_shared(make_shared(element::i32, begin_shape)); @@ -275,7 +277,7 @@ TYPED_TEST_P(PadTest, pad_begin_and_end_has_inf_interval_as_bounds) { auto pad = this->make_op(arg, s_begin, s_end, op::PadMode::CONSTANT); EXPECT_EQ(pad->get_output_partial_shape(0), PartialShape({{9, -1}, {3, -1}, {3, -1}, {3, -1}, {3, -1}})); - EXPECT_THAT(get_shape_labels(pad->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(pad->get_output_partial_shape(0)), Each(nullptr)); } REGISTER_TYPED_TEST_SUITE_P(PadTest, @@ -297,9 +299,9 @@ REGISTER_TYPED_TEST_SUITE_P(PadTest, pad_any_dim_for_padding_reflect, pad_any_dim_for_padding_edge, pad_dynamic_input_type_with_static_value, - pad_preserve_partial_values_and_labels_via_evaluates_bounds, + pad_preserve_partial_values_and_symbols_via_evaluates_bounds, pad_begin_and_end_has_inf_interval_as_bounds, - pad_preserve_partial_values_and_labels_on_inputs); + pad_preserve_partial_values_and_symbols_on_inputs); using PadOpTypes = Types; INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, PadTest, PadOpTypes); diff --git a/src/core/tests/type_prop/prior_box.cpp b/src/core/tests/type_prop/prior_box.cpp index 1c41df09c93d32..67595a3d980e9f 100644 --- a/src/core/tests/type_prop/prior_box.cpp +++ b/src/core/tests/type_prop/prior_box.cpp @@ -103,7 +103,7 @@ TYPED_TEST_P(PriorBoxTest, inputs_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, input_output_size_is_dynamic_rank) { @@ -115,12 +115,12 @@ TYPED_TEST_P(PriorBoxTest, input_output_size_is_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, input_output_size_is_static_rank_with_dynamic_dims) { auto out_size_shape = PartialShape::dynamic(1); - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u32, out_size_shape); const auto image_size = Constant::create(element::u32, Shape{2}, {300, 300}); @@ -130,7 +130,7 @@ TYPED_TEST_P(PriorBoxTest, input_output_size_is_static_rank_with_dynamic_dims) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, input_image_size_is_dynamic_rank) { @@ -142,14 +142,14 @@ TYPED_TEST_P(PriorBoxTest, input_image_size_is_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 20480})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, input_image_size_is_static_rank_dynamic_dim) { this->attrs.flip = true; auto img_size_shape = PartialShape::dynamic(1); - set_shape_labels(img_size_shape, 20); + set_shape_symbols(img_size_shape); const auto output_size = Constant::create(element::u16, Shape{2}, {32, 32}); const auto image_size = std::make_shared(element::u16, img_size_shape); @@ -159,14 +159,14 @@ TYPED_TEST_P(PriorBoxTest, input_image_size_is_static_rank_dynamic_dim) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 32768})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, inputs_are_interval_shapes) { auto out_size_shape = PartialShape{{0, 10}}; auto img_size_shape = PartialShape{{1, 5}}; - set_shape_labels(out_size_shape, 20); - set_shape_labels(img_size_shape, 20); + auto symbol = set_shape_symbols(out_size_shape); + set_shape_symbols(img_size_shape, symbol); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = std::make_shared(element::u64, img_size_shape); @@ -176,12 +176,12 @@ TYPED_TEST_P(PriorBoxTest, inputs_are_interval_shapes) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } -TYPED_TEST_P(PriorBoxTest, preseve_values_and_labels_on_inputs) { +TYPED_TEST_P(PriorBoxTest, preseve_values_and_symbols_on_inputs) { auto out_size_shape = PartialShape{6, 8}; - DimensionTracker::set_label(out_size_shape[0], 10); + out_size_shape[0].set_symbol(std::make_shared()); const auto output_size = std::make_shared(element::i16, out_size_shape); const auto image_size = Constant::create(element::i16, Shape{2}, {300, 300}); @@ -192,12 +192,12 @@ TYPED_TEST_P(PriorBoxTest, preseve_values_and_labels_on_inputs) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 960})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } -TYPED_TEST_P(PriorBoxTest, preseve_partial_values_and_labels_on_inputs) { +TYPED_TEST_P(PriorBoxTest, preseve_partial_values_and_symbols_on_inputs) { auto out_size_shape = PartialShape{{1, 4}, {5, 10}}; - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = Constant::create(element::u64, Shape{2}, {300, 300}); @@ -208,12 +208,12 @@ TYPED_TEST_P(PriorBoxTest, preseve_partial_values_and_labels_on_inputs) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, {100, 800}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, preseve_partial_values_inf_bound) { auto out_size_shape = PartialShape{{1, 4}, {5, -1}}; // ShapeOf make 2nd Dim {0, -1} - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = Constant::create(element::u64, Shape{2}, {300, 300}); @@ -224,7 +224,7 @@ TYPED_TEST_P(PriorBoxTest, preseve_partial_values_inf_bound) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, {0, -1}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxTest, out_size_input_not_integer) { @@ -282,8 +282,8 @@ REGISTER_TYPED_TEST_SUITE_P(PriorBoxTest, input_image_size_is_dynamic_rank, input_image_size_is_static_rank_dynamic_dim, inputs_are_interval_shapes, - preseve_values_and_labels_on_inputs, - preseve_partial_values_and_labels_on_inputs, + preseve_values_and_symbols_on_inputs, + preseve_partial_values_and_symbols_on_inputs, preseve_partial_values_inf_bound, out_size_input_not_integer, img_size_input_not_integer, diff --git a/src/core/tests/type_prop/prior_box_clustered.cpp b/src/core/tests/type_prop/prior_box_clustered.cpp index 04c44ed8ae31d7..3470d798df6eec 100644 --- a/src/core/tests/type_prop/prior_box_clustered.cpp +++ b/src/core/tests/type_prop/prior_box_clustered.cpp @@ -79,7 +79,7 @@ TYPED_TEST_P(PriorBoxClusteredTest, inputs_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, input_output_size_is_dynamic_rank) { @@ -91,12 +91,12 @@ TYPED_TEST_P(PriorBoxClusteredTest, input_output_size_is_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, input_output_size_is_static_rank_with_dynamic_dims) { auto out_size_shape = PartialShape::dynamic(1); - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u32, out_size_shape); const auto image_size = Constant::create(element::u32, Shape{2}, {300, 300}); @@ -106,7 +106,7 @@ TYPED_TEST_P(PriorBoxClusteredTest, input_output_size_is_static_rank_with_dynami EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, input_image_size_is_dynamic_rank) { @@ -118,12 +118,12 @@ TYPED_TEST_P(PriorBoxClusteredTest, input_image_size_is_dynamic_rank) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 12288})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, input_image_size_is_static_rank_dynamic_dim) { auto img_size_shape = PartialShape::dynamic(1); - set_shape_labels(img_size_shape, 20); + set_shape_symbols(img_size_shape); const auto output_size = Constant::create(element::u16, Shape{2}, {32, 32}); const auto image_size = std::make_shared(element::u16, img_size_shape); @@ -133,14 +133,14 @@ TYPED_TEST_P(PriorBoxClusteredTest, input_image_size_is_static_rank_dynamic_dim) EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 12288})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, inputs_are_interval_shapes) { auto out_size_shape = PartialShape{{0, 10}}; auto img_size_shape = PartialShape{{1, 5}}; - set_shape_labels(out_size_shape, 20); - set_shape_labels(img_size_shape, 20); + auto symbols = set_shape_symbols(out_size_shape); + set_shape_symbols(img_size_shape, symbols); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = std::make_shared(element::u64, img_size_shape); @@ -150,12 +150,12 @@ TYPED_TEST_P(PriorBoxClusteredTest, inputs_are_interval_shapes) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } -TYPED_TEST_P(PriorBoxClusteredTest, preseve_values_and_labels_on_inputs) { +TYPED_TEST_P(PriorBoxClusteredTest, preseve_values_and_symbols_on_inputs) { auto out_size_shape = PartialShape{6, 8}; - DimensionTracker::set_label(out_size_shape[0], 10); + out_size_shape[0].set_symbol(std::make_shared()); const auto output_size = std::make_shared(element::i16, out_size_shape); const auto image_size = Constant::create(element::i16, Shape{2}, {300, 300}); @@ -166,12 +166,12 @@ TYPED_TEST_P(PriorBoxClusteredTest, preseve_values_and_labels_on_inputs) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 576})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } -TYPED_TEST_P(PriorBoxClusteredTest, preseve_partial_values_and_labels_on_inputs) { +TYPED_TEST_P(PriorBoxClusteredTest, preseve_partial_values_and_symbols_on_inputs) { auto out_size_shape = PartialShape{{1, 4}, {5, 10}}; - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = Constant::create(element::u64, Shape{2}, {300, 300}); @@ -182,12 +182,12 @@ TYPED_TEST_P(PriorBoxClusteredTest, preseve_partial_values_and_labels_on_inputs) EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, {60, 480}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, preseve_partial_values_inf_bound) { auto out_size_shape = PartialShape{{1, 4}, {5, -1}}; // ShapeOf make 2nd Dim {0, -1} - set_shape_labels(out_size_shape, 10); + set_shape_symbols(out_size_shape); const auto output_size = std::make_shared(element::u64, out_size_shape); const auto image_size = Constant::create(element::u64, Shape{2}, {300, 300}); @@ -198,7 +198,7 @@ TYPED_TEST_P(PriorBoxClusteredTest, preseve_partial_values_inf_bound) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, {0, -1}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(PriorBoxClusteredTest, out_size_input_not_integer) { @@ -268,8 +268,8 @@ REGISTER_TYPED_TEST_SUITE_P(PriorBoxClusteredTest, input_image_size_is_dynamic_rank, input_image_size_is_static_rank_dynamic_dim, inputs_are_interval_shapes, - preseve_values_and_labels_on_inputs, - preseve_partial_values_and_labels_on_inputs, + preseve_values_and_symbols_on_inputs, + preseve_partial_values_and_symbols_on_inputs, preseve_partial_values_inf_bound, out_size_input_not_integer, img_size_input_not_integer, diff --git a/src/core/tests/type_prop/proposal.cpp b/src/core/tests/type_prop/proposal.cpp index 7a3e38502e5bb7..3f8e26e6997c8b 100644 --- a/src/core/tests/type_prop/proposal.cpp +++ b/src/core/tests/type_prop/proposal.cpp @@ -113,8 +113,8 @@ TEST(type_prop, proposal_v0_dynamic_class_probs_dim1_batch_size_infer) { auto class_props_shape = PartialShape{-1, 2, 3, 4}; auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + auto symbols = set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -124,7 +124,7 @@ TEST(type_prop, proposal_v0_dynamic_class_probs_dim1_batch_size_infer) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); } TEST(type_prop, proposal_v0_dynamic_bbox_deltas_dim1_batch_size_infer) { @@ -134,7 +134,7 @@ TEST(type_prop, proposal_v0_dynamic_bbox_deltas_dim1_batch_size_infer) { auto class_props_shape = PartialShape{batch_size, 2, {1, 3}, {1, 4}}; auto class_bbox_shape = PartialShape{-1, 4, 3, 4}; - set_shape_labels(class_props_shape, 10); + auto symbols = set_shape_symbols(class_props_shape); auto class_probs = make_shared(element::f64, class_props_shape); auto class_bbox_deltas = make_shared(element::f64, class_bbox_shape); @@ -144,7 +144,7 @@ TEST(type_prop, proposal_v0_dynamic_bbox_deltas_dim1_batch_size_infer) { EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); } TEST(type_prop, proposal_v0_dynamic_class_probs_bbox_deltas_dim1_batch_size_infer) { @@ -157,7 +157,7 @@ TEST(type_prop, proposal_v0_dynamic_class_probs_bbox_deltas_dim1_batch_size_infe auto op = make_shared(class_probs, class_bbox_deltas, image_shape, attrs); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, proposal_v0_dynamic_range_class_probs_bbox_deltas_dim1_batch_size_infer) { @@ -166,8 +166,8 @@ TEST(type_prop, proposal_v0_dynamic_range_class_probs_bbox_deltas_dim1_batch_siz auto class_props_shape = PartialShape{{8, 14}, 2, 3, 4}; auto class_bbox_shape = PartialShape{{10, 15}, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -176,7 +176,7 @@ TEST(type_prop, proposal_v0_dynamic_range_class_probs_bbox_deltas_dim1_batch_siz auto op = make_shared(class_probs, class_bbox_deltas, image_shape, attrs); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn), 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, proposal_v0_dynamic_image_shape_shape_infer) { @@ -188,8 +188,8 @@ TEST(type_prop, proposal_v0_dynamic_image_shape_shape_infer) { auto class_props_shape = PartialShape{batch_size, 12, 34, 62}; auto class_bbox_shape = PartialShape{batch_size, 24, 34, 62}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -198,7 +198,7 @@ TEST(type_prop, proposal_v0_dynamic_image_shape_shape_infer) { auto op = make_shared(class_probs, class_bbox_deltas, image_shape, attrs); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, proposal_v0_class_probs_dynamic_rank_but_batch_shape_defined_in_bbox) { @@ -420,8 +420,8 @@ TEST(type_prop, proposal_v4_dynamic_class_probs_dim1_batch_size_infer) { auto class_props_shape = PartialShape{-1, 2, 3, 4}; auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + auto symbols = set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f64, class_props_shape); auto class_bbox_deltas = make_shared(element::f64, class_bbox_shape); @@ -431,10 +431,10 @@ TEST(type_prop, proposal_v4_dynamic_class_probs_dim1_batch_size_infer) { EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output::get_element_type, element::f64))); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(symbols[0])); } TEST(type_prop, proposal_v4_dynamic_bbox_deltas_dim1_batch_size_infer) { @@ -444,7 +444,7 @@ TEST(type_prop, proposal_v4_dynamic_bbox_deltas_dim1_batch_size_infer) { auto class_props_shape = PartialShape{batch_size, 2, 3, 4}; auto class_bbox_shape = PartialShape{-1, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); + auto symbols = set_shape_symbols(class_props_shape); auto class_probs = make_shared(element::bf16, class_props_shape); auto class_bbox_deltas = make_shared(element::bf16, class_bbox_shape); @@ -454,10 +454,10 @@ TEST(type_prop, proposal_v4_dynamic_bbox_deltas_dim1_batch_size_infer) { EXPECT_THAT(op->outputs(), Each(Property("Element type", &Output::get_element_type, element::bf16))); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(symbols[0])); } TEST(type_prop, proposal_v4_dynamic_class_probs_bbox_deltas_dim1_batch_size_infer) { @@ -466,7 +466,7 @@ TEST(type_prop, proposal_v4_dynamic_class_probs_bbox_deltas_dim1_batch_size_infe auto class_props_shape = PartialShape{-1, 2, 3, 4}; auto class_bbox_shape = PartialShape{-1, 4, 3, 4}; - set_shape_labels(class_bbox_shape, 20); + auto symbols = set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -475,10 +475,10 @@ TEST(type_prop, proposal_v4_dynamic_class_probs_bbox_deltas_dim1_batch_size_infe auto op = make_shared(class_probs, class_bbox_deltas, image_shape, attrs); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{-1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(20)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(symbols[0])); } TEST(type_prop, proposal_v4_dynamic_image_shape_shape_infer) { @@ -490,8 +490,8 @@ TEST(type_prop, proposal_v4_dynamic_image_shape_shape_infer) { auto class_props_shape = PartialShape{batch_size, 2, 3, 4}; auto class_bbox_shape = PartialShape{batch_size, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -500,10 +500,10 @@ TEST(type_prop, proposal_v4_dynamic_image_shape_shape_infer) { auto op = make_shared(class_probs, class_bbox_deltas, image_shape, attrs); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{batch_size * attrs.post_nms_topn, 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{batch_size * attrs.post_nms_topn})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), ElementsAre(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), ElementsAre(nullptr)); } TEST(type_prop, proposal_v4_everything_dynamic_shape_infer) { @@ -551,8 +551,8 @@ TEST(type_prop, proposal_v4_dynamic_range_class_probs_bbox_deltas_dim1_batch_siz auto class_props_shape = PartialShape{{8, 14}, 2, 3, 4}; auto class_bbox_shape = PartialShape{{10, 15}, 4, {0, 3}, {1, 4}}; - set_shape_labels(class_props_shape, 10); - set_shape_labels(class_bbox_shape, 20); + set_shape_symbols(class_props_shape); + set_shape_symbols(class_bbox_shape); auto class_probs = make_shared(element::f32, class_props_shape); auto class_bbox_deltas = make_shared(element::f32, class_bbox_shape); @@ -562,11 +562,11 @@ TEST(type_prop, proposal_v4_dynamic_range_class_probs_bbox_deltas_dim1_batch_siz EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn), 5})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); EXPECT_EQ(op->get_output_partial_shape(1), (PartialShape{Dimension(10 * attrs.post_nms_topn, 14 * attrs.post_nms_topn)})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(1)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(1)), Each(nullptr)); } TEST(type_prop, proposal_v4_class_dynamic_rank_but_batch_shape_defined_in_bbox) { diff --git a/src/core/tests/type_prop/psroi_pooling.cpp b/src/core/tests/type_prop/psroi_pooling.cpp index e180ea036815e8..5648652f890447 100644 --- a/src/core/tests/type_prop/psroi_pooling.cpp +++ b/src/core/tests/type_prop/psroi_pooling.cpp @@ -149,7 +149,7 @@ TEST_F(TypePropPSROIPoolingV0, invalid_output_dim_in_bilinear_mode) { TEST_F(TypePropPSROIPoolingV0, features_dynamic_rank) { auto coords_shape = PartialShape{150, 5}; - set_shape_labels(coords_shape, 20); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, PartialShape::dynamic()); const auto coords = std::make_shared(element::f16, coords_shape); @@ -157,13 +157,12 @@ TEST_F(TypePropPSROIPoolingV0, features_dynamic_rank) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({150, 2, 6, 6})); // 4d - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropPSROIPoolingV0, rois_dynamic_rank) { auto feat_shape = PartialShape{1, 72, 4, 5}; - set_shape_labels(feat_shape, 10); + set_shape_symbols(feat_shape); const auto inputs = std::make_shared(element::f16, feat_shape); const auto coords = std::make_shared(element::f16, PartialShape::dynamic()); @@ -171,12 +170,12 @@ TEST_F(TypePropPSROIPoolingV0, rois_dynamic_rank) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 2, 6, 6})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropPSROIPoolingV0, dynamic_num_boxes) { auto coords_shape = PartialShape{{Dimension::dynamic(), 5}}; - set_shape_labels(coords_shape, 20); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, PartialShape::dynamic()); const auto coords = std::make_shared(element::f16, coords_shape); @@ -184,15 +183,14 @@ TEST_F(TypePropPSROIPoolingV0, dynamic_num_boxes) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 2, 6, 6})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropPSROIPoolingV0, feat_static_rank_dynamic_shape) { auto feat_shape = PartialShape::dynamic(4); auto coords_shape = PartialShape{{Dimension::dynamic(), 5}}; - set_shape_labels(feat_shape, 10); - set_shape_labels(coords_shape, 20); + set_shape_symbols(feat_shape); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, feat_shape); const auto coords = std::make_shared(element::f16, coords_shape); @@ -200,15 +198,14 @@ TEST_F(TypePropPSROIPoolingV0, feat_static_rank_dynamic_shape) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 2, 6, 6})); // 4d - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropPSROIPoolingV0, feat_and_rois_static_rank_dynamic_shape) { auto feat_shape = PartialShape::dynamic(4); auto coords_shape = PartialShape::dynamic(2); - set_shape_labels(feat_shape, 10); - set_shape_labels(coords_shape, 20); + set_shape_symbols(feat_shape); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, feat_shape); const auto coords = std::make_shared(element::f16, coords_shape); @@ -216,15 +213,14 @@ TEST_F(TypePropPSROIPoolingV0, feat_and_rois_static_rank_dynamic_shape) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, 2, 6, 6})); // 4d - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropPSROIPoolingV0, feat_and_rois_interval_shapes) { auto feat_shape = PartialShape{{1, 2}, {10, 100}, {10, 20}, {30, 90}}; auto coords_shape = PartialShape{{3, 10}, {1, 5}}; - set_shape_labels(feat_shape, 10); - set_shape_labels(coords_shape, 20); + set_shape_symbols(feat_shape); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, feat_shape); const auto coords = std::make_shared(element::f16, coords_shape); @@ -232,15 +228,14 @@ TEST_F(TypePropPSROIPoolingV0, feat_and_rois_interval_shapes) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 10}, 2, 6, 6})); // 4d - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropPSROIPoolingV0, default_ctor) { auto feat_shape = PartialShape{2, {10, 100}, 10, 10}; auto coords_shape = PartialShape{{3, 10}, {1, 5}}; - set_shape_labels(feat_shape, 10); - set_shape_labels(coords_shape, 20); + set_shape_symbols(feat_shape); + auto symbols = set_shape_symbols(coords_shape); const auto inputs = std::make_shared(element::f16, feat_shape); const auto coords = std::make_shared(element::f16, coords_shape); @@ -260,6 +255,5 @@ TEST_F(TypePropPSROIPoolingV0, default_ctor) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 10}, 2, 6, 6})); // 4d - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(20, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } diff --git a/src/core/tests/type_prop/random_uniform.cpp b/src/core/tests/type_prop/random_uniform.cpp index 2ea0a9c6bbb317..6b9dfb995dd120 100644 --- a/src/core/tests/type_prop/random_uniform.cpp +++ b/src/core/tests/type_prop/random_uniform.cpp @@ -61,7 +61,7 @@ TEST(type_prop, random_uniform_dynamic_shape) { TEST(type_prop, random_uniform_dynamic_shape_with_labels) { auto shape = PartialShape{{0, 10}, 4, {3, 7}, -1}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto param = make_shared(element::i32, shape); auto out_shape = make_shared(param); @@ -72,7 +72,7 @@ TEST(type_prop, random_uniform_dynamic_shape_with_labels) { EXPECT_EQ(r->get_output_element_type(0), element::i64); EXPECT_EQ(r->get_output_partial_shape(0), PartialShape({{0, 10}, 4, {3, 7}, -1})); - EXPECT_THAT(get_shape_labels(r->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(r->get_output_partial_shape(0)), symbols); } TEST(type_prop, random_uniform_dynamic_rank) { diff --git a/src/core/tests/type_prop/rdft.cpp b/src/core/tests/type_prop/rdft.cpp index aaebcd6aebad40..1ba8d435384661 100644 --- a/src/core/tests/type_prop/rdft.cpp +++ b/src/core/tests/type_prop/rdft.cpp @@ -21,9 +21,22 @@ struct RDFTConstantAxesAndConstantSignalSizeTestParams { PartialShape ref_output_shape; std::vector axes; std::vector signal_size; - std::vector expected_labels; + std::vector expected_symbols; }; +namespace { +TensorSymbol from_idx_to_symbol_vector(const std::vector& indices, const TensorSymbol& initial_symbols) { + TensorSymbol result; + for (const auto& i : indices) { + if (i == 0) + result.push_back(nullptr); + else + result.push_back(initial_symbols[i - 10]); + } + return result; +} +} // namespace + struct RDFTConstantAxesAndConstantSignalSizeTest : ::testing::TestWithParam {}; @@ -31,7 +44,7 @@ TEST_P(RDFTConstantAxesAndConstantSignalSizeTest, rdft_constant_axes_and_signal_ auto params = GetParam(); auto input_shape = params.input_shape; - set_shape_labels(input_shape, 10); + auto symbols = set_shape_symbols(input_shape); auto data = std::make_shared(element::f32, input_shape); auto axes_input = op::v0::Constant::create(element::i64, params.axes_shape, params.axes); @@ -46,132 +59,133 @@ TEST_P(RDFTConstantAxesAndConstantSignalSizeTest, rdft_constant_axes_and_signal_ EXPECT_EQ(rdft->get_element_type(), element::f32); EXPECT_EQ(rdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(rdft->get_output_partial_shape(0)), params.expected_labels); + auto output_expected_symbols = from_idx_to_symbol_vector(params.expected_symbols, symbols); + EXPECT_EQ(get_shape_symbols(rdft->get_output_partial_shape(0)), output_expected_symbols); } INSTANTIATE_TEST_SUITE_P( type_prop, RDFTConstantAxesAndConstantSignalSizeTest, - ::testing::Values( - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, - {2}, - Shape{}, - {2, 180, 91, 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{6, 180, 180}, - {2}, - Shape{}, - {4, 180, 180, 2}, - {2, 0}, - {}, - {ov::no_label, 11, 12, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{16, 500, 180, 369}, - {3}, - Shape{}, - {16, 251, 180, 369, 2}, - {0, 3, 1}, - {}, - {10, ov::no_label, 12, 13, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(1, 18)}, - {2}, - Shape{}, - {2, 180, Dimension(1, 10), 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(7, 500)}, - {2}, - Shape{}, - {2, 180, Dimension(4, 251), 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), 180}, - {2}, - Shape{}, - {2, Dimension(7, 500), 91, 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), Dimension(7, 500)}, - {2}, - Shape{}, - {2, Dimension(7, 500), Dimension(4, 251), 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, 180}, - {2}, - Shape{}, - {Dimension(0, 2), 180, 91, 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, Dimension(7, 500)}, - {2}, - Shape{}, - {Dimension(0, 2), 180, Dimension(4, 251), 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), 180}, - {2}, - Shape{}, - {Dimension(0, 2), Dimension(7, 500), 91, 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), Dimension(7, 500)}, - {2}, - Shape{}, - {Dimension(0, 2), Dimension(7, 500), Dimension(4, 251), 2}, - {1, 2}, - {}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, - {2}, - {2}, - {2, 180, 39, 2}, - {1, 2}, - {-1, 77}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, - {2}, - {2}, - {44, 180, 390, 2}, - {2, 0}, - {390, 87}, - {0, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{7, 50, 130, 400}, - {3}, - {3}, - {7, 21, 130, 600, 2}, - {3, 0, 1}, - {600, -1, 40}, - {10, ov::no_label, 12, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(0, 200), 180}, - {2}, - {2}, - {2, Dimension(0, 200), 39, 2}, - {1, 2}, - {-1, 77}, - {10, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400)}, - {2}, - {2}, - {44, 180, 390, 2}, - {2, 0}, - {390, 87}, - {ov::no_label, 11, ov::no_label, ov::no_label}}, - RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(8, 129), 50, 130, Dimension(0, 500)}, - {3}, - {3}, - {Dimension(8, 129), 21, 130, 600, 2}, - {3, 0, 1}, - {600, -1, 40}, - {10, ov::no_label, 12, ov::no_label, ov::no_label}}), + ::testing::Values(RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, + {2}, + Shape{}, + {2, 180, 91, 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{6, 180, 180}, + {2}, + Shape{}, + {4, 180, 180, 2}, + {2, 0}, + {}, + {0, 11, 12, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{16, 500, 180, 369}, + {3}, + Shape{}, + {16, 251, 180, 369, 2}, + {0, 3, 1}, + {}, + {10, 0, 12, 13, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(1, 18)}, + {2}, + Shape{}, + {2, 180, Dimension(1, 10), 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, Dimension(7, 500)}, + {2}, + Shape{}, + {2, 180, Dimension(4, 251), 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), 180}, + {2}, + Shape{}, + {2, Dimension(7, 500), 91, 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(7, 500), Dimension(7, 500)}, + {2}, + Shape{}, + {2, Dimension(7, 500), Dimension(4, 251), 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, 180}, + {2}, + Shape{}, + {Dimension(0, 2), 180, 91, 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), 180, Dimension(7, 500)}, + {2}, + Shape{}, + {Dimension(0, 2), 180, Dimension(4, 251), 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 2), Dimension(7, 500), 180}, + {2}, + Shape{}, + {Dimension(0, 2), Dimension(7, 500), 91, 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{ + {Dimension(0, 2), Dimension(7, 500), Dimension(7, 500)}, + {2}, + Shape{}, + {Dimension(0, 2), Dimension(7, 500), Dimension(4, 251), 2}, + {1, 2}, + {}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, + {2}, + {2}, + {2, 180, 39, 2}, + {1, 2}, + {-1, 77}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, 180, 180}, + {2}, + {2}, + {44, 180, 390, 2}, + {2, 0}, + {390, 87}, + {0, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{7, 50, 130, 400}, + {3}, + {3}, + {7, 21, 130, 600, 2}, + {3, 0, 1}, + {600, -1, 40}, + {10, 0, 12, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{2, Dimension(0, 200), 180}, + {2}, + {2}, + {2, Dimension(0, 200), 39, 2}, + {1, 2}, + {-1, 77}, + {10, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400)}, + {2}, + {2}, + {44, 180, 390, 2}, + {2, 0}, + {390, 87}, + {0, 11, 0, 0}}, + RDFTConstantAxesAndConstantSignalSizeTestParams{{Dimension(8, 129), 50, 130, Dimension(0, 500)}, + {3}, + {3}, + {Dimension(8, 129), 21, 130, 600, 2}, + {3, 0, 1}, + {600, -1, 40}, + {10, 0, 12, 0, 0}}), PrintToDummyParamName()); TEST(type_prop, rdft_dynamic_axes) { @@ -204,7 +218,7 @@ TEST_P(RDFTNonConstantAxesTest, rdft_non_constant_axes) { EXPECT_EQ(rdft->get_element_type(), element::f32); EXPECT_EQ(rdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_THAT(get_shape_labels(rdft->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(rdft->get_output_partial_shape(0)), Each(nullptr)); } INSTANTIATE_TEST_SUITE_P( @@ -243,7 +257,7 @@ struct RDFTNonConstantSignalSizeTestParams { Shape signal_size_shape; PartialShape ref_output_shape; std::vector axes; - std::vector expected_labels; + std::vector expected_symbols; }; struct RDFTNonConstantSignalSizeTest : ::testing::TestWithParam {}; @@ -258,7 +272,8 @@ TEST_P(RDFTNonConstantSignalSizeTest, rdft_non_constant_signal_size) { EXPECT_EQ(rdft->get_element_type(), element::f32); EXPECT_EQ(rdft->get_output_partial_shape(0), params.ref_output_shape); - EXPECT_EQ(get_shape_labels(rdft->get_output_partial_shape(0)), params.expected_labels); + EXPECT_EQ(get_shape_symbols(rdft->get_output_partial_shape(0)), + TensorSymbol(params.expected_symbols.size(), nullptr)); } INSTANTIATE_TEST_SUITE_P( @@ -269,20 +284,20 @@ INSTANTIATE_TEST_SUITE_P( {2}, {2, Dimension(0, 200), Dimension::dynamic(), 2}, {1, 2}, - {ov::no_label, ov::no_label, ov::no_label, ov::no_label}}, + {0, 0, 0, 0}}, RDFTNonConstantSignalSizeTestParams{{Dimension(0, 18), 180, Dimension(0, 400)}, {2}, {2}, {Dimension::dynamic(), 180, Dimension(0, 400), 2}, {2, 0}, - {ov::no_label, ov::no_label, ov::no_label, ov::no_label}}, + {0, 0, 0, 0}}, RDFTNonConstantSignalSizeTestParams{ {Dimension(8, 129), 50, 130, Dimension(0, 500)}, {3}, {3}, {Dimension(8, 129), Dimension::dynamic(), 130, Dimension(0, 500), 2}, {3, 0, 1}, - {ov::no_label, ov::no_label, ov::no_label, ov::no_label, ov::no_label}}), + {0, 0, 0, 0, 0}}), PrintToDummyParamName()); TEST(type_prop, rdft_invalid_input) { diff --git a/src/core/tests/type_prop/read_value.cpp b/src/core/tests/type_prop/read_value.cpp index c021aafd89a130..d5d81606c424f0 100644 --- a/src/core/tests/type_prop/read_value.cpp +++ b/src/core/tests/type_prop/read_value.cpp @@ -108,21 +108,21 @@ TEST(type_prop, read_value_v6_no_init) { ASSERT_EQ(read_value->get_variable_id(), "variable_id"); } -TEST(type_prop, read_value_labels_propagation) { +TEST(type_prop, read_value_symbols_propagation) { auto variable_pshape = PartialShape{1, 2, 64, 64}; - set_shape_labels(variable_pshape, 10); + auto symbols = set_shape_symbols(variable_pshape); auto variable_info = op::util::VariableInfo{variable_pshape, element::f32, "variable_id"}; auto variable = std::make_shared(variable_info); std::shared_ptr read_value = std::make_shared(variable); - EXPECT_THAT(get_shape_labels(read_value->get_output_partial_shape(0)), testing::ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(read_value->get_output_partial_shape(0)), symbols); } -TEST(type_prop, DISABLED_read_value_labels_propagation_from_init_subgraph) { +TEST(type_prop, DISABLED_read_value_symbols_propagation_from_init_subgraph) { auto input_pshape = PartialShape{1, 2, 64, 64}; - set_shape_labels(input_pshape, 10); + auto symbols = set_shape_symbols(input_pshape); auto input = make_shared(element::f32, input_pshape); auto variable_info = op::util::VariableInfo{{1, 2, 64, 64}, element::f32, "variable_id"}; auto variable = std::make_shared(variable_info); std::shared_ptr read_value = std::make_shared(input, variable); - EXPECT_THAT(get_shape_labels(read_value->get_output_partial_shape(0)), testing::ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(read_value->get_output_partial_shape(0)), symbols); } diff --git a/src/core/tests/type_prop/reduce_ops.hpp b/src/core/tests/type_prop/reduce_ops.hpp index 55ed050dfcd3da..adf4d9e88729f5 100644 --- a/src/core/tests/type_prop/reduce_ops.hpp +++ b/src/core/tests/type_prop/reduce_ops.hpp @@ -254,13 +254,13 @@ TYPED_TEST_P(ReduceTest, reduce_dynamic_shape_data) { ASSERT_EQ(reduce_op->get_output_partial_shape(0), out_ps); } -TYPED_TEST_P(ReduceTest, dynamic_interval_labeled_shape_data_axes_const) { +TYPED_TEST_P(ReduceTest, dynamic_interval_symboled_shape_data_axes_const) { using namespace testing; PartialShape data_ps{-1, -1, 1, 1, 6, 16, {-1, 8}, {-1, 18}, {4, -1}, {14, -1}, {3, 9}, {13, 19}}; element::Type data_et = element::dynamic; - set_shape_labels(data_ps, 10); + auto symbols = set_shape_symbols(data_ps); Shape axes_ps{6}; element::Type axes_et = element::i64; @@ -273,16 +273,17 @@ TYPED_TEST_P(ReduceTest, dynamic_interval_labeled_shape_data_axes_const) { const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; auto reduce_op = makeReduceOp(params); EXPECT_EQ(reduce_op->get_output_partial_shape(0), out_ps); - EXPECT_THAT(get_shape_labels(reduce_op->get_output_partial_shape(0)), ElementsAre(10, 12, 14, 16, 18, 20)); + EXPECT_THAT(get_shape_symbols(reduce_op->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[2], symbols[4], symbols[6], symbols[8], symbols[10])); } -TYPED_TEST_P(ReduceTest, dynamic_interval_labeled_shape_data_axes_const_keep_dims) { +TYPED_TEST_P(ReduceTest, dynamic_interval_symboled_shape_data_axes_const_keep_dims) { using namespace testing; PartialShape data_ps{-1, -1, 1, 1, 6, 16, {-1, 8}, {-1, 18}, {4, -1}, {14, -1}, {3, 9}, {13, 19}}; element::Type data_et = element::dynamic; - set_shape_labels(data_ps, 10); + auto symbols = set_shape_symbols(data_ps); Shape axes_ps{6}; element::Type axes_et = element::i64; @@ -295,19 +296,19 @@ TYPED_TEST_P(ReduceTest, dynamic_interval_labeled_shape_data_axes_const_keep_dim const ReduceParams params{data_ps, data_et, axes_ps, axes, axes_et, keep_dims}; auto reduce_op = makeReduceOp(params); EXPECT_EQ(reduce_op->get_output_partial_shape(0), out_ps); - EXPECT_THAT(get_shape_labels(reduce_op->get_output_partial_shape(0)), - ElementsAre(10, - ov::no_label, - 12, - ov::no_label, - 14, - ov::no_label, - 16, - ov::no_label, - 18, - ov::no_label, - 20, - ov::no_label)); + EXPECT_THAT(get_shape_symbols(reduce_op->get_output_partial_shape(0)), + ElementsAre(symbols[0], + nullptr, + symbols[2], + nullptr, + symbols[4], + nullptr, + symbols[6], + nullptr, + symbols[8], + nullptr, + symbols[10], + nullptr)); } TYPED_TEST_P(ReduceTest, reduce_invalid_axis_out_of_range) { @@ -386,8 +387,8 @@ REGISTER_TYPED_TEST_SUITE_P(ReduceTest, reduce_dynamic_shape_reduced_axes_static_keep_dims, reduce_dynamic_shape_reduced_axes_not_static, reduce_dynamic_shape_reduced_axes_not_static_keep_dims, - dynamic_interval_labeled_shape_data_axes_const_keep_dims, - dynamic_interval_labeled_shape_data_axes_const, + dynamic_interval_symboled_shape_data_axes_const_keep_dims, + dynamic_interval_symboled_shape_data_axes_const, reduce_invalid_axis_out_of_range, reduce_invalid_axes_shape, reduce_invalid_axes_et); diff --git a/src/core/tests/type_prop/region_yolo.cpp b/src/core/tests/type_prop/region_yolo.cpp index 4534b204a89822..96dc868a0354f3 100644 --- a/src/core/tests/type_prop/region_yolo.cpp +++ b/src/core/tests/type_prop/region_yolo.cpp @@ -79,7 +79,7 @@ TEST_F(TypePropRegionYoloV0Test, data_input_static_rank_do_softmax) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape::dynamic(4); - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f64, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -87,7 +87,7 @@ TEST_F(TypePropRegionYoloV0Test, data_input_static_rank_do_softmax) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic(2)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); } TEST_F(TypePropRegionYoloV0Test, do_softmax_end_axis_is_negative) { @@ -96,7 +96,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_end_axis_is_negative) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape::dynamic(4); - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -104,7 +104,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_end_axis_is_negative) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic(2)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], nullptr)); } TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_eq_end_axis) { @@ -113,7 +113,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_eq_end_axis) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{5, 4, 10, 11}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -121,7 +121,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_eq_end_axis) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({5, 4, 10, 11})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_gt_end_axis) { @@ -130,7 +130,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_gt_end_axis) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{5, 4, 10, 11}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -138,7 +138,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_gt_end_axis) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({5, 4, 10, 11})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_end_axis_on_last_dim) { @@ -147,7 +147,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_end_axis_on_last_dim) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{5, 4, 10, 11}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -155,16 +155,16 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_axis_end_axis_on_last_dim) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({5, 4, 10, 11})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } -TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_labels_do_softmax) { +TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_symbols_do_softmax) { constexpr size_t num = 5, coords = 4, classes = 20; constexpr int axis = 2, end_axis = 3; const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{{2, 4}, {5, 8}, -1, {0, 10}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f16, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -172,7 +172,7 @@ TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_labels_do_softma EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{2, 4}, {5, 8}, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], nullptr)); } TEST_F(TypePropRegionYoloV0Test, do_softmax_start_axis_negative) { @@ -181,7 +181,7 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_start_axis_negative) { const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{{2, 4}, {5, 8}, -1, {0, 10}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f16, data_shape); const auto op = make_op(data, coords, classes, num, true, mask, axis, end_axis); @@ -189,16 +189,16 @@ TEST_F(TypePropRegionYoloV0Test, do_softmax_start_axis_negative) { EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{2, 4}, {5, 8}, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(symbols[0], symbols[1], nullptr)); } -TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_labels_no_softmax) { +TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_symbols_no_softmax) { constexpr size_t num = 5, coords = 4, classes = 20; constexpr int axis = 2, end_axis = 3; const std::vector mask{0, 1, 2}; auto data_shape = PartialShape{{2, 4}, {5, 8}, -1, {0, 10}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f16, data_shape); const auto op = make_op(data, coords, classes, num, false, mask, axis, end_axis); @@ -206,7 +206,8 @@ TEST_F(TypePropRegionYoloV0Test, data_input_interval_shape_with_labels_no_softma EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{2, 4}, 75, -1, {0, 10}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 0, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], symbols[3])); } TEST_F(TypePropRegionYoloV0Test, data_input_not_4d) { diff --git a/src/core/tests/type_prop/reorg_yolo.cpp b/src/core/tests/type_prop/reorg_yolo.cpp index de2c2e76d6f428..b34fc0e241d419 100644 --- a/src/core/tests/type_prop/reorg_yolo.cpp +++ b/src/core/tests/type_prop/reorg_yolo.cpp @@ -52,9 +52,9 @@ TEST_F(TypePropReorgYoloTest, stride_2_dynamic_shape) { EXPECT_EQ(reorg_yolo->get_output_partial_shape(0), expected_shape); } -TEST_F(TypePropReorgYoloTest, stride_2_interval_shape_with_labels) { +TEST_F(TypePropReorgYoloTest, stride_2_interval_shape_with_symbols) { auto in_shape = PartialShape{{1, 4}, {3, 9}, {16, 32}, {16, 32}}; - set_shape_labels(in_shape, 10); + auto symbols = set_shape_symbols(in_shape); size_t stride = 2; auto data_param = std::make_shared(element::f32, in_shape); @@ -64,8 +64,8 @@ TEST_F(TypePropReorgYoloTest, stride_2_interval_shape_with_labels) { const auto expected_shape = PartialShape{{1, 4}, {12, 36}, {8, 16}, {8, 16}}; EXPECT_EQ(reorg_yolo->get_output_partial_shape(0), expected_shape); - EXPECT_THAT(get_shape_labels(reorg_yolo->get_output_partial_shape(0)), - ElementsAre(10, no_label, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(reorg_yolo->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST_F(TypePropReorgYoloTest, stride_2_batch_2) { diff --git a/src/core/tests/type_prop/reshape.cpp b/src/core/tests/type_prop/reshape.cpp index b2d69f7a9304ea..7ed87ce4720ab2 100644 --- a/src/core/tests/type_prop/reshape.cpp +++ b/src/core/tests/type_prop/reshape.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/concat.hpp" #include "openvino/op/constant.hpp" @@ -37,16 +36,16 @@ TEST(type_prop, static_value_propagation) { ASSERT_EQ(r->get_shape(), (Shape{1, 2, 3})); } -TEST(type_prop, reshape_static_dimension_stops_label_propagation_for_auto_batch_case) { +TEST(type_prop, reshape_static_dimension_stops_symbol_propagation_for_auto_batch_case) { auto shape = ov::PartialShape({1, 1280, 1, 1}); - ov::DimensionTracker::set_label(shape[0], 1); + shape[0].set_symbol(std::make_shared()); auto param = make_shared(element::f32, shape); auto pattern = op::v0::Constant::create(element::i64, {2}, {-1, 1280}); auto r = make_shared(param, pattern, false); ASSERT_EQ(r->get_element_type(), element::f32); ASSERT_EQ(r->get_shape(), (Shape{1, 1280})); - ASSERT_EQ(ov::no_label, ov::DimensionTracker::get_label(r->get_output_partial_shape(0)[0])); + ASSERT_EQ(nullptr, r->get_output_partial_shape(0)[0].get_symbol()); } TEST(type_prop, interval_value_propagation) { @@ -680,9 +679,10 @@ TEST(type_prop, reshape_dynamic_shape_propagation_with_i32_precision) { ASSERT_EQ(reshape->get_output_partial_shape(0), (PartialShape{-1, -1, 1})); } -TEST(type_prop, reshape_dynamic_value_and_label_propagation) { +TEST(type_prop, reshape_dynamic_value_and_symbol_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -703,7 +703,7 @@ TEST(type_prop, reshape_dynamic_value_and_label_propagation) { const auto& output_shape = bc->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({3})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbol)); } TEST(type_prop, reshape_when_pattern_has_static_shape_only) { @@ -733,11 +733,11 @@ TEST(type_prop, reshape_when_pattern_has_scalar_shape_only) { HasSubstr("Input must be scalar as pattern is scalar!")); } -TEST(type_prop, reshape_label_propagation) { +TEST(type_prop, reshape_symbol_propagation) { auto param_shape = PartialShape{{1, 2}, {2, 4}, 6, {2, 4}, 8}; auto out_shape = PartialShape{{3, 5}, 0, 1, 0}; - set_shape_labels(param_shape, 10); - set_shape_labels(out_shape, 20); + auto in_symbols = set_shape_symbols(param_shape); + auto out_symbols = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, param_shape); const auto out = make_shared(element::f32, out_shape); @@ -748,14 +748,19 @@ TEST(type_prop, reshape_label_propagation) { const auto op = make_shared(data, shape, true); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 5}, {2, 4}, 1, {2, 4}, {10, 32}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 22, 13, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(out_symbols[0], in_symbols[1], out_symbols[2], in_symbols[3], nullptr)); } -TEST(type_prop, reshape_label_propagation_dynamic_pattern_got_same_label_as_input) { - auto param_shape = PartialShape{{1, 2}, {2, 4}, {3, 5}, {2, 4}, 8}; - auto out_shape = PartialShape{{3, 5}, 0, 1, 0, 8}; - set_shape_labels(param_shape, 10); - set_shape_labels(out_shape, {12, 21, 22, 23, 24}); +TEST(type_prop, reshape_symbol_propagation_dynamic_pattern_got_same_symbol_as_input) { + auto common_dim = Dimension(3, 5); + auto symbol = std::make_shared(); + common_dim.set_symbol(symbol); + + auto param_shape = PartialShape{{1, 2}, {2, 4}, common_dim, {2, 4}, 8}; + auto out_shape = PartialShape{common_dim, 0, 1, 0, 8}; + auto p_symbols = set_shape_symbols(param_shape); + auto out_symbols = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, param_shape); const auto out = make_shared(element::f32, out_shape); @@ -766,14 +771,15 @@ TEST(type_prop, reshape_label_propagation_dynamic_pattern_got_same_label_as_inpu const auto op = make_shared(data, shape, true); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 5}, {2, 4}, 1, {2, 4}, 8, {1, 2}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(12, 11, 22, 13, 24, 10)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbol, p_symbols[1], out_symbols[2], p_symbols[3], out_symbols[4], p_symbols[0])); } -TEST(type_prop, reshape_label_propagation_minus_one_corner_case_zero_div_by_inf) { +TEST(type_prop, reshape_symbol_propagation_minus_one_corner_case_zero_div_by_inf) { auto param_shape = PartialShape{0, 0}; auto out_shape = PartialShape{-1, 2}; - set_shape_labels(param_shape, 10); - set_shape_labels(out_shape, 20); + set_shape_symbols(param_shape); + auto symbols = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, param_shape); const auto out = make_shared(element::f32, out_shape); @@ -784,14 +790,14 @@ TEST(type_prop, reshape_label_propagation_minus_one_corner_case_zero_div_by_inf) const auto op = make_shared(data, shape, true); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, -1, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(ov::no_label, 20, 21)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(nullptr, symbols[0], symbols[1])); } TEST(type_prop, reshape_default_ctor) { auto param_shape = PartialShape{{1, 2}, {2, 4}, 6, {2, 4}, 8}; auto out_shape = PartialShape{{3, 5}, 0, 1, 0}; - set_shape_labels(param_shape, 10); - set_shape_labels(out_shape, 20); + auto in_symbols = set_shape_symbols(param_shape); + auto out_symbols = set_shape_symbols(out_shape); const auto data = make_shared(element::f32, param_shape); const auto out = make_shared(element::f32, out_shape); @@ -805,7 +811,8 @@ TEST(type_prop, reshape_default_ctor) { op->validate_and_infer_types(); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 5}, {2, 4}, 1, {2, 4}, {10, 32}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 22, 13, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(out_symbols[0], in_symbols[1], out_symbols[2], in_symbols[3], nullptr)); } TEST(type_prop, reshape_deduce_wrong_output_shape) { @@ -873,393 +880,443 @@ TEST(type_prop, reshape_zero_dim_in_output_pattern_but_not_in_data_shape) { "also zero-size")); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_input_has_zero) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_input_has_zero) { auto data_shape = PartialShape{4, 0, 2, 1, 3}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{3}, std::vector{12, 0, 1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({12, 0, 1})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_1) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_1) { auto data_shape = PartialShape{4, -1, 2, 1, 3}; - set_shape_labels(data_shape, 10); + auto in_symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{3}, std::vector{-1, 12, 2}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({-1, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(11, 21, 22)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(in_symbols[1], B, C)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_2) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_2) { auto data_shape = PartialShape{4, 2, {2, 6}, 1, 3}; - set_shape_labels(data_shape, 10); + auto in_symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{3}, std::vector{-1, 12, 2}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{2, 6}, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(12, 21, 22)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(in_symbols[2], B, C)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_3) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_3) { auto data_shape = PartialShape{{2, 4}, 2, {2, 6}, 1, 3}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{3}, std::vector{-1, 12, 2}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{1, 6}, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, 21, 22)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, B, C)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_4) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_4) { PartialShape data_shape = PartialShape{2, {2, 4}, 2, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{6}, std::vector{1, 4, 3, 1, 1, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24, 25}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(), F = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E, F}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 4, 3, 1, 1, {2, 4}})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22, 23, 24, 11)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C, D, E, symbols[1])); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_5) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_5) { PartialShape data_shape = PartialShape{2, 4, 2, 3}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{6}, std::vector{1, 4, 3, 1, 1, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24, 25}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(), F = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E, F}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 4, 3, 1, 1, 4})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22, 23, 24, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C, D, E, nullptr)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_6) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_6) { PartialShape data_shape = PartialShape{2, 3, 2, 1, 4}; - DimensionTracker::set_label(data_shape[1], 11); + data_shape[1].set_symbol(std::make_shared()); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{5}, std::vector{4, 1, -1, 1, 4}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({4, 1, 3, 1, 4})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, no_label, 23, 24)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, nullptr, D, E)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_7) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_7) { PartialShape data_shape = PartialShape{{1, 2}, 4, 2, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{4}, std::vector{4, 2, 3, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({4, 2, 3, {1, 2}})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22, 10)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C, symbols[0])); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_8) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_8) { PartialShape data_shape = PartialShape{{1, 2}, 4, 2, 3}; - DimensionTracker::set_label(data_shape[0], 121); + auto symbol = std::make_shared(); + data_shape[0].set_symbol(symbol); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{4}, std::vector{4, 2, 3, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({4, 2, 3, {1, 2}})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22, 121)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C, symbol)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_9) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_9) { PartialShape data_shape = PartialShape{2, 4, 2, 3}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{4}, std::vector{4, 2, 3, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({4, 2, 3, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 21, 22, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, C, nullptr)); } -TEST(type_prop, reshape_label_propagation_minus_one_no_special_zero_case_10) { +TEST(type_prop, reshape_symbol_propagation_minus_one_no_special_zero_case_10) { PartialShape data_shape = PartialShape{1, {1, -1}, {1, -1}, 512}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); constexpr int64_t squeeze_dim = 7 * 7 * 512; auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{2}, std::vector{-1, squeeze_dim}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21}); + auto A = std::make_shared(), B = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{1, -1}, squeeze_dim})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, 21)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, B)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_1) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_1) { auto data_shape = PartialShape{4, -1, 2, 1, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{3}, std::vector{-1, 12, 0}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({-1, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(11, 21, 12)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbols[1], B, symbols[2])); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_2) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_2) { auto data_shape = PartialShape{{2, 4}, 8, {2, 6}, 1, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{4}, std::vector{0, -1, 12, 2}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{2, 4}, {2, 6}, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, 12, 22, 23)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbols[0], symbols[2], C, D)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_3) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_3) { auto data_shape = PartialShape{{2, 4}, 8, 6, 1, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{4}, std::vector{0, -1, 12, 2}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{2, 4}, 6, 12, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, no_label, 22, 23)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbols[0], nullptr, C, D)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_4) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_4) { PartialShape data_shape = PartialShape{2, 10, 4, {1, 5}, {1, 2}, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{7}, std::vector{1, 0, 4, 0, 6, 1, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24, 25, 26}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(), F = std::make_shared(); + auto G = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E, F, G}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 10, 4, {1, 5}, 6, 1, {1, 2}})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 11, 22, 13, 24, 25, 14)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, symbols[1], C, symbols[3], E, F, symbols[4])); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_5) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_5) { PartialShape data_shape = PartialShape{2, 10, 4, {1, 5}, 2, 3}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{7}, std::vector{1, 0, 4, 0, 6, 1, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24, 25, 26}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(), F = std::make_shared(); + auto G = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E, F, G}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 10, 4, {1, 5}, 6, 1, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, 11, 22, 13, 24, 25, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, symbols[1], C, symbols[3], E, F, nullptr)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_6) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_6) { PartialShape data_shape = PartialShape{2, 3, 2, 1, 4}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{5}, std::vector{0, 0, -1, 0, 0}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24}); + output_pattern->get_default_output().get_tensor().set_value_symbol({std::make_shared(), + std::make_shared(), + std::make_shared(), + std::make_shared(), + std::make_shared()}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({2, 3, 2, 1, 4})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, 11, 12, 13, 14)); + EXPECT_THAT(get_shape_symbols(output_shape), symbols); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_7) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_7) { auto data_shape = PartialShape{{2, 4}, 12, -1, 1, 2}; - DimensionTracker::set_label(data_shape[2], 121); - DimensionTracker::set_label(data_shape[0], 10); + auto A = std::make_shared(), B = std::make_shared(); + data_shape[0].set_symbol(A); + data_shape[2].set_symbol(B); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{5}, std::vector{0, -1, 3, 4, 3}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, no_label}); + auto C = std::make_shared(), D = std::make_shared(), E = std::make_shared(), + F = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({C, D, E, F, nullptr}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{2, 4}, -1, 3, 4, 3})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, no_label, 22, 23, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, nullptr, E, F, nullptr)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_8) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_8) { auto data_shape = PartialShape{{2, 4}, 4, -1, 1, 3, 3}; - DimensionTracker::set_label(data_shape[2], 121); - DimensionTracker::set_label(data_shape[0], 10); + auto A = std::make_shared(), B = std::make_shared(); + data_shape[0].set_symbol(A); + data_shape[2].set_symbol(B); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{5}, std::vector{0, -1, 3, 4, 3}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, no_label}); + auto C = std::make_shared(), D = std::make_shared(); + auto E = std::make_shared(), F = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({C, D, E, F, nullptr}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({{2, 4}, -1, 3, 4, 3})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, 121, 22, 23, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, B, E, F, nullptr)); } -TEST(type_prop, reshape_label_propagation_minus_one_special_zero_case_9) { +TEST(type_prop, reshape_symbol_propagation_minus_one_special_zero_case_9) { PartialShape data_shape = PartialShape{2, 3, {2, 4}, 1, 4}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{5}, std::vector{0, 0, -1, 1, 0}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21, 22, 23, 24}); + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(); + auto D = std::make_shared(), E = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B, C, D, E}); const auto reshape = make_shared(input, output_pattern, true); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({2, 3, {2, 4}, 1, 4})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10, 11, 12, 23, 14)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbols[0], symbols[1], symbols[2], D, symbols[4])); } -TEST(type_prop, reshape_tricky_label_propagation_for_auto_batch_case_1) { +TEST(type_prop, reshape_tricky_symbol_propagation_for_auto_batch_case_1) { auto shape = PartialShape({1, 1280, 1, 1}); - DimensionTracker::set_label(shape[0], 1); + auto A = std::make_shared(); + shape[0].set_symbol(A); auto param = make_shared(element::f32, shape); auto pattern = op::v0::Constant::create(element::i64, {2}, {-1, 1280}); auto r = make_shared(param, pattern, false); auto output_shape = r->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 1280})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, nullptr)); } -TEST(type_prop, reshape_tricky_label_propagation_for_auto_batch_case_2) { +TEST(type_prop, reshape_tricky_symbol_propagation_for_auto_batch_case_2) { auto shape = ov::PartialShape({1, 1280, 1, 1}); - DimensionTracker::set_label(shape[2], 2); + auto A = std::make_shared(); + shape[2].set_symbol(A); auto param = make_shared(element::f32, shape); auto pattern = op::v0::Constant::create(element::i64, {2}, {-1, 1280}); auto r = make_shared(param, pattern, false); auto output_shape = r->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 1280})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, nullptr)); } -TEST(type_prop, reshape_tricky_label_propagation_for_auto_batch_case_3) { +TEST(type_prop, reshape_tricky_symbol_propagation_for_auto_batch_case_3) { auto shape = PartialShape({1, 1280, 1, 1}); - DimensionTracker::set_label(shape[0], 1); - DimensionTracker::set_label(shape[2], 2); + auto A = std::make_shared(), B = std::make_shared(); + shape[0].set_symbol(A); + shape[2].set_symbol(B); auto param = make_shared(element::f32, shape); auto pattern = op::v0::Constant::create(element::i64, {2}, {-1, 1280}); auto r = make_shared(param, pattern, false); auto output_shape = r->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 1280})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, nullptr)); } -TEST(type_prop, reshape_tricky_label_propagation_for_auto_batch_case_4) { +TEST(type_prop, reshape_tricky_symbol_propagation_for_auto_batch_case_4) { auto shape = PartialShape({1, 1280}); - DimensionTracker::set_label(shape[0], 1); + auto A = std::make_shared(); + shape[0].set_symbol(A); auto param = make_shared(element::f32, shape); auto pattern = op::v0::Constant::create(element::i64, {2}, {-1, 1280}); auto r = make_shared(param, pattern, false); auto output_shape = r->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, 1280})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(1, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, nullptr)); } TEST(type_prop, reshape_resolve_minus_one_when_static_product_same_value) { auto data_shape = PartialShape{2, 3, 4, 5}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto input = make_shared(element::f32, data_shape); auto output_pattern = make_shared(element::i64, Shape{2}, std::vector{120, -1}); - output_pattern->get_default_output().get_tensor().set_value_label({20, 21}); + auto A = std::make_shared(), B = std::make_shared(); + output_pattern->get_default_output().get_tensor().set_value_symbol({A, B}); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({120, 1})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(20, no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(A, nullptr)); } -TEST(type_prop, reshape_label_not_propagated_on_minus_one_dim_as_not_same_dynamic_dim) { +TEST(type_prop, reshape_symbol_not_propagated_on_minus_one_dim_as_not_same_dynamic_dim) { auto data_shape = PartialShape{-1, 2}; auto pattern_shape = PartialShape{-1, -1, 2}; - set_shape_labels(data_shape, {90, no_label}); - set_shape_labels(pattern_shape, {37, 87, 98}); + + auto A = std::make_shared(), B = std::make_shared(), C = std::make_shared(), + D = std::make_shared(), E = std::make_shared(); + + set_shape_symbols(data_shape, {A, nullptr}); + set_shape_symbols(pattern_shape, {B, C, D}); auto pattern = make_shared(element::i32, pattern_shape); auto pattern_shape_of = make_shared(pattern, element::i32); auto dim_minus_one = ov::op::v0::Constant::create(element::i32, {1}, {-1}); - dim_minus_one->get_default_output().get_tensor().set_value_label({93}); + dim_minus_one->get_default_output().get_tensor().set_value_symbol({E}); auto output_pattern = make_shared(OutputVector{dim_minus_one, pattern_shape_of}, 0); auto input = make_shared(element::f32, data_shape); const auto reshape = make_shared(input, output_pattern, false); auto output_shape = reshape->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({-1, -1, -1, 2})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(no_label, 37, 87, 98)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, B, C, D)); } TEST(type_prop, reshape_pattern_dim_has_invalid_bound) { diff --git a/src/core/tests/type_prop/reverse.cpp b/src/core/tests/type_prop/reverse.cpp index 094f81caf5519e..9df19eb70ce8f0 100644 --- a/src/core/tests/type_prop/reverse.cpp +++ b/src/core/tests/type_prop/reverse.cpp @@ -175,13 +175,13 @@ using namespace ov::opset10; // TEST_F(TypePropReverseV1Test, partial_rank_static_dynamic_axes_ok) { PartialShape param_shape{Dimension::dynamic(), {10, 300}, 2, 3}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto param = make_shared(element::f32, param_shape); auto rev = make_op(param, Constant::create(element::i64, {2}, {0, 2}), op::v1::Reverse::Mode::INDEX); EXPECT_EQ(rev->get_element_type(), element::f32); EXPECT_EQ(rev->get_output_partial_shape(0), param_shape); - EXPECT_THAT(get_shape_labels(rev->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(rev->get_output_partial_shape(0)), symbols); } TEST_F(TypePropReverseV1Test, axes_index_is_not_1d_tensor) { @@ -278,14 +278,14 @@ TEST_F(TypePropReverseV1Test, param_static_rank_partial_shape_axes_out_of_input_ TEST_F(TypePropReverseV1Test, param_static_rank_partial_shape_axes_negatives) { PartialShape param_shape{-1, {2, -1}, {-1, 3}, 5}; - set_shape_labels(param_shape, 10); + auto symbols = set_shape_symbols(param_shape); auto param = make_shared(element::f32, param_shape); auto op = make_op(param, Constant::create(element::i64, {3}, {0, -1, 2}), op::v1::Reverse::Mode::INDEX); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), param_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST_F(TypePropReverseV1Test, more_axes_index_than_input_rank) { diff --git a/src/core/tests/type_prop/reverse_sequence.cpp b/src/core/tests/type_prop/reverse_sequence.cpp index 50b2fceb626a56..450efa86a2d82b 100644 --- a/src/core/tests/type_prop/reverse_sequence.cpp +++ b/src/core/tests/type_prop/reverse_sequence.cpp @@ -213,7 +213,7 @@ TEST(type_prop, reverse_sequence_dynamic_invalid_seq_axis) { TEST(type_prop, reverse_sequence_dynamic_data_input_static_rank) { auto data_shape = PartialShape::dynamic(4); - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = std::make_shared(element::f32, data_shape); auto seq_lengths = std::make_shared(element::i32, PartialShape{3}); int64_t batch_axis = 2; @@ -222,7 +222,7 @@ TEST(type_prop, reverse_sequence_dynamic_data_input_static_rank) { EXPECT_EQ(reverse_seq->get_output_partial_shape(0), PartialShape({-1, -1, 3, -1})); EXPECT_EQ(reverse_seq->get_output_element_type(0), element::f32); - EXPECT_THAT(get_shape_labels(reverse_seq->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(reverse_seq->get_output_partial_shape(0)), symbols); } TEST(type_prop, reverse_sequence_dynamic_data_input_static_rank_seq_lengths_input_dynamic_rank) { @@ -309,11 +309,11 @@ TEST_F(TypePropReverseSequenceV0Test, default_ctor_no_arguments) { EXPECT_EQ(op->get_output_size(), 0); } -TEST_F(TypePropReverseSequenceV0Test, data_shape_interval_and_sequence_static_dim_with_labels) { +TEST_F(TypePropReverseSequenceV0Test, data_shape_interval_and_sequence_static_dim_with_symbols) { auto data_shape = PartialShape{{2, 5}, 4, {1, 3}}; auto seq_shape = PartialShape{3}; - set_shape_labels(data_shape, 10); - set_shape_labels(seq_shape, 20); + auto data_symbols = set_shape_symbols(data_shape); + set_shape_symbols(seq_shape); auto data = std::make_shared(element::f32, data_shape); auto seq_lengths = std::make_shared(element::i32, seq_shape); @@ -321,14 +321,15 @@ TEST_F(TypePropReverseSequenceV0Test, data_shape_interval_and_sequence_static_di EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({3, 4, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], data_symbols[1], data_symbols[2])); } -TEST_F(TypePropReverseSequenceV0Test, data_shape_and_sequence_interval_dim_with_labels) { +TEST_F(TypePropReverseSequenceV0Test, data_shape_and_sequence_interval_dim_with_symbols) { auto data_shape = PartialShape{{2, 5}, 4, {1, 3}}; auto seq_shape = PartialShape{{3, 6}}; - set_shape_labels(data_shape, 10); - set_shape_labels(seq_shape, 20); + auto data_symbols = set_shape_symbols(data_shape); + set_shape_symbols(seq_shape); auto data = std::make_shared(element::f32, data_shape); auto seq_lengths = std::make_shared(element::i32, seq_shape); @@ -336,5 +337,6 @@ TEST_F(TypePropReverseSequenceV0Test, data_shape_and_sequence_interval_dim_with_ EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 5}, 4, {1, 3}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(data_symbols[0], data_symbols[1], data_symbols[2])); } diff --git a/src/core/tests/type_prop/rnn_cell_base.cpp b/src/core/tests/type_prop/rnn_cell_base.cpp index 7a44a5dab0c059..4a2437e4f404ba 100644 --- a/src/core/tests/type_prop/rnn_cell_base.cpp +++ b/src/core/tests/type_prop/rnn_cell_base.cpp @@ -120,32 +120,34 @@ TYPED_TEST_P(RNNCellTest, default_ctor) { } } -TYPED_TEST_P(RNNCellTest, static_labels_dims_shape_infer) { +TYPED_TEST_P(RNNCellTest, static_symbols_dims_shape_infer) { RNNCellParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(); params.batch_size = Dimension(8); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64); - ov::DimensionTracker::set_label(params.input_size, 11); + params.input_size.set_symbol(B); params.hidden_size = Dimension(128); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); auto op = this->make_rnn_cell_based_op(params); EXPECT_EQ(op->get_output_size(), params.outputs_size); for (size_t i = 0; i < params.outputs_size; ++i) { EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, C)); } } -TYPED_TEST_P(RNNCellTest, interval_labels_dims_shape_infer) { +TYPED_TEST_P(RNNCellTest, interval_symbols_dims_shape_infer) { RNNCellParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(); params.batch_size = Dimension(8, 16); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64, 128); - ov::DimensionTracker::set_label(params.input_size, 11); + params.input_size.set_symbol(B); params.hidden_size = Dimension(128, 256); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); auto op = this->make_rnn_cell_based_op(params); EXPECT_EQ(op->get_output_size(), params.outputs_size); @@ -155,11 +157,11 @@ TYPED_TEST_P(RNNCellTest, interval_labels_dims_shape_infer) { // For backward compatibility, if hidden_size dim is dynamic, set the value based on attribute EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, static_cast(op->get_hidden_size())})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 0)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, nullptr)); } else { // For backward compatibility, hidden_size attribute is ignored EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, C)); } } } @@ -167,8 +169,8 @@ TYPED_TEST_P(RNNCellTest, interval_labels_dims_shape_infer) { REGISTER_TYPED_TEST_SUITE_P(RNNCellTest, basic_shape_infer, default_ctor, - static_labels_dims_shape_infer, - interval_labels_dims_shape_infer); + static_symbols_dims_shape_infer, + interval_symbols_dims_shape_infer); using RNNCellBaseTypes = Types; INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, RNNCellTest, RNNCellBaseTypes); diff --git a/src/core/tests/type_prop/rnn_seq_base.cpp b/src/core/tests/type_prop/rnn_seq_base.cpp index 05bf03f69fc2ba..a78c3cccae49ef 100644 --- a/src/core/tests/type_prop/rnn_seq_base.cpp +++ b/src/core/tests/type_prop/rnn_seq_base.cpp @@ -131,10 +131,10 @@ TYPED_TEST_P(RNNSeqBaseTest, basic_shape_infer) { EXPECT_EQ(op->get_output_size(), params.outputs_size); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 1, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); for (size_t i = 1; i < params.outputs_size; ++i) { EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 1, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), Each(nullptr)); } } @@ -145,10 +145,10 @@ TYPED_TEST_P(RNNSeqBaseTest, default_ctor) { EXPECT_EQ(op->get_output_size(), params.outputs_size); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 1, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); for (size_t i = 1; i < params.outputs_size; ++i) { EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 1, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), Each(nullptr)); } } @@ -162,71 +162,74 @@ TYPED_TEST_P(RNNSeqBaseTest, default_ctor_BIDIRECTIONAL) { EXPECT_EQ(op->get_output_size(), params.outputs_size); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 2, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); for (size_t i = 1; i < params.outputs_size; ++i) { EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 2, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), Each(nullptr)); } } -TYPED_TEST_P(RNNSeqBaseTest, static_labels_dims_shape_infer) { +TYPED_TEST_P(RNNSeqBaseTest, static_symbols_dims_shape_infer) { RNNSeqParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(), D = make_shared(); params.batch_size = Dimension(8); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64); - ov::DimensionTracker::set_label(params.seq_length, 11); + params.seq_length.set_symbol(B); params.hidden_size = Dimension(128); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); params.num_directions = Dimension(1); - ov::DimensionTracker::set_label(params.num_directions, 13); + params.num_directions.set_symbol(D); auto op = this->make_rnn_seq_based_op(params); EXPECT_EQ(op->get_output_size(), params.outputs_size); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 1, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 13, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(A, D, B, C)); for (size_t i = 1; i < params.outputs_size; ++i) { EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 1, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 13, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, D, C)); } } -TYPED_TEST_P(RNNSeqBaseTest, interval_labels_dims_shape_infer_FORWARD) { +TYPED_TEST_P(RNNSeqBaseTest, interval_symbols_dims_shape_infer_FORWARD) { RNNSeqParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(), D = make_shared(); params.batch_size = Dimension(8, 16); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64, 128); - ov::DimensionTracker::set_label(params.seq_length, 11); + params.seq_length.set_symbol(B); params.hidden_size = Dimension(128, 256); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); params.num_directions = Dimension(1, 2); - ov::DimensionTracker::set_label(params.num_directions, 13); + params.num_directions.set_symbol(D); auto op = this->make_rnn_seq_based_op(params); EXPECT_EQ(op->get_output_size(), params.outputs_size); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 1, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 13, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(A, D, B, C)); for (size_t i = 1; i < params.outputs_size; ++i) { // For backward compatibility, hidden_size attribute is ignored EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 1, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 13, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, D, C)); } } -TYPED_TEST_P(RNNSeqBaseTest, interval_labels_dims_shape_infer_REVERSE) { +TYPED_TEST_P(RNNSeqBaseTest, interval_symbols_dims_shape_infer_REVERSE) { RNNSeqParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(), D = make_shared(); params.batch_size = Dimension(8, 16); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64, 128); - ov::DimensionTracker::set_label(params.seq_length, 11); + params.seq_length.set_symbol(B); params.hidden_size = Dimension(128, 256); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); params.num_directions = Dimension(1, 2); - ov::DimensionTracker::set_label(params.num_directions, 13); + params.num_directions.set_symbol(D); params.direction = op::RecurrentSequenceDirection::REVERSE; @@ -235,24 +238,25 @@ TYPED_TEST_P(RNNSeqBaseTest, interval_labels_dims_shape_infer_REVERSE) { EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 1, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 13, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(A, D, B, C)); for (size_t i = 1; i < params.outputs_size; ++i) { // For backward compatibility, hidden_size attribute is ignored EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 1, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 13, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, D, C)); } } -TYPED_TEST_P(RNNSeqBaseTest, interval_labels_dims_shape_infer_BIDIRECTIONAL) { +TYPED_TEST_P(RNNSeqBaseTest, interval_symbols_dims_shape_infer_BIDIRECTIONAL) { RNNSeqParams params; + auto A = make_shared(), B = make_shared(), C = make_shared(), D = make_shared(); params.batch_size = Dimension(8, 16); - ov::DimensionTracker::set_label(params.batch_size, 10); + params.batch_size.set_symbol(A); params.input_size = Dimension(64, 128); - ov::DimensionTracker::set_label(params.seq_length, 11); + params.seq_length.set_symbol(B); params.hidden_size = Dimension(128, 256); - ov::DimensionTracker::set_label(params.hidden_size, 12); + params.hidden_size.set_symbol(C); params.num_directions = Dimension(1, 2); - ov::DimensionTracker::set_label(params.num_directions, 13); + params.num_directions.set_symbol(D); params.direction = op::RecurrentSequenceDirection::BIDIRECTIONAL; @@ -261,11 +265,11 @@ TYPED_TEST_P(RNNSeqBaseTest, interval_labels_dims_shape_infer_BIDIRECTIONAL) { EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{params.batch_size, 2, params.seq_length, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 13, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), ElementsAre(A, D, B, C)); for (size_t i = 1; i < params.outputs_size; ++i) { // For backward compatibility, hidden_size attribute is ignored EXPECT_EQ(op->get_output_partial_shape(i), (PartialShape{params.batch_size, 2, params.hidden_size})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(i)), ElementsAre(10, 13, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(i)), ElementsAre(A, D, C)); } } @@ -273,10 +277,10 @@ REGISTER_TYPED_TEST_SUITE_P(RNNSeqBaseTest, default_ctor, default_ctor_BIDIRECTIONAL, basic_shape_infer, - static_labels_dims_shape_infer, - interval_labels_dims_shape_infer_FORWARD, - interval_labels_dims_shape_infer_REVERSE, - interval_labels_dims_shape_infer_BIDIRECTIONAL); + static_symbols_dims_shape_infer, + interval_symbols_dims_shape_infer_FORWARD, + interval_symbols_dims_shape_infer_REVERSE, + interval_symbols_dims_shape_infer_BIDIRECTIONAL); using RNNSeqBaseTypes = Types; INSTANTIATE_TYPED_TEST_SUITE_P(type_prop, RNNSeqBaseTest, RNNSeqBaseTypes); diff --git a/src/core/tests/type_prop/roi_align.cpp b/src/core/tests/type_prop/roi_align.cpp index f31299b3f4ebb3..21f99890eef255 100644 --- a/src/core/tests/type_prop/roi_align.cpp +++ b/src/core/tests/type_prop/roi_align.cpp @@ -40,9 +40,9 @@ TYPED_TEST_P(ROIAlignTest, simple_shape_inference) { auto rois_shape = PartialShape{7, 4}; auto batch_shape = PartialShape{7}; - set_shape_labels(data_shape, 10); - set_shape_labels(rois_shape, 20); - set_shape_labels(batch_shape, 30); + auto data_symbols = set_shape_symbols(data_shape); + set_shape_symbols(rois_shape); + auto batch_symbols = set_shape_symbols(batch_shape); const auto data = make_shared(element::f16, data_shape); const auto rois = make_shared(element::f16, rois_shape); @@ -52,7 +52,8 @@ TYPED_TEST_P(ROIAlignTest, simple_shape_inference) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({7, 3, 2, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(batch_symbols[0], data_symbols[1], nullptr, nullptr)); } TYPED_TEST_P(ROIAlignTest, dynamic_channels_dim) { @@ -60,8 +61,8 @@ TYPED_TEST_P(ROIAlignTest, dynamic_channels_dim) { auto rois_shape = PartialShape{7, 4}; auto batch_shape = PartialShape{7}; - set_shape_labels(data_shape, 10); - set_shape_labels(batch_shape, 30); + auto data_symbols = set_shape_symbols(data_shape); + auto batch_symbols = set_shape_symbols(batch_shape); const auto data = make_shared(element::f64, data_shape); const auto rois = make_shared(element::f64, rois_shape); @@ -71,7 +72,8 @@ TYPED_TEST_P(ROIAlignTest, dynamic_channels_dim) { EXPECT_EQ(op->get_element_type(), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({7, -1, 3, 4})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(30, 11, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(batch_symbols[0], data_symbols[1], nullptr, nullptr)); } TYPED_TEST_P(ROIAlignTest, num_rois_from_batch_indices) { @@ -83,7 +85,7 @@ TYPED_TEST_P(ROIAlignTest, num_rois_from_batch_indices) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({9, 3, 4, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(ROIAlignTest, all_inputs_dynamic_rank) { @@ -95,7 +97,7 @@ TYPED_TEST_P(ROIAlignTest, all_inputs_dynamic_rank) { EXPECT_EQ(op->get_element_type(), element::bf16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, -1, 40, 12})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(ROIAlignTest, all_inputs_static_rank_dynamic_dims) { @@ -103,9 +105,9 @@ TYPED_TEST_P(ROIAlignTest, all_inputs_static_rank_dynamic_dims) { auto rois_shape = PartialShape::dynamic(2); auto batch_shape = PartialShape::dynamic(1); - set_shape_labels(data_shape, 10); - set_shape_labels(rois_shape, 20); - set_shape_labels(batch_shape, 30); + auto data_symbols = set_shape_symbols(data_shape); + set_shape_symbols(rois_shape); + auto batch_symbols = set_shape_symbols(batch_shape); const auto data = make_shared(element::f16, data_shape); const auto rois = make_shared(element::f16, rois_shape); @@ -115,7 +117,8 @@ TYPED_TEST_P(ROIAlignTest, all_inputs_static_rank_dynamic_dims) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({-1, -1, 8, 8})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(batch_symbols[0], data_symbols[1], nullptr, nullptr)); } TYPED_TEST_P(ROIAlignTest, interval_shapes) { @@ -123,9 +126,9 @@ TYPED_TEST_P(ROIAlignTest, interval_shapes) { auto rois_shape = PartialShape{{2, 10}, {2, -1}}; auto batch_shape = PartialShape{{3, 6}}; - set_shape_labels(data_shape, 10); - set_shape_labels(rois_shape, 20); - set_shape_labels(batch_shape, 30); + auto data_symbols = set_shape_symbols(data_shape); + set_shape_symbols(rois_shape); + auto batch_symbols = set_shape_symbols(batch_shape); const auto data = make_shared(element::f32, data_shape); const auto rois = make_shared(element::f32, rois_shape); @@ -135,7 +138,8 @@ TYPED_TEST_P(ROIAlignTest, interval_shapes) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({{3, 6}, {2, 4}, 8, 18})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, no_label, no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(batch_symbols[0], data_symbols[1], nullptr, nullptr)); } TYPED_TEST_P(ROIAlignTest, incompatible_num_rois) { diff --git a/src/core/tests/type_prop/roi_pooling.cpp b/src/core/tests/type_prop/roi_pooling.cpp index 0c5efb349a8e59..4d2b240f128dfb 100644 --- a/src/core/tests/type_prop/roi_pooling.cpp +++ b/src/core/tests/type_prop/roi_pooling.cpp @@ -51,8 +51,8 @@ TEST_F(TypePropROIPoolingV0, basic_shape_inference) { TEST_F(TypePropROIPoolingV0, dynamic_channels_dim) { auto feat_shape = PartialShape{1, -1, 6, 6}; auto rois_shape = PartialShape{4, 5}; - set_shape_labels(feat_shape, 10); - set_shape_labels(rois_shape, 20); + auto feat_symbols = set_shape_symbols(feat_shape); + auto rois_symbols = set_shape_symbols(rois_shape); const auto feat_maps = make_shared(element::f32, feat_shape); const auto rois = make_shared(element::f32, rois_shape); @@ -60,14 +60,15 @@ TEST_F(TypePropROIPoolingV0, dynamic_channels_dim) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, -1, 2, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(rois_symbols[0], feat_symbols[1], nullptr, nullptr)); } TEST_F(TypePropROIPoolingV0, dynamic_num_rois_dim) { auto feat_shape = PartialShape{1, 3, 6, 6}; auto rois_shape = PartialShape{-1, 5}; - set_shape_labels(feat_shape, 10); - set_shape_labels(rois_shape, 20); + auto feat_symbols = set_shape_symbols(feat_shape); + auto rois_symbols = set_shape_symbols(rois_shape); const auto feat_maps = make_shared(element::f64, feat_shape); const auto rois = make_shared(element::f64, rois_shape); @@ -75,7 +76,8 @@ TEST_F(TypePropROIPoolingV0, dynamic_num_rois_dim) { EXPECT_EQ(op->get_element_type(), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 3, 2, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(20, 11, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(rois_symbols[0], feat_symbols[1], nullptr, nullptr)); } TEST_F(TypePropROIPoolingV0, dynamic_rank_feat_maps) { @@ -85,7 +87,7 @@ TEST_F(TypePropROIPoolingV0, dynamic_rank_feat_maps) { EXPECT_EQ(op->get_element_type(), element::f16); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, -1, 2, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropROIPoolingV0, dynamic_rank_feat_rois) { @@ -95,7 +97,7 @@ TEST_F(TypePropROIPoolingV0, dynamic_rank_feat_rois) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{-1, 3, 2, 2})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } TEST_F(TypePropROIPoolingV0, incompatible_input_rank) { diff --git a/src/core/tests/type_prop/roll.cpp b/src/core/tests/type_prop/roll.cpp index 5a39e04f3cb02d..6e5802d20b34f7 100644 --- a/src/core/tests/type_prop/roll.cpp +++ b/src/core/tests/type_prop/roll.cpp @@ -15,7 +15,7 @@ class TypePropRollV7Test : public TypePropOpTest {}; TEST(type_prop, roll_output_shape_type_test) { auto arg_shape = PartialShape{3, 3, 4, 1, 5}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); auto arg = make_shared(element::f32, arg_shape); auto shift = make_shared(element::i32, Shape{2}); auto axes = make_shared(element::i64, Shape{2}); @@ -24,7 +24,7 @@ TEST(type_prop, roll_output_shape_type_test) { EXPECT_EQ(r->get_output_element_type(0), element::f32); EXPECT_EQ(r->get_output_partial_shape(0), PartialShape({3, 3, 4, 1, 5})); - EXPECT_THAT(get_shape_labels(r->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13, 14)); + EXPECT_THAT(get_shape_symbols(r->get_output_partial_shape(0)), symbols); } TEST(type_prop, roll_axis_const_test) { @@ -144,7 +144,7 @@ TEST(type_prop, roll_static_axes_dynamic_shift) { TEST_F(TypePropRollV7Test, static_axes_dynamic_data) { auto arg_shape = PartialShape{-1, -1}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const auto arg = make_shared(element::f32, arg_shape); const auto shift = Constant::create(element::i64, Shape{}, {5}); const auto axes = make_shared(element::i32, PartialShape{Dimension::dynamic()}); @@ -153,12 +153,12 @@ TEST_F(TypePropRollV7Test, static_axes_dynamic_data) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic(2)); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST_F(TypePropRollV7Test, const_shift_axes_and_interval_dim_on_arg_shape) { auto arg_shape = PartialShape{{2, 5}, {-1, 10}, {4, -1}, -1}; - set_shape_labels(arg_shape, 10); + auto symbols = set_shape_symbols(arg_shape); const auto arg = make_shared(element::f32, arg_shape); const auto shift = Constant::create(element::i64, Shape{}, {5}); const auto axes = Constant::create(element::i64, Shape{2}, {0, 1}); @@ -167,7 +167,7 @@ TEST_F(TypePropRollV7Test, const_shift_axes_and_interval_dim_on_arg_shape) { EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), arg_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), symbols); } TEST_F(TypePropRollV7Test, default_ctor) { diff --git a/src/core/tests/type_prop/scaled_dot_product_attention.cpp b/src/core/tests/type_prop/scaled_dot_product_attention.cpp index 60bf73e06792a7..890a8b52d45b09 100644 --- a/src/core/tests/type_prop/scaled_dot_product_attention.cpp +++ b/src/core/tests/type_prop/scaled_dot_product_attention.cpp @@ -196,13 +196,13 @@ TEST(type_prop, scaled_dot_product_attention_dynamic_4d) { TEST(type_prop, scaled_dot_product_attention_mixed_shape_infer_5_inputs) { PartialShape query_shape{{2, 4}, 3, {2, 5}, 4}; - set_shape_labels(query_shape, 10); + auto symbols = set_shape_symbols(query_shape); PartialShape key_shape{{4, 8}, {2, 4}, 5, 4}; - set_shape_labels(key_shape, 20); + set_shape_symbols(key_shape); PartialShape value_shape{{2, 4}, 3, 5, {3, 7}}; - set_shape_labels(value_shape, 40); + auto val_symbols = set_shape_symbols(value_shape); PartialShape attention_mask_shape{{2, 7}, 3, {4, 7}, 5}; - set_shape_labels(attention_mask_shape, 50); + set_shape_symbols(attention_mask_shape); const auto query = std::make_shared(element::dynamic, query_shape); const auto key = std::make_shared(element::f64, key_shape); const auto value = std::make_shared(element::dynamic, value_shape); @@ -214,7 +214,8 @@ TEST(type_prop, scaled_dot_product_attention_mixed_shape_infer_5_inputs) { std::make_shared(query, key, value, attention_mask, scale, causal); EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), (PartialShape{4, 3, {4, 5}, {3, 7}})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), testing::ElementsAre(50, 51, 52, 43)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + testing::ElementsAre(symbols[0], symbols[1], symbols[2], val_symbols[3])); } TEST(type_prop, scaled_dot_product_attention_mixed_shape_infer_5_inputs_ignore_attention) { diff --git a/src/core/tests/type_prop/scatter_elements_update.cpp b/src/core/tests/type_prop/scatter_elements_update.cpp index effdb1475a5648..21f952eec6aa2b 100644 --- a/src/core/tests/type_prop/scatter_elements_update.cpp +++ b/src/core/tests/type_prop/scatter_elements_update.cpp @@ -37,7 +37,7 @@ TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_output_shape) { TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_output_partial_dyn_shape) { PartialShape data_shape{2, Dimension::dynamic(), 5}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape indices_shape{Dimension::dynamic(), 2, 2}; PartialShape updates_shape{2, 2, Dimension::dynamic()}; PartialShape axis_shape = PartialShape::dynamic(); @@ -51,12 +51,12 @@ TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_output_partial_d EXPECT_EQ(scatter->get_output_element_type(0), element::f64); EXPECT_EQ(scatter->get_output_partial_shape(0), data_shape); - EXPECT_THAT(get_shape_labels(scatter->get_output_partial_shape(0)), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(scatter->get_output_partial_shape(0)), symbols); } TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_data_has_interval_dimensions) { PartialShape data_shape{{5, 10}, -1, {-1, 3}, {8, -1}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = make_shared(element::i64, data_shape); const auto indices = make_shared(element::i16, PartialShape{1, 2, 2, {2, 3}}); @@ -67,7 +67,7 @@ TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_data_has_interva EXPECT_EQ(scatter->get_output_element_type(0), element::i64); EXPECT_EQ(scatter->get_output_partial_shape(0), data_shape); - EXPECT_THAT(get_shape_labels(scatter->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(scatter->get_output_partial_shape(0)), symbols); } TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_output_full_dyn_shape) { @@ -101,7 +101,7 @@ TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_default_ctor) { EXPECT_EQ(scatter->get_output_size(), 1); EXPECT_EQ(scatter->get_output_element_type(0), element::f32); EXPECT_EQ(scatter->get_output_partial_shape(0), PartialShape({2, 5, 5, 6})); - EXPECT_THAT(get_shape_labels(scatter->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(scatter->get_output_partial_shape(0)), Each(nullptr)); } TYPED_TEST_P(ScatterElementsUpdateTest, @@ -109,7 +109,7 @@ TYPED_TEST_P(ScatterElementsUpdateTest, const auto data = op::v0::Constant::create(element::i64, Shape{4}, {2, 3, 15, 4}); const auto indices = op::v0::Constant::create(element::i64, Shape{2}, {3, 0}); auto updates_shape = PartialShape{{10, 20}, {3, 4}}; - set_shape_labels(updates_shape, 20); + auto symbols = set_shape_symbols(updates_shape); const auto axis = make_shared(element::i16, Shape{}, 0); const auto shape_of_u = @@ -120,7 +120,8 @@ TYPED_TEST_P(ScatterElementsUpdateTest, auto bc = std::make_shared(param, scatter, op::BroadcastType::BIDIRECTIONAL); EXPECT_EQ(bc->get_output_partial_shape(0), PartialShape({{3, 4}, 3, 15, {10, 20}})); - EXPECT_THAT(get_shape_labels(bc->get_output_partial_shape(0)), ElementsAre(21, ov::no_label, ov::no_label, 20)); + EXPECT_THAT(get_shape_symbols(bc->get_output_partial_shape(0)), + ElementsAre(symbols[1], nullptr, nullptr, symbols[0])); } TYPED_TEST_P(ScatterElementsUpdateTest, scatter_elements_update_axis_validation) { diff --git a/src/core/tests/type_prop/scatter_nd_update.cpp b/src/core/tests/type_prop/scatter_nd_update.cpp index d6bdb6bb0c29f1..c632e63ff5ea27 100644 --- a/src/core/tests/type_prop/scatter_nd_update.cpp +++ b/src/core/tests/type_prop/scatter_nd_update.cpp @@ -115,12 +115,12 @@ using namespace testing; class TypePropScatterUpdateNDV3Test : public TypePropOpTest { protected: void SetUp() override { - set_shape_labels(data_3d_dynamic, 10); + set_shape_symbols(data_3d_dynamic); } PartialShape data_3d_dynamic{{2, 5}, 2, {4, 10}}; }; -TEST_F(TypePropScatterUpdateNDV3Test, data_input_partial_shape_and_labels_propagation) { +TEST_F(TypePropScatterUpdateNDV3Test, data_input_partial_shape_and_symbols_propagation) { const auto d = std::make_shared(element::f32, data_3d_dynamic); const auto i = std::make_shared(element::i32, PartialShape{3, 2}); const auto u = std::make_shared(element::f32, PartialShape{3, 5}); @@ -131,7 +131,7 @@ TEST_F(TypePropScatterUpdateNDV3Test, data_input_partial_shape_and_labels_propag EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_element_type(0), element::f32); EXPECT_EQ(op->get_output_partial_shape(0), data_3d_dynamic); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), get_shape_symbols(data_3d_dynamic)); } TEST_F(TypePropScatterUpdateNDV3Test, indicies_input_is_dynamic) { @@ -143,7 +143,7 @@ TEST_F(TypePropScatterUpdateNDV3Test, indicies_input_is_dynamic) { EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), data_3d_dynamic); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), get_shape_symbols(data_3d_dynamic)); } TEST_F(TypePropScatterUpdateNDV3Test, updates_input_is_dynamic) { @@ -155,7 +155,7 @@ TEST_F(TypePropScatterUpdateNDV3Test, updates_input_is_dynamic) { EXPECT_EQ(op->get_output_element_type(0), element::f64); EXPECT_EQ(op->get_output_partial_shape(0), data_3d_dynamic); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), get_shape_symbols(data_3d_dynamic)); } TEST_F(TypePropScatterUpdateNDV3Test, indicies_input_has_interval_dimensions) { @@ -167,7 +167,7 @@ TEST_F(TypePropScatterUpdateNDV3Test, indicies_input_has_interval_dimensions) { EXPECT_EQ(op->get_output_element_type(0), element::i64); EXPECT_EQ(op->get_output_partial_shape(0), data_3d_dynamic); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), ElementsAre(10, 11, 12)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), get_shape_symbols(data_3d_dynamic)); } TEST_F(TypePropScatterUpdateNDV3Test, updates_input_is_scalar) { @@ -192,14 +192,14 @@ TEST_F(TypePropScatterUpdateNDV3Test, default_ctor) { EXPECT_EQ(op->get_output_element_type(0), element::i64); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, 3, 5, 1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), Each(nullptr)); } -TEST_F(TypePropScatterUpdateNDV3Test, preserve_partial_values_and_labels_via_evaluates_bounds) { +TEST_F(TypePropScatterUpdateNDV3Test, preserve_partial_values_and_symbols_via_evaluates_bounds) { const auto d = Constant::create(element::i64, Shape{4}, {2, 3, 15, 4}); const auto i = Constant::create(element::i64, Shape{2, 1}, {2, 0}); auto u_shape = PartialShape{{10, 20}, {3, 4}}; - set_shape_labels(u_shape, 20); + auto symbols = set_shape_symbols(u_shape); const auto shape_of_u = std::make_shared(std::make_shared(element::i64, u_shape)); const auto op = make_op(d, i, shape_of_u); @@ -208,7 +208,8 @@ TEST_F(TypePropScatterUpdateNDV3Test, preserve_partial_values_and_labels_via_eva auto bc = std::make_shared(param, op, op::BroadcastType::BIDIRECTIONAL); EXPECT_EQ(bc->get_output_partial_shape(0), PartialShape({{3, 4}, 3, {10, 20}, 4})); - EXPECT_THAT(get_shape_labels(bc->get_output_partial_shape(0)), ElementsAre(21, ov::no_label, 20, ov::no_label)); + EXPECT_THAT(get_shape_symbols(bc->get_output_partial_shape(0)), + ElementsAre(symbols[1], nullptr, symbols[0], nullptr)); } TEST_F(TypePropScatterUpdateNDV3Test, indices_dynamic_type) { diff --git a/src/core/tests/type_prop/scatter_update.cpp b/src/core/tests/type_prop/scatter_update.cpp index e932a1e8f96898..9fbe7022dc8acf 100644 --- a/src/core/tests/type_prop/scatter_update.cpp +++ b/src/core/tests/type_prop/scatter_update.cpp @@ -5,7 +5,6 @@ #include "openvino/op/scatter_update.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" @@ -218,8 +217,8 @@ TEST(type_prop, scatter_update_v3_dynamic_data_shape) { TEST(type_prop, scatter_update_v3_interval_label_data_shape) { auto labeled_dim = Dimension(1, 9); - ov::label_t label = 222; - ov::DimensionTracker::set_label(labeled_dim, label); + auto symbol = std::make_shared(); + labeled_dim.set_symbol(symbol); PartialShape data_shape = PartialShape{-1, {2, 8}, labeled_dim, 4}; Shape indices_shape{2, 1}; Shape updates_shape{3, 2, 1, 2, 4}; @@ -233,14 +232,14 @@ TEST(type_prop, scatter_update_v3_interval_label_data_shape) { const auto& output_shape = scatter_update->get_output_partial_shape(0); EXPECT_EQ(output_shape, data_shape); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(ov::no_label, ov::no_label, label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(nullptr, nullptr, symbol, nullptr)); EXPECT_EQ(scatter_update->get_output_element_type(0), element::f32); } TEST(type_prop, scatter_update_v3_value_label_propagation) { auto labeled_dim = Dimension(5, 7); - ov::label_t label = 2345664; - ov::DimensionTracker::set_label(labeled_dim, label); + auto symbol = std::make_shared(); + labeled_dim.set_symbol(symbol); PartialShape data_shape = PartialShape{labeled_dim}; auto data = make_shared(element::i8, data_shape); @@ -255,8 +254,8 @@ TEST(type_prop, scatter_update_v3_value_label_propagation) { const auto& output_shape = broadcast->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({1, {5, 7}})); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), ov::no_label); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[1]), label); + EXPECT_EQ(output_shape[0].get_symbol(), nullptr); + EXPECT_EQ(output_shape[1].get_symbol(), symbol); } TEST(type_prop, scatter_update_v3_partial_value_propagation) { diff --git a/src/core/tests/type_prop/select.cpp b/src/core/tests/type_prop/select.cpp index 35a1d7a8ae7148..218f805a07597f 100644 --- a/src/core/tests/type_prop/select.cpp +++ b/src/core/tests/type_prop/select.cpp @@ -5,7 +5,6 @@ #include "openvino/op/select.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" using namespace std; using namespace ov; @@ -40,12 +39,12 @@ TEST(type_prop, select_default_constructor) { EXPECT_EQ(op->get_output_shape(0), (Shape{2, 4})); } -TEST(type_prop, select_labels_cond_numpy) { - auto labeled_shape = PartialShape{{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}; - set_shape_labels(labeled_shape, 10); - ov::TensorLabel expected_labels{10, 11, 12, ov::no_label, 14}; +TEST(type_prop, select_symbols_cond_numpy) { + auto symboled_shape = PartialShape{{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}; + auto symbols = set_shape_symbols(symboled_shape); + ov::TensorSymbol expected_symbols{symbols[0], symbols[1], symbols[2], nullptr, symbols[4]}; - auto cond_param = make_shared(element::boolean, labeled_shape); + auto cond_param = make_shared(element::boolean, symboled_shape); auto then_param = make_shared(element::f32, PartialShape::dynamic(5)); auto else_param = make_shared(element::f32, PartialShape({{1, 5}, {1, 11}, 5, {1, 8}})); auto op = make_shared(cond_param, then_param, else_param); @@ -54,17 +53,17 @@ TEST(type_prop, select_labels_cond_numpy) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, PartialShape({{2, 8}, {3, 7}, -1, 5, -1})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, select_labels_then_numpy) { - auto labeled_shape = PartialShape::dynamic(5); - set_shape_labels(labeled_shape, 10); - ov::TensorLabel expected_labels{ov::no_label, ov::no_label, 12, ov::no_label, 14}; +TEST(type_prop, select_symbols_then_numpy) { + auto symboled_shape = PartialShape::dynamic(5); + auto symbols = set_shape_symbols(symboled_shape); + ov::TensorSymbol expected_symbols{nullptr, nullptr, symbols[2], nullptr, symbols[4]}; auto cond_param = make_shared(element::boolean, PartialShape{{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}); - auto then_param = make_shared(element::f32, labeled_shape); + auto then_param = make_shared(element::f32, symboled_shape); auto else_param = make_shared(element::f32, PartialShape({{1, 5}, {1, 11}, 5, {1, 8}})); auto op = make_shared(cond_param, then_param, else_param); @@ -72,88 +71,104 @@ TEST(type_prop, select_labels_then_numpy) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, PartialShape({{2, 8}, {3, 7}, -1, 5, -1})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, select_labels_else_numpy) { - auto labeled_shape = PartialShape{{1, 5}, {1, 11}, 5, {1, 8}}; - set_shape_labels(labeled_shape, 10); +TEST(type_prop, select_symbols_else_numpy) { + auto symboled_shape = PartialShape{{1, 5}, {1, 11}, 5, {1, 8}}; + auto symbols = set_shape_symbols(symboled_shape); - ov::TensorLabel expected_labels{ov::no_label, ov::no_label, 11, 12, 13}; + ov::TensorSymbol expected_symbols{nullptr, nullptr, symbols[1], symbols[2], symbols[3]}; auto cond_param = make_shared(element::boolean, PartialShape{{2, 8}, {3, 7}, {1, 10}, {1, 6}, {1, 10}}); auto then_param = make_shared(element::f32, PartialShape::dynamic(5)); - auto else_param = make_shared(element::f32, labeled_shape); + auto else_param = make_shared(element::f32, symboled_shape); auto op = make_shared(cond_param, then_param, else_param); const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, PartialShape({{2, 8}, {3, 7}, -1, 5, -1})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, select_labels_all_params_numpy) { - auto labeled_shape_cond = PartialShape{-1, 2, 1, 3, 1, {2, 5}, {1, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_then = PartialShape{-1, 2, 4, 1, 1, {1, 5}, {2, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_else = PartialShape{-1, 2, 1, 3, 5, {1, 7}, {1, 8}, {5, -1}, {-1, 5}}; - - set_shape_labels(labeled_shape_cond, 10); - set_shape_labels(labeled_shape_then, 20); - set_shape_labels(labeled_shape_else, 30); - - ov::TensorLabel expected_labels{10, 11, 22, 13, 34, 15, 26, 17, 18}; - - auto cond_param = make_shared(element::boolean, labeled_shape_cond); - auto then_param = make_shared(element::f32, labeled_shape_then); - auto else_param = make_shared(element::f32, labeled_shape_else); +TEST(type_prop, select_symbols_all_params_numpy) { + auto symboled_shape_cond = PartialShape{-1, 2, 1, 3, 1, {2, 5}, {1, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_then = PartialShape{-1, 2, 4, 1, 1, {1, 5}, {2, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_else = PartialShape{-1, 2, 1, 3, 5, {1, 7}, {1, 8}, {5, -1}, {-1, 5}}; + + auto cond_symbols = set_shape_symbols(symboled_shape_cond); + auto then_symbols = set_shape_symbols(symboled_shape_then); + auto else_symbols = set_shape_symbols(symboled_shape_else); + + ov::TensorSymbol expected_symbols{cond_symbols[0], + else_symbols[1], + then_symbols[2], + else_symbols[3], + else_symbols[4], + cond_symbols[5], + then_symbols[6], + else_symbols[7], + cond_symbols[8]}; + + auto cond_param = make_shared(element::boolean, symboled_shape_cond); + auto then_param = make_shared(element::f32, symboled_shape_then); + auto else_param = make_shared(element::f32, symboled_shape_else); auto op = make_shared(cond_param, then_param, else_param); const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, (PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, select_labels_all_params_none) { - auto labeled_shape_cond = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_then = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_else = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; +TEST(type_prop, select_symbols_all_params_none) { + auto symboled_shape_cond = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_then = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_else = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; - set_shape_labels(labeled_shape_cond, 10); - set_shape_labels(labeled_shape_then, 20); - set_shape_labels(labeled_shape_else, 30); + auto cond_symbols = set_shape_symbols(symboled_shape_cond); + auto then_symbols = set_shape_symbols(symboled_shape_then); + auto else_symbols = set_shape_symbols(symboled_shape_else); - ov::TensorLabel expected_labels{10, 11, 12, 13, 14, 15, 16, 17, 18}; + ov::TensorSymbol expected_symbols{else_symbols}; - auto cond_param = make_shared(element::boolean, labeled_shape_cond); - auto then_param = make_shared(element::f32, labeled_shape_then); - auto else_param = make_shared(element::f32, labeled_shape_else); + auto cond_param = make_shared(element::boolean, symboled_shape_cond); + auto then_param = make_shared(element::f32, symboled_shape_then); + auto else_param = make_shared(element::f32, symboled_shape_else); auto op = make_shared(cond_param, then_param, else_param, op::AutoBroadcastType::NONE); const auto& out_shape = op->get_output_partial_shape(0); EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, (PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_THAT(get_shape_symbols(out_shape), expected_symbols); } -TEST(type_prop, select_labels_all_params_pdpd) { - auto labeled_shape_cond = PartialShape{-1, 2, 1, 1, 1, {1, 5}, {1, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_then = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; - auto labeled_shape_else = PartialShape{-1, 2, 1, 3, 1, {1, 5}, {1, 8}, {5, -1}, {-1, 5}}; - - set_shape_labels(labeled_shape_cond, 10); - set_shape_labels(labeled_shape_then, 20); - set_shape_labels(labeled_shape_else, 30); - - ov::TensorLabel expected_labels{10, 11, 22, 33, 24, 25, 26, 17, 18}; - - auto cond_param = make_shared(element::boolean, labeled_shape_cond); - auto then_param = make_shared(element::f32, labeled_shape_then); - auto else_param = make_shared(element::f32, labeled_shape_else); +TEST(type_prop, select_symbols_all_params_pdpd) { + auto symboled_shape_cond = PartialShape{-1, 2, 1, 1, 1, {1, 5}, {1, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_then = PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}}; + auto symboled_shape_else = PartialShape{-1, 2, 1, 3, 1, {1, 5}, {1, 8}, {5, -1}, {-1, 5}}; + + auto cond_symbols = set_shape_symbols(symboled_shape_cond); + auto then_symbols = set_shape_symbols(symboled_shape_then); + auto else_symbols = set_shape_symbols(symboled_shape_else); + + ov::TensorSymbol expected_symbols{cond_symbols[0], + then_symbols[1], + then_symbols[2], + then_symbols[3], + then_symbols[4], + then_symbols[5], + then_symbols[6], + then_symbols[7], + cond_symbols[8]}; + + auto cond_param = make_shared(element::boolean, symboled_shape_cond); + auto then_param = make_shared(element::f32, symboled_shape_then); + auto else_param = make_shared(element::f32, symboled_shape_else); auto op = make_shared(cond_param, then_param, else_param, @@ -163,7 +178,7 @@ TEST(type_prop, select_labels_all_params_pdpd) { EXPECT_EQ(op->get_element_type(), element::f32); EXPECT_EQ(out_shape, (PartialShape{-1, 2, 4, 3, 5, {2, 5}, {2, 8}, {5, -1}, {-1, 5}})); - EXPECT_EQ(get_shape_labels(out_shape), expected_labels); + EXPECT_EQ(get_shape_symbols(out_shape), expected_symbols); } TEST(type_prop, select_dynamic) { diff --git a/src/core/tests/type_prop/shape_of.cpp b/src/core/tests/type_prop/shape_of.cpp index b9065404f66d11..3556bf654d64fc 100644 --- a/src/core/tests/type_prop/shape_of.cpp +++ b/src/core/tests/type_prop/shape_of.cpp @@ -5,7 +5,6 @@ #include "openvino/op/shape_of.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" using namespace std; @@ -108,7 +107,8 @@ TEST(type_prop, shape_of_output_type_v3) { TEST(type_prop, shape_of_1_dynamic_value_and_label_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -119,12 +119,13 @@ TEST(type_prop, shape_of_1_dynamic_value_and_label_propagation) { ASSERT_EQ(bc->get_shape(), (Shape{3, 4})); const auto& output_shape = bc->get_output_partial_shape(0); - ASSERT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + ASSERT_EQ(output_shape[0].get_symbol(), symbol); } TEST(type_prop, shape_of_3_dynamic_value_and_label_propagation) { Dimension marked_0 = Dimension(3); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -135,7 +136,7 @@ TEST(type_prop, shape_of_3_dynamic_value_and_label_propagation) { ASSERT_EQ(bc->get_shape(), (Shape{3, 4})); const auto& output_shape = bc->get_output_partial_shape(0); - ASSERT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + ASSERT_EQ(output_shape[0].get_symbol(), symbol); } TEST(type_prop, shape_of_3_dynamic_value_propagation_out_i32) { diff --git a/src/core/tests/type_prop/shuffle_channels.cpp b/src/core/tests/type_prop/shuffle_channels.cpp index b7ccc064928dce..1a8c26c4a9362e 100644 --- a/src/core/tests/type_prop/shuffle_channels.cpp +++ b/src/core/tests/type_prop/shuffle_channels.cpp @@ -33,7 +33,7 @@ TEST(type_prop, shuffle_channels_basic_4D) { TEST(type_prop, shuffle_channels_dynamic_4D) { auto data_input_shape = PartialShape{Dimension::dynamic(), Dimension(3, 9), 4, Dimension(4, 15)}; - set_shape_labels(data_input_shape, 10); + auto symbols = set_shape_symbols(data_input_shape); const auto data = make_shared(element::f32, data_input_shape); const auto axis = 1; const auto group = 3; @@ -41,7 +41,8 @@ TEST(type_prop, shuffle_channels_dynamic_4D) { EXPECT_EQ(shuffle_channels->get_element_type(), element::f32); EXPECT_EQ(shuffle_channels->get_output_partial_shape(0), data_input_shape); - EXPECT_THAT(get_shape_labels(shuffle_channels->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12, 13)); + EXPECT_THAT(get_shape_symbols(shuffle_channels->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2], symbols[3])); } TEST(type_prop, shuffle_channels_dynamic_fully) { diff --git a/src/core/tests/type_prop/slice.cpp b/src/core/tests/type_prop/slice.cpp index eee514de8a21ab..d6b9730fb2e1ad 100644 --- a/src/core/tests/type_prop/slice.cpp +++ b/src/core/tests/type_prop/slice.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/opsets/opset9.hpp" #include "sequnce_generator.hpp" @@ -142,11 +141,11 @@ TEST(type_prop, slice_v8_basic_const_inputs_unordered_axes) { EXPECT_EQ(op->get_output_partial_shape(0), expected_out_shape); } -TEST(type_prop, slice_v8_const_inputs_not_all_axes_unordered_prop_labels) { +TEST(type_prop, slice_v8_const_inputs_not_all_axes_unordered_prop_symbols) { PartialShape data_shape{10, 10, 10, 10, 10, 20, Dimension(20, 30), 30, Dimension(2, 5), Dimension(-1)}; PartialShape expected_out_shape{4, 7, 10, 10, 9, 20, Dimension(10, 15), 30, Dimension(2, 5), Dimension(-1)}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); std::vector start_val{1, 1, -20, 9, 10, 9}; std::vector stop_val{8, 8, 20, -11, 25, 0}; @@ -161,8 +160,17 @@ TEST(type_prop, slice_v8_const_inputs_not_all_axes_unordered_prop_labels) { EXPECT_EQ(op->get_element_type(), et); EXPECT_EQ(op->get_output_partial_shape(0), expected_out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, 12, 13, ov::no_label, 15, ov::no_label, 17, 18, 19)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(nullptr, + nullptr, + symbols[2], + symbols[3], + nullptr, + symbols[5], + nullptr, + symbols[7], + symbols[8], + symbols[9])); } TEST(type_prop, slice_v8_basic_const_inputs_data_dynamic_bounds_dimensions) { @@ -206,7 +214,7 @@ TEST(type_prop, slice_v8_basic_const_inputs_data_dynamic_rank) { EXPECT_TRUE(op->get_output_partial_shape(0).rank().is_dynamic()); } -TEST(type_prop, slice_v8_basic_param_inputs_default_axes_labels_prop) { +TEST(type_prop, slice_v8_basic_param_inputs_default_axes_symbols_prop) { PartialShape data_shape{Dimension(0, 10), Dimension(1, 10), 10, @@ -225,7 +233,7 @@ TEST(type_prop, slice_v8_basic_param_inputs_default_axes_labels_prop) { Dimension(0, 8), Dimension(4, 8), 16}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); PartialShape start_shape{7}; PartialShape stop_shape{7}; @@ -242,8 +250,9 @@ TEST(type_prop, slice_v8_basic_param_inputs_default_axes_labels_prop) { EXPECT_EQ(op->get_element_type(), et); EXPECT_EQ(op->get_output_partial_shape(0), expected_out_shape); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label, ov::no_label, ov::no_label, 16, 17, 18)); + EXPECT_THAT( + get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr, nullptr, nullptr, symbols[6], symbols[7], symbols[8])); } TEST(type_prop, slice_v8_sss_param_inputs_mixed_neg_const_axes) { @@ -1061,9 +1070,10 @@ TEST(type_prop, slice_v8_dynamic_rank_inputs) { EXPECT_EQ(op->get_output_partial_shape(0), dyn_rank_shape); } -TEST(type_prop, slice_v8_dynamic_value_and_label_propagation) { +TEST(type_prop, slice_v8_dynamic_value_and_symbol_propagation) { Dimension marked_0 = Dimension(3, 7); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -1081,7 +1091,7 @@ TEST(type_prop, slice_v8_dynamic_value_and_label_propagation) { const auto& output_shape = bc->get_output_partial_shape(0); EXPECT_EQ(output_shape, (PartialShape{{3, 7}})); - EXPECT_EQ(ov::DimensionTracker::get_label(output_shape[0]), 10); + EXPECT_EQ(output_shape[0].get_symbol(), symbol); } TEST(type_prop, slice_v8_dynamic_dimension_but_slice_min_is_lt_input_min_size) { @@ -1118,7 +1128,7 @@ TEST(type_prop, slice_v8_use_default_ctor) { TEST(type_prop, slice_v8_stop_is_shape_of_with_bounds) { auto shape = PartialShape{1, {5, 7}}; - set_shape_labels(shape, 20); + set_shape_symbols(shape); const auto p_stop = std::make_shared(element::i64, shape); const auto shape_of_stop = std::make_shared(p_stop); @@ -1129,12 +1139,12 @@ TEST(type_prop, slice_v8_stop_is_shape_of_with_bounds) { auto slice = std::make_shared(data, start, shape_of_stop, steps); EXPECT_EQ(slice->get_output_partial_shape(0), PartialShape({1, {5, 7}})); - EXPECT_THAT(get_shape_labels(slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, slice_v8_start_is_shape_of_with_bounds) { auto shape = PartialShape{0, {3, 5}}; - set_shape_labels(shape, 20); + set_shape_symbols(shape); const auto p_start = std::make_shared(element::i64, shape); const auto shape_of_start = std::make_shared(p_start); @@ -1145,14 +1155,14 @@ TEST(type_prop, slice_v8_start_is_shape_of_with_bounds) { auto slice = std::make_shared(data, shape_of_start, stop, steps); EXPECT_EQ(slice->get_output_partial_shape(0), PartialShape({1, {2, 4}})); - EXPECT_THAT(get_shape_labels(slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, slice_v8_start_stop_is_shape_of_with_bounds) { auto start_shape = PartialShape{0, {3, 5}}; auto stop_shape = PartialShape{2, {6, 7}}; - set_shape_labels(start_shape, 10); - set_shape_labels(stop_shape, 20); + set_shape_symbols(start_shape); + set_shape_symbols(stop_shape); const auto p_start = std::make_shared(element::i64, start_shape); const auto p_stop = std::make_shared(element::i64, stop_shape); const auto shape_of_start = std::make_shared(p_start); @@ -1164,7 +1174,7 @@ TEST(type_prop, slice_v8_start_stop_is_shape_of_with_bounds) { auto slice = std::make_shared(data, shape_of_start, shape_of_stop, steps); EXPECT_EQ(slice->get_output_partial_shape(0), PartialShape({1, {1, 4}})); - EXPECT_THAT(get_shape_labels(slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, slice_v8_unknowns_axes) { diff --git a/src/core/tests/type_prop/space_to_batch.cpp b/src/core/tests/type_prop/space_to_batch.cpp index cc68b2c755cc44..b433c6f8e1f6c6 100644 --- a/src/core/tests/type_prop/space_to_batch.cpp +++ b/src/core/tests/type_prop/space_to_batch.cpp @@ -72,7 +72,7 @@ TEST(type_prop, space_to_batch_and_batch_to_space) { TEST(type_prop, space_to_batch_when_space_is_static) { auto data_shape = PartialShape{{2, 5}, 100, 1024, 3}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto data = make_shared(element::f32, data_shape); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 12, 100, 2}); auto pads_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 38, 1}); @@ -83,12 +83,12 @@ TEST(type_prop, space_to_batch_when_space_is_static) { EXPECT_EQ( space_to_batch->get_output_partial_shape(0), (PartialShape{{2 * 12 * 100 * 2, 5 * 12 * 100 * 2}, (100 + 3 + 5) / 12, (1024 + 38 + 38) / 100, (3 + 1) / 2})); - EXPECT_THAT(get_shape_labels(space_to_batch->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(space_to_batch->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, space_to_batch_when_data_dynamic_) { auto data_shape = PartialShape{{2, 5}, {5, 100}, {100, 1024}, {3, 10}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); auto data = make_shared(element::f32, data_shape); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 1, 1, 1}); auto pads_begin = make_shared(element::i64, Shape{4}, vector{1, 0, 2, 0}); @@ -98,12 +98,13 @@ TEST(type_prop, space_to_batch_when_data_dynamic_) { EXPECT_EQ(space_to_batch->get_output_partial_shape(0), PartialShape({{2, 5}, {5, 100}, {(100 + 2 + 3) / 1, (1024 + 2 + 3) / 1}, {3, 10}})); - EXPECT_THAT(get_shape_labels(space_to_batch->get_output_partial_shape(0)), ElementsAre(10, 11, ov::no_label, 13)); + EXPECT_THAT(get_shape_symbols(space_to_batch->get_output_partial_shape(0)), + ElementsAre(symbols[0], symbols[1], nullptr, symbols[3])); } TEST(type_prop, space_to_batch_when_space_is_dynamic) { auto data_shape = PartialShape{{2, 5}, {5, 100}, {100, 1024}, {3, 10}}; - set_shape_labels(data_shape, 10); + set_shape_symbols(data_shape); auto data = make_shared(element::f32, data_shape); auto block_shape = make_shared(element::i64, Shape{4}, vector{1, 12, 100, 2}); auto pads_begin = make_shared(element::i64, Shape{4}, vector{0, 3, 38, 1}); @@ -116,7 +117,7 @@ TEST(type_prop, space_to_batch_when_space_is_dynamic) { {DIV_ROUND_UP((5 + 5 + 3), 12), (100 + 5 + 3) / 12}, {DIV_ROUND_UP((100 + 38 + 38), 100), (1024 + 38 + 38) / 100}, {DIV_ROUND_UP((3 + 1), 2), (10 + 1) / 2}})); - EXPECT_THAT(get_shape_labels(space_to_batch->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(space_to_batch->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, space_to_batch_dynamic_shape_static_rank) { diff --git a/src/core/tests/type_prop/space_to_depth.cpp b/src/core/tests/type_prop/space_to_depth.cpp index a6462f86c764bf..070ce783679f98 100644 --- a/src/core/tests/type_prop/space_to_depth.cpp +++ b/src/core/tests/type_prop/space_to_depth.cpp @@ -52,19 +52,19 @@ TEST(type_prop, space_to_depth_output_shape_depth_first_5D) { TEST(type_prop, space_to_depth_output_shape_depth_first_5D_1) { auto a_shape = PartialShape{{1, 4}, {12, 36}, 1080, 1616}; - set_shape_labels(a_shape, 10); + auto symbols = set_shape_symbols(a_shape); auto A = make_shared(element::f32, a_shape); const auto mode = ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; auto space_to_depth = make_shared(A, mode, 1); EXPECT_EQ(space_to_depth->get_element_type(), element::f32); EXPECT_EQ(space_to_depth->get_output_partial_shape(0), a_shape); - EXPECT_THAT(get_shape_labels(space_to_depth->get_output_partial_shape(0)), ElementsAre(10, 11, 12, 13)); + EXPECT_THAT(get_shape_symbols(space_to_depth->get_output_partial_shape(0)), symbols); } TEST(type_prop, space_to_depth_output_shape_when_space_is_static) { auto a_shape = PartialShape{{1, 4}, {12, 36}, 1080, 1616}; - set_shape_labels(a_shape, 10); + auto symbols = set_shape_symbols(a_shape); auto A = make_shared(element::f32, a_shape); const auto mode = ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; auto space_to_depth = make_shared(A, mode, 2); @@ -72,13 +72,13 @@ TEST(type_prop, space_to_depth_output_shape_when_space_is_static) { EXPECT_EQ(space_to_depth->get_element_type(), element::f32); EXPECT_EQ(space_to_depth->get_output_partial_shape(0), (PartialShape{{1, 4}, {12 * 4, 36 * 4}, 1080 / 2, 1616 / 2})); - EXPECT_THAT(get_shape_labels(space_to_depth->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(space_to_depth->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, space_to_depth_output_shape_when_space_is_dynamic) { auto a_shape = PartialShape{{1, 4}, {12, 36}, {100, 1081}, {99, 1616}}; - set_shape_labels(a_shape, 10); + auto symbols = set_shape_symbols(a_shape); auto A = make_shared(element::f32, a_shape); const auto mode = ov::op::v0::SpaceToDepth::SpaceToDepthMode::DEPTH_FIRST; auto space_to_depth = make_shared(A, mode, 2); @@ -87,8 +87,8 @@ TEST(type_prop, space_to_depth_output_shape_when_space_is_dynamic) { EXPECT_EQ( space_to_depth->get_output_partial_shape(0), (PartialShape{{1, 4}, {12 * 4, 36 * 4}, {DIV_ROUND_UP(100, 2), 1081 / 2}, {DIV_ROUND_UP(99, 2), 1616 / 2}})); - EXPECT_THAT(get_shape_labels(space_to_depth->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(space_to_depth->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr)); } TEST(type_prop, space_to_depth_dynamic_shape_static_rank) { diff --git a/src/core/tests/type_prop/split.cpp b/src/core/tests/type_prop/split.cpp index 8773917613e1e9..744f736ba54bb6 100644 --- a/src/core/tests/type_prop/split.cpp +++ b/src/core/tests/type_prop/split.cpp @@ -242,14 +242,15 @@ class SplitTest : public TestWithParam { std::tie(p_shape, axis, num_splits, exp_shape) = GetParam(); } - std::pair make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(1)); + std::pair make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); - auto exp_labels = in_labels; - exp_labels[axis] = 0; + auto exp_symbols = in_symbols; + exp_symbols[axis] = nullptr; - return {in_labels, exp_labels}; + return {in_symbols, exp_symbols}; } int64_t axis; @@ -260,7 +261,7 @@ class SplitTest : public TestWithParam { INSTANTIATE_TEST_SUITE_P(type_prop_static_shape, SplitTest, Values( - // Label is lost in this case see shape_infer for explanation. + // Symbol is lost in this case see shape_infer for explanation. std::make_tuple(PartialShape{6, 2}, 0, 1, PartialShape{6, 2}), std::make_tuple(PartialShape{6}, 0, 2, PartialShape{3}), std::make_tuple(PartialShape{3, 6, 7, 3}, 1, 2, PartialShape{3, 3, 7, 3})), @@ -269,7 +270,7 @@ INSTANTIATE_TEST_SUITE_P(type_prop_static_shape, INSTANTIATE_TEST_SUITE_P(type_prop_dynamic_shape, SplitTest, Values( - // Label is lost in this case see shape_infer for explanation. + // Symbol is lost in this case see shape_infer for explanation. std::make_tuple(PartialShape{Dimension(2, 6), 2}, 0, 1, PartialShape{Dimension(2, 6), 2}), std::make_tuple(PartialShape{Dimension(4, 8)}, 0, 2, PartialShape{Dimension(2, 4)}), std::make_tuple(PartialShape{3, 6, Dimension(10, 20), Dimension(1, 3)}, @@ -295,11 +296,11 @@ TEST_P(SplitTest, use_default_ctor) { Property("Partial shape", &Output::get_partial_shape, exp_shape)))); } -TEST_P(SplitTest, labels_propagation) { - ov::TensorLabel in_labels, exp_labels; - std::tie(in_labels, exp_labels) = make_in_exp_labels(); +TEST_P(SplitTest, symbols_propagation) { + ov::TensorSymbol in_symbols, exp_symbols; + std::tie(in_symbols, exp_symbols) = make_in_exp_symbols(); - set_shape_labels(p_shape, in_labels); + set_shape_symbols(p_shape, in_symbols); const auto param = make_shared(element::f32, p_shape); const auto axis_node = make_shared(element::i32, Shape{}, axis); const auto split = make_shared(param, axis_node, num_splits); @@ -308,7 +309,7 @@ TEST_P(SplitTest, labels_propagation) { EXPECT_EQ(outputs.size(), num_splits); EXPECT_THAT( outputs, - Each(Property("Partial shape", &Output::get_partial_shape, ResultOf(get_shape_labels, exp_labels)))); + Each(Property("Partial shape", &Output::get_partial_shape, ResultOf(get_shape_symbols, exp_symbols)))); } using SplitBoundTestParam = std::tuple { std::tie(p_shape, num_of_splits, exp_shapes) = GetParam(); } - std::pair> make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(1)); + std::pair> make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); - auto split_size = in_labels.size() / num_of_splits; - std::vector exp_labels; - for (auto it = in_labels.begin(); it < in_labels.end(); it += split_size) { - exp_labels.emplace_back(it, it + split_size); + auto split_size = in_symbols.size() / num_of_splits; + std::vector exp_symbols; + for (auto it = in_symbols.begin(); it < in_symbols.end(); it += split_size) { + exp_symbols.emplace_back(it, it + split_size); } - return {in_labels, exp_labels}; + return {in_symbols, exp_symbols}; } - ov::TensorLabel in_labels; - std::vector out_labels; + ov::TensorSymbol in_symbols; + std::vector out_symbols; PartialShape p_shape; size_t num_of_splits; @@ -357,26 +359,26 @@ INSTANTIATE_TEST_SUITE_P( {Dimension(-1, 6), Dimension::dynamic()}})), PrintToStringParamName()); -TEST_P(SplitBoundTest, propagate_label_and_dynamic_value) { - const auto in_exp_labels = make_in_exp_labels(); - set_shape_labels(p_shape, in_exp_labels.first); +TEST_P(SplitBoundTest, propagate_symbol_and_dynamic_value) { + const auto in_exp_symbols = make_in_exp_symbols(); + set_shape_symbols(p_shape, in_exp_symbols.first); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto zero = std::vector{0}; const auto axis = std::make_shared(et, Shape{}, zero); - const auto split = std::make_shared(labeled_shape_of, axis, num_of_splits); + const auto split = std::make_shared(symboled_shape_of, axis, num_of_splits); for (auto& output : split->outputs()) { const auto& bc = std::make_shared( std::make_shared(ov::element::i32, PartialShape{1}), output); out_shapes.push_back(bc->get_output_partial_shape(0)); - out_labels.push_back(get_shape_labels(bc->get_output_partial_shape(0))); + out_symbols.push_back(get_shape_symbols(bc->get_output_partial_shape(0))); } EXPECT_EQ(out_shapes, exp_shapes); - EXPECT_EQ(out_labels, in_exp_labels.second); + EXPECT_EQ(out_symbols, in_exp_symbols.second); } diff --git a/src/core/tests/type_prop/squeeze.cpp b/src/core/tests/type_prop/squeeze.cpp index dd2da98d343b6c..ca0563e00d58ff 100644 --- a/src/core/tests/type_prop/squeeze.cpp +++ b/src/core/tests/type_prop/squeeze.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" @@ -207,9 +206,10 @@ class SqueezeTest : public WithParamInterface, public UnSqueezeFixture::SetUp(); } - std::pair make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(1)); + std::pair make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); std::set axes_to_remove; if (axes.empty()) { @@ -226,19 +226,19 @@ class SqueezeTest : public WithParamInterface, public auto rm_iter = axes_to_remove.begin(); int64_t rm_idx = 0; - auto exp_labels = in_labels; - exp_labels.erase(std::remove_if(exp_labels.begin(), - exp_labels.end(), - [&](ov::label_t& label) { - if ((rm_iter != axes_to_remove.end()) && (*rm_iter == rm_idx++)) { - return ++rm_iter, true; - } else { - return false; - } - }), - exp_labels.end()); - - return {in_labels, exp_labels}; + auto exp_symbols = in_symbols; + exp_symbols.erase(std::remove_if(exp_symbols.begin(), + exp_symbols.end(), + [&](shared_ptr symbol) { + if ((rm_iter != axes_to_remove.end()) && (*rm_iter == rm_idx++)) { + return ++rm_iter, true; + } else { + return false; + } + }), + exp_symbols.end()); + + return {in_symbols, exp_symbols}; } std::vector axes; @@ -310,20 +310,20 @@ TEST_P(SqueezeTest, partial_shape_dimension_propagation_dynamic_axes) { EXPECT_EQ(squeeze->get_output_partial_shape(0), PartialShape::dynamic()); } -TEST_P(SqueezeTest, labels_propagation) { +TEST_P(SqueezeTest, symbols_propagation) { if (p_shape.rank().is_dynamic()) { - GTEST_SKIP() << "No dimension to set label"; + GTEST_SKIP() << "No dimension to set symbol"; } - ov::TensorLabel in_labels, exp_labels; - std::tie(in_labels, exp_labels) = make_in_exp_labels(); + ov::TensorSymbol in_symbols, exp_symbols; + std::tie(in_symbols, exp_symbols) = make_in_exp_symbols(); - set_shape_labels(p_shape, in_labels); + set_shape_symbols(p_shape, in_symbols); param = make_shared(element::f32, p_shape); const auto axes_node = std::make_shared(element::i32, Shape{axes.size()}, axes); const auto squeeze = std::make_shared(param, axes_node); - EXPECT_EQ(get_shape_labels(squeeze->get_output_partial_shape(0)), exp_labels); + EXPECT_EQ(get_shape_symbols(squeeze->get_output_partial_shape(0)), exp_symbols); } using SqueezeShapeTests = SqueezeTest; @@ -398,24 +398,23 @@ INSTANTIATE_TEST_SUITE_P( PrintToStringParamName()); /** - * \brief Check label and dynamic value propagation. + * \brief Check symbol and dynamic value propagation. * - * Test use evaluate label, lower/upper. + * Test use evaluate symbol, lower/upper. */ -TEST_P(SqueezeBoundTest, propagate_label_and_dynamic_value) { - PartialShape labeled_shape = PartialShape{p_shape}; +TEST_P(SqueezeBoundTest, propagate_symbol_and_dynamic_value) { + PartialShape symboled_shape = PartialShape{p_shape}; - std::generate_n(std::back_inserter(in_labels), labeled_shape.size(), ov::SeqGen(1)); - set_shape_labels(labeled_shape, in_labels); + in_symbols = set_shape_symbols(symboled_shape); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, labeled_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, symboled_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto zero = std::vector{0}; const auto axis = std::make_shared(et, Shape{}, zero); const auto indices = std::make_shared(et, Shape{}, zero); - const auto gather = std::make_shared(labeled_shape_of, indices, axis); + const auto gather = std::make_shared(symboled_shape_of, indices, axis); const auto axis_1 = std::make_shared(et, Shape{2}, std::vector{0, 1}); const auto unsqueeze = std::make_shared(gather, axis_1); const auto squeeze = std::make_shared(unsqueeze, axis); @@ -423,6 +422,6 @@ TEST_P(SqueezeBoundTest, propagate_label_and_dynamic_value) { const auto bc = std::make_shared(param, squeeze); EXPECT_EQ(bc->get_output_partial_shape(0), exp_shape); - const auto labels = get_shape_labels(bc->get_output_partial_shape(0)); - EXPECT_THAT(labels, ElementsAre(in_labels.front())); + const auto symbols = get_shape_symbols(bc->get_output_partial_shape(0)); + EXPECT_THAT(symbols, ElementsAre(in_symbols.front())); } diff --git a/src/core/tests/type_prop/strided_slice.cpp b/src/core/tests/type_prop/strided_slice.cpp index c6a3a058b2ae99..355f408c34451c 100644 --- a/src/core/tests/type_prop/strided_slice.cpp +++ b/src/core/tests/type_prop/strided_slice.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/except.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" @@ -136,22 +135,21 @@ TEST(type_prop, strided_slice_default_stride_dynamic_shape_input_begin_not_1d) { TEST(type_prop, strided_slice_default_stride_dynamic_shape_input) { auto shape = PartialShape{2, 4, 6, 8}; - set_shape_labels(shape, 11); + auto symbols = set_shape_symbols(shape); auto data = make_shared(element::f32, shape); auto begin = make_shared(element::i64, PartialShape::dynamic()); auto end = make_shared(element::i64, Shape{2}); - auto strided_slice = make_shared(data, begin, end, vector{0, 0}, vector{0, 0}); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({{0, 2}, {0, 4}, 6, 8})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, 13, 14)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, symbols[2], symbols[3])); } TEST(type_prop, strided_slice_reverse_out_of_bounds_on_dims_0_1) { auto shape = PartialShape{3, 4, 5}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{2}, {10, 2}); auto end = ov::op::v0::Constant::create(element::i64, Shape{2}, {-10, -10}); @@ -162,12 +160,13 @@ TEST(type_prop, strided_slice_reverse_out_of_bounds_on_dims_0_1) { auto strided_slice = std::make_shared(data, begin, end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({3, 3, 5})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), ElementsAre(10, ov::no_label, 12)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, symbols[2])); } TEST(type_prop, strided_slice_ignore_begin_mask_stride_pos_1) { auto shape = PartialShape{4, 4, 4, 4, 4, 4, 4, 4}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 2, 4, 10, -1, -2, -4, 10}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 3, 4, 5, -1, -3, -4, -5}); @@ -179,14 +178,13 @@ TEST(type_prop, strided_slice_ignore_begin_mask_stride_pos_1) { auto strided_slice = std::make_shared(data, begin, end, stride, begin_mask, end_mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, 3, 4, 4, 3, 1, 0, 0})); - EXPECT_THAT( - get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, 12, 13, ov::no_label, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, symbols[2], symbols[3], nullptr, nullptr, nullptr, nullptr)); } TEST(type_prop, strided_slice_ignore_begin_mask_stride_neg_1) { auto shape = PartialShape{4, 4, 4, 4, 4, 4, 4, 4}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 2, 4, 10, -1, -2, -4, -10}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 3, 4, 5, -1, -3, -4, -5}); @@ -198,20 +196,13 @@ TEST(type_prop, strided_slice_ignore_begin_mask_stride_neg_1) { auto strided_slice = std::make_shared(data, begin, end, stride, begin_mask, end_mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({2, 0, 0, 0, 0, 2, 3, 4})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(ov::no_label, - ov::no_label, - ov::no_label, - ov::no_label, - ov::no_label, - ov::no_label, - ov::no_label, - 17)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, symbols[7])); } TEST(type_prop, strided_slice_ignore_end_mask_stride_pos_1) { auto shape = PartialShape{4, 4, 4, 4, 4, 4, 4, 4}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 2, 4, 10, -1, -2, -4, -10}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 3, 4, 5, -1, -3, -4, -5}); @@ -223,13 +214,13 @@ TEST(type_prop, strided_slice_ignore_end_mask_stride_pos_1) { auto strided_slice = std::make_shared(data, begin, end, stride, begin_mask, end_mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({4, 2, 0, 0, 1, 2, 4, 4})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label, ov::no_label, ov::no_label, 16, 17)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr, nullptr, nullptr, symbols[6], symbols[7])); } TEST(type_prop, strided_slice_ignore_end_mask_stride_neg_1) { auto shape = PartialShape{4, 4, 4, 4, 4, 4, 4, 4}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 2, 4, 10, -1, -2, -4, -10}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 3, 4, 5, -1, -3, -4, -5}); @@ -241,13 +232,13 @@ TEST(type_prop, strided_slice_ignore_end_mask_stride_neg_1) { auto strided_slice = std::make_shared(data, begin, end, stride, begin_mask, end_mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, 3, 4, 4, 4, 3, 1, 1})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, 12, 13, 14, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, symbols[2], symbols[3], symbols[4], nullptr, nullptr, nullptr)); } TEST(type_prop, strided_slice_ignore_begin_end_masks_variadic_stride) { auto shape = PartialShape{4, 4, 4, 4, 4, 4, 4, 4}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 2, 4, 10, -1, -2, -4, -10}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 3, 4, 5, -1, -3, -4, -5}); @@ -258,14 +249,13 @@ TEST(type_prop, strided_slice_ignore_begin_end_masks_variadic_stride) { auto strided_slice = std::make_shared(data, begin, end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({4, 2, 2, 1, 4, 2, 2, 1})); - EXPECT_THAT( - get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(10, ov::no_label, ov::no_label, ov::no_label, 14, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(symbols[0], nullptr, nullptr, nullptr, symbols[4], nullptr, nullptr, nullptr)); } TEST(type_prop, strided_slice_end_over_dimension_size) { auto shape = PartialShape{3, 3, 3, 3, 3, 3, 3, 3}; - set_shape_labels(shape, 10); + auto symbols = set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {0, 0, 0, 0, 1, 1, 1, 1}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 2, 3, 4, 1, 2, 3, 4}); @@ -276,14 +266,13 @@ TEST(type_prop, strided_slice_end_over_dimension_size) { auto strided_slice = std::make_shared(data, begin, end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, 2, 3, 3, 0, 1, 2, 2})); - EXPECT_THAT( - get_shape_labels(strided_slice->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, 12, 13, ov::no_label, ov::no_label, ov::no_label, ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, symbols[2], symbols[3], nullptr, nullptr, nullptr, nullptr)); } TEST(type_prop, strided_slice_begin_over_dimension_size) { auto shape = PartialShape{3, 3, 3, 3, 3, 3, 3, 3}; - set_shape_labels(shape, 10); + set_shape_symbols(shape); auto data = std::make_shared(element::f32, shape); auto begin = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {-1, -1, -1, -1, -2, -2, -2, -2}); auto end = ov::op::v0::Constant::create(element::i64, Shape{shape.size()}, {1, 2, 3, 4, 1, 2, 3, 4}); @@ -294,12 +283,12 @@ TEST(type_prop, strided_slice_begin_over_dimension_size) { auto strided_slice = std::make_shared(data, begin, end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({0, 0, 1, 1, 0, 1, 2, 2})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, strided_slice_end_is_shape_of_with_bounds) { auto shape = PartialShape{1, {5, 7}}; - set_shape_labels(shape, 20); + set_shape_symbols(shape); const auto p_end = std::make_shared(element::i64, shape); const auto shape_of_end = std::make_shared(p_end); @@ -312,12 +301,12 @@ TEST(type_prop, strided_slice_end_is_shape_of_with_bounds) { auto strided_slice = std::make_shared(data, begin, shape_of_end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, {5, 7}})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, strided_slice_begin_is_shape_of_with_bounds) { auto shape = PartialShape{0, {3, 5}}; - set_shape_labels(shape, 20); + set_shape_symbols(shape); const auto p_begin = std::make_shared(element::i64, shape); const auto shape_of_begin = std::make_shared(p_begin); @@ -330,14 +319,14 @@ TEST(type_prop, strided_slice_begin_is_shape_of_with_bounds) { auto strided_slice = std::make_shared(data, shape_of_begin, end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, {2, 4}})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, strided_slice_begin_end_is_shape_of_with_bounds) { auto begin_shape = PartialShape{0, {3, 5}}; auto end_shape = PartialShape{2, {6, 7}}; - set_shape_labels(begin_shape, 10); - set_shape_labels(end_shape, 20); + set_shape_symbols(begin_shape); + set_shape_symbols(end_shape); const auto p_begin = std::make_shared(element::i64, begin_shape); const auto p_end = std::make_shared(element::i64, end_shape); const auto shape_of_begin = std::make_shared(p_begin); @@ -351,7 +340,7 @@ TEST(type_prop, strided_slice_begin_end_is_shape_of_with_bounds) { auto strided_slice = std::make_shared(data, shape_of_begin, shape_of_end, stride, mask, mask); EXPECT_EQ(strided_slice->get_output_partial_shape(0), PartialShape({1, {1, 4}})); - EXPECT_THAT(get_shape_labels(strided_slice->get_output_partial_shape(0)), Each(ov::no_label)); + EXPECT_THAT(get_shape_symbols(strided_slice->get_output_partial_shape(0)), Each(nullptr)); } TEST(type_prop, strided_slice_out_of_bounds_different_stride) { @@ -383,10 +372,11 @@ TEST(type_prop, strided_slice_reverse_end_is_int64_min) { EXPECT_EQ(ss->get_output_partial_shape(0), PartialShape({{0, 20}, {0, 21}})); } -TEST(type_prop, strided_slice_dynamic_value_and_label_propagation) { - // Use evaluate upper,lower and labels +TEST(type_prop, strided_slice_dynamic_value_and_symbol_propagation) { + // Use evaluate upper,lower and symbols auto marked_0 = Dimension(3, 5); - ov::DimensionTracker::set_label(marked_0, 10); + auto symbol = std::make_shared(); + marked_0.set_symbol(symbol); PartialShape target_0 = PartialShape{marked_0, 4}; auto param = std::make_shared(element::f32, Shape{1}); @@ -409,7 +399,7 @@ TEST(type_prop, strided_slice_dynamic_value_and_label_propagation) { const auto& output_shape = bc->get_output_partial_shape(0); EXPECT_EQ(output_shape, PartialShape({marked_0})); - EXPECT_THAT(get_shape_labels(output_shape), ElementsAre(10)); + EXPECT_THAT(get_shape_symbols(output_shape), ElementsAre(symbol)); } TEST(type_prop, strided_slice_use_default_ctor) { diff --git a/src/core/tests/type_prop/tile.cpp b/src/core/tests/type_prop/tile.cpp index b1180f837c7588..d3a9e5377ea9d4 100644 --- a/src/core/tests/type_prop/tile.cpp +++ b/src/core/tests/type_prop/tile.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/shape_of.hpp" @@ -87,16 +86,16 @@ TEST_F(TypePropTileTest, data_and_repeats_are_dynamic_rank) { EXPECT_EQ(op->get_output_partial_shape(0), PartialShape::dynamic()); } -TEST_F(TypePropTileTest, propagate_label_and_dynamic_value_no_repeats) { +TEST_F(TypePropTileTest, propagate_symbol_and_dynamic_value_no_repeats) { auto p_shape = PartialShape{{2, 5}, 3}; - set_shape_labels(p_shape, 1); + auto symbols = set_shape_symbols(p_shape); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto repeats = ov::op::v0::Constant::create(element::i32, Shape{1}, {1}); - const auto op = make_op(labeled_shape_of, repeats); + const auto op = make_op(symboled_shape_of, repeats); const auto bc = std::make_shared(std::make_shared(ov::element::i32, PartialShape{1}), op, @@ -104,19 +103,19 @@ TEST_F(TypePropTileTest, propagate_label_and_dynamic_value_no_repeats) { const auto& out_shape = bc->get_output_partial_shape(0); EXPECT_EQ(out_shape, p_shape); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(1, 2)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1])); } -TEST_F(TypePropTileTest, propagate_label_and_dynamic_value) { +TEST_F(TypePropTileTest, propagate_symbol_and_dynamic_value) { auto p_shape = PartialShape{{2, 5}, 3}; - set_shape_labels(p_shape, 1); + auto symbols = set_shape_symbols(p_shape); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto repeats = ov::op::v0::Constant::create(element::i32, Shape{1}, {2}); - const auto op = make_op(labeled_shape_of, repeats); + const auto op = make_op(symboled_shape_of, repeats); const auto bc = std::make_shared(std::make_shared(ov::element::i32, PartialShape{1}), op, @@ -124,12 +123,12 @@ TEST_F(TypePropTileTest, propagate_label_and_dynamic_value) { const auto& out_shape = bc->get_output_partial_shape(0); EXPECT_EQ(out_shape, PartialShape({{2, 5}, 3, {2, 5}, 3})); - EXPECT_THAT(get_shape_labels(out_shape), ElementsAre(1, 2, 1, 2)); + EXPECT_THAT(get_shape_symbols(out_shape), ElementsAre(symbols[0], symbols[1], symbols[0], symbols[1])); } -TEST_F(TypePropTileTest, preserve_partial_values_and_labels) { +TEST_F(TypePropTileTest, preserve_partial_values_and_symbols) { auto shape = PartialShape{1, {1, 2}, {-1, 3}, {2, -1}, -1}; - set_shape_labels(shape, 20); + auto symbols = set_shape_symbols(shape); const auto p_repeats = std::make_shared(element::i64, shape); const auto shape_of_repeats = std::make_shared(p_repeats); @@ -138,8 +137,8 @@ TEST_F(TypePropTileTest, preserve_partial_values_and_labels) { const auto op = make_op(data, shape_of_repeats); EXPECT_EQ(op->get_output_partial_shape(0), PartialShape({2, {2, 4}, {-1, 6}, -1, -1})); - EXPECT_THAT(get_shape_labels(op->get_output_partial_shape(0)), - ElementsAre(ov::no_label, ov::no_label, ov::no_label, 23, 24)); + EXPECT_THAT(get_shape_symbols(op->get_output_partial_shape(0)), + ElementsAre(nullptr, nullptr, nullptr, symbols[3], symbols[4])); } TEST_F(TypePropTileTest, repeats_has_dynamic_shape) { @@ -168,27 +167,27 @@ class TileTest : public TypePropTileTest, public WithParamInterface repeats.size()) { - repeats.insert(repeats.begin(), labels.size() - repeats.size(), 1); + if (symbols.size() > repeats.size()) { + repeats.insert(repeats.begin(), symbols.size() - repeats.size(), 1); } else { - labels.insert(labels.begin(), repeats.size() - labels.size(), ov::no_label); + symbols.insert(symbols.begin(), repeats.size() - symbols.size(), nullptr); } - std::transform(labels.begin(), - labels.end(), + std::transform(symbols.begin(), + symbols.end(), repeats.begin(), - labels.begin(), - [](const ov::label_t label, const int64_t repeat) { - return (label != ov::no_label && repeat == 1) ? label : ov::no_label; + symbols.begin(), + [](const shared_ptr symbol, const int64_t repeat) { + return (symbol != nullptr && repeat == 1) ? symbol : nullptr; }); } - return labels; + return symbols; } PartialShape exp_shape; @@ -236,8 +235,8 @@ TEST_P(TileTest, default_ctor) { EXPECT_EQ(op->get_output_partial_shape(0), exp_shape); } -TEST_P(TileTest, propagate_shapes_and_labels) { - ASSERT_TRUE(shape_in.rank().is_static()) << "Cannot test labels propagation for dynamic rank."; +TEST_P(TileTest, propagate_shapes_and_symbols) { + ASSERT_TRUE(shape_in.rank().is_static()) << "Cannot test symbols propagation for dynamic rank."; constexpr auto dt = element::f32; const auto data = make_shared(dt, shape_in); @@ -248,5 +247,5 @@ TEST_P(TileTest, propagate_shapes_and_labels) { EXPECT_EQ(op->get_element_type(), dt); EXPECT_EQ(op->get_output_size(), 1); EXPECT_EQ(op->get_output_partial_shape(0), exp_shape); - EXPECT_EQ(get_shape_labels(op->get_output_partial_shape(0)), get_exp_labels()); + EXPECT_EQ(get_shape_symbols(op->get_output_partial_shape(0)), get_exp_symbols()); } diff --git a/src/core/tests/type_prop/top_k.cpp b/src/core/tests/type_prop/top_k.cpp index fd5a3d957c73f3..d34c8f17fc1ba4 100644 --- a/src/core/tests/type_prop/top_k.cpp +++ b/src/core/tests/type_prop/top_k.cpp @@ -4,7 +4,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/opsets/opset11.hpp" #include "topk_shape_inference.hpp" @@ -93,7 +92,7 @@ TYPED_TEST_P(topk_type_prop, negative_axis_support) { constexpr auto exp_idx_type = element::i64; auto data_shape = PartialShape{1, 2, 3, 4}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(exp_data_type, data_shape); const auto k = Constant::create(exp_idx_type, Shape{}, {2}); @@ -111,7 +110,7 @@ TYPED_TEST_P(topk_type_prop, negative_axis_support) { EXPECT_THAT(op->outputs(), Each(Property("Shape", &Output::get_shape, Shape({1, 2, 3, 2})))); EXPECT_THAT(op->outputs(), Each(Property(&Output::get_partial_shape, - ResultOf(get_shape_labels, ElementsAre(10, 11, 12, ov::no_label))))); + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], symbols[2], nullptr))))); } TYPED_TEST_P(topk_type_prop, default_index_element_type) { @@ -211,51 +210,52 @@ TYPED_TEST_P(topk_type_prop, data_and_k_shapes_are_dynamic) { Each(Property("Partial Shape", &Output::get_partial_shape, PartialShape::dynamic()))); } -TYPED_TEST_P(topk_type_prop_with_evaluate, propagate_label_and_not_interval_value_max) { +TYPED_TEST_P(topk_type_prop_with_evaluate, propagate_symbol_and_not_interval_value_max) { auto p_shape = PartialShape{5, 6, 4, 3, 8}; - set_shape_labels(p_shape, 1); + set_shape_symbols(p_shape); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto k = Constant::create(et, Shape{}, {3}); - const auto op = this->make_op(labeled_shape_of, k, 0, "max", "index", element::i32); + const auto op = this->make_op(symboled_shape_of, k, 0, "max", "index", element::i32); const auto bc_shapes = this->make_broadcast_shapes_of_topk_outs(op.get()); EXPECT_THAT(bc_shapes, ElementsAre(PartialShape({5, 6, 8}), PartialShape({0, 1, 4}))); - EXPECT_THAT(bc_shapes, Each(ResultOf(get_shape_labels, Each(ov::no_label)))); + EXPECT_THAT(bc_shapes, Each(ResultOf(get_shape_symbols, Each(nullptr)))); } -TYPED_TEST_P(topk_type_prop_with_evaluate, propagate_label_and_not_interval_value_min) { +TYPED_TEST_P(topk_type_prop_with_evaluate, propagate_symbol_and_not_interval_value_min) { auto p_shape = PartialShape{5, 6, 3, 4, 8}; - set_shape_labels(p_shape, 1); + set_shape_symbols(p_shape); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto k = Constant::create(et, Shape{}, {3}); - const auto op = this->make_op(labeled_shape_of, k, 0, "min", "index", element::i32); + const auto op = this->make_op(symboled_shape_of, k, 0, "min", "index", element::i32); const auto bc_shapes = this->make_broadcast_shapes_of_topk_outs(op.get()); EXPECT_THAT(bc_shapes, ElementsAre(PartialShape({5, 3, 4}), PartialShape({0, 2, 3}))); - EXPECT_THAT(bc_shapes, Each(ResultOf(get_shape_labels, Each(ov::no_label)))); + EXPECT_THAT(bc_shapes, Each(ResultOf(get_shape_symbols, Each(nullptr)))); } -TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_labels_k_is_interval) { +TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_symbols_k_is_interval) { auto k_dim = Dimension{10, 20}; auto shape = PartialShape{k_dim}; - ov::DimensionTracker::set_label(k_dim, 20); + auto k_symbol = std::make_shared(); + k_dim.set_symbol(k_symbol); const auto p_k = std::make_shared(element::i64, shape); const auto shape_of_k = std::make_shared(p_k); const auto k = std::make_shared(shape_of_k, Constant::create(element::i64, Shape{}, {0})); auto data_shape = PartialShape{{2, 5}, {12, 18}, {2, 30}, {30, 40}, {-1, 15}, {15, -1}}; - set_shape_labels(data_shape, 1); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); { @@ -263,48 +263,54 @@ TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_labels_k_is_interval) { const auto op = this->make_op(data, k, 0, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {12, 18}, {2, 30}, {30, 40}, {-1, 15}, {15, -1}}), - ResultOf(get_shape_labels, ElementsAre(no_label, 2, 3, 4, 5, 6)))); + ResultOf(get_shape_symbols, + ElementsAre(nullptr, symbols[1], symbols[2], symbols[3], symbols[4], symbols[5])))); } { // dim{12,18} k{10,20} -> {10,18} const auto op = this->make_op(data, k, 1, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {10, 18}, {2, 30}, {30, 40}, {-1, 15}, {15, -1}}), - ResultOf(get_shape_labels, ElementsAre(1, no_label, 3, 4, 5, 6)))); + ResultOf(get_shape_symbols, + ElementsAre(symbols[0], nullptr, symbols[2], symbols[3], symbols[4], symbols[5])))); } { // dim{2, 30} k{10,20} -> {2,20} const auto op = this->make_op(data, k, 2, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {12, 18}, {2, 20}, {30, 40}, {-1, 15}, {15, -1}}), - ResultOf(get_shape_labels, ElementsAre(1, 2, no_label, 4, 5, 6)))); + ResultOf(get_shape_symbols, + ElementsAre(symbols[0], symbols[1], nullptr, symbols[3], symbols[4], symbols[5])))); } { // dim{30,40} k{10,20} -> {10,20} (should use k upper bounds??) const auto op = this->make_op(data, k, 3, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {12, 18}, {2, 30}, {10, 20}, {-1, 15}, {15, -1}}), - ResultOf(get_shape_labels, ElementsAre(1, 2, 3, no_label, 5, 6)))); + ResultOf(get_shape_symbols, + ElementsAre(symbols[0], symbols[1], symbols[2], nullptr, symbols[4], symbols[5])))); } { // dim{-inf,15} k{10,20} -> {0,15} const auto op = this->make_op(data, k, 4, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {12, 18}, {2, 30}, {30, 40}, {0, 15}, {15, -1}}), - ResultOf(get_shape_labels, ElementsAre(1, 2, 3, 4, no_label, 6)))); + ResultOf(get_shape_symbols, + ElementsAre(symbols[0], symbols[1], symbols[2], symbols[3], nullptr, symbols[5])))); } { // dim{15,inf} k{10,20} -> {10,inf} const auto op = this->make_op(data, k, 5, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{2, 5}, {12, 18}, {2, 30}, {30, 40}, {-1, 15}, {10, -1}}), - ResultOf(get_shape_labels, ElementsAre(1, 2, 3, 4, 5, no_label)))); + ResultOf(get_shape_symbols, + ElementsAre(symbols[0], symbols[1], symbols[2], symbols[3], symbols[4], nullptr)))); } } -TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_labels_k_is_interval_with_no_upper_bound) { +TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_symbols_k_is_interval_with_no_upper_bound) { auto shape = PartialShape{{10, -1}}; - set_shape_labels(shape, 20); + auto k_symbols = set_shape_symbols(shape); const auto p_k = std::make_shared(element::i64, shape); const auto shape_of_k = std::make_shared(p_k); @@ -312,7 +318,7 @@ TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_labels_k_is_interval_wi const auto k = std::make_shared(shape_of_k, Constant::create(element::i64, Shape{}, {0})); auto data_shape = PartialShape{5, {2, 8}, {2, 100}}; - set_shape_labels(data_shape, 10); + auto symbols = set_shape_symbols(data_shape); const auto data = std::make_shared(element::f32, data_shape); { @@ -320,21 +326,21 @@ TYPED_TEST_P(topk_type_prop, preserve_partial_values_and_labels_k_is_interval_wi const auto op = this->make_op(data, k, 0, "max", "value"); EXPECT_THAT(op->get_output_partial_shape(0), AllOf(PartialShape({{0, 5}, {2, 8}, {2, 100}}), - ResultOf(get_shape_labels, ElementsAre(ov::no_label, 11, 12)))); + ResultOf(get_shape_symbols, ElementsAre(nullptr, symbols[1], symbols[2])))); } { // dim{2,8} k{0,inf} -> {0,8} const auto op = this->make_op(data, k, 1, "max", "value"); - EXPECT_THAT( - op->get_output_partial_shape(0), - AllOf(PartialShape({5, {0, 8}, {2, 100}}), ResultOf(get_shape_labels, ElementsAre(10, ov::no_label, 12)))); + EXPECT_THAT(op->get_output_partial_shape(0), + AllOf(PartialShape({5, {0, 8}, {2, 100}}), + ResultOf(get_shape_symbols, ElementsAre(symbols[0], nullptr, symbols[2])))); } { // dim{2,100} k{0,inf} -> {0,100} const auto op = this->make_op(data, k, 2, "max", "value"); - EXPECT_THAT( - op->get_output_partial_shape(0), - AllOf(PartialShape({5, {2, 8}, {0, 100}}), ResultOf(get_shape_labels, ElementsAre(10, 11, ov::no_label)))); + EXPECT_THAT(op->get_output_partial_shape(0), + AllOf(PartialShape({5, {2, 8}, {0, 100}}), + ResultOf(get_shape_symbols, ElementsAre(symbols[0], symbols[1], nullptr)))); } } @@ -370,14 +376,14 @@ REGISTER_TYPED_TEST_SUITE_P(topk_type_prop, k_is_unknown_for_interval_dimension, k_is_unknown_for_interval_with_no_upper_bound_dimension, data_and_k_shapes_are_dynamic, - preserve_partial_values_and_labels_k_is_interval, - preserve_partial_values_and_labels_k_is_interval_with_no_upper_bound, + preserve_partial_values_and_symbols_k_is_interval, + preserve_partial_values_and_symbols_k_is_interval_with_no_upper_bound, negative_axis_dynamic_rank, incorrect_index_element_type); REGISTER_TYPED_TEST_SUITE_P(topk_type_prop_with_evaluate, - propagate_label_and_not_interval_value_max, - propagate_label_and_not_interval_value_min); + propagate_symbol_and_not_interval_value_max, + propagate_symbol_and_not_interval_value_min); // TODO: merge the two instantiations into one when v11::TopK gets the evaluate() method typedef Types TopKTypes; diff --git a/src/core/tests/type_prop/transpose.cpp b/src/core/tests/type_prop/transpose.cpp index 1ab837ad1a672c..dbd825386793a9 100644 --- a/src/core/tests/type_prop/transpose.cpp +++ b/src/core/tests/type_prop/transpose.cpp @@ -5,7 +5,6 @@ #include "openvino/op/transpose.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/convert.hpp" #include "openvino/op/divide.hpp" @@ -55,7 +54,7 @@ TEST(type_prop, transpose_arg_static_input_order_constant_invalid_perm) { } TEST(type_prop, transpose_with_not_unique_order) { - const auto order = ov::TensorLabel{1, 0, 1}; + const auto order = std::vector{1, 0, 1}; auto arg = make_shared(element::f32, Shape{1, 4, 300}); auto input_order = make_shared(element::i64, Shape{order.size()}, order); @@ -265,7 +264,7 @@ TEST(type_prop, transpose_input_order_et_wrong) { TEST(type_prop, transpose_with_empty_order) { auto arg = make_shared(element::f32, Shape{1, 300}); - auto input_order = make_shared(element::i64, Shape({0}), ov::TensorLabel()); + auto input_order = make_shared(element::i64, Shape({0}), std::vector()); auto r = make_shared(arg, input_order); @@ -351,19 +350,18 @@ class TransposeTest : public TestWithParam { std::tie(transpose_order, input_p_shape, exp_p_shape) = GetParam(); } - ov::TensorLabel make_seq_labels(const ov::label_t first, const size_t count) { - ov::TensorLabel labels; - - generate_n(std::back_inserter(labels), count, ov::SeqGen(first)); - return labels; + ov::TensorSymbol make_seq_symbols(const size_t count) { + ov::TensorSymbol symbols; + for (size_t i = 0; i < count; ++i) + symbols.push_back(std::make_shared()); + return symbols; } - ov::TensorLabel make_seq_labels_by_order(const ov::label_t first, const vector order) { - ov::TensorLabel labels; - transform(order.cbegin(), order.cend(), back_inserter(labels), [&first](const int64_t& dim) -> ov::label_t { - return static_cast(dim + first); - }); - return labels; + ov::TensorSymbol make_seq_symbols_by_order(ov::TensorSymbol symbols, const vector order) { + ov::TensorSymbol new_symbols; + for (const auto& i : order) + new_symbols.push_back(symbols[i]); + return new_symbols; } }; @@ -413,21 +411,19 @@ TEST_P(TransposeTest, propagate_interval_shape) { } /** - * \brief Check labels propagation for all dimensions. + * \brief Check symbols propagation for all dimensions. * - * The labels should be moved accordingly to transpose order. + * The symbols should be moved accordingly to transpose order. */ -TEST_P(TransposeTest, propagate_labels) { - constexpr ov::label_t first_label = 33; - - const auto labels = make_seq_labels(first_label, transpose_order.size()); - const auto exp_labels = make_seq_labels_by_order(first_label, transpose_order); +TEST_P(TransposeTest, propagate_symbols) { + const auto symbols = make_seq_symbols(transpose_order.size()); + const auto exp_symbols = make_seq_symbols_by_order(symbols, transpose_order); - set_shape_labels(input_p_shape, labels); + set_shape_symbols(input_p_shape, symbols); const auto input = make_shared(exp_type, input_p_shape); const auto order = ov::op::v0::Constant::create(element::i64, Shape{transpose_order.size()}, transpose_order); const auto output = make_shared(input, order); - EXPECT_EQ(get_shape_labels(output->get_output_partial_shape(op::v1::Transpose::ARG_T)), exp_labels); + EXPECT_EQ(get_shape_symbols(output->get_output_partial_shape(op::v1::Transpose::ARG_T)), exp_symbols); } diff --git a/src/core/tests/type_prop/unsqueeze.cpp b/src/core/tests/type_prop/unsqueeze.cpp index 84701abd0f5ef9..090628f4bcc4a6 100644 --- a/src/core/tests/type_prop/unsqueeze.cpp +++ b/src/core/tests/type_prop/unsqueeze.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/type_prop.hpp" #include "gmock/gmock.h" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/gather.hpp" @@ -97,27 +96,28 @@ class UnsqueezeTest : public WithParamInterface, pub UnSqueezeFixture::SetUp(); } - std::pair make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(1)); + std::pair make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); auto unique_axes = std::set(axes.begin(), axes.end()); auto out_rank = unique_axes.size() + p_shape.size(); - std::set no_label_axes; + std::set no_symbol_axes; for (const auto& axis : axes) { - no_label_axes.insert(axis < 0 ? axis + out_rank : axis); + no_symbol_axes.insert(axis < 0 ? axis + out_rank : axis); } - auto exp_labels = in_labels; - for (const auto& axis : no_label_axes) { - if (axis < static_cast(exp_labels.size())) { - exp_labels.insert(exp_labels.begin() + axis, ov::no_label); + auto exp_symbols = in_symbols; + for (const auto& axis : no_symbol_axes) { + if (axis < static_cast(exp_symbols.size())) { + exp_symbols.insert(exp_symbols.begin() + axis, nullptr); } else { - exp_labels.push_back(ov::no_label); + exp_symbols.push_back(nullptr); } } - return {in_labels, exp_labels}; + return {in_symbols, exp_symbols}; } std::vector axes; @@ -239,20 +239,20 @@ TEST_P(UnsqueezeTest, use_default_ctor) { EXPECT_EQ(unsqueeze->get_output_partial_shape(0), exp_shape); } -TEST_P(UnsqueezeTest, labels_propagation) { +TEST_P(UnsqueezeTest, symbols_propagation) { if (p_shape.rank().is_dynamic()) { - GTEST_SKIP() << "No dimension to set label"; + GTEST_SKIP() << "No dimension to set symbol"; } - ov::TensorLabel in_labels, exp_labels; - std::tie(in_labels, exp_labels) = make_in_exp_labels(); + ov::TensorSymbol in_symbols, exp_symbols; + std::tie(in_symbols, exp_symbols) = make_in_exp_symbols(); - set_shape_labels(p_shape, in_labels); + set_shape_symbols(p_shape, in_symbols); param = make_shared(element::f32, p_shape); const auto axes_node = std::make_shared(element::i32, Shape{axes.size()}, axes); const auto unsqueeze = std::make_shared(param, axes_node); - EXPECT_EQ(get_shape_labels(unsqueeze->get_output_partial_shape(0)), exp_labels); + EXPECT_EQ(get_shape_symbols(unsqueeze->get_output_partial_shape(0)), exp_symbols); } using UnsqueezeBoundTest = UnSqueezeBoundTest; @@ -271,29 +271,29 @@ INSTANTIATE_TEST_SUITE_P( PrintToStringParamName()); /** - * \brief Check label and dynamic value propagation. + * \brief Check symbol and dynamic value propagation. * - * Test use evaluate label, lower/upper. + * Test use evaluate symbol, lower/upper. */ -TEST_P(UnsqueezeBoundTest, propagate_label_and_dynamic_value) { - PartialShape labeled_shape = PartialShape{p_shape}; - - std::generate_n(std::back_inserter(in_labels), labeled_shape.size(), ov::SeqGen(1)); - set_shape_labels(labeled_shape, in_labels); +TEST_P(UnsqueezeBoundTest, propagate_symbol_and_dynamic_value) { + PartialShape symboled_shape = PartialShape{p_shape}; + for (size_t s = 0; s < symboled_shape.size(); ++s) + in_symbols.push_back(std::make_shared()); + set_shape_symbols(symboled_shape, in_symbols); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, labeled_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, symboled_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto zero = std::vector{0}; const auto axis = std::make_shared(et, Shape{}, zero); const auto indices = std::make_shared(et, Shape{}, zero); - const auto gather = std::make_shared(labeled_shape_of, indices, axis); + const auto gather = std::make_shared(symboled_shape_of, indices, axis); const auto unsqueeze = std::make_shared(gather, axis); const auto bc = std::make_shared(param, unsqueeze); EXPECT_EQ(bc->get_output_partial_shape(0), exp_shape); - const auto labels = get_shape_labels(bc->get_output_partial_shape(0)); - EXPECT_THAT(labels, ElementsAre(in_labels.front())); + const auto symbols = get_shape_symbols(bc->get_output_partial_shape(0)); + EXPECT_THAT(symbols, ElementsAre(in_symbols.front())); } diff --git a/src/core/tests/type_prop/variadic_split.cpp b/src/core/tests/type_prop/variadic_split.cpp index 0ae0d10f729163..f399092dd20e50 100644 --- a/src/core/tests/type_prop/variadic_split.cpp +++ b/src/core/tests/type_prop/variadic_split.cpp @@ -6,7 +6,6 @@ #include "common_test_utils/test_assertions.hpp" #include "common_test_utils/type_prop.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/core/validation_util.hpp" #include "openvino/op/broadcast.hpp" #include "openvino/op/shape_of.hpp" @@ -37,15 +36,16 @@ class VariadicSplitTest : public TestWithParam { return out; } - std::pair make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(10)); + std::pair make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); - auto exp_labels = in_labels; + auto exp_symbols = in_symbols; const auto n_axis = ov::util::normalize_axis("", axis, p_shape.rank()); - exp_labels[n_axis] = ov::no_label; + exp_symbols[n_axis] = nullptr; - return {in_labels, exp_labels}; + return {in_symbols, exp_symbols}; } int64_t axis; @@ -135,11 +135,11 @@ TEST_P(VariadicSplitTest, use_default_ctor) { EXPECT_THAT(get_output_partial_shapes(*var_split), ElementsAreArray(exp_shapes)); } -TEST_P(VariadicSplitTest, label_propagation) { - ov::TensorLabel in_labels, exp_labels; - std::tie(in_labels, exp_labels) = make_in_exp_labels(); +TEST_P(VariadicSplitTest, symbol_propagation) { + ov::TensorSymbol in_symbols, exp_symbols; + std::tie(in_symbols, exp_symbols) = make_in_exp_symbols(); - set_shape_labels(p_shape, in_labels); + set_shape_symbols(p_shape, in_symbols); const auto data = make_shared(element::f32, p_shape); const auto axis_node = make_shared(element::i64, Shape{}, axis); const auto lengths_node = @@ -149,21 +149,22 @@ TEST_P(VariadicSplitTest, label_propagation) { EXPECT_EQ(var_split->get_output_size(), split_lengths.size()); EXPECT_THAT( var_split->outputs(), - Each(Property("Partial shape", &Output::get_partial_shape, ResultOf(get_shape_labels, exp_labels)))); + Each(Property("Partial shape", &Output::get_partial_shape, ResultOf(get_shape_symbols, exp_symbols)))); } class VariadicSplitBoundTest : public VariadicSplitTest { protected: - std::pair> make_in_exp_labels() const { - ov::TensorLabel in_labels; - std::generate_n(std::back_inserter(in_labels), p_shape.size(), ov::SeqGen(8)); + std::pair> make_in_exp_symbols() const { + ov::TensorSymbol in_symbols; + for (size_t i = 0; i < p_shape.size(); ++i) + in_symbols.push_back(std::make_shared()); - std::vector exp_labels; + std::vector exp_symbols; - auto label_it = in_labels.begin(); + auto symbol_it = in_symbols.begin(); for (auto split_length : split_lengths) { if (split_length == 0) { - exp_labels.emplace_back(ov::TensorLabel(1, ov::no_label)); + exp_symbols.emplace_back(ov::TensorSymbol(1, nullptr)); } else if (split_length == -1) { split_length = std::accumulate(split_lengths.cbegin(), split_lengths.cend(), @@ -171,17 +172,17 @@ class VariadicSplitBoundTest : public VariadicSplitTest { [](const int64_t& a, const int64_t& v) { return (v != -1) ? a - v : a; }); - exp_labels.emplace_back(label_it, label_it + split_length); + exp_symbols.emplace_back(symbol_it, symbol_it + split_length); } else { - exp_labels.emplace_back(label_it, label_it + split_length); + exp_symbols.emplace_back(symbol_it, symbol_it + split_length); } - label_it += split_length; + symbol_it += split_length; } - return {in_labels, exp_labels}; + return {in_symbols, exp_symbols}; } std::vector out_shapes; - std::vector out_labels; + std::vector out_symbols; }; INSTANTIATE_TEST_SUITE_P(type_prop_bounds_propagate, @@ -204,20 +205,20 @@ INSTANTIATE_TEST_SUITE_P(type_prop_bounds_propagate, PartialShapes{{{2, 6}, 2}, {3, 5}, {1}})), PrintToStringParamName()); -TEST_P(VariadicSplitBoundTest, propagate_label_and_dynamic_value) { - ov::TensorLabel in_labels; - std::vector exp_labels; - std::tie(in_labels, exp_labels) = make_in_exp_labels(); - set_shape_labels(p_shape, in_labels); +TEST_P(VariadicSplitBoundTest, propagate_symbol_and_dynamic_value) { + ov::TensorSymbol in_symbols; + std::vector exp_symbols; + std::tie(in_symbols, exp_symbols) = make_in_exp_symbols(); + set_shape_symbols(p_shape, in_symbols); constexpr auto et = element::i64; - const auto labeled_param = std::make_shared(et, p_shape); - const auto labeled_shape_of = std::make_shared(labeled_param); + const auto symboled_param = std::make_shared(et, p_shape); + const auto symboled_shape_of = std::make_shared(symboled_param); const auto zero = std::vector{0}; const auto axis_node = std::make_shared(et, Shape{}, zero); const auto lengths_node = std::make_shared(et, Shape{split_lengths.size()}, split_lengths); - const auto var_split = std::make_shared(labeled_shape_of, axis_node, lengths_node); + const auto var_split = std::make_shared(symboled_shape_of, axis_node, lengths_node); for (auto& output : var_split->outputs()) { const auto& bc = std::make_shared( @@ -225,9 +226,9 @@ TEST_P(VariadicSplitBoundTest, propagate_label_and_dynamic_value) { output, "BIDIRECTIONAL"); out_shapes.push_back(bc->get_output_partial_shape(0)); - out_labels.push_back(get_shape_labels(bc->get_output_partial_shape(0))); + out_symbols.push_back(get_shape_symbols(bc->get_output_partial_shape(0))); } EXPECT_EQ(out_shapes, exp_shapes); - EXPECT_EQ(out_labels, exp_labels); + EXPECT_EQ(out_symbols, exp_symbols); } diff --git a/src/inference/src/check_network_batchable.cpp b/src/inference/src/check_network_batchable.cpp index b456fec87912b2..d3dfd20b4888a8 100644 --- a/src/inference/src/check_network_batchable.cpp +++ b/src/inference/src/check_network_batchable.cpp @@ -1,6 +1,6 @@ #include "check_network_batchable.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/op/detection_output.hpp" #include "openvino/op/ops.hpp" #include "openvino/pass/manager.hpp" @@ -48,7 +48,7 @@ NetworkBatchAbility is_model_batchable(const std::shared_ptr& m if (shape.is_dynamic()) return NetworkBatchAbility::NO; // check the batch dim: either 0th (and the original batch size of 1) or none - if (shape.size() && ov::DimensionTracker::get_label(shape[0])) { + if (shape.size() && shape[0].has_symbol()) { const auto& static_shape = input->get_shape(); if (static_shape[0] != 1) return NetworkBatchAbility::NO; @@ -57,7 +57,7 @@ NetworkBatchAbility is_model_batchable(const std::shared_ptr& m } else { // if the 0-th dim is not for the batch, then we support only the case when NONE dimension is batch for (size_t s = 1; s < shape.size(); s++) - if (ov::DimensionTracker::get_label(shape[s])) + if (shape[s].has_symbol()) return NetworkBatchAbility::NO; } } diff --git a/src/plugins/auto_batch/src/plugin.cpp b/src/plugins/auto_batch/src/plugin.cpp index 8afcfc776b3cd9..fba538554e770d 100644 --- a/src/plugins/auto_batch/src/plugin.cpp +++ b/src/plugins/auto_batch/src/plugin.cpp @@ -7,7 +7,7 @@ #include "plugin.hpp" #include "compiled_model.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/pass/manager.hpp" #include "openvino/runtime/intel_gpu/properties.hpp" #include "openvino/runtime/internal_properties.hpp" @@ -168,7 +168,7 @@ std::shared_ptr Plugin::compile_model(const std::shared_ptr< if (shape.is_dynamic()) OPENVINO_THROW("Auto-batching does not support dynamic networks!"); // check the batch dim: either 0th (and the original batch size of 1) or none - if (shape.size() && ov::DimensionTracker::get_label(shape[0])) { + if (shape.size() && shape[0].has_symbol()) { const auto& static_shape = input->get_shape(); if (static_shape[0] != 1) OPENVINO_THROW("Auto-batching does not reshape/re-batch originally batched networks!"); @@ -176,7 +176,7 @@ std::shared_ptr Plugin::compile_model(const std::shared_ptr< } else { // if the 0-th dim is not for the batch, then we support only the case when NONE dimension is batch for (size_t s = 1; s < shape.size(); s++) - if (ov::DimensionTracker::get_label(shape[s])) + if (shape[s].has_symbol()) OPENVINO_THROW( "Auto-batching operates only networks with inputs/outputs batched by 0th dimension"); } @@ -188,14 +188,14 @@ std::shared_ptr Plugin::compile_model(const std::shared_ptr< if (shape.is_dynamic()) OPENVINO_THROW("Auto-batching does not support dynamic networks!"); // check the batch dim: either 0th (and the original batch size of 1) or none - if (shape.size() && ov::DimensionTracker::get_label(shape[0])) { + if (shape.size() && shape[0].has_symbol()) { if (shape[0] != 1) OPENVINO_THROW("Auto-batching does not reshape/re-batch originally batched networks!"); batched_outputs.insert(output_id); } else { // if the 0-th dim is not for the batch, then we support only the case when NONE dimension is batch for (size_t s = 1; s < shape.size(); s++) - if (ov::DimensionTracker::get_label(shape[s])) + if (shape[s].get_symbol()) OPENVINO_THROW("Auto-batching operates only networks with outputs batched by 0th dimension"); } } diff --git a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp index fbf473db41f085..caced95268df81 100644 --- a/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp +++ b/src/plugins/auto_batch/tests/unit/async_infer_request_test.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/subgraph_builders/multi_single_conv.hpp" #include "mock_common.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/threading/immediate_executor.hpp" #include "transformations/utils/utils.hpp" diff --git a/src/plugins/auto_batch/tests/unit/plugin_compile_model_test.cpp b/src/plugins/auto_batch/tests/unit/plugin_compile_model_test.cpp index bfe9b60f2410e3..ce91cbb827107b 100644 --- a/src/plugins/auto_batch/tests/unit/plugin_compile_model_test.cpp +++ b/src/plugins/auto_batch/tests/unit/plugin_compile_model_test.cpp @@ -5,7 +5,7 @@ #include "common_test_utils/subgraph_builders/conv_pool_relu_non_zero.hpp" #include "common_test_utils/subgraph_builders/multi_single_conv.hpp" #include "mock_common.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/runtime/intel_gpu/properties.hpp" #include "unit_test_utils/mocks/openvino/runtime/mock_icore.hpp" @@ -114,7 +114,7 @@ TEST_P(PluginCompileModelTest, PluginCompileModelWithRemoteContextTestCase) { TEST_P(PluginCompileModelTest, PluginCompileModelBatchedModelTestCase) { m_model = ov::test::utils::make_conv_pool_relu_non_zero({1, 1, 32, 32}); auto batch = ov::Dimension(5); - ov::DimensionTracker::set_label(batch, 11); + batch.set_symbol(std::make_shared()); auto p_shape = ov::PartialShape{batch, 1, 32, 32}; m_model->reshape(p_shape); ASSERT_NO_THROW(m_plugin->compile_model(m_model, m_plugin_properities)); @@ -123,7 +123,7 @@ TEST_P(PluginCompileModelTest, PluginCompileModelBatchedModelTestCase) { TEST_P(PluginCompileModelTest, PluginCompileModelBatchedModelWithRemoteContextTestCase) { m_model = ov::test::utils::make_conv_pool_relu_non_zero({1, 1, 32, 32}); auto batch = ov::Dimension(5); - ov::DimensionTracker::set_label(batch, 11); + batch.set_symbol(std::make_shared()); auto p_shape = ov::PartialShape{batch, 1, 32, 32}; m_model->reshape(p_shape); ASSERT_NO_THROW(m_plugin->compile_model(m_model, m_plugin_properities, m_remote_context)); diff --git a/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp b/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp index f99a0bf933eeb1..b769386120ae8d 100644 --- a/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp +++ b/src/plugins/auto_batch/tests/unit/sync_infer_request_test.cpp @@ -6,7 +6,7 @@ #include "common_test_utils/subgraph_builders/multi_single_conv.hpp" #include "mock_common.hpp" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/type/element_type.hpp" #include "openvino/runtime/threading/immediate_executor.hpp" #include "transformations/utils/utils.hpp" diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/ngram_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/ngram_fusion.cpp index bf2a3d5dd57695..3fe96815559d9d 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/ngram_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/ngram_fusion.cpp @@ -7,7 +7,7 @@ #include "openvino/opsets/opset1.hpp" #include #include -#include +#include #include #include #include @@ -59,11 +59,11 @@ ov::intel_cpu::NgramFusion::NgramFusion() { return ov::pass::pattern::rank_equals(2)(output) && ov::pass::pattern::type_matches(ov::element::i32)(output); }; auto as_is_cropped_shape_match = [](ov::Output output) -> bool { - const auto& labels = output.get_tensor().get_value_label(); - return ov::pass::pattern::rank_equals(1)(output) && !labels.empty() && labels[0] != ov::no_label; + const auto& symbols = output.get_tensor().get_value_symbol(); + return ov::pass::pattern::rank_equals(1)(output) && !symbols.empty() && symbols[0] != nullptr; }; - ov::label_t cropped_shape_label = ov::no_label; + std::shared_ptr cropped_shape_symbol = nullptr; ov::Output tokens; // "as_is" input validation @@ -97,27 +97,27 @@ ov::intel_cpu::NgramFusion::NgramFusion() { concat_shape.rank() != tokens_shape.rank() || tokens_shape[1] * k != concat_shape[1]) { return false; } - // save label of cropped_shape and check it against first dimension of tokens shape - cropped_shape_label = pattern_map.at(cropped_shape_m).get_tensor().get_value_label()[0]; - if (ov::DimensionTracker::get_label(tokens_shape[0]) != cropped_shape_label) + // save symbol of cropped_shape and check it against first dimension of tokens shape + cropped_shape_symbol = pattern_map.at(cropped_shape_m).get_tensor().get_value_symbol()[0]; + if (!symbol::are_equal(tokens_shape[0].get_symbol(), cropped_shape_symbol)) return false; } - auto cropped_shape_label_match = [cropped_shape_label](ov::Output output) -> bool { - const auto& labels = output.get_tensor().get_value_label(); - return ov::pass::pattern::rank_equals(1)(output) && !labels.empty() && labels[0] != ov::no_label && labels[0] == cropped_shape_label; + auto cropped_shape_symbol_match = [cropped_shape_symbol](ov::Output output) -> bool { + const auto& symbols = output.get_tensor().get_value_symbol(); + return ov::pass::pattern::rank_equals(1)(output) && !symbols.empty() && ov::symbol::are_equal(symbols[0], cropped_shape_symbol); }; - auto tokens_label_match = [tokens_match, cropped_shape_label](ov::Output output) -> bool { - return tokens_match(output) && ov::DimensionTracker::get_label(output.get_partial_shape()[0]) == cropped_shape_label; + auto tokens_symbol_match = [tokens_match, cropped_shape_symbol](ov::Output output) -> bool { + return tokens_match(output) && symbol::are_equal(output.get_partial_shape()[0].get_symbol(), cropped_shape_symbol); }; ov::Output indices; // select branches validation { using namespace ov::opset1; - auto tokens_m = any_input(tokens_label_match); - auto cropped_shape_m = any_input(cropped_shape_label_match); + auto tokens_m = any_input(tokens_symbol_match); + auto cropped_shape_m = any_input(cropped_shape_symbol_match); auto idces_m = any_input(idces_match); auto idces_concat_inputs = as_is_idx == 0 ? ov::OutputVector{idces_m, wrap_type()} diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp index 200659f5f2e322..da659a34371d7a 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/rope_fusion.cpp @@ -42,7 +42,7 @@ ov::intel_cpu::RoPEFusionGPTNEOX::RoPEFusionGPTNEOX() { x->set_friendly_name("x"); - auto half_ndims = Symbol("half_ndims"); + auto half_ndims = ov::gen_pattern::Symbol("half_ndims"); auto int32_max = std::numeric_limits::max(); // rotate half : [-x2, x1] @@ -130,7 +130,7 @@ ov::intel_cpu::RoPEFusionCosSinPreprocess::RoPEFusionCosSinPreprocess() { auto seq_len = makePattern("i32[1]"); auto gather_positions_2d = makePattern("i32[?,?]"); - auto head_dims = Symbol("head_dims"); + auto head_dims = ov::gen_pattern::Symbol("head_dims"); auto prepare_cos_sin_llama = [&](std::shared_ptr const_tab) { auto ScatterUpdate = makePattern({{0, 0, 0}, 2, seq_len, 0}); auto slice_Slice = makePattern({const_tab, {0, 0, 0}, ScatterUpdate, {1, 1, 1}}, @@ -205,7 +205,7 @@ ov::intel_cpu::RoPEFusionIOSlicing::RoPEFusionIOSlicing() { auto int32_max = std::numeric_limits::max(); auto data = makePattern(ov::Rank(4)); - auto ndims = Symbol("ndims"); + auto ndims = ov::gen_pattern::Symbol("ndims"); auto x = GenSlice(data, 0, ndims, 1, 3); auto y = GenSlice(data, ndims, int32_max, 1, 3); auto x_emb = makePattern({x, {}, {}}) | makePattern({x, {}, {}, {}}); @@ -254,8 +254,8 @@ ov::intel_cpu::RoPEFusionPreprocess::RoPEFusionPreprocess() { // in some model qkv prejection is combined and // needs to be sliced before RoPE - auto slice_start = Symbol("slice_start"); - auto slice_stop = Symbol("slice_stop"); + auto slice_start = ov::gen_pattern::Symbol("slice_start"); + auto slice_stop = ov::gen_pattern::Symbol("slice_stop"); auto input_slice = GenSlice(input_to_slice, slice_start, slice_stop, 1, 3); // some model will transpose from [B,L,H,S] to [B,H,L,S] before RoPE @@ -376,7 +376,7 @@ ov::intel_cpu::RoPEFusionGPTJ::RoPEFusionGPTJ() { MATCHER_SCOPE(RoPEFusionGPTJ); auto int32_max = std::numeric_limits::max(); - auto ndims = Symbol("ndims"); + auto ndims = ov::gen_pattern::Symbol("ndims"); auto view_Reshape = makePattern(ov::Rank(4)); @@ -501,12 +501,12 @@ ov::intel_cpu::RoPEFusionChatGLM::RoPEFusionChatGLM(int split_output_id) { auto seq_length = makePattern("i32[1]"); auto cos_sin_cache = makePattern("f32[?,?,?,?]"); // [max_pos_embeddings, batch_size, 32, 2] - auto ndims = Symbol("ndims"); - auto head_cnt = Symbol("head_cnt"); - auto head_size = Symbol("head_size"); - auto total_size_q = Symbol("total_size_q"); - auto total_size_k = Symbol("total_size_k"); - auto total_size_v = Symbol("total_size_v"); + auto ndims = ov::gen_pattern::Symbol("ndims"); + auto head_cnt = ov::gen_pattern::Symbol("head_cnt"); + auto head_size = ov::gen_pattern::Symbol("head_size"); + auto total_size_q = ov::gen_pattern::Symbol("total_size_q"); + auto total_size_k = ov::gen_pattern::Symbol("total_size_k"); + auto total_size_v = ov::gen_pattern::Symbol("total_size_v"); auto qkv_proj = makePattern({qkv_linear, -1, {total_size_q, total_size_k, total_size_v}}); qkv_proj->set_output_size(3); @@ -631,8 +631,8 @@ ov::intel_cpu::RoPEFusionQwen::RoPEFusionQwen(int split_output_id) { auto rotary_emb_sin = makePattern("f32[1,?,1,?]"); // [1,..4096,1,128] auto qkv_proj = makePattern("f32[?,?,?]"); // f32[?,?,12288] - auto head_cnt = Symbol("head_cnt"); - auto head_size = Symbol("head_size"); + auto head_cnt = ov::gen_pattern::Symbol("head_cnt"); + auto head_size = ov::gen_pattern::Symbol("head_size"); auto ListUnpack_410_VariadicSplit = makePattern({qkv_proj, 2, {head_cnt * head_size, head_cnt * head_size, -1}}); diff --git a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp index fc43aeaccf5fab..b31db3367dea6e 100644 --- a/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp +++ b/src/plugins/intel_cpu/src/transformations/cpu_opset/common/pass/stateful_sdpa_fusion.cpp @@ -35,8 +35,8 @@ StatefulSDPAFusion::StatefulSDPAFusion() { auto cur_k = any_input(); auto cur_v = any_input(); - auto axis_seq_len = Symbol("axis_seq_len"); - auto axis_beam = Symbol("axis_beam"); + auto axis_seq_len = ov::gen_pattern::Symbol("axis_seq_len"); + auto axis_beam = ov::gen_pattern::Symbol("axis_beam"); // past_kv can be BHLS/LBHS auto past_k = makePattern({}); diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp index 8592feaea0bb94..3f26c86a241644 100644 --- a/src/plugins/intel_gpu/src/plugin/plugin.cpp +++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp @@ -26,7 +26,6 @@ #include "intel_gpu/runtime/execution_config.hpp" #include "intel_gpu/runtime/itt.hpp" #include "openvino/core/deprecated.hpp" -#include "openvino/core/dimension_tracker.hpp" #include "openvino/pass/manager.hpp" #include "openvino/pass/visualize_tree.hpp" #include "openvino/runtime/device_id_parser.hpp" @@ -674,10 +673,10 @@ uint32_t Plugin::get_max_batch_size(const ov::AnyMap& options) const { if (shape.size()) { for (size_t s = 0; s < shape.size(); s++) { - if (ov::DimensionTracker::get_label(shape[s])) { + if (const auto& symbol = shape[s].get_symbol()) { batched_inputs.insert(std::make_pair(input_id, s)); GPU_DEBUG_LOG << "[MAX_BATCH_SIZE] detected batched input " << input->get_friendly_name() - << " with index " << input_id + << " with index " << symbol << "[" << s << "]" << std::endl; } } diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/type_prop.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/type_prop.hpp index 2afce010d29913..2a953ad27740e6 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/type_prop.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/type_prop.hpp @@ -5,7 +5,7 @@ #pragma once #include "gmock/gmock.h" -#include "openvino/core/dimension_tracker.hpp" +#include "openvino/core/dimension.hpp" #include "openvino/core/partial_shape.hpp" #include "openvino/op/parameter.hpp" @@ -19,22 +19,20 @@ struct PrintToDummyParamName { }; /** - * \brief Set labels on all shape dimensions start from first label. + * \brief Set symbols on all shape dimensions start from first symbol. * - * \param p_shape Shape to set labels. - * \param first_label Vale of first label (can't be 0) + * \param p_shape Shape to set symbols. + * \return vector of set symbols */ -void set_shape_labels(ov::PartialShape& p_shape, const ov::label_t first_label); -ov::TensorLabel get_shape_labels(const ov::PartialShape& p_shape); +ov::TensorSymbol get_shape_symbols(const ov::PartialShape& p_shape); /** - * \brief Set labels on all shape dimensions start from first label. + * \brief Set symbols on all shape dimensions start from first symbol. * - * \param p_shape Shape to set labels. - * \param first_label Vale of first label (can't be 0) + * \param p_shape Shape to set symbols. */ -void set_shape_labels(ov::PartialShape& p_shape, const ov::label_t first_label); -void set_shape_labels(ov::PartialShape& p_shape, const ov::TensorLabel& labels); +ov::TensorSymbol set_shape_symbols(ov::PartialShape& p_shape); +void set_shape_symbols(ov::PartialShape& p_shape, const ov::TensorSymbol& symbols); /** * \brief Test fixture for Unsqueeze/Squeeze type_prop tests. @@ -58,7 +56,7 @@ class UnSqueezeBoundTest : public testing::WithParamInterface(ov::element::f32, ov::PartialShape{1}); } - ov::TensorLabel in_labels; + ov::TensorSymbol in_symbols; }; using PartialShapes = std::vector; diff --git a/src/tests/test_utils/common_test_utils/src/type_prop.cpp b/src/tests/test_utils/common_test_utils/src/type_prop.cpp index 19384d778d243b..38a706b22af1aa 100644 --- a/src/tests/test_utils/common_test_utils/src/type_prop.cpp +++ b/src/tests/test_utils/common_test_utils/src/type_prop.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2022 Intel Corporation +// Copyright (C) 2018-2024 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // @@ -7,28 +7,28 @@ #include "openvino/core/dimension.hpp" #include "sequnce_generator.hpp" -ov::TensorLabel get_shape_labels(const ov::PartialShape& p_shape) { - ov::TensorLabel labels; - transform(p_shape.cbegin(), p_shape.cend(), back_inserter(labels), [](const ov::Dimension& dim) { - return ov::DimensionTracker::get_label(dim); +ov::TensorSymbol get_shape_symbols(const ov::PartialShape& p_shape) { + ov::TensorSymbol symbols; + transform(p_shape.cbegin(), p_shape.cend(), back_inserter(symbols), [](const ov::Dimension& dim) { + return dim.get_symbol(); }); - return labels; + return symbols; } -void set_shape_labels(ov::PartialShape& p_shape, const ov::label_t first_label) { - ov::TensorLabel labels; - std::generate_n(std::back_inserter(labels), p_shape.size(), ov::SeqGen(first_label)); - set_shape_labels(p_shape, labels); +ov::TensorSymbol set_shape_symbols(ov::PartialShape& p_shape) { + ov::TensorSymbol symbols; + for (auto& dim : p_shape) { + if (!dim.has_symbol()) { + auto new_symbol = std::make_shared(); + dim.set_symbol(new_symbol); + } + symbols.push_back(dim.get_symbol()); + } + return symbols; } -void set_shape_labels(ov::PartialShape& p_shape, const ov::TensorLabel& labels) { - ASSERT_EQ(labels.size(), p_shape.size()); - auto label_it = labels.begin(); - - std::for_each(p_shape.begin(), p_shape.end(), [&label_it](ov::Dimension& dim) { - if (*label_it > 0) { - ov::DimensionTracker::set_label(dim, *label_it); - } - ++label_it; - }); +void set_shape_symbols(ov::PartialShape& p_shape, const ov::TensorSymbol& symbols) { + ASSERT_EQ(symbols.size(), p_shape.size()); + for (size_t i = 0; i < p_shape.size(); ++i) + p_shape[i].set_symbol(symbols[i]); }