From f3d4665f7b93fc03cc8e3e7c2563ccda377fbf8e Mon Sep 17 00:00:00 2001 From: Pawel Raasz Date: Tue, 12 Sep 2023 13:15:04 +0200 Subject: [PATCH] Api 2.0/migrate shape inference test to new api (#19665) * Migrate static shape inference test to new API * Use new API in CPU custom shape inference tests * Rename range shape inference test file --- ...adaptive_avg_pool_shape_inference_test.cpp | 17 +-- ...adaptive_max_pool_shape_inference_test.cpp | 17 +-- .../assign_shape_inference.cpp | 2 +- .../shape_inference_test/augru_cell_test.cpp | 4 +- .../augru_sequence_test.cpp | 8 +- .../batch_to_space_shape_inference_test.cpp | 27 ++-- .../bec_shape_inference_test.cpp | 16 +-- .../bel_shape_inference_test.cpp | 18 ++- ...inary_convolution_shape_inference_test.cpp | 8 +- .../binary_elementwise_arithmetic.cpp | 30 ++-- .../broadcast_shape_inference.cpp | 122 +++++++--------- .../bucketize_shape_inference_test.cpp | 8 +- .../concat_shape_inference_test.cpp | 2 +- ...volution_backprop_shape_inference_test.cpp | 9 +- .../convolution_shape_inference_test.cpp | 8 +- ...y_decoder_seq_len_shape_inference_test.cpp | 10 +- ...tc_greedy_decoder_shape_inference_test.cpp | 8 +- .../ctc_loss_shape_inference_test.cpp | 4 +- .../custom_shape_infer/adaptive_avg_pool.cpp | 6 +- .../custom_shape_infer/adaptive_max_pool.cpp | 5 +- .../custom_shape_infer/custom_shape_infer.cpp | 30 ++-- .../custom_shape_infer/custom_shape_infer.hpp | 15 +- .../custom_shape_infer/gather.cpp | 3 +- .../custom_shape_infer/one_hot.cpp | 27 ++-- .../custom_shape_infer/prior_box.cpp | 13 +- .../prior_box_clustered.cpp | 7 +- .../custom_shape_infer/reshape.cpp | 11 +- .../custom_shape_infer/squeeze.cpp | 12 +- .../custom_shape_infer/strided_slice.cpp | 16 +-- .../custom_shape_infer/transpose.cpp | 7 +- .../custom_shape_infer/unsqueeze.cpp | 11 +- ...mable_convolution_shape_inference_test.cpp | 10 +- ...ble_psroi_pooling_shape_inference_test.cpp | 11 +- .../depth_to_space_shape_inference_test.cpp | 4 +- .../detection_output_shape_inference_test.cpp | 16 +-- .../einsum_shape_infernce_test.cpp | 17 ++- .../shape_inference_test/elementwises.cpp | 20 ++- .../embedding_segments_sum_test.cpp | 25 ++-- ...ngbag_offsets_sum_shape_inference_test.cpp | 16 +-- ...ingbag_packed_sum_shape_inference_test.cpp | 11 +- ..._detection_output_shape_inference_test.cpp | 12 +- ...generate_proposal_shape_inference_test.cpp | 10 +- ...or_grid_generator_shape_inference_test.cpp | 10 +- ...feature_extractor_shape_inference_test.cpp | 10 +- ...etectron_topkrois_shape_inference_test.cpp | 12 +- ...act_image_patches_shape_inference_test.cpp | 8 +- .../eye_shape_inference_test.cpp | 60 ++++---- .../fft_base_shape_inference_test.cpp | 136 ++++++++---------- .../gather_elements_shape_inference_test.cpp | 8 +- .../gather_nd_shape_inference_test.cpp | 5 +- .../gather_shape_inference_test.cpp | 17 ++- .../gather_tree_shape_inference_test.cpp | 4 +- .../grid_sample_shape_inference_test.cpp | 4 +- ...volution_backprop_shape_inference_test.cpp | 15 +- ...group_convolution_shape_inference_test.cpp | 6 +- .../gru_cell_shape_inference_test.cpp | 10 +- .../gru_sequence_shape_inference_test.cpp | 10 +- .../interpolate_shape_inference_test.cpp | 67 ++++----- .../logical_not_shape_inference_test.cpp | 7 +- .../lstm_cell_shape_inference_test.cpp | 9 +- .../lstm_seq_shape_inference_test.cpp | 18 +-- .../make_shape_inference.cpp | 38 ++--- .../matmul_shape_inference.cpp | 8 +- .../one_hot_shape_inference_test.cpp | 50 +++---- .../pad_shape_inference_test.cpp | 34 ++--- ...ior_box_clustered_shape_inference_test.cpp | 29 +--- .../prior_box_shape_inference_test.cpp | 29 +--- .../proposal_shape_inference_test.cpp | 10 +- .../psroi_pooling_shape_inference_test.cpp | 10 +- .../range_shape_inference_test.cpp | 67 +++++++++ .../unit/shape_inference_test/range_test.cpp | 37 ----- .../read_value_shape_inference.cpp | 4 +- .../reduce_shape_inference_test.cpp | 19 ++- .../region_yolo_shape_inference_test.cpp | 8 +- .../reorg_yolo_shape_inference_test.cpp | 10 +- .../reverse_sequence_shape_inference_test.cpp | 12 +- .../reverse_shape_inference_test.cpp | 23 ++- .../rnn_cell_shape_inference_test.cpp | 8 +- .../rnn_seq_shape_inference_test.cpp | 8 +- .../roi_align_shape_inference_test.cpp | 14 +- .../roi_pooling_shape_inference_test.cpp | 8 +- .../roll_shape_inference_test.cpp | 29 ++-- ...r_elements_update_shape_inference_test.cpp | 17 +-- .../scatter_nd_shape_inference_test.cpp | 6 +- .../scatter_update_shape_inference_test.cpp | 35 +++-- .../select_shape_inference_test.cpp | 26 ++-- .../shape_inference_test/shape_node_tests.cpp | 32 ++--- .../shuffle_channels_shape_inference_test.cpp | 4 +- .../slice_shape_inference_test.cpp | 34 ++--- .../space_to_batch_shape_inference_test.cpp | 27 ++-- .../space_to_depth_shape_inference_test.cpp | 4 +- .../split_shape_inference_tests.cpp | 12 +- .../squeeze_shape_inference_test.cpp | 17 +-- .../strided_slice_shape_inference_test.cpp | 99 +++++++++++-- .../tile_shape_inference_test.cpp | 28 ++-- .../topk_shape_inference_test.cpp | 31 ++-- .../transpose_shape_infernece_test.cpp | 17 +-- .../unsqueeze_shape_inference_test.cpp | 14 +- .../tests/unit/shape_inference_test/utils.cpp | 28 ++++ .../tests/unit/shape_inference_test/utils.hpp | 111 ++------------ .../variadic_split_shape_inference_tests.cpp | 24 ++-- 101 files changed, 956 insertions(+), 1114 deletions(-) create mode 100644 src/plugins/intel_cpu/tests/unit/shape_inference_test/range_shape_inference_test.cpp delete mode 100644 src/plugins/intel_cpu/tests/unit/shape_inference_test/range_test.cpp create mode 100644 src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.cpp diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_avg_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_avg_pool_shape_inference_test.cpp index 0059829fe39..885146b8e02 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_avg_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_avg_pool_shape_inference_test.cpp @@ -21,12 +21,11 @@ protected: TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, default_ctor) { int32_t spatial_dims[] = {10, 20}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{2}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}}; op = make_op(); input_shapes = ShapeVector{{1, 3, 1, 2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 10, 20})); @@ -39,7 +38,7 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_as_constant) op = make_op(data, out_shape); input_shapes = ShapeVector{{1, 3, 10}, {1}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 17})); @@ -52,11 +51,10 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map) op = make_op(data, out_shape); int32_t spatial_dims[] = {9, 8, 7}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{3}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{3}, spatial_dims}}}; input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({1, 3, 9, 8, 7})); @@ -69,11 +67,10 @@ TEST_F(AdaptiveAvgPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map_ op = make_op(data, out_shape); int32_t spatial_dims[] = {9, 8}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{2}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}}; input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), ov::NodeValidationFailure, HasSubstr("Number of spatial dimensions is not compatible with input data rank")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_max_pool_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_max_pool_shape_inference_test.cpp index a9619b747b0..6de1a9ce5ce 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_max_pool_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/adaptive_max_pool_shape_inference_test.cpp @@ -21,12 +21,11 @@ protected: TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, default_ctor) { int32_t spatial_dims[] = {10, 20}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{2}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}}; op = make_op(); input_shapes = ShapeVector{{1, 3, 1, 2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(StaticShape({1, 3, 10, 20}))); @@ -39,7 +38,7 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_as_constant) op = make_op(data, out_shape); input_shapes = ShapeVector{{1, 3, 10}, {1}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(StaticShape({1, 3, 17}))); @@ -52,11 +51,10 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map) op = make_op(data, out_shape); int32_t spatial_dims[] = {9, 8, 7}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{3}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{3}, spatial_dims}}}; input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(StaticShape({1, 3, 9, 8, 7}))); @@ -69,11 +67,10 @@ TEST_F(AdaptiveMaxPoolV8StaticShapeInferenceTest, out_spatial_dims_in_const_map_ op = make_op(data, out_shape); int32_t spatial_dims[] = {9, 8}; - const std::map const_data{ - {1, std::make_shared(element::i32, ov::Shape{2}, spatial_dims)}}; + const std::unordered_map const_data{{1, {element::i32, ov::Shape{2}, spatial_dims}}}; input_shapes = ShapeVector{{1, 3, 10, 2, 4}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), ov::NodeValidationFailure, HasSubstr("Number of spatial dimensions is not compatible with input data rank")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/assign_shape_inference.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/assign_shape_inference.cpp index 9500ca8138f..ea2e1819a2d 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/assign_shape_inference.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/assign_shape_inference.cpp @@ -34,7 +34,7 @@ void assignTest() { // Test StaticShape std::vector static_input_shapes = {StaticShape{1, 2, 64, 64}}, static_output_shapes = {StaticShape{}}; - shape_inference(assign.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(assign.get(), static_input_shapes); ASSERT_EQ(static_input_shapes[0], (StaticShape{1, 2, 64, 64})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_cell_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_cell_test.cpp index 311e43dc634..c392e549e16 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_cell_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_cell_test.cpp @@ -34,7 +34,7 @@ TEST(StaticShapeInferenceTest, AUGRUCellTest_all_inputs_static_rank) { std::vector static_output_shapes{StaticShape{}, StaticShape{}}; - shape_inference(augru.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(augru.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -62,6 +62,6 @@ TEST(StaticShapeInferenceTest, AUGRUCellTest_all_inputs_dynamic_rank) { std::vector static_output_shapes{StaticShape{}, StaticShape{}}; - shape_inference(augru.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(augru.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({batch_size, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_sequence_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_sequence_test.cpp index 55cb4958110..5dfe469e7b6 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_sequence_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/augru_sequence_test.cpp @@ -38,9 +38,7 @@ TEST(StaticShapeInferenceTest, AGRUSequenceTest_FORWARD_all_static_rank) { StaticShape{num_directions, gates_count * hidden_size}, // B StaticShape{batch_size, seq_len, 1}}; // A - std::vector static_output_shapes{StaticShape{}, StaticShape{}}; - - shape_inference(augru_sequence.get(), static_input_shapes, static_output_shapes); + const auto static_output_shapes = shape_inference(augru_sequence.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(static_output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -73,9 +71,7 @@ TEST(StaticShapeInferenceTest, AGRUSequenceTest_FORWARD_all_inputs_dynamic_rank) StaticShape{num_directions, gates_count * hidden_size}, // B StaticShape{batch_size, seq_len, 1}}; // A - std::vector static_output_shapes{StaticShape{}, StaticShape{}}; - - shape_inference(augru_sequence.get(), static_input_shapes, static_output_shapes); + const auto static_output_shapes = shape_inference(augru_sequence.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(static_output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/batch_to_space_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/batch_to_space_shape_inference_test.cpp index a79f3fd98a4..cf80cd9ca95 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/batch_to_space_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/batch_to_space_shape_inference_test.cpp @@ -35,13 +35,12 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, default_ctor) { int32_t crops_begin_val[] = {0, 2, 0, 0, 0}; int32_t crops_end_val[] = {0, 2, 1, 0, 0}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}, - {2, std::make_shared(element::i32, Shape{5}, crops_begin_val)}, - {3, std::make_shared(element::i32, Shape{5}, crops_end_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}, + {2, {element::i32, Shape{5}, crops_begin_val}}, + {3, {element::i32, Shape{5}, crops_end_val}}}; input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{960 / (6 * 5 * 16), 6 * 6 - 2 - 2, 13 * 5 - 1, 128, 16 * 16})); } @@ -53,14 +52,13 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, blocks_crops_in_constant_map) { int32_t crops_begin_val[] = {0, 2, 0, 0, 0}; int32_t crops_end_val[] = {0, 2, 1, 0, 0}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}, - {2, std::make_shared(element::i32, Shape{5}, crops_begin_val)}, - {3, std::make_shared(element::i32, Shape{5}, crops_end_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}, + {2, {element::i32, Shape{5}, crops_begin_val}}, + {3, {element::i32, Shape{5}, crops_end_val}}}; input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], (StaticShape{960 / (6 * 5 * 16), 6 * 6 - 2 - 2, 13 * 5 - 1, 128, 16 * 16})); } @@ -72,7 +70,7 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, blocs_crops_as_constants) { op = make_op(data, block_shape, crops_begin, crops_end); input_shapes = {{100, 7, 13, 3}, {4}, {4}, {4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{100 / (10 * 5), 7 * 10 - 3 - 3, 13 * 5 - 1, 3})); } @@ -83,11 +81,10 @@ TEST_F(BatchToSpaceV1StaticShapeInferenceTest, missing_tensor_data) { int32_t block_val[] = {1, 6, 5, 1, 16}; int32_t crops_end_val[] = {0, 2, 1, 0, 0}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}, - {3, std::make_shared(element::i32, Shape{5}, crops_end_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}, + {3, {element::i32, Shape{5}, crops_end_val}}}; input_shapes = {{960, 6, 13, 128, 16}, {5}, {5}, {5}}; - EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, constant_data), NodeValidationFailure); + EXPECT_THROW(shape_inference(op.get(), input_shapes, constant_data), NodeValidationFailure); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bec_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bec_shape_inference_test.cpp index d6ced8c162c..496c06bb2eb 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bec_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bec_shape_inference_test.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/op/parameter.hpp" #include "utils.hpp" @@ -27,8 +28,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_none) { const auto op = this->make_op(a, b, op::AutoBroadcastType::NONE); this->input_shapes = {StaticShape{3, 4, 7, 5}, StaticShape{3, 4, 7, 5}}; - - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 4, 7, 5})); } @@ -40,7 +40,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_none_incompatible_shapes) { this->input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 1, 6, 1}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Argument shapes are inconsistent.")) } @@ -52,7 +52,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_numpy_equal_rank) { this->input_shapes = {StaticShape{3, 1, 1, 5}, StaticShape{3, 1, 6, 1}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 1, 6, 5})); } @@ -64,7 +64,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_numpy_a_rank_higher) { this->input_shapes = {StaticShape{6, 5, 1, 8}, StaticShape{5, 6, 1}}, - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({6, 5, 6, 8})); } @@ -76,7 +76,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_numpy_b_rank_higher) { this->input_shapes = {StaticShape{5, 6, 1}, StaticShape{6, 5, 1, 8}}, - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({6, 5, 6, 8})); } @@ -88,7 +88,7 @@ TYPED_TEST_P(BECStaticShapeInferenceTest, broadcast_numpy_incompatible_shapes) { this->input_shapes = {StaticShape{3, 4, 6, 6}, StaticShape{2, 4, 6, 6}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Argument shapes are inconsistent.")) } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bel_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bel_shape_inference_test.cpp index a2fde95bb65..2f0760b90ef 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bel_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bel_shape_inference_test.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/op/parameter.hpp" #include "utils.hpp" @@ -30,7 +31,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_none) { this->input_shapes = {StaticShape{3, 4, 7, 5}, StaticShape{3, 4, 7, 5}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 4, 7, 5})); } @@ -42,7 +43,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_none_incompatible_shapes) { this->input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 1, 6, 1}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Argument shapes are inconsistent.")) } @@ -53,8 +54,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_numpy_equal_rank) { const auto op = this->make_op(a, b); this->input_shapes = {StaticShape{3, 1, 1, 5}, StaticShape{3, 1, 6, 1}}; - - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 1, 6, 5})); } @@ -65,8 +65,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_numpy_a_rank_higher) { const auto op = this->make_op(a, b); this->input_shapes = {StaticShape{6, 5, 1, 8}, StaticShape{5, 6, 1}}, - - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({6, 5, 6, 8})); } @@ -77,8 +76,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_numpy_b_rank_higher) { const auto op = this->make_op(a, b); this->input_shapes = {StaticShape{5, 6, 1}, StaticShape{6, 5, 1, 8}}, - - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({6, 5, 6, 8})); } @@ -90,7 +88,7 @@ TYPED_TEST_P(BELStaticShapeInferenceTest, broadcast_numpy_incompatible_shapes) { this->input_shapes = {StaticShape{3, 4, 6, 6}, StaticShape{2, 4, 6, 6}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Argument shapes are inconsistent.")) } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_convolution_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_convolution_shape_inference_test.cpp index 219e20257c1..13ca00304ea 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_convolution_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_convolution_shape_inference_test.cpp @@ -74,7 +74,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, auto_pads_same_lower_inputs_ op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 7, 5, 5})); @@ -93,7 +93,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, auto_pad_same_lower_inputs_s op = make_op(data, filters, strides, pads_begin, pads_end, dilations, mode, pad_value, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 7, 5, 5})); @@ -113,7 +113,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, data_and_filters_num_channel input_shapes = ShapeVector{{3, 5, 5, 5}, {7, 6, 3, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Data batch channel count (5) does not match filter")); } @@ -132,7 +132,7 @@ TEST_F(BinaryConvolutionV1StaticShapeInferenceTest, data_rank_not_4) { input_shapes = ShapeVector{{3, 6, 5}, {7, 6, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Expected 4D for the input. Got:")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_elementwise_arithmetic.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_elementwise_arithmetic.cpp index 6a174e392fd..e48c6542b23 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_elementwise_arithmetic.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/binary_elementwise_arithmetic.cpp @@ -25,9 +25,8 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_autob_numpy_equal_ran auto node = std::make_shared(A, B); - std::vector static_input_shapes = {StaticShape{3, 1, 1, 5}, StaticShape{3, 1, 6, 1}}, - static_output_shapes = {StaticShape{}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3, 1, 1, 5}, StaticShape{3, 1, 6, 1}}; + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 1, 6, 5})); } @@ -38,9 +37,8 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_autob_numpy_a_rank_hi auto node = std::make_shared(A, B); - std::vector static_input_shapes = {StaticShape{3, 4, 1, 5}, StaticShape{4, 6, 1}}, - static_output_shapes = {StaticShape{}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3, 4, 1, 5}, StaticShape{4, 6, 1}}; + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 4, 6, 5})); } @@ -51,9 +49,8 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_autob_numpy_b_rank_hi auto node = std::make_shared(A, B); - std::vector static_input_shapes = {StaticShape{4, 6, 1}, StaticShape{3, 4, 1, 5}}, - static_output_shapes = {StaticShape{}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{4, 6, 1}, StaticShape{3, 4, 1, 5}}; + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 4, 6, 5})); } @@ -64,10 +61,9 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_autob_numpy_incompati auto node = std::make_shared(A, B); - std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{2, 4, 6, 5}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{2, 4, 6, 5}}; - ASSERT_THROW(shape_inference(node.get(), static_input_shapes, static_output_shapes), NodeValidationFailure); + ASSERT_THROW(shape_inference(node.get(), static_input_shapes), NodeValidationFailure); } TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_aubtob_none) { @@ -76,9 +72,8 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_aubtob_none) { auto node = std::make_shared(A, B, op::AutoBroadcastType::NONE); - std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 4, 6, 5}}, - static_output_shapes = {StaticShape{}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 4, 6, 5}}; + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 4, 6, 5})); } @@ -89,10 +84,9 @@ TYPED_TEST_P(StaticShapeInferenceTest_BEA, shape_inference_aubtob_none_incompati auto node = std::make_shared(A, B, op::AutoBroadcastType::NONE); - std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 1, 6, 1}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{3, 4, 6, 5}, StaticShape{3, 1, 6, 1}}; - ASSERT_THROW(shape_inference(node.get(), static_input_shapes, static_output_shapes), NodeValidationFailure); + ASSERT_THROW(shape_inference(node.get(), static_input_shapes), NodeValidationFailure); } REGISTER_TYPED_TEST_SUITE_P(StaticShapeInferenceTest_BEA, diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/broadcast_shape_inference.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/broadcast_shape_inference.cpp index 263062e4ece..6aa0879bbff 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/broadcast_shape_inference.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/broadcast_shape_inference.cpp @@ -15,18 +15,16 @@ TEST(StaticShapeInferenceTest, BroadcastBidirectionalTest) { auto broadcast_v3 = std::make_shared(input, target_shape, op::BroadcastType::BIDIRECTIONAL); int32_t target_shape_val[] = {1, 16, 50, 1}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{4}, target_shape_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{4}, target_shape_val}}}; + + std::vector static_input_shapes = {StaticShape{16, 1, 8}, StaticShape{4}}; + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes, constant_data); - std::vector static_input_shapes = {StaticShape{16, 1, 8}, StaticShape{4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 8})); static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastBidirectionalConstantTest) { @@ -34,9 +32,9 @@ TEST(StaticShapeInferenceTest, BroadcastBidirectionalConstantTest) { auto target_shape = std::make_shared(element::i32, ov::Shape{3}, std::vector{16, 1, 40}); auto broadcast_v3 = std::make_shared(input, target_shape, op::BroadcastType::BIDIRECTIONAL); - std::vector static_input_shapes = {StaticShape{1, 16, 50, 1}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}); + std::vector static_input_shapes = {StaticShape{1, 16, 50, 1}, StaticShape{3}}; + + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 40})); } @@ -47,18 +45,16 @@ TEST(StaticShapeInferenceTest, BroadcastPDPDTest) { std::make_shared(input, target_shape, op::BroadcastModeSpec(op::BroadcastType::PDPD, 1)); int32_t target_shape_val[] = {2, 3, 6}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{3}, target_shape_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{3}, target_shape_val}}}; - std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; + + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 3, 6})); static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastPDPDConstantTest) { @@ -67,9 +63,8 @@ TEST(StaticShapeInferenceTest, BroadcastPDPDConstantTest) { auto broadcast_v3 = std::make_shared(input, target_shape, op::BroadcastModeSpec(op::BroadcastType::PDPD, 1)); - std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}); + std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 3, 6})); } @@ -79,18 +74,16 @@ TEST(StaticShapeInferenceTest, BroadcastNumpyTest) { auto broadcast_v3 = std::make_shared(input, target_shape, op::BroadcastType::NUMPY); int32_t target_shape_val[] = {1, 16, 50, 50}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{4}, target_shape_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{4}, target_shape_val}}}; - std::vector static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}; + + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 50})); static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastNumpyConstantTest) { @@ -99,9 +92,9 @@ TEST(StaticShapeInferenceTest, BroadcastNumpyConstantTest) { std::make_shared(element::i32, ov::Shape{4}, std::vector{1, 16, 50, 50}); auto broadcast_v3 = std::make_shared(input, target_shape, op::BroadcastType::NUMPY); - std::vector static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}); + std::vector static_input_shapes = {StaticShape{16, 1, 1}, StaticShape{4}}; + + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 50})); } @@ -114,21 +107,16 @@ TEST(StaticShapeInferenceTest, BroadcastExplicitTest) { int32_t target_shape_val[] = {1, 16, 50, 50}; int32_t axes_mapping_val[] = {1}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{4}, target_shape_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{1}, axes_mapping_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{4}, target_shape_val}}, + {2, {element::Type_t::i32, ov::Shape{1}, axes_mapping_val}}}; std::vector static_input_shapes = {StaticShape{16}, StaticShape{4}, StaticShape{1}}; - std::vector static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 50})); constant_data.erase(1); - EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, constant_data), - NodeValidationFailure); - EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes, constant_data), NodeValidationFailure); + EXPECT_THROW(shape_inference(broadcast_v3.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastExplicitConstantTest) { @@ -140,8 +128,7 @@ TEST(StaticShapeInferenceTest, BroadcastExplicitConstantTest) { std::make_shared(input, target_shape, axes_mapping, op::BroadcastType::EXPLICIT); std::vector static_input_shapes = {StaticShape{16}, StaticShape{4}, StaticShape{1}}; - std::vector static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v3.get(), static_input_shapes, static_output_shapes, {}); + const auto static_output_shapes = shape_inference(broadcast_v3.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 16, 50, 50})); } @@ -154,18 +141,16 @@ TEST(StaticShapeInferenceTest, BroadcastV1PDPDTest) { std::make_shared(input, target_shape, op::AutoBroadcastSpec(op::AutoBroadcastType::PDPD, 1)); int32_t target_shape_val[] = {2, 3, 6}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{3}, target_shape_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{3}, target_shape_val}}}; - std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; + + const auto static_output_shapes = shape_inference(broadcast_v1.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 3, 6})); static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastV1NumpyTest) { @@ -174,18 +159,16 @@ TEST(StaticShapeInferenceTest, BroadcastV1NumpyTest) { auto broadcast_v1 = std::make_shared(input, target_shape); int32_t target_shape_val[] = {2, 3, 6}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{3}, target_shape_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{3}, target_shape_val}}}; - std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; + + const auto static_output_shapes = shape_inference(broadcast_v1.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 3, 6})); static_input_shapes = {StaticShape{3, 1}, StaticShape{3}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes), NodeValidationFailure); } TEST(StaticShapeInferenceTest, BroadcastV1ExplicitTest) { @@ -196,18 +179,15 @@ TEST(StaticShapeInferenceTest, BroadcastV1ExplicitTest) { int32_t target_shape_val[] = {2, 3, 1}; int32_t axes_mapping_val[] = {1, 2}; - std::map> constant_data; - constant_data[1] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{3}, target_shape_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, ov::Shape{2}, axes_mapping_val); + std::unordered_map constant_data{{1, {element::Type_t::i32, ov::Shape{3}, target_shape_val}}, + {2, {element::Type_t::i32, ov::Shape{2}, axes_mapping_val}}}; - std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{3, 1}, StaticShape{3}, StaticShape{2}}; + + const auto static_output_shapes = shape_inference(broadcast_v1.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 3, 1})); static_input_shapes = {StaticShape{3, 1}, StaticShape{3}, StaticShape{2}}; - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes, static_output_shapes, {}), NodeValidationFailure); + + EXPECT_THROW(shape_inference(broadcast_v1.get(), static_input_shapes), NodeValidationFailure); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bucketize_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bucketize_shape_inference_test.cpp index 02a17e2c99c..472d8d09835 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/bucketize_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/bucketize_shape_inference_test.cpp @@ -22,7 +22,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, default_ctor) { op->set_with_right_bound(false); input_shapes = ShapeVector{{3, 2, 7, 89}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({3, 2, 7, 89})); @@ -34,7 +34,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, dynamic_rank_inputs) { op = make_op(data, buckets, element::i32); input_shapes = ShapeVector{{10, 12, 1}, {5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 12, 1})); @@ -46,7 +46,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, static_rank_inputs) { op = make_op(data, buckets); input_shapes = ShapeVector{{100, 11}, {1}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({100, 11})); @@ -58,7 +58,7 @@ TEST_F(BucketizeV3StaticShapeInferenceTest, bucket_incorrect_rank) { op = make_op(data, buckets, element::i32); input_shapes = ShapeVector{{100, 11}, {2, 1}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Buckets input must be a 1D tensor")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/concat_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/concat_shape_inference_test.cpp index 444a1f7dec6..026a4aee497 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/concat_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/concat_shape_inference_test.cpp @@ -67,7 +67,7 @@ INSTANTIATE_TEST_SUITE_P( /** \brief Check shape_infer for concat op on static shapes. */ TEST_P(ConcatStaticShapeInferenceTest, concat_static) { - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes.front(), exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_backprop_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_backprop_shape_inference_test.cpp index 53b6fa03823..a3919cd2581 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_backprop_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_backprop_shape_inference_test.cpp @@ -122,7 +122,7 @@ TEST_F(ConvolutionBackpropDataV1StaticShapeInferenceTest, 2d_inputs_dynamic_rank op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5}, {6, 1, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 1, 7, 7})); @@ -142,7 +142,7 @@ TEST_F(ConvolutionBackpropDataV1StaticShapeInferenceTest, 3d_auto_pad_same_lower op = make_op(data, filters, out_spatial, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5, 5}, {6, 2, 3, 3, 3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 2, 2, 1, 3})); @@ -161,11 +161,10 @@ TEST_F(ConvolutionBackpropDataV1StaticShapeInferenceTest, 3d_auto_pad_same_upper op = make_op(data, filters, out_spatial, strides, pads_begin, pads_end, dilations, auto_pad); int32_t spatial_dims[] = {2, 6, 1}; - const auto const_map = - std::map{{2, std::make_shared(element::i32, Shape{3}, spatial_dims)}}; + const auto const_map = std::unordered_map{{2, {element::i32, Shape{3}, spatial_dims}}}; input_shapes = ShapeVector{{3, 5, 5, 5, 5}, {5, 7, 3, 3, 3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_map); + output_shapes = shape_inference(op.get(), input_shapes, const_map); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 7, 2, 6, 1})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_shape_inference_test.cpp index 04eecc6067b..2621d3a3b7a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/convolution_shape_inference_test.cpp @@ -71,7 +71,7 @@ TEST_F(ConvolutionV1StaticShapeInferenceTest, 2d_auto_pads_same_lower_inputs_dyn op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5}, {7, 6, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 7, 5, 5})); @@ -90,7 +90,7 @@ TEST_F(ConvolutionV1StaticShapeInferenceTest, 3d_auto_pad_same_lower_inputs_stat op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5, 5}, {7, 6, 3, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 7, 5, 5, 5})); @@ -110,7 +110,7 @@ TEST_F(ConvolutionV1StaticShapeInferenceTest, data_and_filters_num_channels_not_ input_shapes = ShapeVector{{3, 5, 5, 5, 5}, {7, 6, 3, 3, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Data batch channel count (5) does not match filter")); } @@ -129,7 +129,7 @@ TEST_F(ConvolutionV1StaticShapeInferenceTest, data_rank_not_compatible_with_filt input_shapes = ShapeVector{{3, 6, 5, 5, 5}, {7, 6, 3, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Data batch and filters rank do not match")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_seq_len_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_seq_len_shape_inference_test.cpp index 4e143270e48..853aef2f378 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_seq_len_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_seq_len_shape_inference_test.cpp @@ -26,7 +26,7 @@ TEST_F(CTCGreedyDecoderSeqLenV6StaticShapeInferenceTest, basic) { input_shapes = {StaticShape{4, 100, 1200}, StaticShape{4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 100})); EXPECT_EQ(output_shapes[1], StaticShape({4})); } @@ -36,13 +36,13 @@ TEST_F(CTCGreedyDecoderSeqLenV6StaticShapeInferenceTest, default_ctor) { // Two inputs input_shapes = {StaticShape{4, 100, 1200}, StaticShape{4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 100})); EXPECT_EQ(output_shapes[1], StaticShape({4})); // Three inputs (the last one is optional) input_shapes = {StaticShape{4, 100, 1200}, StaticShape{4}, {}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 100})); EXPECT_EQ(output_shapes[1], StaticShape({4})); } @@ -54,7 +54,7 @@ TEST_F(CTCGreedyDecoderSeqLenV6StaticShapeInferenceTest, incompatible_batch) { input_shapes = {StaticShape{4, 100, 1200}, StaticShape{6}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The first dimensions of input tensors must match")) } @@ -66,7 +66,7 @@ TEST_F(CTCGreedyDecoderSeqLenV6StaticShapeInferenceTest, incompatible_seq_len_ra input_shapes = {StaticShape{4, 100, 1200}, StaticShape{4, 1}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The rank of sequence len tensor must be equal to 1")) } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_shape_inference_test.cpp index 77e79873277..e98876f7b02 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_greedy_decoder_shape_inference_test.cpp @@ -26,7 +26,7 @@ TEST_F(CTCGreedyDecoderV0StaticShapeInferenceTest, basic) { input_shapes = {StaticShape{100, 3, 1200}, StaticShape{100, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({3, 100, 1, 1})); } @@ -35,7 +35,7 @@ TEST_F(CTCGreedyDecoderV0StaticShapeInferenceTest, decoder_default_ctor) { input_shapes = {StaticShape{100, 3, 1200}, StaticShape{100, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({3, 100, 1, 1})); } @@ -46,7 +46,7 @@ TEST_F(CTCGreedyDecoderV0StaticShapeInferenceTest, incompatible_batch) { input_shapes = {StaticShape{10, 3, 1200}, StaticShape{100, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The first dimensions of input tensors must match")) } @@ -58,7 +58,7 @@ TEST_F(CTCGreedyDecoderV0StaticShapeInferenceTest, incompatible_t_dim) { input_shapes = {StaticShape{100, 3, 1200}, StaticShape{100, 5}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The second dimensions of input tensors must match")) } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_loss_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_loss_shape_inference_test.cpp index b69e7ede990..71e479e9e57 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_loss_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/ctc_loss_shape_inference_test.cpp @@ -29,7 +29,7 @@ TEST_F(CTCLossV4StaticShapeInferenceTest, correct_input_shapes) { auto op = make_op(logits, logit_length, labels, label_length, blank_index); input_shapes = ShapeVector{{10, 120, 28}, {10}, {10, 120}, {10}, {}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10})); @@ -39,7 +39,7 @@ TEST_F(CTCLossV4StaticShapeInferenceTest, default_ctor) { auto op = make_op(); input_shapes = ShapeVector{{12, 120, 28}, {12}, {12, 120}, {12}, {}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({12})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_avg_pool.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_avg_pool.cpp index 44c5eed6790..cf6976dac42 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_avg_pool.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_avg_pool.cpp @@ -57,9 +57,8 @@ TEST_P(AdaptiveAvgPoolV8CpuShapeInferenceTest , shape_inference_with_const_map) const auto axes_node = std::make_shared(element::i32, PartialShape::dynamic()); const auto op = make_op(arg, axes_node); - const auto axes_const = std::make_shared(element::i32, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i32, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); } @@ -74,4 +73,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_max_pool.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_max_pool.cpp index af07648d0e4..4cf9d13a18a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_max_pool.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/adaptive_max_pool.cpp @@ -61,8 +61,8 @@ TEST_P(AdaptiveMaxPoolV8CpuShapeInferenceTest , shape_inference_with_const_map) const auto op = make_op(arg, axes_node); const auto axes_const = std::make_shared(element::i32, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i32, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); } @@ -77,4 +77,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.cpp index 3cf0753ae34..f4a35907253 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.cpp @@ -1,29 +1,31 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include +#include + +#include "custom_shape_infer.hpp" +#include "ie_ngraph_utils.hpp" +#include "openvino/cc/factory.h" #include "openvino/core/partial_shape.hpp" #include "openvino/core/type.hpp" #include "openvino/op/ops.hpp" #include "openvino/op/parameter.hpp" -#include "shape_inference/custom/reshape.hpp" -#include "shape_inference/custom/gather.hpp" -#include "shape_inference/custom/transpose.hpp" +#include "shape_inference/custom/adaptive_pooling.hpp" #include "shape_inference/custom/color_convert.hpp" #include "shape_inference/custom/eltwise.hpp" -#include "shape_inference/custom/adaptive_pooling.hpp" #include "shape_inference/custom/fullyconnected.hpp" +#include "shape_inference/custom/gather.hpp" #include "shape_inference/custom/matmul.hpp" #include "shape_inference/custom/ngram.hpp" #include "shape_inference/custom/one_hot.hpp" #include "shape_inference/custom/priorbox.hpp" #include "shape_inference/custom/priorbox_clustered.hpp" +#include "shape_inference/custom/reshape.hpp" #include "shape_inference/custom/shapeof.hpp" #include "shape_inference/custom/strided_slice.hpp" -#include "ie_ngraph_utils.hpp" -#include "custom_shape_infer.hpp" +#include "shape_inference/custom/transpose.hpp" #include "shape_inference/shape_inference_status.hpp" -#include + namespace ov { namespace intel_cpu { namespace unit_test { @@ -84,9 +86,9 @@ void compare_result(const std::vector& ref, const std::vector& input_shapes, - std::vector& output_shapes, - const std::map& constant_data) { + const std::vector& input_shapes, + std::vector& output_shapes, + const std::unordered_map& constant_data) { static std::shared_ptr cusFactory = std::make_shared(); auto shapeInferFactory = cusFactory->create(op->shared_from_this()); ASSERT_TRUE(shapeInferFactory != nullptr); @@ -114,9 +116,9 @@ void cpu_test_shape_infer(ov::Node* op, const void* data = nullptr; ov::element::Type elementType; if (tensorIter != constant_data.end()) { - const auto tensor = tensorIter->second; - data = tensor->get_data_ptr(); - elementType = tensor->get_element_type(); + const auto& tensor = tensorIter->second; + data = tensor.data(); + elementType = tensor.get_element_type(); } else { const auto input_op = op->input_value(port).get_node_shared_ptr(); const auto const_op = ov::as_type_ptr(input_op); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.hpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.hpp index a3e2d149c33..7edc933e0eb 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.hpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/custom_shape_infer.hpp @@ -2,21 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "cpu_types.h" -#include -#include -#include #include +#include "common_test_utils/common_utils.hpp" +#include "cpu_types.h" +#include "shape_inference/shape_inference_cpu.hpp" +#include "shape_inference/static_shape.hpp" + #pragma once namespace ov { namespace intel_cpu { namespace unit_test { void cpu_test_shape_infer(ov::Node* op, - const std::vector& input_shapes, - std::vector& output_shapes, - const std::map& constant_data = {}); + const std::vector& input_shapes, + std::vector& output_shapes, + const std::unordered_map& constant_data = {}); using ShapeVector = std::vector; diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/gather.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/gather.cpp index e462cada491..1ebb1693a81 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/gather.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/gather.cpp @@ -68,7 +68,7 @@ TYPED_TEST_P(CpuShapeInferenceGatherTest, axis_in_const_map) { std::tie(this->axis_val, this->input_shapes, this->exp_shape) = params; auto op = this->make_gather(this->input_shapes); - auto axis_tensor = std::make_shared(element::i32, ov::Shape{1}, &this->axis_val); + auto axis_tensor = ov::Tensor(element::i32, ov::Shape{1}, &this->axis_val); this->output_shapes = {this->exp_shape}; unit_test::cpu_test_shape_infer(op.get(), this->input_shapes, this->output_shapes, {{2, axis_tensor}}); @@ -83,4 +83,3 @@ INSTANTIATE_TYPED_TEST_SUITE_P(CpuShapeInfer, CpuShapeInferenceGatherTest, Gathe } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/one_hot.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/one_hot.cpp index 6f5efcf329a..57e007c7d9a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/one_hot.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/one_hot.cpp @@ -72,15 +72,10 @@ TEST_P(OneHotCpuShapeInferenceTest , shape_inference_with_const_map) { int64_t axis = -1; const auto op = make_op(arg, depth, on, off, axis); - const auto depth_const = std::make_shared(element::i64, ov::Shape{}, std::vector{m_depth}); - const auto on_const = std::make_shared(element::i32, ov::Shape{}, std::vector{m_on}); - const auto off_const = std::make_shared(element::i32, ov::Shape{}, std::vector{m_off}); - const auto depth_tensor = std::make_shared(depth_const); - const auto on_tensor = std::make_shared(on_const); - const auto off_tensor = std::make_shared(off_const); - const std::map& constant_data = {{1, depth_tensor}, - {2, on_tensor}, - {3, off_tensor}}; + const auto depth_tensor = ov::Tensor(element::i64, ov::Shape{}, &m_depth); + const auto on_tensor = ov::Tensor(element::i32, ov::Shape{}, &m_on); + const auto off_tensor = ov::Tensor(element::i32, ov::Shape{}, &m_off); + const std::unordered_map constant_data = {{1, depth_tensor}, {2, on_tensor}, {3, off_tensor}}; unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); } @@ -101,15 +96,10 @@ TEST_P(OneHotCpuShapeInferenceThrowExceptionTest, wrong_pattern) { int64_t axis = -1; const auto op = make_op(arg, depth, on, off, axis); - const auto depth_const = std::make_shared(element::i64, ov::Shape{}, std::vector{m_depth}); - const auto on_const = std::make_shared(element::i32, ov::Shape{}, std::vector{m_on}); - const auto off_const = std::make_shared(element::i32, ov::Shape{}, std::vector{m_off}); - const auto depth_tensor = std::make_shared(depth_const); - const auto on_tensor = std::make_shared(on_const); - const auto off_tensor = std::make_shared(off_const); - const std::map& constant_data = {{1, depth_tensor}, - {2, on_tensor}, - {3, off_tensor}}; + const auto depth_tensor = ov::Tensor(element::i64, ov::Shape{}, &m_depth); + const auto on_tensor = ov::Tensor(element::i32, ov::Shape{}, &m_on); + const auto off_tensor = ov::Tensor(element::i32, ov::Shape{}, &m_off); + const std::unordered_map constant_data = {{1, depth_tensor}, {2, on_tensor}, {3, off_tensor}}; // TODO , implementation should throw exception ASSERT_THROW(unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data), @@ -126,4 +116,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box.cpp index 80726f1b54e..5fb1b6f29d5 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box.cpp @@ -4,10 +4,11 @@ #include +#include + #include "common_test_utils/test_assertions.hpp" #include "custom_shape_infer.hpp" -#include -#include +#include "openvino/opsets/opset8.hpp" namespace ov { namespace intel_cpu { namespace unit_test { @@ -180,12 +181,8 @@ TEST_P(PriorBoxV0CpuShapeInferenceTest , shape_inference_with_const_map) { const auto image_shape = std::make_shared(element::i32, PartialShape::dynamic()); auto op = make_op(layer_shape, image_shape, attrs); - const auto layer_const = std::make_shared(element::i32, ov::Shape{2}, data[0]); - const auto image_const = std::make_shared(element::i32, ov::Shape{2}, data[1]); - const std::map const_data { - {0, std::make_shared(layer_const)}, - {1, std::make_shared(image_const)}, - }; + const std::unordered_map const_data{{0, {element::i32, ov::Shape{2}, data[0].data()}}, + {1, {element::i32, ov::Shape{2}, data[1].data()}}}; unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, const_data); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box_clustered.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box_clustered.cpp index e5b2e53e2db..08ac749f6d8 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box_clustered.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/prior_box_clustered.cpp @@ -144,12 +144,10 @@ TEST_P(PriorBoxClusteredV0CpuShapeInferenceTest , shape_inference_with_const_map const auto layer_shape = std::make_shared(element::i32, PartialShape::dynamic()); const auto image_shape = std::make_shared(element::i32, PartialShape::dynamic()); auto op = make_op(layer_shape, image_shape, attrs); - const auto layer_const = std::make_shared(element::i32, ov::Shape{2}, data[0]); - std::map const_data{{0, std::make_shared(layer_const)}}; + std::unordered_map const_data{{0, {element::i32, ov::Shape{2}, data[0].data()}}}; if (input_shapes.size() == 2) { - const auto image_const = std::make_shared(element::i32, ov::Shape{2}, data[1]); - const_data.insert({1, std::make_shared(image_const)}); + const_data.insert({1, {element::i32, ov::Shape{2}, data[1].data()}}); } unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, const_data); } @@ -171,4 +169,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/reshape.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/reshape.cpp index ed3f87b2e8c..98687a6b0d1 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/reshape.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/reshape.cpp @@ -63,9 +63,8 @@ TEST_P(ReshapeCpuShapeInferenceTest , shape_inference_with_const_map) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); const auto op = make_op(arg, axes_node, specalZero); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; output_shapes.push_back(exp_shape); unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); @@ -92,9 +91,8 @@ TEST_P(ReshapeCpuShapeInferenceThrowExceptionTest, wrong_pattern) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); const auto op = make_op(arg, axes_node, specalZero); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; std::ostringstream os; os << "[cpu]reshape: the shape of input data "; os << "("; @@ -134,4 +132,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/squeeze.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/squeeze.cpp index 6f7dd89a2ef..7de0e1a67ed 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/squeeze.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/squeeze.cpp @@ -57,9 +57,9 @@ TEST_P(SqueezeCpuShapeInferenceTest , shape_inference_with_const_map) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); const auto op = make_op(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = axes.empty() ? ov::Tensor(element::i64, ov::Shape{axes.size()}) + : ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); } @@ -92,9 +92,8 @@ TEST_P(SqueezeCpuShapeInferenceThrowExceptionTest, wrong_pattern) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); const auto op = make_op(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; std::ostringstream os; os << "[cpu]squeeze: the shape of input data "; os << "("; @@ -135,4 +134,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/strided_slice.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/strided_slice.cpp index b899d6d76a6..9a9fe23f00a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/strided_slice.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/strided_slice.cpp @@ -78,15 +78,10 @@ TEST_P(StridedSliceCpuShapeInferenceTest , shape_inference_in_const_map) { const auto stride = std::make_shared(element::i32, input_shapes[3].get_shape()); const auto op = make_op(arg, begin, end, stride, begin_mask, end_mask); - const auto begin_const = std::make_shared(element::i32, input_shapes[1].get_shape(), data[BEGIN]); - const auto end_const = std::make_shared(element::i32, input_shapes[2].get_shape(), data[END]); - const auto stride_const = std::make_shared(element::i32, input_shapes[3].get_shape(), data[STRIDE]); - const auto begin_tensor = std::make_shared(begin_const); - const auto end_tensor = std::make_shared(end_const); - const auto stride_tensor = std::make_shared(stride_const); - const std::map& constant_data = {{1, begin_tensor}, - {2, end_tensor}, - {3, stride_tensor}}; + const auto begin_tensor = ov::Tensor(element::i32, input_shapes[1].get_shape(), data[BEGIN].data()); + const auto end_tensor = ov::Tensor(element::i32, input_shapes[2].get_shape(), data[END].data()); + const auto stride_tensor = ov::Tensor(element::i32, input_shapes[3].get_shape(), data[STRIDE].data()); + const std::unordered_map constant_data = {{1, begin_tensor}, {2, end_tensor}, {3, stride_tensor}}; // implementation depends on some output information of the op op->set_output_type(0, element::i32, {-1, -1, -1}); unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); @@ -95,7 +90,7 @@ TEST_P(StridedSliceCpuShapeInferenceTest , shape_inference_in_const_map) { INSTANTIATE_TEST_SUITE_P( CpuShapeInfer, StridedSliceCpuShapeInferenceTest, - Values(make_tuple(unit_test::ShapeVector{{3, 4, 5}, {3}, {3}, {3}}, std::vector>{{100}, {-100}, {-1}}, + Values(make_tuple(unit_test::ShapeVector{{3, 4, 5}, {3}, {3}, {3}}, std::vector>{{100, 100, 100}, {-100, -100, -100}, {-1, -1, -1}}, std::vector(4, 0), std::vector(4, 0), StaticShape({3, 4, 5})), make_tuple(unit_test::ShapeVector{{3, 2, 3}, {3}, {3}, {3}}, std::vector>{{1, 0, 0}, {2, 1, 3}, {1, 1, 1}}, std::vector(4, 0), std::vector(4, 0), StaticShape({1, 1, 3})), @@ -133,4 +128,3 @@ TEST(CpuShapeInfer, StridedSliceDefault_stride) { } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/transpose.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/transpose.cpp index c31d9f7917f..e0ee0db8089 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/transpose.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/transpose.cpp @@ -79,9 +79,9 @@ TEST_P(TransposeCpuShapeInferenceThrowExceptionTest, shape_inference_in_const_ma const auto order = std::make_shared(element::i64, PartialShape::dynamic()); auto op = make_op(arg, order); - const auto axes = std::make_shared(element::i64, ov::Shape{transpose_order.size()}, transpose_order); - const auto const_tensor = std::make_shared(axes); - const std::map const_map = {{1, const_tensor}}; + const auto const_tensor = transpose_order.empty() ? ov::Tensor(element::i64, ov::Shape{transpose_order.size()}) + : ov::Tensor(element::i64, ov::Shape{transpose_order.size()}, transpose_order.data()); + const std::unordered_map const_map = {{1, const_tensor}}; OV_EXPECT_THROW(unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, const_map), ov::Exception, @@ -99,4 +99,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/unsqueeze.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/unsqueeze.cpp index c8cbf748749..ee484b101d7 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/unsqueeze.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/custom_shape_infer/unsqueeze.cpp @@ -57,9 +57,8 @@ TEST_P(UnsqueezeCpuShapeInferenceTest , shape_inference_with_const_map) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); op = std::make_shared(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; output_shapes.push_back(exp_shape); unit_test::cpu_test_shape_infer(op.get(), input_shapes, output_shapes, constant_data); } @@ -95,9 +94,8 @@ TEST_P(UnsqueezeCpuShapeInferenceThrowExceptionTest, wrong_pattern) { const auto axes_node = std::make_shared(element::i64, PartialShape::dynamic()); const auto op = make_op(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const std::unordered_map constant_data = {{1, axes_tensor}}; std::ostringstream os; os << "[cpu]unsqueeze: the shape of input data "; os << "("; @@ -135,4 +133,3 @@ INSTANTIATE_TEST_SUITE_P( } // namespace unit_test } // namespace intel_cpu } // namespace ov - diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_convolution_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_convolution_shape_inference_test.cpp index ff7125b3150..d897c45f024 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_convolution_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_convolution_shape_inference_test.cpp @@ -55,7 +55,7 @@ TEST_F(DeformableConvolutionV8StaticShapeInferenceTest, pads_same_lower_inputs_d op = make_op(data, offsets, filters, strides, pads_begin, pads_end, dilations, auto_pad, 4, 2); input_shapes = ShapeVector{{1, 4, 5, 5}, {1, 36, 5, 5}, {4, 1, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 4, 5, 5})); @@ -76,7 +76,7 @@ TEST_F(DeformableConvolutionV8StaticShapeInferenceTest, pads_same_lower_inputs_d op = make_op(data, offsets, filters, masks, strides, pads_begin, pads_end, dilations, auto_pad, 4, 2); input_shapes = ShapeVector{{1, 4, 5, 5}, {1, 36, 5, 5}, {4, 1, 3, 3}, {1, 18, 5, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 4, 5, 5})); @@ -96,7 +96,7 @@ TEST_F(DeformableConvolutionV8StaticShapeInferenceTest, pads_same_uper_inputs_st op = make_op(data, offsets, filters, strides, pads_begin, pads_end, dilations, auto_pad, 4, 2); input_shapes = ShapeVector{{1, 4, 5, 5}, {1, 36, 5, 5}, {4, 1, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 4, 5, 5})); @@ -117,7 +117,7 @@ TEST_F(DeformableConvolutionV8StaticShapeInferenceTest, pads_same_upper_inputs_s op = make_op(data, offsets, filters, masks, strides, pads_begin, pads_end, dilations, auto_pad, 4, 2); input_shapes = ShapeVector{{1, 4, 5, 5}, {1, 36, 5, 5}, {4, 1, 3, 3}, {1, 18, 5, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 4, 5, 5})); @@ -140,7 +140,7 @@ TEST_F(DeformableConvolutionV8StaticShapeInferenceTest, mask_channel_dimension_n input_shapes = ShapeVector{{1, 4, 5, 5}, {1, 36, 5, 5}, {4, 1, 3, 3}, {1, 17, 5, 5}}; OV_EXPECT_THROW( - shape_inference(op.get(), input_shapes, output_shapes), + shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr( "The channels dimension of mask input is not compatible with filters and 'deformable group' attribute")); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_psroi_pooling_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_psroi_pooling_shape_inference_test.cpp index f136e7cff9f..5b50f597f4a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_psroi_pooling_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/deformable_psroi_pooling_shape_inference_test.cpp @@ -1,10 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "utils.hpp" @@ -36,13 +37,13 @@ TEST_F(DeformablePSROIPoolingV1StaticShapeInferenceTest, default_ctor) { // 2 inputs { input_shapes = {StaticShape{2, 4, 8, 6}, StaticShape{rois_dim, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } // 3 inputs { input_shapes = {StaticShape{2, 4, 8, 6}, StaticShape{rois_dim, 5}, StaticShape{rois_dim, 20, group_size, group_size}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } } @@ -62,7 +63,7 @@ TEST_F(DeformablePSROIPoolingV1StaticShapeInferenceTest, no_offsets_input) { StaticShape expected_output{rois_dim, output_dim, group_size, group_size}; input_shapes = {StaticShape{2, 4, 8, 6}, StaticShape{rois_dim, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } @@ -82,6 +83,6 @@ TEST_F(DeformablePSROIPoolingV1StaticShapeInferenceTest, offsets_input) { StaticShape expected_output{rois_dim, output_dim, group_size, group_size}; input_shapes = {StaticShape{2, 4, 8, 6}, StaticShape{rois_dim, 5}, StaticShape{rois_dim, 20, group_size, group_size}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/depth_to_space_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/depth_to_space_shape_inference_test.cpp index d7fb9d9f4e6..30a0621a956 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/depth_to_space_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/depth_to_space_shape_inference_test.cpp @@ -24,7 +24,7 @@ TEST_F(DepthToSpaceV0StaticShapeInferenceTest, default_ctor) { const auto op = make_op(); op->set_block_size(2); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{1, 2, 2 * 3, 2 * 1080, 2 * 1616})); @@ -34,7 +34,7 @@ TEST_F(DepthToSpaceV0StaticShapeInferenceTest, block_first) { const auto data = std::make_shared(element::f32, PartialShape::dynamic(4)); const auto op = make_op(data, op_type::DepthToSpaceMode::BLOCKS_FIRST, 2); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{1, 2, 2 * 3, 2 * 1080, 2 * 1616})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/detection_output_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/detection_output_shape_inference_test.cpp index 146a4ec1f2e..23db7df4dba 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/detection_output_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/detection_output_shape_inference_test.cpp @@ -48,7 +48,7 @@ TEST(StaticShapeInferenceTest, detection_output_v0_top_k) { StaticShape{4, 10}, StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], StaticShape({1, 1, 56, 7})); } @@ -74,7 +74,7 @@ TEST(StaticShapeInferenceTest, detection_output_v0_no_share_location) { StaticShape{4, 10}, StaticShape{4, 40}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], StaticShape({1, 1, 40, 7})); } @@ -98,7 +98,7 @@ TEST(StaticShapeInferenceTest, detection_output_v0_basic) { StaticShape{4, 10}, StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], (StaticShape{1, 1, 800, 7})); } @@ -118,7 +118,7 @@ TEST(StaticShapeInferenceTest, detection_output_v0_default_ctor) { StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{1, 1, 800, 7})); } @@ -142,7 +142,7 @@ TEST(StaticShapeInferenceTest, detection_output_v8_top_k) { StaticShape{4, 10}, StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], StaticShape({1, 1, 56, 7})); } @@ -167,7 +167,7 @@ TEST(StaticShapeInferenceTest, detection_output_v8_no_share_location) { StaticShape{4, 10}, StaticShape{4, 40}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], StaticShape({1, 1, 40, 7})); } @@ -190,7 +190,7 @@ TEST(StaticShapeInferenceTest, detection_output_v8_basic) { StaticShape{4, 10}, StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes[0], (StaticShape{1, 1, 800, 7})); } @@ -209,6 +209,6 @@ TEST(StaticShapeInferenceTest, detection_output_v8_default_ctor) { StaticShape{4, 20}}; std::vector output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{1, 1, 800, 7})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/einsum_shape_infernce_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/einsum_shape_infernce_test.cpp index 6fce6f5cd15..6113fdf8e13 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/einsum_shape_infernce_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/einsum_shape_infernce_test.cpp @@ -1,12 +1,14 @@ // Copyright (C) 2022 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "openvino/op/einsum.hpp" #include "utils.hpp" using namespace ov; using namespace ov::intel_cpu; +using testing::ElementsAre; class EinsumStaticShapeInferenceTest : public OpStaticShapeInferenceTest {}; @@ -14,33 +16,38 @@ TEST_F(EinsumStaticShapeInferenceTest, dot_product) { auto inputs = OutputVector(2, std::make_shared(element::f32, ov::PartialShape::dynamic())); auto op = make_op(inputs, "i,i->"); - check_static_shape(op.get(), {StaticShape{3}, StaticShape{3}}, {StaticShape{}}); + output_shapes = shape_inference(op.get(), ShapeVector{{3}, {3}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{})); } TEST_F(EinsumStaticShapeInferenceTest, matmul) { auto inputs = OutputVector(2, std::make_shared(element::f32, ov::PartialShape::dynamic())); auto op = make_op(inputs, "ab,bc->ac"); - check_static_shape(op.get(), {StaticShape{2, 3}, StaticShape{3, 4}}, {StaticShape{2, 4}}); + output_shapes = shape_inference(op.get(), ShapeVector{{2, 3}, {3, 4}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{2, 4})); } TEST_F(EinsumStaticShapeInferenceTest, trace) { auto I1 = std::make_shared(element::f32, ov::PartialShape::dynamic()); auto op = make_op(OutputVector{I1}, "kii->k"); - check_static_shape(op.get(), {StaticShape{2, 3, 3}}, {StaticShape{2}}); + output_shapes = shape_inference(op.get(), ShapeVector{{2, 3, 3}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{2})); } TEST_F(EinsumStaticShapeInferenceTest, transpose) { auto I1 = std::make_shared(element::f32, ov::PartialShape::dynamic()); auto op = make_op(OutputVector{I1}, "ijk->kij"); - check_static_shape(op.get(), {StaticShape{1, 2, 3}}, {StaticShape{3, 1, 2}}); + output_shapes = shape_inference(op.get(), ShapeVector{{1, 2, 3}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{3, 1, 2})); } TEST_F(EinsumStaticShapeInferenceTest, multi_matmul) { auto inputs = OutputVector(3, std::make_shared(element::i32, ov::PartialShape::dynamic())); auto op = make_op(inputs, "ab,bcd,bc->ca"); - check_static_shape(op.get(), {StaticShape{2, 5}, StaticShape{5, 3, 6}, StaticShape{5, 3}}, {StaticShape{3, 2}}); + output_shapes = shape_inference(op.get(), ShapeVector{{2, 5}, {5, 3, 6}, {5, 3}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{3, 2})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/elementwises.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/elementwises.cpp index b77b1330ea4..e1ca0de7d21 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/elementwises.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/elementwises.cpp @@ -13,9 +13,8 @@ TEST(StaticShapeInferenceTest, UnaryEltwiseTest) { auto data = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); auto node = std::make_shared(data); - std::vector static_input_shapes = {StaticShape{3, 6, 5, 5}}, - static_output_shapes = {StaticShape{}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3, 6, 5, 5}}; + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 6, 5, 5})); } @@ -29,15 +28,12 @@ TEST(StaticShapeInferenceTest, FakeQuantizeTest) { auto node = std::make_shared(data, il, ih, ol, oh, 256); - std::vector static_input_shapes = { - StaticShape{3, 6, 3, 5}, - StaticShape{1, 3, 1}, - StaticShape{1}, - StaticShape{5}, - StaticShape{1, 1, 1, 1} - }, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{3, 6, 3, 5}, + StaticShape{1, 3, 1}, + StaticShape{1}, + StaticShape{5}, + StaticShape{1, 1, 1, 1}}; - shape_inference(node.get(), static_input_shapes, static_output_shapes); + const auto static_output_shapes = shape_inference(node.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 6, 3, 5})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embedding_segments_sum_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embedding_segments_sum_test.cpp index 76eef8cdaaa..14c67c65795 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embedding_segments_sum_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embedding_segments_sum_test.cpp @@ -26,10 +26,9 @@ TEST_F(EmbeddingSegmentsSumV3StaticShapeInferenceTest, default_ctor) { input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{4}, StaticShape{}, StaticShape{}, StaticShape{4}}; int64_t num_segments = 4; - const auto const_map = - std::map{{3, std::make_shared(element::i64, Shape{}, &num_segments)}}; + const auto const_map = std::unordered_map{{3, {element::i64, Shape{}, &num_segments}}}; - shape_inference(op.get(), input_shapes, output_shapes, const_map); + output_shapes = shape_inference(op.get(), input_shapes, const_map); EXPECT_EQ(output_shapes[0], (StaticShape{4, 2, 6})); } @@ -43,7 +42,7 @@ TEST_F(EmbeddingSegmentsSumV3StaticShapeInferenceTest, constant_input) { auto op = make_op(emb_table, indices, segment_ids, num_segments, default_index, per_sample_weights); input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{4}, StaticShape{}, StaticShape{}, StaticShape{4}}, - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{3, 2, 6})); } @@ -59,10 +58,9 @@ TEST_F(EmbeddingSegmentsSumV3StaticShapeInferenceTest, constant_map) { input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{4}, StaticShape{}, StaticShape{}, StaticShape{4}}; int64_t num_segm_val = 3; - const auto const_map = - std::map{{3, std::make_shared(element::i64, Shape{}, &num_segm_val)}}; + const auto const_map = std::unordered_map{{3, {element::i64, Shape{}, &num_segm_val}}}; - shape_inference(op.get(), input_shapes, output_shapes, const_map); + output_shapes = shape_inference(op.get(), input_shapes, const_map); EXPECT_EQ(output_shapes[0], (StaticShape{3, 2, 6})); } @@ -76,12 +74,11 @@ TEST_F(EmbeddingSegmentsSumV3StaticShapeInferenceTest, basic) { auto op = make_op(emb_table, indices, segment_ids, num_segments, default_index, per_sample_weights); - check_static_shape( - op.get(), - {StaticShape{5, 2}, StaticShape{4}, StaticShape{4}, StaticShape{}, StaticShape{}, StaticShape{4}}, - {StaticShape{3, 2}}); + output_shapes = shape_inference(op.get(), ShapeVector{{5, 2}, {4}, {4}, {}, {}, {4}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{3, 2})); - check_static_shape(op.get(), - {StaticShape{5, 2}, StaticShape{4}, StaticShape{4}, 8, StaticShape{}, StaticShape{4}}, - {StaticShape{8, 2}}); + int64_t num_segm_val = 8; + const auto const_map = std::unordered_map{{3, {element::i64, Shape{}, &num_segm_val}}}; + output_shapes = shape_inference(op.get(), ShapeVector{{5, 2}, {4}, {4}, {}, {}, {4}}, const_map); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{8, 2})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_offsets_sum_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_offsets_sum_shape_inference_test.cpp index 76698a8a33f..dac5ff8307f 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_offsets_sum_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_offsets_sum_shape_inference_test.cpp @@ -1,12 +1,12 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/test_assertions.hpp" #include "embeddingbag_offsets_shape_inference.hpp" - -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "utils.hpp" @@ -31,19 +31,19 @@ TEST_F(EmbeddingBagOffsetsSumV3StaticShapeInferenceTest, default_ctor) { // 3 inputs { input_shapes = {StaticShape{3, 4, 5, 6}, StaticShape{2}, StaticShape{batch}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } // 4 inputs { input_shapes = {StaticShape{3, 4, 5, 6}, StaticShape{2}, StaticShape{batch}, StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } // 5 inputs { input_shapes = {StaticShape{3, 4, 5, 6}, StaticShape{2}, StaticShape{batch}, StaticShape{}, StaticShape{2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } } @@ -58,7 +58,7 @@ TEST_F(EmbeddingBagOffsetsSumV3StaticShapeInferenceTest, basic_3in) { auto expected_output = StaticShape{3, 2, 6}; input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } @@ -73,7 +73,7 @@ TEST_F(EmbeddingBagOffsetsSumV3StaticShapeInferenceTest, basic_4in) { auto expected_output = StaticShape{3, 2, 6}; input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{3}, StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } @@ -89,6 +89,6 @@ TEST_F(EmbeddingBagOffsetsSumV3StaticShapeInferenceTest, basic_5in) { auto expected_output = StaticShape{3, 2, 6}; input_shapes = {StaticShape{5, 2, 6}, StaticShape{4}, StaticShape{3}, StaticShape{}, StaticShape{4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_packed_sum_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_packed_sum_shape_inference_test.cpp index b79b6b92f5e..9b90704c42a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_packed_sum_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/embeddingbag_packed_sum_shape_inference_test.cpp @@ -1,11 +1,12 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/test_assertions.hpp" #include "embeddingbag_packed_shape_inference.hpp" -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "utils.hpp" @@ -30,13 +31,13 @@ TEST_F(EmbeddingBagPackedSumV3StaticShapeInferenceTest, default_ctor) { // 2 inputs { input_shapes = {StaticShape{3, 4, 5, 6}, StaticShape{batch, 2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } // 3 inputs { input_shapes = {StaticShape{3, 4, 5, 6}, StaticShape{batch, 2}, StaticShape{batch, 2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], expected_output); } } @@ -49,7 +50,7 @@ TEST_F(EmbeddingBagPackedSumV3StaticShapeInferenceTest, basic_2in) { auto op = make_op(emb_table, indices); input_shapes = {StaticShape{5, 2, 6}, StaticShape{3, 4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{3, 2, 6})); } @@ -61,6 +62,6 @@ TEST_F(EmbeddingBagPackedSumV3StaticShapeInferenceTest, basic_3in) { auto op = make_op(emb_table, indices, per_sample_weights); input_shapes = {StaticShape{5, 2, 6}, StaticShape{3, 4}, StaticShape{3, 4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{3, 2, 6})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_detection_output_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_detection_output_shape_inference_test.cpp index 8238885da10..75af42b9596 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_detection_output_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_detection_output_shape_inference_test.cpp @@ -30,7 +30,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, default_c op->set_attrs({.05f, .5f, 4.1352f, 12, 20, 7, false, {10.0f, 10.0f, 5.0f, 5.0f}}); input_shapes = ShapeVector{{10, 4}, {10, 48}, {10, 12}, {1, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{7, 4}, {7}, {7}})); } @@ -43,7 +43,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, inputs_dy op = make_op(rois, deltas, scores, im_info, make_attrs()); input_shapes = ShapeVector{{10, 4}, {10, 40}, {10, 10}, {1, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{5, 4}, {5}, {5}})); } @@ -56,7 +56,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, inputs_st op = make_op(rois, deltas, scores, im_info, make_attrs()); input_shapes = ShapeVector{{10, 4}, {10, 40}, {10, 10}, {1, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{5, 4}, {5}, {5}})); } @@ -69,7 +69,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, im_info_b op = make_op(rois, deltas, scores, im_info, make_attrs()); input_shapes = ShapeVector{{10, 4}, {10, 40}, {10, 10}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Input image info shape must be compatible with [1,3]")); } @@ -82,7 +82,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, deltas_no op = make_op(rois, deltas, scores, im_info, make_attrs()); input_shapes = ShapeVector{{10, 4}, {10, 40, 1}, {10, 10}, {1, 3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Input deltas rank must be equal to 2")); } @@ -96,7 +96,7 @@ TEST_F(ExperimentalDetectronDetectionOutputV6StaticShapeInferenceTest, rois_1st_ input_shapes = ShapeVector{{9, 4}, {10, 40}, {10, 10}, {1, 3}}; OV_EXPECT_THROW( - shape_inference(op.get(), input_shapes, output_shapes), + shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The first dimension of inputs 'input_rois', 'input_deltas', 'input_scores' must be the compatible")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_generate_proposal_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_generate_proposal_shape_inference_test.cpp index 288ca8b5867..60921e07627 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_generate_proposal_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_generate_proposal_shape_inference_test.cpp @@ -29,7 +29,7 @@ TEST_F(ExperimentalDetectronGenerateProposalsSingleImageV6StaticShapeInferenceTe op->set_attrs({0.0f, 0.0f, 100, 0}); input_shapes = ShapeVector{{3}, {12, 4}, {3, 12, 15}, {5, 12, 15}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{100, 4}, {100}})); } @@ -42,7 +42,7 @@ TEST_F(ExperimentalDetectronGenerateProposalsSingleImageV6StaticShapeInferenceTe op = make_op(im_info, anchors, deltas, scores, make_attrs(100)); input_shapes = ShapeVector{{3}, {12, 4}, {3, 12, 15}, {5, 12, 15}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{100, 4}, {100}})); } @@ -55,7 +55,7 @@ TEST_F(ExperimentalDetectronGenerateProposalsSingleImageV6StaticShapeInferenceTe op = make_op(im_info, anchors, deltas, scores, make_attrs(1000)); input_shapes = ShapeVector{{3}, {12, 4}, {3, 120, 15}, {5, 120, 15}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{1000, 4}, {1000}})); } @@ -68,7 +68,7 @@ TEST_F(ExperimentalDetectronGenerateProposalsSingleImageV6StaticShapeInferenceTe op = make_op(im_info, anchors, deltas, scores, make_attrs(40)); input_shapes = ShapeVector{{4}, {12, 4}, {3, 120, 15}, {5, 120, 15}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The 'input_im_info' shape is expected to be a compatible with [3]")); } @@ -81,7 +81,7 @@ TEST_F(ExperimentalDetectronGenerateProposalsSingleImageV6StaticShapeInferenceTe op = make_op(im_info, anchors, deltas, scores, make_attrs(40)); input_shapes = ShapeVector{{3}, {12, 4}, {3, 120, 15, 1}, {5, 120, 15}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The 'input_deltas' input is expected to be a 3D")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_prior_grid_generator_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_prior_grid_generator_shape_inference_test.cpp index cb1a39f1fba..7a4bd8b00cf 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_prior_grid_generator_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_prior_grid_generator_shape_inference_test.cpp @@ -30,7 +30,7 @@ TEST_F(ExperimentalDetectronPriorGridGeneratorV6StaticShapeInferenceTest, defaul op->set_attrs({true, 0, 0, 5.0f, 5.0f}); input_shapes = ShapeVector{{3, 4}, {1, 5, 7, 2}, {1, 5, 50, 50}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes, ShapeVector({{42, 4}})); } @@ -42,7 +42,7 @@ TEST_F(ExperimentalDetectronPriorGridGeneratorV6StaticShapeInferenceTest, inputs op = make_op(priors, feat_map, im_data, make_attrs(false)); input_shapes = ShapeVector{{10, 4}, {1, 2, 4, 5}, {1, 2, 100, 100}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({4, 5, 10, 4})); @@ -55,7 +55,7 @@ TEST_F(ExperimentalDetectronPriorGridGeneratorV6StaticShapeInferenceTest, inputs op = make_op(priors, feat_map, im_data, make_attrs(true)); input_shapes = ShapeVector{{10, 4}, {1, 2, 4, 5}, {1, 2, 100, 100}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({200, 4})); @@ -68,7 +68,7 @@ TEST_F(ExperimentalDetectronPriorGridGeneratorV6StaticShapeInferenceTest, feat_m op = make_op(priors, feat_map, im_data, make_attrs(true)); input_shapes = ShapeVector{{10, 4}, {1, 2, 4, 5, 1}, {1, 2, 100, 100}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Feature_map rank must be equal to 4")); } @@ -80,7 +80,7 @@ TEST_F(ExperimentalDetectronPriorGridGeneratorV6StaticShapeInferenceTest, priors op = make_op(priors, feat_map, im_data, make_attrs(true)); input_shapes = ShapeVector{{10, 5}, {1, 2, 4, 5}, {1, 2, 100, 100}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The last dimension of the 'priors' input must be equal to 4")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_roi_feature_extractor_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_roi_feature_extractor_shape_inference_test.cpp index 51dd87f1b1a..26ecd6c4d47 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_roi_feature_extractor_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_roi_feature_extractor_shape_inference_test.cpp @@ -28,7 +28,7 @@ TEST_F(ExperimentalDetectronROIFeatureExtractorV6StaticShapeInferenceTest, defau op->set_attrs(make_attrs(16)); input_shapes = ShapeVector{{1000, 4}, {1, 5, 8, 8}, {1, 5, 16, 16}, {1, 5, 64, 64}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1000, 5, 16, 16}, StaticShape{1000, 4})); } @@ -40,7 +40,7 @@ TEST_F(ExperimentalDetectronROIFeatureExtractorV6StaticShapeInferenceTest, input op = make_op(OutputVector{rois, layer_0, layer_1}, make_attrs(100)); input_shapes = ShapeVector{{25, 4}, {1, 2, 100, 100}, {1, 2, 20, 300}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_THAT(output_shapes, ElementsAre(StaticShape{25, 2, 100, 100}, StaticShape{25, 4})); } @@ -54,7 +54,7 @@ TEST_F(ExperimentalDetectronROIFeatureExtractorV6StaticShapeInferenceTest, input op = make_op(OutputVector{rois, layer_0, layer_1, layer_2, layer_3}, make_attrs(15)); input_shapes = ShapeVector{{25, 4}, {1, 2, 100, 100}, {1, 2, 20, 300}, {1, 2, 30, 30}, {1, 2, 200, 50}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_THAT(output_shapes, ElementsAre(StaticShape{25, 2, 15, 15}, StaticShape{25, 4})); } @@ -67,7 +67,7 @@ TEST_F(ExperimentalDetectronROIFeatureExtractorV6StaticShapeInferenceTest, rois_ op = make_op(OutputVector{rois, layer_0, layer_1, layer_2}, make_attrs(15)); input_shapes = ShapeVector{{25, 4, 1}, {1, 2, 20, 300}, {1, 2, 30, 30}, {1, 2, 200, 50}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Input rois rank must be equal to 2")); } @@ -80,7 +80,7 @@ TEST_F(ExperimentalDetectronROIFeatureExtractorV6StaticShapeInferenceTest, layer op = make_op(OutputVector{rois, layer_0, layer_1, layer_2}, make_attrs(15)); input_shapes = ShapeVector{{25, 4}, {1, 2, 20, 300}, {1, 2, 30, 30}, {1, 3, 200, 50}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The number of channels must be the same for all layers of the pyramid")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_topkrois_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_topkrois_shape_inference_test.cpp index b2bfc2a3437..f797a2fcc67 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_topkrois_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/experimental_detectron_topkrois_shape_inference_test.cpp @@ -25,7 +25,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, default_ctor) { op->set_max_rois(100); input_shapes = ShapeVector{{12, 4}, {12}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({100, 4})); @@ -37,7 +37,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, inputs_dynamic_r op = make_op(input_rois, rois_probs, 5); input_shapes = ShapeVector{{10, 4}, {10}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 4})); @@ -49,7 +49,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, inputs_static_ra op = make_op(input_rois, rois_probs, 15); input_shapes = ShapeVector{{100, 4}, {100}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({15, 4})); @@ -62,7 +62,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, input_rois_not_2 input_shapes = ShapeVector{{10, 4, 10}, {10}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The 'input_rois' input is expected to be a 2D.")); } @@ -74,7 +74,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, rois_prob_not_1d input_shapes = ShapeVector{{10, 4}, {10, 2}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The 'rois_probs' input is expected to be a 1D.")); } @@ -86,7 +86,7 @@ TEST_F(ExperimentalDetectronTopKROIsV6StaticShapeInferenceTest, input_rois_secon input_shapes = ShapeVector{{10, 5}, {10}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The second dimension of 'input_rois' should be 4.")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/extract_image_patches_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/extract_image_patches_shape_inference_test.cpp index 11d5a24d8bb..b2c3704337c 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/extract_image_patches_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/extract_image_patches_shape_inference_test.cpp @@ -25,7 +25,7 @@ TEST_F(StaticShapeExtractImagePatchesV3Test, default_ctor_no_args) { op->set_auto_pad(pad_type); input_shapes = ShapeVector{{10, 8, 12, 6}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 72, 2, 1})); @@ -36,7 +36,7 @@ TEST_F(StaticShapeExtractImagePatchesV3Test, data_input_is_dynamic_rank) { op = make_op(data, ov::Shape{3, 3}, ov::Strides{5, 5}, ov::Shape{2, 2}, op::PadType::VALID); input_shapes = ShapeVector{{2, 2, 23, 24}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 18, 4, 4})); @@ -47,7 +47,7 @@ TEST_F(StaticShapeExtractImagePatchesV3Test, data_input_is_static_rank) { op = make_op(data, ov::Shape{3, 3}, ov::Strides{5, 5}, ov::Shape{1, 1}, op::PadType::SAME_UPPER); input_shapes = ShapeVector{{2, 2, 43, 34}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 18, 9, 7})); @@ -57,7 +57,7 @@ TEST_F(StaticShapeExtractImagePatchesV3Test, data_shape_not_compatible_rank_4) { const auto data = std::make_shared(element::f32, ov::PartialShape::dynamic(4)); op = make_op(data, ov::Shape{3, 3}, ov::Strides{5, 5}, ov::Shape{1, 1}, op::PadType::SAME_UPPER); - OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 12, 24, 1}}, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 12, 24, 1}}), NodeValidationFailure, HasSubstr("input tensor must be 4D tensor")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/eye_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/eye_shape_inference_test.cpp index d2dcd363403..d848d3c04d1 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/eye_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/eye_shape_inference_test.cpp @@ -2,10 +2,11 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "utils.hpp" @@ -30,7 +31,7 @@ TEST_F(EyeV9StaticShapeInferenceTest, parameters_as_constant) { const auto op = make_op(rows, cols, diag, batch, element::f64); input_shapes = ShapeVector{rows->get_shape(), cols->get_shape(), diag->get_shape(), batch->get_shape()}; - shape_inference(op.get(), input_shapes, output_shapes, {}); + const auto output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 5, 4})); @@ -46,13 +47,12 @@ TEST_F(EyeV9StaticShapeInferenceTest, parameters_in_const_data_map) { int32_t rows = 3, cols = 8; auto batch = std::array{2, 4, 1}; - const auto const_data = - std::map{{0, std::make_shared(element::i32, Shape{}, &rows)}, - {1, std::make_shared(element::i32, Shape{1}, &cols)}, - {3, std::make_shared(element::i32, Shape{3}, batch.data())}}; + const auto const_data = std::unordered_map{{0, {element::i32, Shape{}, &rows}}, + {1, {element::i32, Shape{1}, &cols}}, + {3, {element::i32, Shape{3}, batch.data()}}}; input_shapes = ShapeVector{{}, {1}, {1}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 4, 1, 3, 8})); @@ -69,13 +69,13 @@ TEST_F(EyeV9StaticShapeInferenceTest, assert_on_negative_rows) { int64_t rows = -3, cols = 8; auto batch = std::array{2, 4, 1}; const auto const_data = - std::map{{0, std::make_shared(element::i64, Shape{}, &rows)}, - {1, std::make_shared(element::i64, Shape{1}, &cols)}, - {3, std::make_shared(element::i32, Shape{3}, batch.data())}}; + std::unordered_map{{0, {element::i32, Shape{}, &rows}}, + {1, {element::i32, Shape{1}, &cols}}, + {3, {element::i32, Shape{batch.size()}, batch.data()}}}; input_shapes = ShapeVector{{}, {1}, {1}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), AssertFailure, HasSubstr("Value -3 not in range [0:")); } @@ -91,13 +91,13 @@ TEST_F(EyeV9StaticShapeInferenceTest, assert_on_negative_columns) { int64_t rows = 3, cols = -8; auto batch = std::array{2, 4, 1}; const auto const_data = - std::map{{0, std::make_shared(element::i64, Shape{}, &rows)}, - {1, std::make_shared(element::i64, Shape{1}, &cols)}, - {3, std::make_shared(element::i32, Shape{3}, batch.data())}}; + std::unordered_map{{0, {element::i32, Shape{}, &rows}}, + {1, {element::i32, Shape{1}, &cols}}, + {3, {element::i32, Shape{batch.size()}, batch.data()}}}; input_shapes = ShapeVector{{}, {1}, {1}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), AssertFailure, HasSubstr("Value -8 not in range [0:")); } @@ -113,14 +113,14 @@ TEST_F(EyeV9StaticShapeInferenceTest, assert_on_rows_not_1D) { int64_t cols = 8; auto rows = std::array{2, 1}; auto batch = std::array{2, 4, 1}; - const auto const_data = std::map{ - {0, std::make_shared(element::i64, Shape{rows.size()}, rows.data())}, - {1, std::make_shared(element::i64, Shape{1}, &cols)}, - {3, std::make_shared(element::i32, Shape{batch.size()}, batch.data())}}; + const auto const_data = + std::unordered_map{{0, {element::i32, Shape{rows.size()}, &rows}}, + {1, {element::i32, Shape{1}, &cols}}, + {3, {element::i32, Shape{batch.size()}, batch.data()}}}; input_shapes = ShapeVector{{}, {1}, {1}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), NodeValidationFailure, HasSubstr("'num_rows' value must be a scalar or 1D tensor. Got:")); } @@ -136,14 +136,14 @@ TEST_F(EyeV9StaticShapeInferenceTest, assert_on_columns_not_1D) { int64_t rows = 8; auto cols = std::array{2, 1}; auto batch = std::array{2, 4, 1}; - const auto const_data = std::map{ - {0, std::make_shared(element::i64, Shape{}, &rows)}, - {1, std::make_shared(element::i64, Shape{cols.size()}, cols.data())}, - {3, std::make_shared(element::i32, Shape{batch.size()}, batch.data())}}; + const auto const_data = + std::unordered_map{{0, {element::i32, Shape{}, &rows}}, + {1, {element::i32, Shape{cols.size()}, &cols}}, + {3, {element::i32, Shape{batch.size()}, batch.data()}}}; input_shapes = ShapeVector{{1}, {}, {1}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), NodeValidationFailure, HasSubstr("'num_columns' value must be a scalar or 1D tensor. Got:")); } @@ -158,14 +158,14 @@ TEST_F(EyeV9StaticShapeInferenceTest, assert_on_batch_shape_not_match_shape_in_c int64_t rows = 8, cols = 5; auto batch = std::array{2, 4, 1}; - const auto const_data = std::map{ - {0, std::make_shared(element::i64, Shape{}, &rows)}, - {1, std::make_shared(element::i64, Shape{}, &cols)}, - {3, std::make_shared(element::i32, Shape{batch.size()}, batch.data())}}; + const auto const_data = + std::unordered_map{{0, {element::i32, Shape{}, &rows}}, + {1, {element::i32, Shape{}, &cols}}, + {3, {element::i32, Shape{batch.size()}, batch.data()}}}; input_shapes = ShapeVector{{}, {}, {}, {2}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), NodeValidationFailure, HasSubstr("Check 'static_cast(batch_shape[0].get_length()) == " "static_cast(batch_as_shape->rank().get_length())'")); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/fft_base_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/fft_base_shape_inference_test.cpp index d597461d36d..d333988672d 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/fft_base_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/fft_base_shape_inference_test.cpp @@ -49,108 +49,96 @@ static std::shared_ptr build_idft_signal() { TEST(StaticShapeInferenceTest, DFTTest) { auto DFT = build_dft(); - std::map> constant_data; int32_t axes_val[] = {1, 2}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}}; - shape_inference(DFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(DFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 320, 320, 2})); } TEST(StaticShapeInferenceTest, DFTSignalTest) { auto DFT = build_dft_signal(); - std::map> constant_data; + int32_t axes_val[] = {1, 2}; int32_t signal_val[] = {512, 100}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, Shape{2}, signal_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}, + {2, {element::i32, ov::Shape{2}, signal_val}}}; - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}; - shape_inference(DFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(DFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 512, 100, 2})); } TEST(StaticShapeInferenceTest, DFTConstantTest) { auto DFT = build_dft_constant(); - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}; - shape_inference(DFT.get(), static_input_shapes, static_output_shapes); + const auto static_output_shapes = shape_inference(DFT.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 512, 100, 2})); } TEST(StaticShapeInferenceTest, DFTSignalMissingConstDataTest) { auto DFT = build_dft_signal(); - std::map> constant_data; - int32_t axes_val[] = {1, 2}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(DFT.get(), static_input_shapes, static_output_shapes, constant_data), - NodeValidationFailure); + int32_t axes_val[] = {1, 2}; + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; + + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}; + + EXPECT_THROW(shape_inference(DFT.get(), static_input_shapes, constant_data), NodeValidationFailure); } TEST(StaticShapeInferenceTest, IDFTTest) { auto IDFT = build_idft(); - std::map> constant_data; int32_t axes_val[] = {1, 2}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}}; - shape_inference(IDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(IDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 320, 320, 2})); } TEST(StaticShapeInferenceTest, IDFTSignalTest) { auto IDFT = build_idft_signal(); - std::map> constant_data; + int32_t axes_val[] = {1, 2}; int32_t signal_val[] = {512, 100}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, Shape{2}, signal_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}, + {2, {element::i32, ov::Shape{2}, signal_val}}}; - std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}; - shape_inference(IDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(IDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 512, 100, 2})); } TEST(StaticShapeInferenceTest, IDFTSignalMissingConstDataTest) { auto IDFT = build_idft_signal(); - std::map> constant_data; + int32_t axes_val[] = {1, 2}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; std::vector static_input_shapes = {StaticShape{1, 320, 320, 2}, StaticShape{2}, StaticShape{2}}, static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(IDFT.get(), static_input_shapes, static_output_shapes, constant_data), - NodeValidationFailure); + EXPECT_THROW(shape_inference(IDFT.get(), static_input_shapes, constant_data), NodeValidationFailure); } TEST(StaticShapeInferenceTest, RDFT) { auto input_shape = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto RDFT = std::make_shared(input_shape, axes); - std::map> constant_data; + int32_t axes_val[] = {2, 3}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; - std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}}; - shape_inference(RDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(RDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 120, 64, 33, 2})); } @@ -159,17 +147,15 @@ TEST(StaticShapeInferenceTest, RDFTWithSignalSizes) { auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto signal = std::make_shared(element::i32, PartialShape::dynamic()); auto RDFT = std::make_shared(input_shape, axes, signal); - std::map> constant_data; + int32_t axes_val[] = {2, 3}; int32_t signal_val[] = {40, 30}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, Shape{2}, signal_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}, + {2, {element::i32, ov::Shape{2}, signal_val}}}; - std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}; - shape_inference(RDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(RDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 120, 40, 16, 2})); } @@ -179,10 +165,9 @@ TEST(StaticShapeInferenceTest, RDFTWithConstAxesAndSignalSizes) { auto signal = std::make_shared(element::i32, Shape{2}, std::vector{64, 64}); auto RDFT = std::make_shared(input_shape, axes, signal); - std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}; - shape_inference(RDFT.get(), static_input_shapes, static_output_shapes); + const auto static_output_shapes = shape_inference(RDFT.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 120, 64, 33, 2})); } @@ -191,28 +176,25 @@ TEST(StaticShapeInferenceTest, RDFTMissingSignalTensor) { auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto signal = std::make_shared(element::i32, PartialShape::dynamic()); auto RDFT = std::make_shared(input_shape, axes, signal); - std::map> constant_data; - int32_t axes_val[] = {2, 3}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(RDFT.get(), static_input_shapes, static_output_shapes, constant_data), - NodeValidationFailure); + int32_t axes_val[] = {2, 3}; + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; + + std::vector static_input_shapes = {StaticShape{1, 120, 64, 64}, StaticShape{2}, StaticShape{2}}; + EXPECT_THROW(shape_inference(RDFT.get(), static_input_shapes, constant_data), NodeValidationFailure); } TEST(StaticShapeInferenceTest, IRDFT) { auto input_shape = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1, -1}); auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto IRDFT = std::make_shared(input_shape, axes); - std::map> constant_data; + int32_t axes_val[] = {2, 3}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; - std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}}; - shape_inference(IRDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(IRDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 120, 64, 64})); } @@ -221,17 +203,15 @@ TEST(StaticShapeInferenceTest, IRDFTWithSignalSizes) { auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto signal = std::make_shared(element::i32, PartialShape::dynamic()); auto IRDFT = std::make_shared(input_shape, axes, signal); - std::map> constant_data; + int32_t axes_val[] = {2, 3}; int32_t signal_val[] = {64, 64}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - constant_data[2] = - std::make_shared(ngraph::element::Type_t::i32, Shape{2}, signal_val); + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}, + {2, {element::i32, ov::Shape{2}, signal_val}}}; - std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}, StaticShape{2}}; - shape_inference(IRDFT.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(IRDFT.get(), static_input_shapes, constant_data); ASSERT_EQ(static_output_shapes[0], StaticShape({1, 120, 64, 64})); } @@ -240,12 +220,10 @@ TEST(StaticShapeInferenceTest, IRDFTMissingSignalSizesTensor) { auto axes = std::make_shared(element::i32, PartialShape::dynamic()); auto signal = std::make_shared(element::i32, PartialShape::dynamic()); auto IRDFT = std::make_shared(input_shape, axes, signal); - std::map> constant_data; - int32_t axes_val[] = {2, 3}; - constant_data[1] = std::make_shared(ngraph::element::Type_t::i32, Shape{2}, axes_val); - std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - EXPECT_THROW(shape_inference(IRDFT.get(), static_input_shapes, static_output_shapes, constant_data), - NodeValidationFailure); + int32_t axes_val[] = {2, 3}; + auto constant_data = std::unordered_map{{1, {element::i32, ov::Shape{2}, axes_val}}}; + + std::vector static_input_shapes = {StaticShape{1, 120, 64, 33, 2}, StaticShape{2}, StaticShape{2}}; + EXPECT_THROW(shape_inference(IRDFT.get(), static_input_shapes, constant_data), NodeValidationFailure); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_elements_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_elements_shape_inference_test.cpp index 8d5f6ce0eef..c1fc73c1bea 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_elements_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_elements_shape_inference_test.cpp @@ -23,7 +23,7 @@ TEST_F(GatherElementsStaticShapeInferenceTest, GatherElements_basic) { input_shapes = {StaticShape{300, 3, 10, 2}, StaticShape{300, 3, 10, 33333}}; output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{300, 3, 10, 33333})); } @@ -35,7 +35,7 @@ TEST_F(GatherElementsStaticShapeInferenceTest, GatherElements_incompatible_rank) op = make_op(data, indices, axis); input_shapes = {StaticShape{1, 2, 3, 4, 5}, StaticShape{1, 2, 3, 4}}; output_shapes = {StaticShape{}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), ov::NodeValidationFailure, HasSubstr("rank must be equal")); } @@ -48,7 +48,7 @@ TEST_F(GatherElementsStaticShapeInferenceTest, GatherElements_incompatible_dims) op = make_op(data, indices, axis); input_shapes = {StaticShape{300, 4, 10, 2}, StaticShape{300, 5, 10, 33333}}; output_shapes = {StaticShape{}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), ov::NodeValidationFailure, HasSubstr("are not consistent")); } @@ -60,6 +60,6 @@ TEST_F(GatherElementsStaticShapeInferenceTest, GatherElements_default_constructo input_shapes = {StaticShape{300, 3, 10, 2}, StaticShape{300, 3, 10, 33333}}; output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{300, 3, 10, 33333})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_nd_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_nd_shape_inference_test.cpp index f3cf457802b..0f017e18de2 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_nd_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_nd_shape_inference_test.cpp @@ -34,8 +34,7 @@ template void run_gather_nd_test(const GatherNDTestParams& test_params) { auto op = make_gather_nd(test_params.batch_dims); - ShapeVector output_shapes(1); - shape_inference(op.get(), test_params.input_shapes, output_shapes); + auto output_shapes = shape_inference(op.get(), test_params.input_shapes); EXPECT_EQ(output_shapes[0], test_params.exp_shape) << "Failed for input shapes: " << ov::util::vector_to_string(test_params.input_shapes) @@ -105,7 +104,7 @@ TYPED_TEST_P(StaticShapeInferenceGatherNDTest, gather_nd_common_default_ctor) { ShapeVector input_shapes{{8, 3, 11, 12}, {8, 5, 2}}; ShapeVector output_shapes(1); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{8, 5, 12})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_shape_inference_test.cpp index 40eb4bf2d3d..9c866155950 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_shape_inference_test.cpp @@ -4,12 +4,11 @@ #include -#include -#include -#include -#include -#include - +#include "openvino/op/constant.hpp" +#include "openvino/op/gather.hpp" +#include "openvino/op/parameter.hpp" +#include "openvino/util/common_util.hpp" +#include "shape_inference/shape_inference.hpp" #include "utils.hpp" using namespace ov; @@ -61,7 +60,7 @@ TYPED_TEST_P(StaticShapeInferenceGatherTest, axis_const) { auto op = this->make_gather(this->input_shapes, &this->axis_val); - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), this->exp_shape) << "Failed for axis: " << this->axis_val @@ -74,9 +73,9 @@ TYPED_TEST_P(StaticShapeInferenceGatherTest, axis_in_const_map) { std::tie(this->axis_val, this->input_shapes, this->exp_shape) = params; auto op = this->make_gather(this->input_shapes); - auto axis_tensor = std::make_shared(element::i32, Shape{1}, &this->axis_val); + auto axis_tensor = ov::Tensor(element::i32, Shape{1}, &this->axis_val); - shape_inference(op.get(), this->input_shapes, this->output_shapes, {{2, axis_tensor}}); + this->output_shapes = shape_inference(op.get(), this->input_shapes, {{2, axis_tensor}}); ASSERT_EQ(this->output_shapes.front(), this->exp_shape) << "Failed for axis: " << this->axis_val diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_tree_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_tree_shape_inference_test.cpp index e6ef234693b..d460ffa1217 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_tree_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gather_tree_shape_inference_test.cpp @@ -23,7 +23,7 @@ TEST_F(GatherTreeStaticShapeInferenceTest, gather_tree) { input_shapes = {StaticShape{1, 2, 3}, StaticShape{1, 2, 3}, StaticShape{2}, StaticShape{}}; output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{1, 2, 3})); } @@ -31,6 +31,6 @@ TEST_F(GatherTreeStaticShapeInferenceTest, gather_tree_default_ctor) { op = make_op(); input_shapes = {StaticShape{2, 4, 3}, StaticShape{2, 4, 3}, StaticShape{4}, StaticShape{}}; output_shapes = {StaticShape{}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{2, 4, 3})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/grid_sample_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/grid_sample_shape_inference_test.cpp index b673b069651..66a28bd1cb3 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/grid_sample_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/grid_sample_shape_inference_test.cpp @@ -23,7 +23,7 @@ TEST_F(GridSampleStaticShapeInferenceTest, GridSample) { output_shapes = {StaticShape{}}; exp_shape = StaticShape{2, 3, 6, 7}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], exp_shape); } @@ -34,6 +34,6 @@ TEST_F(GridSampleStaticShapeInferenceTest, GridSample_default_constructor) { output_shapes = {StaticShape{}}; exp_shape = StaticShape{2, 3, 6, 7}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_backprop_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_backprop_shape_inference_test.cpp index 06a32822842..a11ae5e3881 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_backprop_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_backprop_shape_inference_test.cpp @@ -53,8 +53,7 @@ TEST_F(GroupConvolutionBackpropDataStaticShapeInferenceTest, default_ctor) { op->set_auto_pad(op::PadType::EXPLICIT); int32_t spatial_shape[] = {5, 10, 15}; - const auto const_data = - std::map{{2, std::make_shared(element::i32, Shape{3}, spatial_shape)}}; + const auto const_data = std::unordered_map{{2, {element::i32, Shape{3}, spatial_shape}}}; input_shapes = ShapeVector{{1, 6, 10, 12, 2}, {3, 2, 2, 5, 5, 5}, {3}}; auto shape_infer = make_shape_inference(op); @@ -77,8 +76,7 @@ TEST_F(GroupConvolutionBackpropDataStaticShapeInferenceTest, default_ctor_more_i op->set_auto_pad(op::PadType::EXPLICIT); int32_t spatial_shape[] = {5, 10, 15}; - const auto const_data = - std::map{{2, std::make_shared(element::i32, Shape{3}, spatial_shape)}}; + const auto const_data = std::unordered_map{{2, {element::i32, Shape{3}, spatial_shape}}}; // More than three inputs can be provided, but not used input_shapes = ShapeVector{{1, 6, 10, 12, 2}, {3, 2, 2, 5, 5, 5}, {3}, {0}}; @@ -105,7 +103,7 @@ TEST_F(GroupConvolutionBackpropDataStaticShapeInferenceTest, 2d_inputs_dynamic_r op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{1, 2, 5, 5}, {2, 1, 2, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 4, 7, 7})); @@ -125,7 +123,7 @@ TEST_F(GroupConvolutionBackpropDataStaticShapeInferenceTest, 3d_auto_pad_same_lo op = make_op(data, filters, out_spatial, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5, 5}, {1, 6, 6, 3, 3, 3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 6, 2, 1, 3})); @@ -144,11 +142,10 @@ TEST_F(GroupConvolutionBackpropDataStaticShapeInferenceTest, 3d_auto_pad_same_up op = make_op(data, filters, out_spatial, strides, pads_begin, pads_end, dilations, auto_pad); int32_t spatial_dims[] = {2, 6, 1}; - const auto const_data = - std::map{{2, std::make_shared(element::i32, Shape{3}, spatial_dims)}}; + const auto const_data = std::unordered_map{{2, {element::i32, Shape{3}, spatial_dims}}}; input_shapes = ShapeVector{{3, 5, 5, 5, 5}, {1, 5, 1, 3, 3, 3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 1, 2, 6, 1})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_shape_inference_test.cpp index c0dda6e598a..9b104e9aa7a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/group_convolution_shape_inference_test.cpp @@ -90,7 +90,7 @@ TEST_F(GroupConvolutionV1StaticShapeInferenceTest, 1d_explicit_pads_inputs_stati op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{1, 12, 20}, {12, 1, 1, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 12, 18})); @@ -109,7 +109,7 @@ TEST_F(GroupConvolutionV1StaticShapeInferenceTest, 2d_auto_pads_same_lower_input op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{1, 4, 5, 5}, {2, 1, 2, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1, 2, 5, 5})); @@ -128,7 +128,7 @@ TEST_F(GroupConvolutionV1StaticShapeInferenceTest, 3d_auto_pad_same_lower_inputs op = make_op(data, filters, strides, pads_begin, pads_end, dilations, auto_pad); input_shapes = ShapeVector{{3, 6, 5, 5, 5}, {1, 6, 6, 3, 3, 3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({3, 6, 5, 5, 5})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_cell_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_cell_shape_inference_test.cpp index 229178fb0f1..1910cdeb948 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_cell_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_cell_shape_inference_test.cpp @@ -30,7 +30,7 @@ TEST_F(GRUCellV3StaticShapeInferenceTest, default_ctor) { StaticShape{gates_count * hidden_size, hidden_size}, // R StaticShape{gates_count * hidden_size}}; // B - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -54,7 +54,7 @@ TEST_F(GRUCellV3StaticShapeInferenceTest, default_bias) { StaticShape{gates_count * hidden_size, hidden_size}, // R StaticShape{gates_count * hidden_size}}; // B - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -79,7 +79,7 @@ TEST_F(GRUCellV3StaticShapeInferenceTest, with_bias) { output_shapes = {StaticShape{}, StaticShape{}}; - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -115,7 +115,7 @@ TEST_F(GRUCellV3StaticShapeInferenceTest, linear_before) { output_shapes = {StaticShape{}, StaticShape{}}; - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -139,6 +139,6 @@ TEST_F(GRUCellV3StaticShapeInferenceTest, dynamic_rank_inputs) { StaticShape{gates_count * hidden_size, hidden_size}, // R StaticShape{gates_count * hidden_size}}; // B - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_sequence_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_sequence_shape_inference_test.cpp index c42f1c8c659..3be0fe38665 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_sequence_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/gru_sequence_shape_inference_test.cpp @@ -33,7 +33,7 @@ TEST_F(GRUSequenceV5StaticShapeInferenceTest, default_ctor) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(gru_sequence.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru_sequence.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -65,7 +65,7 @@ TEST_F(GRUSequenceV5StaticShapeInferenceTest, FORWARD) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(gru_sequence.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru_sequence.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -108,7 +108,7 @@ TEST_F(GRUSequenceV5StaticShapeInferenceTest, FORWARD_linear_before) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, (gates_count + 1) * hidden_size}}; // B - shape_inference(gru_sequence.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru_sequence.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -140,7 +140,7 @@ TEST_F(GRUSequenceV5StaticShapeInferenceTest, REVERSE) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(gru_sequence.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru_sequence.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -172,7 +172,7 @@ TEST_F(GRUSequenceV5StaticShapeInferenceTest, BIDIRECTIONAL) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(gru_sequence.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru_sequence.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/interpolate_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/interpolate_shape_inference_test.cpp index c25b9245638..68fe1766daf 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/interpolate_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/interpolate_shape_inference_test.cpp @@ -30,11 +30,10 @@ TEST_F(InterpolateV0StaticShapeInferenceTest, default_ctor_no_attributes) { op->set_attrs(attrs); int32_t out_shape_v[] = {10, 20, 30}; - const auto const_data = - std::map{{1, std::make_shared(element::i32, Shape{3}, out_shape_v)}}; + const auto const_data = std::unordered_map{{1, {element::i32, Shape{3}, out_shape_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 2, 20, 128, 128, 30})); @@ -48,7 +47,7 @@ TEST_F(InterpolateV0StaticShapeInferenceTest, out_shape_as_constant) { op = make_op(img, out_shape, attrs); input_shapes = ShapeVector{{5, 2, 128, 128, 128}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 100, 128, 100, 128})); @@ -62,11 +61,10 @@ TEST_F(InterpolateV0StaticShapeInferenceTest, all_inputs_dynamic_rank_use_scales op = make_op(img, out_shape, attrs); int32_t out_shape_v[] = {10, 20, 30}; - const auto const_data = - std::map{{1, std::make_shared(element::i32, Shape{3}, out_shape_v)}}; + const auto const_data = std::unordered_map{{1, {element::i32, Shape{3}, out_shape_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 2, 10, 128, 20, 30})); @@ -80,11 +78,10 @@ TEST_F(InterpolateV0StaticShapeInferenceTest, all_inputs_static_rank_use_sizes) op = make_op(img, out_shape, attrs); int32_t out_shape_v[] = {10, 20, 30}; - const auto const_data = - std::map{{1, std::make_shared(element::i32, Shape{3}, out_shape_v)}}; + const auto const_data = std::unordered_map{{1, {element::i32, Shape{3}, out_shape_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 20, 30, 128, 128, 64})); @@ -111,12 +108,11 @@ TEST_F(InterpolateV4StaticShapeInferenceTest, default_ctor_no_attributes) { float scales_v[] = {1.5f, 3.0f, 0.2f}; int32_t axes_v[] = {2, 0, 5}; - const auto const_data = - std::map{{2, std::make_shared(element::f32, Shape{3}, scales_v)}, - {3, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{2, {element::f32, Shape{3}, scales_v}}, + {3, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({15, 2, 192, 128, 128, 12})); @@ -132,7 +128,7 @@ TEST_F(InterpolateV4StaticShapeInferenceTest, scales_as_constant) { op = make_op(img, sizes, scales, axes, attrs); input_shapes = ShapeVector{{5, 2, 128, 128, 128}, {1}, {2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 4, 128, 89, 128})); @@ -146,7 +142,7 @@ TEST_F(InterpolateV4StaticShapeInferenceTest, sizes_as_constant) { op = make_op(img, sizes, scales, axes, attrs); input_shapes = ShapeVector{{5, 2, 128, 128, 128}, {2}, {1}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 5, 128, 10, 128})); @@ -164,12 +160,11 @@ TEST_F(InterpolateV4StaticShapeInferenceTest, all_inputs_dynamic_rank_use_scales float scales_v[] = {1.5f, 3.0f, 0.2f}; int32_t axes_v[] = {2, 0, 5}; - const auto const_data = - std::map{{2, std::make_shared(element::f32, Shape{3}, scales_v)}, - {3, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{2, {element::f32, Shape{3}, scales_v}}, + {3, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({18, 3, 193, 129, 129, 12})); @@ -186,12 +181,11 @@ TEST_F(InterpolateV4StaticShapeInferenceTest, all_inputs_static_rank_use_sizes) int32_t sizes_v[] = {10, 50, 60}; int32_t axes_v[] = {1, 0, 3}; - const auto const_data = - std::map{{1, std::make_shared(element::i32, Shape{3}, sizes_v)}, - {3, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{1, {element::i32, Shape{3}, sizes_v}}, + {3, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({50, 10, 128, 60, 128, 64})); @@ -218,12 +212,11 @@ TEST_F(InterpolateV11StaticShapeInferenceTest, default_ctor_no_attributes) { float scales_v[] = {1.5f, 3.0f, 0.2f}; int32_t axes_v[] = {2, 0, 5}; - const auto const_data = - std::map{{1, std::make_shared(element::f32, Shape{3}, scales_v)}, - {2, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{1, {element::f32, Shape{3}, scales_v}}, + {2, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({15, 2, 192, 128, 128, 12})); @@ -238,7 +231,7 @@ TEST_F(InterpolateV11StaticShapeInferenceTest, scales_as_constant) { op = make_op(img, scales, axes, attrs); input_shapes = ShapeVector{{5, 2, 128, 128, 128}, {2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 4, 128, 89, 128})); @@ -251,7 +244,7 @@ TEST_F(InterpolateV11StaticShapeInferenceTest, sizes_as_constant) { op = make_op(img, sizes, axes, attrs); input_shapes = ShapeVector{{5, 2, 128, 128, 128}, {2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({5, 5, 128, 10, 128})); @@ -267,12 +260,11 @@ TEST_F(InterpolateV11StaticShapeInferenceTest, all_inputs_dynamic_rank_use_scale float scales_v[] = {1.5f, 3.0f, 0.2f}; int32_t axes_v[] = {2, 0, 5}; - const auto const_data = - std::map{{1, std::make_shared(element::f32, Shape{3}, scales_v)}, - {2, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{1, {element::f32, Shape{3}, scales_v}}, + {2, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({15, 2, 192, 128, 128, 12})); @@ -288,12 +280,11 @@ TEST_F(InterpolateV11StaticShapeInferenceTest, all_inputs_static_rank_use_sizes) int32_t sizes_v[] = {10, 50, 60}; int32_t axes_v[] = {1, 0, 3}; - const auto const_data = - std::map{{1, std::make_shared(element::i32, Shape{3}, sizes_v)}, - {2, std::make_shared(element::i32, Shape{3}, axes_v)}}; + const auto const_data = std::unordered_map{{1, {element::i32, Shape{3}, sizes_v}}, + {2, {element::i32, Shape{3}, axes_v}}}; input_shapes = ShapeVector{{5, 2, 128, 128, 128, 64}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({50, 10, 128, 60, 128, 64})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/logical_not_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/logical_not_shape_inference_test.cpp index f51a6a8cc7f..2e7945731b7 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/logical_not_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/logical_not_shape_inference_test.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/op/logical_not.hpp" #include "openvino/op/parameter.hpp" #include "utils.hpp" @@ -25,7 +26,7 @@ TEST_F(LogicalNotStaticShapeInferenceTest, static_rank) { this->input_shapes = {StaticShape{3, 4, 7, 5}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 4, 7, 5})); } @@ -36,7 +37,7 @@ TEST_F(LogicalNotStaticShapeInferenceTest, dynamic_rank) { this->input_shapes = {StaticShape{3, 1, 5, 2}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); ASSERT_EQ(this->output_shapes.front(), StaticShape({3, 1, 5, 2})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_cell_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_cell_shape_inference_test.cpp index 23d7d31515a..9042a26859f 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_cell_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_cell_shape_inference_test.cpp @@ -30,7 +30,7 @@ TEST_F(LSTMCellV4StaticShapeInferenceTest, default_ctor) { StaticShape{gates_count * hidden_size, input_size}, StaticShape{gates_count * hidden_size, hidden_size}, StaticShape{gates_count * hidden_size}}, - shape_inference(lstm_cell.get(), input_shapes, output_shapes); + output_shapes = shape_inference(lstm_cell.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, hidden_size})); } @@ -55,7 +55,7 @@ TEST_F(LSTMCellV4StaticShapeInferenceTest, basic_shape_infer) { StaticShape{gates_count * hidden_size, input_size}, StaticShape{gates_count * hidden_size, hidden_size}, StaticShape{gates_count * hidden_size}}, - shape_inference(lstm_cell.get(), input_shapes, output_shapes); + output_shapes = shape_inference(lstm_cell.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, hidden_size})); } @@ -81,9 +81,8 @@ TEST(StaticShapeInferenceTest, LSTMCellV0Test) { StaticShape{gates_count * hidden_size, input_size}, StaticShape{gates_count * hidden_size, hidden_size}, StaticShape{gates_count * hidden_size}, - StaticShape{3 * hidden_size}}, - static_output_shapes = {StaticShape{}, StaticShape{}}; - shape_inference(lstm_cell.get(), static_input_shapes, static_output_shapes); + StaticShape{3 * hidden_size}}; + const auto static_output_shapes = shape_inference(lstm_cell.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({batch_size, hidden_size})); ASSERT_EQ(static_output_shapes[1], StaticShape({batch_size, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_seq_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_seq_shape_inference_test.cpp index bf6ef9e3676..8b4692d843f 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_seq_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/lstm_seq_shape_inference_test.cpp @@ -35,7 +35,7 @@ TEST_F(LSTMSequenceV0StaticShapeInferenceTest, default_ctor) { StaticShape{num_directions, gates_count * hidden_size}, // B StaticShape{num_directions, (gates_count - 1) * hidden_size}}; // P - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); @@ -71,7 +71,7 @@ TEST_F(LSTMSequenceV0StaticShapeInferenceTest, FORWARD_without_P) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); @@ -109,7 +109,7 @@ TEST_F(LSTMSequenceV0StaticShapeInferenceTest, FORWARD_with_P) { StaticShape{num_directions, gates_count * hidden_size}, // B StaticShape{num_directions, (gates_count - 1) * hidden_size}}; // P - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); @@ -145,7 +145,7 @@ TEST_F(LSTMSequenceV0StaticShapeInferenceTest, REVERSE) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); @@ -180,7 +180,7 @@ TEST_F(LSTMSequenceV0StaticShapeInferenceTest, BIDIRECTIONAL) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); @@ -212,7 +212,7 @@ TEST_F(LSTMSequenceV5StaticShapeInferenceTest, default_ctor) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); @@ -248,7 +248,7 @@ TEST_F(LSTMSequenceV5StaticShapeInferenceTest, FORWARD) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); @@ -284,7 +284,7 @@ TEST_F(LSTMSequenceV5StaticShapeInferenceTest, REVERSE) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); @@ -319,7 +319,7 @@ TEST_F(LSTMSequenceV5StaticShapeInferenceTest, BIDIRECTIONAL) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 3); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/make_shape_inference.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/make_shape_inference.cpp index c6f9e315b63..65840a85967 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/make_shape_inference.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/make_shape_inference.cpp @@ -3,36 +3,38 @@ // #include -#include -#include -#include -#include -#include -#include "ngraph_functions/builders.hpp" -#include #include -#include +#include + +#include "openvino/core/coordinate_diff.hpp" +#include "openvino/op/ops.hpp" +#include "openvino/op/parameter.hpp" +#include "ov_ops/type_relaxed.hpp" +#include "shape_inference/shape_inference.hpp" using namespace ov; using namespace ov::intel_cpu; +using ov::op::v0::MatMul; +using ov::op::v0::Parameter; +using ov::op::v0::Result; TEST(StaticShapeInferenceTest, MakeShapeInference) { - auto inp1_f32 = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); - auto inp2_f32 = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); + auto inp1_f32 = std::make_shared(element::f32, PartialShape::dynamic(4)); + auto inp2_f32 = std::make_shared(element::f32, PartialShape::dynamic(4)); - auto inp1 = std::make_shared(element::i8, PartialShape{-1, -1, -1, -1}); - auto inp2 = std::make_shared(element::i8, PartialShape{-1, -1, -1, -1}); + auto inp1 = std::make_shared(element::i8, PartialShape::dynamic(4)); + auto inp2 = std::make_shared(element::i8, PartialShape::dynamic(4)); - auto matMulRelaxed = std::make_shared>( - *as_type_ptr(ngraph::builder::makeMatMul(inp1_f32, inp2_f32, false, false)), - element::f32); + auto matMulRelaxed = std::make_shared>( + *as_type_ptr(std::make_shared(inp1_f32, inp2_f32, false, false)), + element::f32); auto matMul = matMulRelaxed->clone_with_new_inputs({inp1, inp2}); - ngraph::ResultVector results; - results.push_back(std::make_shared(matMul->output(0))); + ov::ResultVector results; + results.push_back(std::make_shared(matMul->output(0))); - auto function = std::make_shared(results, ngraph::ParameterVector{inp1, inp2}, "testFunction"); + auto model = std::make_shared(results, ov::ParameterVector{inp1, inp2}, "testFunction"); std::atomic_flag wrongPrcFlag; wrongPrcFlag.clear(); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/matmul_shape_inference.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/matmul_shape_inference.cpp index 99ca54e4d11..c3b73d3e973 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/matmul_shape_inference.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/matmul_shape_inference.cpp @@ -81,7 +81,7 @@ TEST_P(MatMulTest, no_input_transpose) { std::vector static_input_shapes = {a_shape, b_shape}, static_output_shapes = {StaticShape{}}; - shape_inference(matmul.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(matmul.get(), static_input_shapes); ASSERT_EQ(static_output_shapes.front(), exp_shape); } @@ -91,7 +91,7 @@ TEST_P(MatMulTest, transpose_input_a) { const auto a_transpose = make_transpose_input(a_shape); std::vector static_input_shapes = {a_transpose, b_shape}, static_output_shapes = {StaticShape{}}; - shape_inference(matmul.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(matmul.get(), static_input_shapes); ASSERT_EQ(static_output_shapes.front(), exp_shape); } @@ -101,7 +101,7 @@ TEST_P(MatMulTest, transpose_input_b) { const auto b_transpose = make_transpose_input(b_shape); std::vector static_input_shapes = {a_shape, b_transpose}, static_output_shapes = {StaticShape{}}; - shape_inference(matmul.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(matmul.get(), static_input_shapes); ASSERT_EQ(static_output_shapes.front(), exp_shape); } @@ -113,6 +113,6 @@ TEST_P(MatMulTest, transpose_inputs_a_b) { std::vector static_input_shapes = {a_transpose, b_transpose}, static_output_shapes = {StaticShape{}}; - shape_inference(matmul.get(), static_input_shapes, static_output_shapes); + static_output_shapes = shape_inference(matmul.get(), static_input_shapes); ASSERT_EQ(static_output_shapes.front(), exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/one_hot_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/one_hot_shape_inference_test.cpp index 1c8ab310b5b..487fd0890dc 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/one_hot_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/one_hot_shape_inference_test.cpp @@ -20,9 +20,8 @@ TEST(StaticShapeInferenceTest, OneHotTestConstantInput) { int64_t axis = -1; auto ont_hot = std::make_shared(indices, depth, on_value, off_value, axis); // Test StaticShape - std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}, - static_output_shapes = {StaticShape{}}; - shape_inference(ont_hot.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}; + const auto static_output_shapes = shape_inference(ont_hot.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], (StaticShape{3, 2})); } @@ -38,17 +37,12 @@ TEST(StaticShapeInferenceTest, OneHotTestConstantMap) { int32_t on_value[] = {1}; int32_t off_value[] = {0}; - std::map> constant_data; - constant_data[1] = - std::make_shared(element::Type_t::i64, Shape{}, depth_value); - constant_data[2] = - std::make_shared(element::Type_t::i32, Shape{}, on_value); - constant_data[3] = - std::make_shared(element::Type_t::i32, Shape{}, off_value); + const auto constant_data = std::unordered_map{{1, {element::i64, ov::Shape{}, depth_value}}, + {2, {element::i32, ov::Shape{}, on_value}}, + {1, {element::i32, ov::Shape{}, off_value}}}; - std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}, - static_output_shapes = {StaticShape{}}; - shape_inference(ont_hot.get(), static_input_shapes, static_output_shapes, constant_data); + std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}; + const auto static_output_shapes = shape_inference(ont_hot.get(), static_input_shapes, constant_data); EXPECT_EQ(static_output_shapes[0], (StaticShape{3, 2})); } @@ -60,18 +54,13 @@ TEST(StaticShapeInferenceTest, OneHotTestConstantMapDefaultCtor) { int32_t on_value[] = {1}; int32_t off_value[] = {0}; - std::map> constant_data; - constant_data[1] = - std::make_shared(element::Type_t::i64, Shape{}, depth_value); - constant_data[2] = - std::make_shared(element::Type_t::i32, Shape{}, on_value); - constant_data[3] = - std::make_shared(element::Type_t::i32, Shape{}, off_value); + const auto constant_data = std::unordered_map{{1, {element::i64, ov::Shape{}, depth_value}}, + {2, {element::i32, ov::Shape{}, on_value}}, + {1, {element::i32, ov::Shape{}, off_value}}}; - std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}; - shape_inference(ont_hot.get(), static_input_shapes, static_output_shapes, constant_data); + const auto static_output_shapes = shape_inference(ont_hot.get(), static_input_shapes, constant_data); EXPECT_EQ(static_output_shapes[0], (StaticShape{3, 2})); } @@ -88,18 +77,13 @@ TEST(StaticShapeInferenceTest, OneHotTestConstantMapNegativeDepth) { int32_t on_value[] = {1}; int32_t off_value[] = {0}; - std::map> constant_data; - constant_data[1] = - std::make_shared(element::Type_t::i64, Shape{}, depth_value); - constant_data[2] = - std::make_shared(element::Type_t::i32, Shape{}, on_value); - constant_data[3] = - std::make_shared(element::Type_t::i32, Shape{}, off_value); + const auto constant_data = std::unordered_map{{1, {element::i64, ov::Shape{}, depth_value}}, + {2, {element::i32, ov::Shape{}, on_value}}, + {1, {element::i32, ov::Shape{}, off_value}}}; - std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}, - static_output_shapes = {StaticShape{}}; + std::vector static_input_shapes = {StaticShape{3}, StaticShape{}, StaticShape{}, StaticShape{}}; - OV_EXPECT_THROW(shape_inference(ont_hot.get(), static_input_shapes, static_output_shapes, constant_data), + OV_EXPECT_THROW(shape_inference(ont_hot.get(), static_input_shapes, constant_data), ov::NodeValidationFailure, HasSubstr("can't be negative")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/pad_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/pad_shape_inference_test.cpp index 223ab734db8..8887cc5f49c 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/pad_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/pad_shape_inference_test.cpp @@ -30,12 +30,11 @@ TYPED_TEST_P(PadStaticShapeInference, default_ctor) { int64_t pads_begin[] = {3, 2, 1, 1}; int32_t pads_end[] = {0, 1, 2, 3}; - const auto const_data = - std::map{{1, std::make_shared(element::i64, Shape{4}, pads_begin)}, - {2, std::make_shared(element::i32, Shape{4}, pads_end)}}; + const auto const_data = std::unordered_map{{1, {element::i64, Shape{4}, pads_begin}}, + {2, {element::i32, Shape{4}, pads_end}}}; this->input_shapes = ShapeVector{{3, 6, 5, 5}, {4}, {4}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data); + this->output_shapes = shape_inference(op.get(), this->input_shapes, const_data); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({6, 9, 8, 9})); @@ -51,7 +50,7 @@ TYPED_TEST_P(PadStaticShapeInference, pads_begin_end_value_as_constants) { const auto op = this->make_op(data, pads_begin, pads_end, pad_val, op::PadMode::CONSTANT); this->input_shapes = ShapeVector{{3, 6, 5, 5}, {4}, {4}, {}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({6, 9, 8, 8})); @@ -65,14 +64,13 @@ TYPED_TEST_P(PadStaticShapeInference, pads_begin_end_in_constant_map) { uint64_t pads_begin_data[] = {0, 2, 2, 0}; uint32_t pads_end_data[] = {0, 1, 2, 0}; - const auto const_data = - std::map{{1, std::make_shared(element::u64, Shape{4}, pads_begin_data)}, - {2, std::make_shared(element::u32, Shape{4}, pads_end_data)}}; + const auto const_data = std::unordered_map{{1, {element::u64, Shape{4}, pads_begin_data}}, + {2, {element::u32, Shape{4}, pads_end_data}}}; const auto op = this->make_op(data, pads_begin, pads_end, op::PadMode::REFLECT); this->input_shapes = ShapeVector{{3, 6, 5, 1}, {4}, {4}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data); + this->output_shapes = shape_inference(op.get(), this->input_shapes, const_data); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, 9, 9, 1})); } @@ -84,13 +82,12 @@ TYPED_TEST_P(PadStaticShapeInference, pads_begin_got_negative_value) { int8_t pads_begin_data[] = {0, -2, -2, 0}; - const auto const_data = - std::map{{1, std::make_shared(element::i8, Shape{4}, pads_begin_data)}}; + const auto const_data = std::unordered_map{{1, {element::i8, Shape{4}, pads_begin_data}}}; const auto op = this->make_op(data, pads_begin, pads_end, op::PadMode::REFLECT); this->input_shapes = ShapeVector{{3, SIZE_MAX, 5, 2}, {4}, {4}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data); + this->output_shapes = shape_inference(op.get(), this->input_shapes, const_data); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, SIZE_MAX, 3, 2})); } @@ -103,12 +100,11 @@ TYPED_TEST_P(PadStaticShapeInference, pads_end_got_negative_value) { int8_t pads_end_data[] = {0, -3, -2, 0}; - const auto const_data = - std::map{{2, std::make_shared(element::i8, Shape{4}, pads_end_data)}}; + const auto const_data = std::unordered_map{{2, {element::i8, Shape{4}, pads_end_data}}}; this->input_shapes = ShapeVector{{3, 6, 5, SIZE_MAX}, {4}, {4}}; - shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data); + this->output_shapes = shape_inference(op.get(), this->input_shapes, const_data); EXPECT_EQ(this->output_shapes.front(), StaticShape({4, 4, 5, SIZE_MAX})); } @@ -119,11 +115,11 @@ TYPED_TEST_P(PadStaticShapeInference, pads_begin_is_empty) { const auto pads_end = Constant::create(element::i64, Shape{4}, {0, 0, 0, 0}); const auto op = this->make_op(data, pads_begin, pads_end, op::PadMode::REFLECT); - const auto const_data = std::map{{1, std::make_shared(element::u64, Shape{0})}}; + const auto const_data = std::unordered_map{{1, {element::u64, Shape{0}}}}; this->input_shapes = ShapeVector{{3, 6, 5, 2}, {0}, {4}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, const_data), NodeValidationFailure, HasSubstr("length of pads_begin mismatches with rank of input")); } @@ -134,11 +130,11 @@ TYPED_TEST_P(PadStaticShapeInference, pads_end_is_empty) { const auto pads_end = std::make_shared(element::i8, PartialShape::dynamic()); const auto op = this->make_op(data, pads_begin, pads_end, op::PadMode::REFLECT); - const auto const_data = std::map{{2, std::make_shared(element::i8, Shape{0})}}; + const auto const_data = std::unordered_map{{2, {element::i8, Shape{0}}}}; this->input_shapes = ShapeVector{{3, 6, 5, 2}, {4}, {0}}; - OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, this->output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), this->input_shapes, const_data), NodeValidationFailure, HasSubstr("length of pads_end mismatches with rank of input")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_clustered_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_clustered_shape_inference_test.cpp index a099d4ca5f8..a7da58358ee 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_clustered_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_clustered_shape_inference_test.cpp @@ -31,10 +31,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, default_ctor_no_args) { int32_t out_size[] = {2, 5}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, out_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, out_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 80})); @@ -49,10 +46,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, all_inputs_dynamic_rank) { int32_t output_size[] = {2, 5}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, output_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, output_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 4 * 2 * 5 * 2})); @@ -67,10 +61,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, all_inputs_static_rank) { int32_t output_size[] = {5, 2}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, output_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, output_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 4 * 5 * 2 * 2})); @@ -83,7 +74,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, out_size_constant) { op = make_op(out_size, img_size, attrs); input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 4 * 4 * 6 * 2})); @@ -96,7 +87,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, all_inputs_constants) { op = make_op(out_size, img_size, attrs); input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 4 * 12 * 16 * 2})); @@ -111,10 +102,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, invalid_number_of_elements_i int64_t output_size[] = {5, 2, 1}; input_shapes = ShapeVector{{2}, {2}}; - OV_EXPECT_THROW(shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i64, ov::Shape{3}, output_size)}}), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, {{0, {element::i64, ov::Shape{3}, output_size}}}), NodeValidationFailure, HasSubstr("Output size must have two elements")); } @@ -128,10 +116,7 @@ TEST_F(PriorBoxClusteredV0StaticShapeInferenceTest, invalid_input_ranks) { int64_t output_size[] = {5, 2, 1}; input_shapes = ShapeVector{{2, 1}, {2}}; - OV_EXPECT_THROW(shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i64, ov::Shape{3}, output_size)}}), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, {{0, {element::i64, ov::Shape{3}, output_size}}}), NodeValidationFailure, HasSubstr("output size input rank 2 must match image shape input rank 1")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_shape_inference_test.cpp index 5fec63e33a5..263582507de 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/prior_box_shape_inference_test.cpp @@ -32,10 +32,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, default_ctor_no_args) { int32_t out_size[] = {2, 5}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, out_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, out_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 200})); @@ -50,10 +47,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, all_inputs_dynamic_rank) { int32_t output_size[] = {2, 5}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, output_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, output_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 200})); @@ -68,10 +62,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, all_inputs_static_rank) { int32_t output_size[] = {5, 2}; input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i32, ov::Shape{2}, output_size)}}); + output_shapes = shape_inference(op.get(), input_shapes, {{0, {element::i32, ov::Shape{2}, output_size}}}); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 200})); @@ -84,7 +75,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, out_size_constant) { op = make_op(out_size, img_size, attrs); input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 480})); @@ -97,7 +88,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, all_inputs_constants) { op = make_op(out_size, img_size, attrs); input_shapes = ShapeVector{{2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2, 3840})); @@ -112,10 +103,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, invalid_number_of_elements_in_out_siz int64_t output_size[] = {5, 2, 1}; input_shapes = ShapeVector{{2}, {2}}; - OV_EXPECT_THROW(shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i64, ov::Shape{3}, output_size)}}), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, {{0, {element::i64, ov::Shape{3}, output_size}}}), NodeValidationFailure, HasSubstr("Output size must have two elements")); } @@ -129,10 +117,7 @@ TEST_F(PriorBoxV8StaticShapeInferenceTest, invalid_input_ranks) { int64_t output_size[] = {5, 2, 1}; input_shapes = ShapeVector{{2, 1}, {2}}; - OV_EXPECT_THROW(shape_inference(op.get(), - input_shapes, - output_shapes, - {{0, std::make_shared(element::i64, ov::Shape{3}, output_size)}}), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, {{0, {element::i64, ov::Shape{3}, output_size}}}), NodeValidationFailure, HasSubstr("output size input rank 2 must match image shape input rank 1")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/proposal_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/proposal_shape_inference_test.cpp index 4c9237fd270..7ef8f9802b5 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/proposal_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/proposal_shape_inference_test.cpp @@ -40,7 +40,7 @@ TYPED_TEST_P(ProposalTest, default_ctor) { this->op->set_attrs(this->make_attrs(10)); this->input_shapes = ShapeVector{{2, 3, 10, 10}, {2, 6, 10, 10}, {3}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), this->exp_out_size()); EXPECT_EQ(this->output_shapes.front(), StaticShape({20, 5})); @@ -54,7 +54,7 @@ TYPED_TEST_P(ProposalTest, all_inputs_dynamic_rank) { this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(4)); this->input_shapes = ShapeVector{{2, 3, 10, 10}, {2, 6, 10, 10}, {3}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), this->exp_out_size()); EXPECT_EQ(this->output_shapes[0], StaticShape({8, 5})); @@ -68,7 +68,7 @@ TYPED_TEST_P(ProposalTest, all_inputs_static_rank) { this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5)); this->input_shapes = ShapeVector{{3, 4, 10, 10}, {3, 8, 10, 10}, {4}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), this->exp_out_size()); EXPECT_EQ(this->output_shapes[0], StaticShape({15, 5})); @@ -82,7 +82,7 @@ TYPED_TEST_P(ProposalTest, batch_size_not_compatible) { this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5)); this->input_shapes = ShapeVector{{3, 4, 10, 10}, {4, 8, 10, 10}, {3}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Batch size inconsistent between class_probs")); } @@ -95,7 +95,7 @@ TYPED_TEST_P(ProposalTest, image_shape_input_not_compatible_shape) { this->op = this->make_op(class_probs, class_bbox_deltas, image_shape, this->make_attrs(5)); this->input_shapes = ShapeVector{{3, 4, 10, 10}, {3, 8, 10, 10}, {5}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Image_shape must be 1-D tensor and has got 3 or 4 elements")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/psroi_pooling_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/psroi_pooling_shape_inference_test.cpp index b5b0b6ca294..d32c173c911 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/psroi_pooling_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/psroi_pooling_shape_inference_test.cpp @@ -33,7 +33,7 @@ TEST_F(PSROIPoolingV0StaticShapeInferenceTest, default_ctor_avg_mode) { input_shapes = ShapeVector{{1, 45, 10, 10}, {3, 5}}; auto shape_infer = make_shape_inference(op); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({3, 5, 3, 3})); @@ -50,7 +50,7 @@ TEST_F(PSROIPoolingV0StaticShapeInferenceTest, default_ctor_bilinear_mode) { input_shapes = ShapeVector{{1, 75, 10, 10}, {2, 5}}; auto shape_infer = make_shape_inference(op); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 5, 8, 8})); @@ -63,7 +63,7 @@ TEST_F(PSROIPoolingV0StaticShapeInferenceTest, inputs_dynamic_rank) { op = make_op(feat, rois, 4, group, scale, 0, 0, "average"); input_shapes = ShapeVector{{2, 36, 100, 100}, {10, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 4, 3, 3})); @@ -76,7 +76,7 @@ TEST_F(PSROIPoolingV0StaticShapeInferenceTest, inputs_static_rank) { op = make_op(feat, rois, 2, 1, scale, bins_x, bins_y, "bilinear"); input_shapes = ShapeVector{{2, 24, 20, 100}, {1, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({1, 2, 1, 1})); @@ -90,7 +90,7 @@ TEST_F(PSROIPoolingV0StaticShapeInferenceTest, invalid_rois_batch_size) { input_shapes = ShapeVector{{2, 24, 20, 100}, {1, 6}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The second dimension of ROIs input should contain batch id and box coordinates. This " "dimension is expected to be equal to 5")); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_shape_inference_test.cpp new file mode 100644 index 00000000000..a7debe18e3e --- /dev/null +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_shape_inference_test.cpp @@ -0,0 +1,67 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "range_shape_inference.hpp" +#include "utils.hpp" + +using namespace ov; +using namespace ov::intel_cpu; +using std::make_shared; +using testing::ElementsAre; + +TEST(StaticShapeInferenceTest, Rangev4_i32) { + auto start = make_shared(element::i32, ov::PartialShape{}); + auto stop = make_shared(element::i32, ov::PartialShape{}); + auto step = make_shared(element::i32, ov::PartialShape{}); + auto range = make_shared(start, stop, step, element::i32); + + int32_t start_v = 2, stop_v = 0, step_v = -2; + auto const_data = std::unordered_map{{0, {element::i32, Shape{}, &start_v}}, + {1, {element::i32, Shape{}, &stop_v}}, + {2, {element::i32, Shape{}, &step_v}}}; + + auto output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1})); + + step_v = -1; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{2})); + + start_v = -19, stop_v = 19, step_v = 1; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{38})); + + step_v = 3; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{13})); + + start_v = 20, stop_v = -19, step_v = 1; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{0})); +} + +TEST(StaticShapeInferenceTest, Rangev4_f32) { + auto start = make_shared(element::f32, ov::PartialShape{}); + auto stop = make_shared(element::f32, ov::PartialShape{}); + auto step = make_shared(element::f32, ov::PartialShape{}); + auto range = make_shared(start, stop, step, element::f32); + + float start_v = 0.f, stop_v = 1.f, step_v = .25f; + auto const_data = std::unordered_map{{0, {element::f32, Shape{}, &start_v}}, + {1, {element::f32, Shape{}, &stop_v}}, + {2, {element::f32, Shape{}, &step_v}}}; + + auto output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{4})); + + start_v = -1.f; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{8})); + + stop_v = .875f; + output_shapes = shape_inference(range.get(), ShapeVector{{}, {}, {}}, const_data); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{8})); +} diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_test.cpp deleted file mode 100644 index 81898749ee0..00000000000 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/range_test.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2023 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include "utils.hpp" - -using namespace ov; -using namespace ov::intel_cpu; -using namespace std; - -TEST(StaticShapeInferenceTest, Rangev4_i32) { - auto start = make_shared(element::i32, ov::PartialShape{}); - auto stop = make_shared(element::i32, ov::PartialShape{}); - auto step = make_shared(element::i32, ov::PartialShape{}); - - auto range = make_shared(start, stop, step, element::i32); - - check_static_shape(range.get(), {2, 0, -2}, {StaticShape{1}}); - check_static_shape(range.get(), {2, 0, -1}, {StaticShape{2}}); - check_static_shape(range.get(), {-19, 19, 1}, {StaticShape{38}}); - check_static_shape(range.get(), {-19, 19, 3}, {StaticShape{13}}); - check_static_shape(range.get(), {20, -19, 1}, {StaticShape{0}}); -} - -TEST(StaticShapeInferenceTest, Rangev4_f32) { - auto start = make_shared(element::f32, ov::PartialShape{}); - auto stop = make_shared(element::f32, ov::PartialShape{}); - auto step = make_shared(element::f32, ov::PartialShape{}); - - auto range = make_shared(start, stop, step, element::f32); - - check_static_shape(range.get(), {0., 1., 0.25}, {StaticShape{4}}); - check_static_shape(range.get(), {-1., 1., 0.25}, {StaticShape{8}}); - check_static_shape(range.get(), {-1., 0.875, 0.25}, {StaticShape{8}}); -} diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/read_value_shape_inference.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/read_value_shape_inference.cpp index 43426ca1f2b..cc627d55533 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/read_value_shape_inference.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/read_value_shape_inference.cpp @@ -30,8 +30,8 @@ void readValueTest() { auto readValue = constructGraph(); // Test StaticShape - std::vector static_input_shapes = {StaticShape{1, 2, 64, 64}}, static_output_shapes = {StaticShape{}}; - shape_inference(readValue.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{1, 2, 64, 64}}; + const auto static_output_shapes = shape_inference(readValue.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], (StaticShape{1, 2, 64, 64})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reduce_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reduce_shape_inference_test.cpp index 94f0c852b73..45f587c5c23 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reduce_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reduce_shape_inference_test.cpp @@ -28,9 +28,8 @@ TYPED_TEST_P(ReduceStaticShapeInferenceTest, default_ctor) { this->input_shapes = ShapeVector{{1, 6, 7, 8, 4}, {3}}; int32_t axes_val[] = {0, 1, 3}; - const std::map>& constant_data = { - {1, std::make_shared(element::i32, Shape{3}, axes_val)}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes, constant_data); + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{3}, axes_val}}}; + this->output_shapes = shape_inference(this->op.get(), this->input_shapes, constant_data); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({1, 1, 7, 1, 4})); @@ -43,7 +42,7 @@ TYPED_TEST_P(ReduceStaticShapeInferenceTest, axes_constant) { this->op = this->make_op(data, axes, false); this->input_shapes = {StaticShape{3, 6, 5, 8}, StaticShape{2}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, 5})); @@ -57,9 +56,8 @@ TYPED_TEST_P(ReduceStaticShapeInferenceTest, axes_param) { this->input_shapes = {StaticShape{3, 6, 5, 8}, StaticShape{2}}; int32_t axes_val[] = {1, 3}; - const std::map>& constant_data = { - {1, std::make_shared(element::i32, Shape{2}, axes_val)}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes, constant_data); + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{2}, axes_val}}}; + this->output_shapes = shape_inference(this->op.get(), this->input_shapes, constant_data); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, 5})); @@ -72,7 +70,7 @@ TYPED_TEST_P(ReduceStaticShapeInferenceTest, axes_constant_keep_dims) { this->op = this->make_op(data, axes, true); this->input_shapes = {StaticShape{3, 6, 5, 8}, StaticShape{2}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, 1, 5, 1})); @@ -86,9 +84,8 @@ TYPED_TEST_P(ReduceStaticShapeInferenceTest, axes_param_keep_dims) { this->input_shapes = {StaticShape{3, 6, 5, 8}, StaticShape{2}}; int32_t axes_val[] = {1, 3}; - const std::map>& constant_data = { - {1, std::make_shared(element::i32, Shape{2}, axes_val)}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes, constant_data); + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{2}, axes_val}}}; + this->output_shapes = shape_inference(this->op.get(), this->input_shapes, constant_data); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes.front(), StaticShape({3, 1, 5, 1})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/region_yolo_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/region_yolo_shape_inference_test.cpp index d33ff2b1c14..e42aabcb3a3 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/region_yolo_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/region_yolo_shape_inference_test.cpp @@ -22,7 +22,7 @@ TEST_F(StaticShapeRegionYoloTest, default_ctor_do_soft_max_no_args) { op->set_end_axis(3); input_shapes = ShapeVector{{10, 8, 12, 6}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 8, 72})); @@ -33,7 +33,7 @@ TEST_F(StaticShapeRegionYoloTest, data_input_is_dynamic_rank) { op = make_op(data, 0, 0, 0, true, std::vector(), 1, 3); input_shapes = ShapeVector{{2, 2, 3, 4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 24})); @@ -44,7 +44,7 @@ TEST_F(StaticShapeRegionYoloTest, data_input_is_static_rank) { op = make_op(data, 5, 4, 20, false, std::vector{0, 1}, 1, 3); input_shapes = ShapeVector{{2, 5, 6, 7}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 20, 6, 7})); @@ -54,7 +54,7 @@ TEST_F(StaticShapeRegionYoloTest, data_shape_not_compatible_rank_4) { const auto data = std::make_shared(element::f32, PartialShape::dynamic()); op = make_op(data, 5, 4, 20, false, std::vector{0, 1}, 1, 3); - OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 12, 24, 1}}, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector({{2, 20, 12, 24, 1}})), NodeValidationFailure, HasSubstr("Input must be a tensor of rank 4, but got")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reorg_yolo_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reorg_yolo_shape_inference_test.cpp index 8c6947fa54c..91651234c80 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reorg_yolo_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reorg_yolo_shape_inference_test.cpp @@ -20,7 +20,7 @@ TEST_F(StaticShapeReorgYoloTest, default_ctor_no_args) { op->set_strides(3); input_shapes = ShapeVector{{2, 9, 12, 6}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 81, 4, 2})); @@ -31,7 +31,7 @@ TEST_F(StaticShapeReorgYoloTest, data_input_is_dynamic_rank) { op = make_op(data, 2); input_shapes = ShapeVector{{2, 12, 12, 24}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 48, 6, 12})); @@ -42,7 +42,7 @@ TEST_F(StaticShapeReorgYoloTest, data_input_is_static_rank) { op = make_op(data, 2); input_shapes = ShapeVector{{2, 20, 12, 24}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 80, 6, 12})); @@ -52,7 +52,7 @@ TEST_F(StaticShapeReorgYoloTest, data_shape_not_compatible_rank_4) { const auto data = std::make_shared(element::f32, PartialShape::dynamic()); op = make_op(data, 2); - OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 12, 24, 1}}, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector({{2, 20, 12, 24, 1}})), NodeValidationFailure, HasSubstr("[N, C, H, W] input shape is required")); } @@ -61,7 +61,7 @@ TEST_F(StaticShapeReorgYoloTest, h_dim_not_div_by_stride) { const auto data = std::make_shared(element::f32, PartialShape::dynamic()); op = make_op(data, 2); - OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 11, 24}}, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), ShapeVector{{2, 20, 11, 24}}), NodeValidationFailure, HasSubstr("H and W should be divisible by stride")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_sequence_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_sequence_shape_inference_test.cpp index ca367910fe7..2ad1978785c 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_sequence_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_sequence_shape_inference_test.cpp @@ -27,7 +27,7 @@ TEST_F(ReverseSequenceV0StaticShapeInferenceTest, default_batch_seq_axes) { auto op = make_op(data, seq_lengths); input_shapes = ShapeVector{{4, 3, 2}, {4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2})); } @@ -36,7 +36,7 @@ TEST_F(ReverseSequenceV0StaticShapeInferenceTest, set_batch_seq_axes) { auto op = make_op(data, seq_lengths, -1, 1); input_shapes = ShapeVector{{4, 3, 2}, {2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2})); } @@ -45,14 +45,14 @@ TEST_F(ReverseSequenceV0StaticShapeInferenceTest, invalid_input_shapes_count) { auto op = make_op(data, seq_lengths); input_shapes = ShapeVector{{1, 2, 4}}; - EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), NodeValidationFailure); + EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure); } TEST_F(ReverseSequenceV0StaticShapeInferenceTest, invalid_data_shape_rank) { auto op = make_op(data, seq_lengths); input_shapes = ShapeVector{{4}, {4}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Data input rank should be equal or greater than 2. Got: ")); } @@ -61,7 +61,7 @@ TEST_F(ReverseSequenceV0StaticShapeInferenceTest, invalid_sequence_shape_rank) { auto op = make_op(data, seq_lengths); input_shapes = ShapeVector{{4, 5, 6}, {2, 2}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Sequence lengths rank must be equal to 1. Got: ")); } @@ -70,7 +70,7 @@ TEST_F(ReverseSequenceV0StaticShapeInferenceTest, default_ctor) { auto op = make_op(); input_shapes = ShapeVector{{11, 2, 3}, {11}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({11, 2, 3})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_shape_inference_test.cpp index e5f6313a038..34b010cf353 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/reverse_shape_inference_test.cpp @@ -28,7 +28,7 @@ TEST_F(ReverseV1StaticShapeInferenceTest, axes_index_as_constant) { auto op = make_op(data, Constant::create(element::i16, Shape{4}, {-1000, 1, 2, 2}), Reverse::Mode::INDEX); input_shapes = ShapeVector{{4, 3, 2, 4}, {4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2, 4})); } @@ -38,9 +38,8 @@ TEST_F(ReverseV1StaticShapeInferenceTest, axes_index_in_constant_data) { input_shapes = ShapeVector{{4, 3, 2, 4}, {4}}; int8_t axes_val[] = {-1, 2, 1}; - auto const_data = - std::map{{1, std::make_shared(element::i8, Shape{3}, axes_val)}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + auto const_data = std::unordered_map{{1, {element::i8, Shape{3}, axes_val}}}; + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2, 4})); } @@ -51,7 +50,7 @@ TEST_F(ReverseV1StaticShapeInferenceTest, axes_mask_as_constant) { input_shapes = ShapeVector{{4, 3, 2, 4}, {4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2, 4})); } @@ -62,9 +61,8 @@ TEST_F(ReverseV1StaticShapeInferenceTest, axes_mask_in_constant_data) { input_shapes = ShapeVector{{4, 3, 2, 4}, {4}}; bool axes_val[] = {true, true, false, false}; - auto const_data = - std::map{{1, std::make_shared(element::boolean, Shape{4}, axes_val)}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + auto const_data = std::unordered_map{{1, {element::boolean, Shape{4}, axes_val}}}; + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes[0], StaticShape({4, 3, 2, 4})); } @@ -73,7 +71,7 @@ TEST_F(ReverseV1StaticShapeInferenceTest, invalid_axes_mask_length) { auto op = make_op(data, Constant::create(element::boolean, Shape{3}, {false, false, true}), Reverse::Mode::MASK); input_shapes = ShapeVector{{1, 2, 4, 3}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The number of elements in the reversed_axes tensor (3) must match the input data tensor " "rank (4) in 'mask' mode")); @@ -83,7 +81,7 @@ TEST_F(ReverseV1StaticShapeInferenceTest, axes_index_out_of_data_rank) { auto op = make_op(data, Constant::create(element::u8, Shape{3}, {0, 20, 3}), Reverse::Mode::INDEX); input_shapes = ShapeVector{{1, 2, 4, 3}, {3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Some of the provided axes (AxisSet{0, 3, 20}) are out of bounds (input rank: 4)")); } @@ -95,9 +93,8 @@ TEST_F(ReverseV1StaticShapeInferenceTest, default_ctor) { input_shapes = ShapeVector{{11, 2, 3}, {3}}; int64_t axes_val[] = {-1, 2, 0}; - auto const_data = - std::map{{1, std::make_shared(element::i64, Shape{3}, axes_val)}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + auto const_data = std::unordered_map{{1, {element::i64, Shape{3}, axes_val}}}; + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes[0], StaticShape({11, 2, 3})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_cell_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_cell_shape_inference_test.cpp index 8427492edf6..2bbd022f966 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_cell_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_cell_shape_inference_test.cpp @@ -32,7 +32,7 @@ TEST_F(RNNCellV0StaticShapeInferenceTest, default_ctor) { StaticShape{gates_count * hidden_size}}; // B std::vector output_shapes; - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -57,7 +57,7 @@ TEST_F(RNNCellV0StaticShapeInferenceTest, default_bias) { StaticShape{gates_count * hidden_size}}; // B std::vector output_shapes; - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -80,7 +80,7 @@ TEST_F(RNNCellV0StaticShapeInferenceTest, with_bias) { StaticShape{gates_count * hidden_size, hidden_size}, // R StaticShape{gates_count * hidden_size}}; // B - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } @@ -105,6 +105,6 @@ TEST_F(RNNCellV0StaticShapeInferenceTest, dynamic_rank_inputs) { StaticShape{gates_count * hidden_size}}; // B std::vector output_shapes; - shape_inference(gru.get(), input_shapes, output_shapes); + output_shapes = shape_inference(gru.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_seq_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_seq_shape_inference_test.cpp index ef409775ab6..cd29aa4905c 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_seq_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/rnn_seq_shape_inference_test.cpp @@ -33,7 +33,7 @@ TEST_F(RNNSequenceV5StaticShapeInferenceTest, default_ctor) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -64,7 +64,7 @@ TEST_F(RNNSequenceV5StaticShapeInferenceTest, FORWARD) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -95,7 +95,7 @@ TEST_F(RNNSequenceV5StaticShapeInferenceTest, REVERSE) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } @@ -126,7 +126,7 @@ TEST_F(RNNSequenceV5StaticShapeInferenceTest, BIDIRECTIONAL) { StaticShape{num_directions, gates_count * hidden_size, hidden_size}, // R StaticShape{num_directions, gates_count * hidden_size}}; // B - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({batch_size, num_directions, seq_len, hidden_size})); EXPECT_EQ(output_shapes[1], StaticShape({batch_size, num_directions, hidden_size})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_align_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_align_shape_inference_test.cpp index 2e8eca5e286..696c5ebe454 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_align_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_align_shape_inference_test.cpp @@ -27,7 +27,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, default_ctor_no_args) { this->op->set_pooled_w(2); this->input_shapes = ShapeVector{{2, 3, 5, 5}, {7, 4}, {7}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes[0], (StaticShape{7, 3, 2, 2})); @@ -41,7 +41,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, all_inputs_dynamic_rank) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 3, 5, 5}, {10, 4}, {10}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes[0], (StaticShape{10, 3, 2, 2})); @@ -55,7 +55,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, all_inputs_static_rank) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 8, 5, 5}, {10, 4}, {10}}; - shape_inference(this->op.get(), this->input_shapes, this->output_shapes); + this->output_shapes = shape_inference(this->op.get(), this->input_shapes); EXPECT_EQ(this->output_shapes.size(), 1); EXPECT_EQ(this->output_shapes[0], (StaticShape{10, 8, 2, 2})); @@ -69,7 +69,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, incompatible_input_rank) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 8, 5}, {10, 3}, {10}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Expected a 4D tensor for the input data")); } @@ -82,7 +82,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, incompatible_rois_rank) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 8, 5, 5}, {10, 3, 1}, {10}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Expected a 2D tensor for the ROIs input")); } @@ -94,7 +94,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, incompatible_batch_indicies_rank) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 8, 5, 5}, {10, 3}, {}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("Expected a 1D tensor for the batch indices input.")); } @@ -107,7 +107,7 @@ TYPED_TEST_P(StaticShapeROIAlignTest, invalid_rois_2nd_dim) { this->op = this->make_op(data, rois, batch_indices, 2, 2, 2, 1.0f, TypeParam::PoolingMode::AVG); this->input_shapes = ShapeVector{{2, 8, 5, 5}, {10, 3}, {10}}; - OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes, this->output_shapes), + OV_EXPECT_THROW(shape_inference(this->op.get(), this->input_shapes), NodeValidationFailure, HasSubstr("op dimension is expected to be equal to 4")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_pooling_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_pooling_shape_inference_test.cpp index 0999e278c95..1bae78a4f4a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_pooling_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roi_pooling_shape_inference_test.cpp @@ -27,7 +27,7 @@ TEST_F(ROIPoolingV0StaticShapeInferenceTest, default_ctor) { input_shapes = ShapeVector{{1, 5, 10, 10}, {2, 5}}; auto shape_infer = make_shape_inference(op); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({2, 5, 3, 3})); @@ -40,7 +40,7 @@ TEST_F(ROIPoolingV0StaticShapeInferenceTest, inputs_dynamic_rank) { op = make_op(feat, rois, ov::Shape{5, 5}, 0.9f); input_shapes = ShapeVector{{2, 3, 100, 100}, {10, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 3, 5, 5})); @@ -53,7 +53,7 @@ TEST_F(ROIPoolingV0StaticShapeInferenceTest, inputs_static_rank) { op = make_op(feat, rois, ov::Shape{7, 5}, 1.9f, "max"); input_shapes = ShapeVector{{2, 3, 20, 100}, {10, 5}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes.front(), StaticShape({10, 3, 7, 5})); @@ -67,7 +67,7 @@ TEST_F(ROIPoolingV0StaticShapeInferenceTest, invalid_rois_batch_size) { input_shapes = ShapeVector{{2, 3, 20, 100}, {10, 6}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("The second dimension of ROIs input should contain batch id and box coordinates. This " "dimension is expected to be equal to 5")); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roll_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roll_shape_inference_test.cpp index a507324c18c..91370a2ae1d 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/roll_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/roll_shape_inference_test.cpp @@ -1,10 +1,11 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include + #include #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "utils.hpp" @@ -29,7 +30,7 @@ TEST_F(RollV7StaticShapeInferenceTest, axes_as_constant) { input_shapes = {StaticShape{3, 5}, StaticShape{2}, StaticShape{2}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], input_shapes[0]); } @@ -41,12 +42,12 @@ TEST_F(RollV7StaticShapeInferenceTest, axes_in_const_map) { const auto op = make_op(arg, shift, axes); auto axes_val = std::array{0, 1, -1}; - const auto constant_data = std::map{ - {2, std::make_shared(element::i32, Shape{axes_val.size()}, axes_val.data())}}; + const auto constant_data = + std::unordered_map{{2, {element::i32, Shape{axes_val.size()}, axes_val.data()}}}; input_shapes = {StaticShape{3, 3, 3}, StaticShape{3}, StaticShape{3}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], input_shapes[0]); } @@ -58,12 +59,12 @@ TEST_F(RollV7StaticShapeInferenceTest, axes_over_arg_rank) { const auto op = make_op(arg, shift, axes); auto axes_val = std::array{0, 3, -1}; - const auto constant_data = std::map{ - {2, std::make_shared(element::i32, Shape{axes_val.size()}, axes_val.data())}}; + const auto constant_data = + std::unordered_map{{2, {element::i32, Shape{axes_val.size()}, axes_val.data()}}}; input_shapes = {StaticShape{3, 3, 3}, StaticShape{3}, StaticShape{3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, constant_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, constant_data), NodeValidationFailure, HasSubstr("Parameter axis 3 out of the tensor rank range")); } @@ -76,12 +77,12 @@ TEST_F(RollV7StaticShapeInferenceTest, axes_has_negative_after_normalization) { const auto op = make_op(arg, shift, axes); auto axes_val = std::array{-4, 2, -1}; - const auto constant_data = std::map{ - {2, std::make_shared(element::i64, Shape{axes_val.size()}, axes_val.data())}}; + const auto constant_data = + std::unordered_map{{2, {element::i64, Shape{axes_val.size()}, axes_val.data()}}}; input_shapes = {StaticShape{3, 3, 3}, StaticShape{3}, StaticShape{3}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, constant_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, constant_data), NodeValidationFailure, HasSubstr(" Parameter axis -4 out of the tensor rank range")); } @@ -90,11 +91,11 @@ TEST_F(RollV7StaticShapeInferenceTest, default_ctor) { const auto op = make_op(); auto axes_val = std::array{-4, 2, -1, 1}; - const auto constant_data = std::map{ - {2, std::make_shared(element::i64, Shape{axes_val.size()}, axes_val.data())}}; + const auto constant_data = + std::unordered_map{{2, {element::i64, Shape{axes_val.size()}, axes_val.data()}}}; input_shapes = {StaticShape{3, 2, 5, 1}, StaticShape{}, StaticShape{4}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], input_shapes[0]); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_elements_update_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_elements_update_shape_inference_test.cpp index 4ea2cf3fef8..599d0a6b61c 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_elements_update_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_elements_update_shape_inference_test.cpp @@ -25,11 +25,10 @@ TEST_F(ScatterElementsUpdateV3StaticShapeInferenceTest, default_ctor) { const auto op = make_op(); int32_t axis = 1; - const auto const_data = - std::map{{3, std::make_shared(element::i32, Shape{1}, &axis)}}; + const auto const_data = std::unordered_map{{3, {element::i32, Shape{1}, &axis}}}; input_shapes = ShapeVector{{1000, 256, 10, 13}, {25, 125, 3, 1}, {25, 125, 3, 1}, {1}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 13})); @@ -44,7 +43,7 @@ TEST_F(ScatterElementsUpdateV3StaticShapeInferenceTest, correct_inputs_axis_as_c const auto op = make_op(d, i, u, a); input_shapes = ShapeVector{{2, 5, 10, 15}, {2, 1, 10, 15}, {2, 1, 10, 15}, {}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({2, 5, 10, 15})); @@ -59,11 +58,10 @@ TEST_F(ScatterElementsUpdateV3StaticShapeInferenceTest, params_are_dynamic_rank_ const auto op = make_op(d, i, u, a); uint32_t axis = 2; - const auto const_data = - std::map{{3, std::make_shared(element::u32, Shape{}, &axis)}}; + const auto const_data = std::unordered_map{{3, {element::u32, Shape{}, &axis}}}; input_shapes = ShapeVector{{5000, 256, 10, 15}, {30, 25, 3, 3}, {30, 25, 3, 3}, {}}; - shape_inference(op.get(), input_shapes, output_shapes, const_data); + const auto output_shapes = shape_inference(op.get(), input_shapes, const_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({5000, 256, 10, 15})); @@ -78,11 +76,10 @@ TEST_F(ScatterElementsUpdateV3StaticShapeInferenceTest, incorrect_axis_value) { const auto op = make_op(d, i, u, a); uint32_t axis = 4; - const auto const_data = - std::map{{3, std::make_shared(element::u32, Shape{}, &axis)}}; + const auto const_data = std::unordered_map{{3, {element::u32, Shape{}, &axis}}}; input_shapes = ShapeVector{{5000, 256, 10, 15}, {30, 25, 3, 3}, {30, 25, 3, 3}, {}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_data), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_data), AssertFailure, HasSubstr("Parameter axis 4 out of the tensor rank range [-4, 3]")); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_nd_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_nd_shape_inference_test.cpp index 3b10cb4a956..2bb4ddb7a73 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_nd_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_nd_shape_inference_test.cpp @@ -21,7 +21,7 @@ TEST_F(ScatterNDUpdateV3StaticShapeInferenceTest, default_ctor) { const auto op = make_op(); input_shapes = ShapeVector{{1000, 256, 10, 13}, {25, 125, 3}, {25, 125, 13}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 13})); @@ -35,7 +35,7 @@ TEST_F(ScatterNDUpdateV3StaticShapeInferenceTest, correct_inputs) { const auto op = make_op(d, i, u); input_shapes = ShapeVector{{1000, 256, 10, 15}, {25, 125, 3}, {25, 125, 15}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); @@ -49,7 +49,7 @@ TEST_F(ScatterNDUpdateV3StaticShapeInferenceTest, params_are_dynamic_rank) { const auto op = make_op(d, i, u); input_shapes = ShapeVector{{5000, 256, 10, 15}, {30, 25, 3}, {30, 25, 15}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], StaticShape({5000, 256, 10, 15})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_update_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_update_shape_inference_test.cpp index d88c8a20f46..0174dadffa3 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_update_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/scatter_update_shape_inference_test.cpp @@ -18,14 +18,14 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_3D_axis_1) { auto scatter_update = std::make_shared(data_param, indices_param, updates_param, axis_param); int32_t axis_val[] = {1}; - std::map> constant_data; - constant_data[3] = std::make_shared(element::Type_t::i32, Shape{1}, axis_val); + std::unordered_map constant_data; + constant_data[3] = ov::Tensor(element::Type_t::i32, Shape{1}, axis_val); std::vector input_shapes = {StaticShape{2, 3, 4}, StaticShape{2, 1}, StaticShape{2, 2, 1, 4}, StaticShape{1}}, output_shapes = {StaticShape{}}; - shape_inference(scatter_update.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(scatter_update.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], StaticShape({2, 3, 4})); } @@ -38,14 +38,14 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_4D_axis_2) { auto scatter_update = std::make_shared(data_param, indices_param, updates_param, axis_param); int32_t axis_val[] = {2}; - std::map> constant_data; - constant_data[3] = std::make_shared(element::Type_t::i32, Shape{1}, axis_val); + std::unordered_map constant_data; + constant_data[3] = ov::Tensor(element::Type_t::i32, Shape{1}, axis_val); std::vector input_shapes = {StaticShape{1000, 256, 10, 15}, StaticShape{125, 20}, StaticShape{1000, 125, 20, 10, 15}, StaticShape{1}}, output_shapes = {StaticShape{}}; - shape_inference(scatter_update.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(scatter_update.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); } @@ -58,14 +58,14 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_4D_incompatible_axis) { auto scatter_update = std::make_shared(data_param, indices_param, updates_param, axis_param); int32_t axis_val[] = {1}; - std::map> constant_data; - constant_data[3] = std::make_shared(element::Type_t::i32, Shape{1}, axis_val); + std::unordered_map constant_data; + constant_data[3] = ov::Tensor(element::Type_t::i32, Shape{1}, axis_val); std::vector input_shapes = {StaticShape{1000, 256, 10, 15}, StaticShape{125, 20}, StaticShape{1000, 125, 20, 10, 15}, StaticShape{1}}, output_shapes = {StaticShape{}}; - shape_inference(scatter_update.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(scatter_update.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); } @@ -80,9 +80,8 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_axis_as_const) { std::vector input_shapes = {StaticShape{1000, 256, 10, 15}, StaticShape{125, 20}, StaticShape{1000, 125, 20, 10, 15}, - StaticShape{1}}, - output_shapes = {StaticShape{}}; - shape_inference(scatter_update.get(), input_shapes, output_shapes); + StaticShape{1}}; + const auto output_shapes = shape_inference(scatter_update.get(), input_shapes); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); } @@ -95,14 +94,14 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_dynamic_rank) { auto scatter_update = std::make_shared(data_param, indices_param, updates_param, axis_param); int32_t axis_val[] = {1}; - std::map> constant_data; - constant_data[3] = std::make_shared(element::Type_t::i32, Shape{1}, axis_val); + std::unordered_map constant_data; + constant_data[3] = ov::Tensor(element::Type_t::i32, Shape{1}, axis_val); std::vector input_shapes = {StaticShape{1000, 256, 10, 15}, StaticShape{125, 20}, StaticShape{1000, 125, 20, 10, 15}, StaticShape{1}}, output_shapes = {StaticShape{}}; - shape_inference(scatter_update.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(scatter_update.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); } @@ -115,8 +114,8 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_params_dynamic_rank_incorrect_updat auto scatter_update = std::make_shared(data_param, indices_param, updates_param, axis_param); int32_t axis_val[] = {1}; - std::map> constant_data; - constant_data[3] = std::make_shared(element::Type_t::i32, Shape{1}, axis_val); + std::unordered_map constant_data; + constant_data[3] = ov::Tensor(element::Type_t::i32, Shape{1}, axis_val); // Incorrect rank of the third input shape std::vector input_shapes = {StaticShape{1000, 256, 10, 15}, @@ -126,6 +125,6 @@ TEST(StaticShapeInferenceTest, ScatterUpdate_params_dynamic_rank_incorrect_updat output_shapes = {StaticShape{}}; // ScatterUpdate shape_inference is implemented by usage of entryFirstPassthrough, no additional checks - shape_inference(scatter_update.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(scatter_update.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes[0], StaticShape({1000, 256, 10, 15})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/select_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/select_shape_inference_test.cpp index 8242f81777d..e70a62c6d9e 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/select_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/select_shape_inference_test.cpp @@ -15,35 +15,32 @@ TEST(StaticShapeInferenceTest, SelectTestBCastModeNUMPY) { auto pfalse = std::make_shared(element::f32, PartialShape::dynamic()); auto select = std::make_shared(cond, ptrue, pfalse, op::AutoBroadcastType::NUMPY); { - std::vector static_input_shapes = {StaticShape{}, StaticShape{4}, StaticShape{2, 4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(select.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{}, StaticShape{4}, StaticShape{2, 4}}; + const auto static_output_shapes = shape_inference(select.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({2, 4})); } { - std::vector static_input_shapes = {StaticShape{}, StaticShape{2, 4}, StaticShape{2, 4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(select.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{}, StaticShape{2, 4}, StaticShape{2, 4}}; + const auto static_output_shapes = shape_inference(select.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({2, 4})); } { - std::vector static_input_shapes = {StaticShape{4}, StaticShape{2, 4}, StaticShape{4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(select.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{4}, StaticShape{2, 4}, StaticShape{4}}; + const auto static_output_shapes = shape_inference(select.get(), static_input_shapes); EXPECT_EQ(static_output_shapes[0], StaticShape({2, 4})); } } + TEST(StaticShapeInferenceTest, SelectTestBCastModePDPD) { auto cond = std::make_shared(element::boolean, PartialShape::dynamic()); auto ptrue = std::make_shared(element::f32, PartialShape::dynamic()); auto pfalse = std::make_shared(element::f32, PartialShape::dynamic()); auto select = std::make_shared(cond, ptrue, pfalse, op::AutoBroadcastSpec{op::AutoBroadcastType::PDPD, 1}); - std::vector static_input_shapes = {StaticShape{4}, StaticShape{2, 4}, StaticShape{4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(select.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{4}, StaticShape{2, 4}, StaticShape{4}}; + const auto static_output_shapes = shape_inference(select.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({2, 4})); } @@ -53,8 +50,7 @@ TEST(StaticShapeInferenceTest, SelectTestBCastModeNone) { auto pfalse = std::make_shared(element::f32, PartialShape::dynamic()); auto select = std::make_shared(cond, ptrue, pfalse, op::AutoBroadcastType::NONE); - std::vector static_input_shapes = {StaticShape{6, 4}, StaticShape{6, 4}, StaticShape{6, 4}}, - static_output_shapes = {StaticShape{}}; - shape_inference(select.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{6, 4}, StaticShape{6, 4}, StaticShape{6, 4}}; + const auto static_output_shapes = shape_inference(select.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({6, 4})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/shape_node_tests.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/shape_node_tests.cpp index 7f2bc62fd1f..51379da0339 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/shape_node_tests.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/shape_node_tests.cpp @@ -13,12 +13,10 @@ TEST(StaticShapeInferenceTest, ReshapeTest) { auto data = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); auto pattern = std::make_shared(element::i32, Shape{2}, std::vector{0, -1}); - auto reduce = - std::make_shared(data, pattern, true); + auto reduce = std::make_shared(data, pattern, true); - std::vector static_input_shapes = {StaticShape{3, 6, 5, 5}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - shape_inference(reduce.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{3, 6, 5, 5}, StaticShape{2}}; + const auto static_output_shapes = shape_inference(reduce.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 150})); } @@ -27,12 +25,10 @@ TEST(StaticShapeInferenceTest, ReshapeEmptyTest) { auto data = std::make_shared(element::f32, PartialShape{-1, 2, 2}); auto pattern = std::make_shared(element::i32, Shape{2}, std::vector{0, 4}); - auto reduce = - std::make_shared(data, pattern, false); + auto reduce = std::make_shared(data, pattern, false); - std::vector static_input_shapes = {StaticShape{0, 2, 2}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - shape_inference(reduce.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{0, 2, 2}, StaticShape{2}}; + const auto static_output_shapes = shape_inference(reduce.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({0, 4})); } @@ -40,12 +36,10 @@ TEST(StaticShapeInferenceTest, ReshapeEmptyTest) { TEST(StaticShapeInferenceTest, ShapeOf5DTest) { auto data = std::make_shared(element::f32, PartialShape{-1, -1, -1, -1}); - auto shapeof = - std::make_shared(data); + auto shapeof = std::make_shared(data); - std::vector static_input_shapes = {StaticShape{2, 3, 4, 5, 6}}, - static_output_shapes = {StaticShape{}}; - shape_inference(shapeof.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{2, 3, 4, 5, 6}}; + const auto static_output_shapes = shape_inference(shapeof.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({5})); } @@ -53,12 +47,10 @@ TEST(StaticShapeInferenceTest, ShapeOf5DTest) { TEST(StaticShapeInferenceTest, ShapeOf0DTest) { auto data = std::make_shared(element::f32, PartialShape{}); - auto shapeof = - std::make_shared(data); + auto shapeof = std::make_shared(data); - std::vector static_input_shapes = {StaticShape{}}, - static_output_shapes = {StaticShape{}}; - shape_inference(shapeof.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{}}; + const auto static_output_shapes = shape_inference(shapeof.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/shuffle_channels_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/shuffle_channels_shape_inference_test.cpp index f9b9b2fdd15..41088ff6956 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/shuffle_channels_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/shuffle_channels_shape_inference_test.cpp @@ -25,7 +25,7 @@ TEST_F(ShuffleChannelsV0StaticShapeInferenceTest, default_ctor) { op->set_group(2); input_shapes = {StaticShape{5, 4, 9}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], input_shapes[0]); @@ -36,7 +36,7 @@ TEST_F(ShuffleChannelsV0StaticShapeInferenceTest, correct_shape_infer) { op = make_op(data, -1, 3); input_shapes = {StaticShape{5, 4, 9}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], input_shapes[0]); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/slice_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/slice_shape_inference_test.cpp index 988ad1b8ec5..3aed5f4d512 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/slice_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/slice_shape_inference_test.cpp @@ -34,7 +34,7 @@ TEST_F(SliceStaticShapeInferenceTest, reverse_steps_start_stop_outside_dimension input_shapes.push_back({3, 4, 5, max_d, max_d}); input_shapes.resize(4, start->get_shape()); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), num_of_outputs); EXPECT_EQ(output_shapes.front(), StaticShape({3, 2, 5, max_d, 3})); @@ -53,19 +53,19 @@ TEST_F(SliceStaticShapeInferenceTest, reverse_step_on_signle_axis_but_start_stop auto stop_buff = std::vector{2}; auto steps_buff = std::vector{-2}; - const auto start_tensor = std::make_shared(et, Shape{1}, static_cast(start_buff.data())); - const auto stop_tensor = std::make_shared(et, Shape{1}, static_cast(stop_buff.data())); - const auto steps_tensor = std::make_shared(et, Shape{1}, static_cast(steps_buff.data())); + const auto start_tensor = ov::Tensor(element::i64, Shape{1}, static_cast(start_buff.data())); + const auto stop_tensor = ov::Tensor(element::i64, Shape{1}, static_cast(stop_buff.data())); + const auto steps_tensor = ov::Tensor(element::i64, Shape{1}, static_cast(steps_buff.data())); const auto op = make_op(data, start, stop, steps, axes); input_shapes = ShapeVector{{3, 4, 10}, {1}, {1}, {1}, axes->get_shape()}; - const std::map>& constant_data = {{1, start_tensor}, - {2, stop_tensor}, - {3, steps_tensor}}; + const std::unordered_map& constant_data = {{1, start_tensor}, + {2, stop_tensor}, + {3, steps_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), num_of_outputs); EXPECT_EQ(output_shapes.front(), StaticShape({3, 4, 4})); @@ -86,22 +86,22 @@ TEST_F(SliceStaticShapeInferenceTest, forward_step_all_data_in_const_map) { const auto common_shape = Shape{start_buff.size()}; - const auto start_tensor = std::make_shared(et, common_shape, static_cast(start_buff.data())); - const auto stop_tensor = std::make_shared(et, common_shape, static_cast(stop_buff.data())); - const auto steps_tensor = std::make_shared(et, common_shape, static_cast(steps_buff.data())); - const auto axes_tensor = std::make_shared(et, common_shape, static_cast(axes_buff.data())); + const auto start_tensor = ov::Tensor(element::i64, common_shape, static_cast(start_buff.data())); + const auto stop_tensor = ov::Tensor(element::i64, common_shape, static_cast(stop_buff.data())); + const auto steps_tensor = ov::Tensor(element::i64, common_shape, static_cast(steps_buff.data())); + const auto axes_tensor = ov::Tensor(element::i64, common_shape, static_cast(axes_buff.data())); const auto op = make_op(data, start, stop, steps); input_shapes.push_back({10, 10, 8, max_d, max_d, max_d, 10}); input_shapes.resize(5, common_shape); - const std::map>& constant_data = {{1, start_tensor}, - {2, stop_tensor}, - {3, steps_tensor}, - {4, axes_tensor}}; + const std::unordered_map& constant_data = {{1, start_tensor}, + {2, stop_tensor}, + {3, steps_tensor}, + {4, axes_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), num_of_outputs); EXPECT_EQ(output_shapes.front(), StaticShape({10, 3, 0, 4, max_d, max_d, 3})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_batch_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_batch_shape_inference_test.cpp index fd6969e0622..7fad4a0c467 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_batch_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_batch_shape_inference_test.cpp @@ -35,13 +35,12 @@ TEST_F(SpaceToBatchV1StaticShapeInferenceTest, default_ctor) { int32_t pads_begin_val[] = {0, 2, 0, 0, 0}; int32_t pads_end_val[] = {0, 2, 1, 0, 0}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}, - {2, std::make_shared(element::i32, Shape{5}, pads_begin_val)}, - {3, std::make_shared(element::i32, Shape{5}, pads_end_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}, + {2, {element::i32, Shape{5}, pads_begin_val}}, + {3, {element::i32, Shape{5}, pads_end_val}}}; input_shapes = {{2, 32, 64, 128, 256}, {5}, {5}, {5}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2 * 6 * 5 * 16, (32 + 2 + 2) / 6, (64 + 1) / 5, 128, 256 / 16})); } @@ -55,7 +54,7 @@ TEST_F(SpaceToBatchV1StaticShapeInferenceTest, blocks_pads_as_constants) { const auto op = make_op(data, block_shape, pads_begin, pads_end); input_shapes = {{2, 100, 1024, 3}, {4}, {4}, {4}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes[0], (StaticShape{2 * 12 * 100 * 2, (100 + 3 + 5) / 12, (1024 + 38 + 38) / 100, (3 + 1) / 2})); @@ -68,13 +67,12 @@ TEST_F(SpaceToBatchV1StaticShapeInferenceTest, blocks_pads_in_constant_map) { int32_t pads_begin_val[] = {0, 2, 0, 0, 0}; int32_t pads_end_val[] = {0, 2, 1, 0, 0}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}, - {2, std::make_shared(element::i32, Shape{5}, pads_begin_val)}, - {3, std::make_shared(element::i32, Shape{5}, pads_end_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}, + {2, {element::i32, Shape{5}, pads_begin_val}}, + {3, {element::i32, Shape{5}, pads_end_val}}}; input_shapes = {{2, 32, 64, 128, 256}, {5}, {5}, {5}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{2 * 6 * 5 * 16, (32 + 2 + 2) / 6, (64 + 1) / 5, 128, 256 / 16})); } @@ -83,17 +81,16 @@ TEST_F(SpaceToBatchV1StaticShapeInferenceTest, throw_no_data_const_map) { const auto op = make_space_to_batch_dynamic(); input_shapes = {{2, 32, 64, 128, 256}, {5}, {5}, {5}}; - EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), NodeValidationFailure); + EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure); } TEST_F(SpaceToBatchV1StaticShapeInferenceTest, exception_missing_pads_data_in_const_map) { const auto op = make_space_to_batch_dynamic(); int32_t block_val[] = {1, 6, 5, 1, 16}; - const auto constant_data = - std::map{{1, std::make_shared(element::i32, Shape{5}, block_val)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{5}, block_val}}}; input_shapes = {{2, 32, 64, 128, 256}, {5}, {5}, {5}}; - EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), NodeValidationFailure); + EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_depth_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_depth_shape_inference_test.cpp index da8851751ee..b65397e0c2a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_depth_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/space_to_depth_shape_inference_test.cpp @@ -24,7 +24,7 @@ TEST_F(SpaceToDepthV0StaticShapeInferenceTest, default_ctor) { op->set_block_size(2); input_shapes = {StaticShape{1, 12, 4, 1080, 1616}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{1, 12 * 8, 4 / 2, 1080 / 2, 1616 / 2})); @@ -35,7 +35,7 @@ TEST_F(SpaceToDepthV0StaticShapeInferenceTest, depth_first_block_2) { const auto op = make_op(data, op_type::SpaceToDepthMode::DEPTH_FIRST, 2); input_shapes = {StaticShape{1, 12, 4, 1080, 1616}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 1); EXPECT_EQ(output_shapes[0], (StaticShape{1, 12 * 8, 4 / 2, 1080 / 2, 1616 / 2})); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/split_shape_inference_tests.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/split_shape_inference_tests.cpp index acbe99c6095..ccec0099e9a 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/split_shape_inference_tests.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/split_shape_inference_tests.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gmock/gmock.h" +#include + #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/split.hpp" @@ -58,7 +59,7 @@ TEST_P(SplitStaticShapeInferenceTest, shape_inference_empty_const_map) { const auto axis_node = std::make_shared(element::i64, Shape{}, axis); op = make_op(arg, axis_node, num_of_splits); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), num_of_splits); EXPECT_THAT(output_shapes, Each(exp_shape)); @@ -68,11 +69,10 @@ TEST_P(SplitStaticShapeInferenceTest, shape_inference_with_const_map) { const auto axis_node = std::make_shared(element::i64, Shape{}); op = make_op(arg, axis_node, num_of_splits); - const auto axis_const = std::make_shared(element::i64, ov::Shape{}, axis); - const auto axis_tensor = std::make_shared(axis_const); - const std::map>& constant_data = {{1, axis_tensor}}; + const auto axis_tensor = ov::Tensor(element::i64, ov::Shape{}, &axis); + const auto constant_data = std::unordered_map{{1, axis_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); ASSERT_EQ(output_shapes.front(), exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp index 72662af0cc8..bd42a19aa70 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/squeeze_shape_inference_test.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/squeeze.hpp" @@ -28,7 +29,7 @@ TEST_F(SqueezeStaticShapeInferenceAssertTest, no_axes) { input_shapes = ShapeVector{{5, 6}, axes->get_shape()}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Check 'constant != nullptr'")); } @@ -40,7 +41,7 @@ TEST_F(SqueezeStaticShapeInferenceAssertTest, parameter_static_shape_axes_no_dat input_shapes = ShapeVector{arg->get_shape(), axes->get_shape()}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Check 'constant != nullptr'")); } @@ -100,7 +101,7 @@ TEST_P(SqueezeStaticShapeInferenceTest, shape_inference_empty_const_map) { const auto axes_node = std::make_shared(element::i64, Shape{axes.size()}, axes); const auto op = make_op(arg, axes_node); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes.front(), exp_shape); } @@ -109,11 +110,11 @@ TEST_P(SqueezeStaticShapeInferenceTest, shape_inference_with_const_map) { const auto axes_node = std::make_shared(element::i64, Shape{1}); const auto op = make_op(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map>& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = axes.empty() ? ov::Tensor(element::i64, ov::Shape{axes.size()}) + : ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const auto constant_data = std::unordered_map{{1, axes_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); ASSERT_EQ(output_shapes.front(), exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/strided_slice_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/strided_slice_shape_inference_test.cpp index edcff1d0a85..6dda651db4d 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/strided_slice_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/strided_slice_shape_inference_test.cpp @@ -1,6 +1,7 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // +#include #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" @@ -28,12 +29,12 @@ TEST_F(StridedSliceStaticShapeInferenceTest, reverse_stride_begin_end_clip_to_di const auto op = make_op(data, begin, end, stride, mask, mask); - check_static_shape(op.get(), - {StaticShape{3, 4, 5}, StaticShape{3}, StaticShape{3}, StaticShape{3}}, - {StaticShape{3, 4, 5}}); + input_shapes = ShapeVector{{3, 4, 5}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{3, 4, 5})); } -TEST_F(StridedSliceStaticShapeInferenceTest, use_begin_end) { +TEST_F(StridedSliceStaticShapeInferenceTest, use_begin_end_variant_1) { const auto mask = std::vector(4, 0); const auto data = std::make_shared(element::f32, ov::PartialShape::dynamic()); @@ -43,11 +44,60 @@ TEST_F(StridedSliceStaticShapeInferenceTest, use_begin_end) { const auto op = make_op(data, begin, end, stride, mask, mask); - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {1, 0, 0}, {2, 1, 3}, {1, 1, 1}}, {StaticShape{1, 1, 3}}); + int64_t begin_v[] = {1, 0, 0}; + int64_t end_v[] = {2, 1, 3}; + int64_t stride_v[] = {1, 1, 1}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {1, 0, 0}, {2, 2, 3}, {1, 1, 1}}, {StaticShape{1, 2, 3}}); + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1, 1, 3})); +} - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {2, 0, 0}, {3, 2, 3}, {1, 1, 2}}, {StaticShape{1, 2, 2}}); +TEST_F(StridedSliceStaticShapeInferenceTest, use_begin_end_variant_2) { + const auto mask = std::vector(4, 0); + + const auto data = std::make_shared(element::f32, ov::PartialShape::dynamic()); + const auto begin = std::make_shared(element::i64, Shape{3}); + const auto end = std::make_shared(element::i64, Shape{3}); + const auto stride = std::make_shared(element::i64, Shape{3}); + + const auto op = make_op(data, begin, end, stride, mask, mask); + + int64_t begin_v[] = {1, 0, 0}; + int64_t end_v[] = {2, 2, 3}; + int64_t stride_v[] = {1, 1, 1}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); + + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1, 2, 3})); +} + +TEST_F(StridedSliceStaticShapeInferenceTest, use_begin_end_variant_3) { + const auto mask = std::vector(4, 0); + + const auto data = std::make_shared(element::f32, ov::PartialShape::dynamic()); + const auto begin = std::make_shared(element::i64, Shape{3}); + const auto end = std::make_shared(element::i64, Shape{3}); + const auto stride = std::make_shared(element::i64, Shape{3}); + + const auto op = make_op(data, begin, end, stride, mask, mask); + + int64_t begin_v[] = {2, 0, 0}; + int64_t end_v[] = {3, 2, 3}; + int64_t stride_v[] = {1, 1, 2}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); + + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1, 2, 2})); } TEST_F(StridedSliceStaticShapeInferenceTest, ignore_begin_end) { @@ -61,7 +111,16 @@ TEST_F(StridedSliceStaticShapeInferenceTest, ignore_begin_end) { const auto op = make_op(data, begin, end, stride, begin_mask, end_mask); - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {1, 0, 0}, {0, 0, 0}, {1, 1, 1}}, {StaticShape{2, 2, 3}}); + int64_t begin_v[] = {1, 0, 0}; + int64_t end_v[] = {0, 0, 0}; + int64_t stride_v[] = {1, 1, 1}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); + + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{2, 2, 3})); } TEST_F(StridedSliceStaticShapeInferenceTest, ignore_begin_end_stride_by_two_last_dim) { @@ -75,7 +134,16 @@ TEST_F(StridedSliceStaticShapeInferenceTest, ignore_begin_end_stride_by_two_last auto op = make_op(data, begin, end, stride, begin_mask, end_mask); - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {0, 1, 0}, {2, 0, 0}, {1, 1, 2}}, {StaticShape{2, 1, 2}}); + int64_t begin_v[] = {0, 1, 0}; + int64_t end_v[] = {2, 0, 0}; + int64_t stride_v[] = {1, 1, 2}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); + + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{2, 1, 2})); } TEST_F(StridedSliceStaticShapeInferenceTest, use_reverse_stride_on_last_dimension) { @@ -88,7 +156,16 @@ TEST_F(StridedSliceStaticShapeInferenceTest, use_reverse_stride_on_last_dimensio const auto op = make_op(data, begin, end, stride, mask, mask); - check_static_shape(op.get(), {StaticShape{3, 2, 3}, {0, 0, 0}, {1, 0, 0}, {1, 1, -1}}, {StaticShape{1, 2, 3}}); + int64_t begin_v[] = {0, 0, 0}; + int64_t end_v[] = {1, 0, 0}; + int64_t stride_v[] = {1, 1, -1}; + const auto const_data = std::unordered_map{{1, {element::i64, ov::Shape{3}, begin_v}}, + {2, {element::i64, ov::Shape{3}, end_v}}, + {3, {element::i64, ov::Shape{3}, stride_v}}}; + input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}, {3}}; + output_shapes = shape_inference(op.get(), input_shapes, const_data); + + EXPECT_THAT(output_shapes, ElementsAre(StaticShape{1, 2, 3})); } TEST_F(StridedSliceStaticShapeInferenceTest, default_stride) { @@ -101,7 +178,7 @@ TEST_F(StridedSliceStaticShapeInferenceTest, default_stride) { input_shapes = ShapeVector{{3, 2, 3}, {3}, {3}}; - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes.front(), StaticShape({1, 2, 2})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/tile_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/tile_shape_inference_test.cpp index 1b793c9133b..8b232bb7deb 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/tile_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/tile_shape_inference_test.cpp @@ -14,15 +14,13 @@ TEST(StaticShapeInferenceTest, TileTest) { auto param1 = std::make_shared(element::i64, ov::Shape{3}, std::vector{3, 4, 1}); auto tile = std::make_shared(param0, param1); // Test Static Shape - std::vector static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(tile.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{3}}; + const auto static_output_shapes = shape_inference(tile.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({18, 32, 10})); // Test Wrong Static Shape - std::vector wrong_static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{}}, - wrong_static_output_shapes = {StaticShape{}}; + std::vector wrong_static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{}}; - ASSERT_THROW(shape_inference(tile.get(), wrong_static_input_shapes, wrong_static_output_shapes), ov::AssertFailure); + ASSERT_THROW(shape_inference(tile.get(), wrong_static_input_shapes), ov::AssertFailure); } TEST(StaticShapeInferenceTest, TileFewRepeatsTest) { @@ -30,9 +28,8 @@ TEST(StaticShapeInferenceTest, TileFewRepeatsTest) { auto param1 = ov::op::v0::Constant::create(element::i64, Shape{2}, {4, 1}); auto tile = std::make_shared(param0, param1); // Test Static Shape - std::vector static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{2}}, - static_output_shapes = {StaticShape{}}; - shape_inference(tile.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{6, 8, 10}, StaticShape{2}}; + const auto static_output_shapes = shape_inference(tile.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({6, 32, 10})); } @@ -41,9 +38,8 @@ TEST(StaticShapeInferenceTest, TileSmallDataRankTest) { auto param1 = ov::op::v0::Constant::create(element::i64, Shape{3}, {3, 4, 1}); auto tile = std::make_shared(param0, param1); // Test Static Shape - std::vector static_input_shapes = {StaticShape{8, 10}, StaticShape{3}}, - static_output_shapes = {StaticShape{}}; - shape_inference(tile.get(), static_input_shapes, static_output_shapes); + std::vector static_input_shapes = {StaticShape{8, 10}, StaticShape{3}}; + const auto static_output_shapes = shape_inference(tile.get(), static_input_shapes); ASSERT_EQ(static_output_shapes[0], StaticShape({3, 32, 10})); } @@ -53,12 +49,11 @@ TEST(StaticShapeInferenceTest, TileSmallDataRankTestRepeatsInConstMap) { auto tile = std::make_shared(param0, param1); int32_t repeats[] = {3, 4, 1}; - const std::map>& constant_data = { - {1, std::make_shared(element::i32, Shape{3}, repeats)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{3}, repeats}}}; // Test Static Shape ShapeVector input_shapes = {StaticShape{8, 10}, StaticShape{3}}, output_shapes = {StaticShape{}}; - shape_inference(tile.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(tile.get(), input_shapes, constant_data); ASSERT_EQ(output_shapes.front(), StaticShape({3, 32, 10})); } @@ -86,8 +81,7 @@ TEST(StaticShapeInferenceTest, TileNewApiInputsStaticRank) { auto tile = std::make_shared(param0, param1); int32_t repeats[] = {3, 4, 1, 2}; - const std::map>& constant_data = { - {1, std::make_shared(element::i32, Shape{4}, repeats)}}; + const auto constant_data = std::unordered_map{{1, {element::i32, Shape{4}, repeats}}}; auto dims = std::vector{{8, 10}, {4}}; auto in_shapes = std::vector(dims.begin(), dims.end()); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/topk_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/topk_shape_inference_test.cpp index 7ef0658cb28..9f1ed780153 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/topk_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/topk_shape_inference_test.cpp @@ -2,8 +2,9 @@ // SPDX-License-Identifier: Apache-2.0 // +#include + #include "common_test_utils/test_assertions.hpp" -#include "gmock/gmock.h" #include "openvino/opsets/opset10.hpp" #include "topk_shape_inference.hpp" #include "utils.hpp" @@ -46,10 +47,9 @@ TEST_F(TopKV1AssertStaticShapeInferenceTest, k_is_negative) { output_shapes = ShapeVector(2); int64_t k = -2; - const auto const_map = - std::map{{1, std::make_shared(element::i64, Shape{}, &k)}}; + const auto const_map = std::unordered_map{{1, {element::i64, Shape{}, &k}}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_map), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_map), ov::AssertFailure, HasSubstr("The value of 'K' must be greater or equal to zero. (got " + std::to_string(k) + ")")); } @@ -63,7 +63,7 @@ TEST_P(TopKV1Test, no_constant_map) { const auto op = make_op(data, k_node, axis, "max", "value"); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(exp_shape)); @@ -75,7 +75,7 @@ TEST_P(TopKV1Test, k_as_param_no_const_map) { const auto op = make_op(data, k_node, axis, "min", "value"); - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Static shape inference lacks constant data on port 1")); } @@ -84,12 +84,11 @@ TEST_P(TopKV1Test, k_as_param_in_const_map) { const auto data = std::make_shared(element::f32, PartialShape::dynamic()); const auto k_node = std::make_shared(element::i64, PartialShape::dynamic()); - const auto const_map = - std::map{{1, std::make_shared(element::i64, Shape{}, &k)}}; + const auto const_map = std::unordered_map{{1, {element::i64, Shape{}, &k}}}; const auto op = make_op(data, k_node, axis, "min", "value"); - shape_inference(op.get(), input_shapes, output_shapes, const_map); + output_shapes = shape_inference(op.get(), input_shapes, const_map); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(exp_shape)); @@ -109,10 +108,9 @@ TEST_F(TopKV3AssertStaticShapeInferenceTest, k_is_negative) { output_shapes = ShapeVector(2); int64_t k = -2; - const auto const_map = - std::map{{1, std::make_shared(element::i64, Shape{}, &k)}}; + const auto const_map = std::unordered_map{{1, {element::i64, Shape{}, &k}}}; - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes, const_map), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, const_map), ov::AssertFailure, HasSubstr("The value of 'K' must be greater or equal to zero. (got " + std::to_string(k) + ")")); } @@ -126,7 +124,7 @@ TEST_P(TopKV3Test, k_as_constant) { const auto op = make_op(data, k_node, axis, "min", "value"); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(exp_shape)); @@ -138,7 +136,7 @@ TEST_P(TopKV3Test, k_as_param_no_const_map) { const auto op = make_op(data, k_node, axis, "min", "value"); - OV_EXPECT_THROW(shape_inference(op.get(), input_shapes, output_shapes), + OV_EXPECT_THROW(shape_inference(op.get(), input_shapes), NodeValidationFailure, HasSubstr("Static shape inference lacks constant data on port 1")); } @@ -147,12 +145,11 @@ TEST_P(TopKV3Test, k_as_param_in_const_map) { const auto data = std::make_shared(element::f32, PartialShape::dynamic()); const auto k_node = std::make_shared(element::i64, PartialShape::dynamic()); - const auto const_map = - std::map{{1, std::make_shared(element::i64, Shape{}, &k)}}; + const auto const_map = std::unordered_map{{1, {element::i64, Shape{}, &k}}}; const auto op = make_op(data, k_node, axis, "max", "value"); - shape_inference(op.get(), input_shapes, output_shapes, const_map); + output_shapes = shape_inference(op.get(), input_shapes, const_map); EXPECT_EQ(output_shapes.size(), 2); EXPECT_THAT(output_shapes, Each(exp_shape)); diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/transpose_shape_infernece_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/transpose_shape_infernece_test.cpp index b905d641d01..4461ab3e7b8 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/transpose_shape_infernece_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/transpose_shape_infernece_test.cpp @@ -68,9 +68,7 @@ INSTANTIATE_TEST_SUITE_P( /** \brief Check shape_infer for transpose on static shapes. */ TEST_P(StaticShapeInferenceTest, transpose_static) { - auto output_shapes = std::vector{StaticShape{}}; - - shape_inference(transpose.get(), {input_shape, transpose_order}, output_shapes); + auto output_shapes = shape_inference(transpose.get(), {input_shape, transpose_order}); ASSERT_EQ(output_shapes[op::v1::Transpose::ARG_T], exp_shape); } @@ -81,9 +79,7 @@ TEST(StaticShapeInferenceTest, transpose_input_shape_dim_dynamic) { const auto order = std::vector{1, 2, 0}; const auto transpose = make_transpose(input_shape, order); - auto output_shapes = std::vector{StaticShape{}}; - - shape_inference(transpose.get(), {StaticShape{2, 6, 3}, order}, output_shapes); + auto output_shapes = shape_inference(transpose.get(), {StaticShape{2, 6, 3}, order}); ASSERT_EQ(output_shapes[op::v1::Transpose::ARG_T], StaticShape({6, 3, 2})); } @@ -95,13 +91,12 @@ TEST(StaticShapeInferenceTest, transpose_order_in_constant_map) { const auto transpose = std::make_shared(input, order); - const auto axes_order = std::vector{1, 2, 0, 3}; - const auto axes = std::make_shared(element::i64, ov::Shape{axes_order.size()}, axes_order); - const auto const_tensor = std::make_shared(axes); - const std::map> const_map = {{1, const_tensor}}; + auto axes_order = std::vector{1, 2, 0, 3}; + const auto const_tensor = ov::Tensor(element::i64, ov::Shape{axes_order.size()}, axes_order.data()); + const std::unordered_map const_map = {{1, const_tensor}}; auto output_shapes = std::vector{StaticShape{}}; - shape_inference(transpose.get(), {StaticShape({2, 4, 6, 8}), StaticShape()}, output_shapes, const_map); + output_shapes = shape_inference(transpose.get(), {StaticShape({2, 4, 6, 8}), StaticShape()}, const_map); ASSERT_EQ(output_shapes[op::v1::Transpose::ARG_T], StaticShape({4, 6, 2, 8})); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/unsqueeze_shape_inference_test.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/unsqueeze_shape_inference_test.cpp index 83ec4002797..fbb086f93be 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/unsqueeze_shape_inference_test.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/unsqueeze_shape_inference_test.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gmock/gmock.h" +#include + #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/unsqueeze.hpp" @@ -28,7 +29,7 @@ TEST_F(UnsqueezeStaticShapeInferenceAssertTest, no_axes) { input_shapes = ShapeVector{{5, 6}, axes->get_shape()}; try { - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); FAIL() << "Axes nullptr not detected"; } catch (const NodeValidationFailure& error) { EXPECT_THAT(error.what(), HasSubstr("Check 'constant != nullptr'")); @@ -111,7 +112,7 @@ TEST_P(UnsqueezeStaticShapeInferenceTest, shape_inference_empty_const_map) { const auto axes_node = std::make_shared(element::i64, Shape{axes.size()}, axes); op = std::make_shared(arg, axes_node); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); ASSERT_EQ(output_shapes.front(), exp_shape); } @@ -120,11 +121,10 @@ TEST_P(UnsqueezeStaticShapeInferenceTest, shape_inference_with_const_map) { const auto axes_node = std::make_shared(element::i64, Shape{1}); op = std::make_shared(arg, axes_node); - const auto axes_const = std::make_shared(element::i64, ov::Shape{axes.size()}, axes); - const auto axes_tensor = std::make_shared(axes_const); - const std::map>& constant_data = {{1, axes_tensor}}; + const auto axes_tensor = ov::Tensor(element::i64, ov::Shape{axes.size()}, axes.data()); + const auto constant_data = std::unordered_map{{1, axes_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); ASSERT_EQ(output_shapes.front(), exp_shape); } diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.cpp new file mode 100644 index 00000000000..ccc4b1898e5 --- /dev/null +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "utils.hpp" + +namespace ov { +namespace intel_cpu { +std::vector make_static_shape_refs(const ShapeVector& shapes) { + std::vector out; + out.reserve(shapes.size()); + for (auto& s : shapes) { + out.emplace_back(s); + } + return out; +} + +ShapeVector shape_inference(ov::Node* op, + const ShapeVector& input_shapes, + const std::unordered_map& constant_data) { + const auto in_shapes = intel_cpu::make_static_shape_refs(input_shapes); + const auto shape_infer = intel_cpu::make_shape_inference(op->shared_from_this()); + auto result = shape_infer->infer(in_shapes, make_tensor_accessor(constant_data)); + OPENVINO_ASSERT(result, "There are no output shapes in shape inference result"); + return *result; +} +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.hpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.hpp index a7cf2cbd62c..0cbe8685af7 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.hpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/utils.hpp @@ -10,114 +10,16 @@ #include "shape_inference/shape_inference.hpp" #include "shape_inference/static_shape.hpp" -using ShapeVector = std::vector; namespace ov { namespace intel_cpu { -namespace { -std::vector make_static_shape_refs(const ShapeVector& shapes) { - std::vector out; - out.reserve(shapes.size()); - for (auto& s : shapes) { - out.emplace_back(s); - } - return out; -} -} // namespace -template -void shape_inference(ov::Node* op, - const std::vector& input_shapes, - std::vector& output_shapes, - const std::map& constant_data = {}) { - const auto in_shapes = make_static_shape_refs(input_shapes); - const auto shape_infer = make_shape_inference(op->shared_from_this()); - auto result = shape_infer->infer(in_shapes, ov::make_tensor_accessor(constant_data)); - OPENVINO_ASSERT(result, "There are no output shapes in shape inference result"); - output_shapes = std::move(*result); -} +using ShapeVector = std::vector; -template > -ShapeVector shape_inference(ov::Node* op, const ShapeVector& input_shapes, const T& constant_data = T{}) { - const auto in_shapes = intel_cpu::make_static_shape_refs(input_shapes); - const auto shape_infer = intel_cpu::make_shape_inference(op->shared_from_this()); - auto result = shape_infer->infer(in_shapes, make_tensor_accessor(constant_data)); - OPENVINO_ASSERT(result, "There are no output shapes in shape inference result"); - return *result; -} -} // namespace intel_cpu -} // namespace ov +std::vector make_static_shape_refs(const ShapeVector& shapes); -struct TestTensor { - std::shared_ptr tensor; - ov::intel_cpu::StaticShape static_shape; - - template - TestTensor(std::initializer_list values) : TestTensor(ov::intel_cpu::StaticShape({values.size()}), values) {} - - template - TestTensor(T scalar) : TestTensor(ov::intel_cpu::StaticShape({}), {scalar}) {} - - TestTensor(ov::intel_cpu::StaticShape shape) : static_shape(shape) {} - - template - TestTensor(ov::intel_cpu::StaticShape shape, std::initializer_list values) { - static_shape = shape; - - ov::Shape s; - for (auto dim : shape) - s.push_back(dim); - - if (values.size() > 0) { - tensor = std::make_shared(ov::element::from(), s); - T* ptr = tensor->get_data_ptr(); - int i = 0; - for (auto& v : values) - ptr[i++] = v; - } - } -}; - -// TestTensor can be constructed from initializer_list/int64_t/Shape/Shape+initializer_list -// so each element of inputs can be: -// {1,2,3,4} tensor of shape [4] and values (1,2,3,4) -// 2 tensor of scalar with value 2 -// Shape{2,2} tensor of shape [2,2] and value unknown -// {Shape{2,2}, {1,2,3,4}} tensor of shape [2,2] and values (1,2,3,4) -inline void check_static_shape(ov::Node* op, - std::initializer_list inputs, - std::initializer_list expect_shapes) { - std::vector output_shapes; - std::vector input_shapes; - std::map> constData; - - int index = 0; - std::for_each(inputs.begin(), inputs.end(), [&](TestTensor t) { - input_shapes.push_back(t.static_shape); - if (t.tensor) - constData[index] = t.tensor; - index++; - }); - - output_shapes.resize(expect_shapes.size(), ov::intel_cpu::StaticShape{}); - - shape_inference(op, input_shapes, output_shapes, constData); - - EXPECT_EQ(output_shapes.size(), expect_shapes.size()); - int id = 0; - for (auto& shape : expect_shapes) { - EXPECT_EQ(output_shapes[id], shape); - id++; - } -} - -inline void check_output_shape(ov::Node* op, std::initializer_list expect_shapes) { - int id = 0; - EXPECT_EQ(op->outputs().size(), expect_shapes.size()); - for (auto& shape : expect_shapes) { - EXPECT_EQ(op->get_output_partial_shape(id), shape); - id++; - } -} +ShapeVector shape_inference(ov::Node* op, + const ShapeVector& input_shapes, + const std::unordered_map& constant_data = {}); template class OpStaticShapeInferenceTest : public testing::Test { @@ -133,3 +35,6 @@ protected: return std::make_shared(std::forward(args)...); } }; + +} // namespace intel_cpu +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/unit/shape_inference_test/variadic_split_shape_inference_tests.cpp b/src/plugins/intel_cpu/tests/unit/shape_inference_test/variadic_split_shape_inference_tests.cpp index a8840bc3838..d8c5b95f5d3 100644 --- a/src/plugins/intel_cpu/tests/unit/shape_inference_test/variadic_split_shape_inference_tests.cpp +++ b/src/plugins/intel_cpu/tests/unit/shape_inference_test/variadic_split_shape_inference_tests.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "gmock/gmock.h" +#include + #include "openvino/op/constant.hpp" #include "openvino/op/parameter.hpp" #include "openvino/op/variadic_split.hpp" @@ -74,7 +75,7 @@ TEST_P(VariadicSplitStaticShapeInferenceTest, shape_inference_empty_const_map) { std::make_shared(element::i64, Shape{split_lengths.size()}, split_lengths); op = make_op(data, axis_node, split_len_node); - shape_inference(op.get(), input_shapes, output_shapes); + output_shapes = shape_inference(op.get(), input_shapes); EXPECT_EQ(output_shapes.size(), split_lengths.size()); EXPECT_EQ(output_shapes, exp_shapes); @@ -86,11 +87,10 @@ TEST_P(VariadicSplitStaticShapeInferenceTest, shape_inference_axis_in_const_map) std::make_shared(element::i64, Shape{split_lengths.size()}, split_lengths); op = make_op(data, axis_node, split_len_node); - const auto axis_const = std::make_shared(element::i64, ov::Shape{}, axis); - const auto axis_tensor = std::make_shared(axis_const); - const std::map>& constant_data = {{1, axis_tensor}}; + const auto axis_tensor = ov::Tensor(element::i64, ov::Shape{}, &axis); + const auto constant_data = std::unordered_map{{1, axis_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), split_lengths.size()); EXPECT_EQ(output_shapes, exp_shapes); @@ -101,16 +101,12 @@ TEST_P(VariadicSplitStaticShapeInferenceTest, shape_inference_all_const_in_map) const auto split_len_node = std::make_shared(element::i64, ov::PartialShape::dynamic()); op = make_op(data, axis_node, split_len_node); - const auto axis_const = std::make_shared(element::i64, Shape{}, axis); - const auto axis_tensor = std::make_shared(axis_const); - const auto split_len_const = - std::make_shared(element::i64, Shape{split_lengths.size()}, split_lengths); - const auto split_len_tensor = std::make_shared(split_len_const); + const auto axis_tensor = ov::Tensor(element::i64, Shape{}, &axis); + const auto split_len_tensor = ov::Tensor(element::i64, Shape{split_lengths.size()}, split_lengths.data()); - const std::map>& constant_data = {{2, split_len_tensor}, - {1, axis_tensor}}; + const auto constant_data = std::unordered_map{{2, split_len_tensor}, {1, axis_tensor}}; - shape_inference(op.get(), input_shapes, output_shapes, constant_data); + output_shapes = shape_inference(op.get(), input_shapes, constant_data); EXPECT_EQ(output_shapes.size(), split_lengths.size()); EXPECT_EQ(output_shapes, exp_shapes);