diff --git a/src/core/src/op/non_max_suppression.cpp b/src/core/src/op/non_max_suppression.cpp index 19d923019ac..c583b6edfab 100644 --- a/src/core/src/op/non_max_suppression.cpp +++ b/src/core/src/op/non_max_suppression.cpp @@ -805,15 +805,12 @@ void op::v5::NonMaxSuppression::validate_and_infer_types() { validate(); if (boxes_ps.rank().is_static() && scores_ps.rank().is_static() && get_input_size() > 2) { - const auto num_boxes_boxes = boxes_ps[1]; - if (num_boxes_boxes.is_static() && scores_ps[0].is_static() && scores_ps[1].is_static() && - has_and_set_equal_bounds(input_value(2))) { - const auto num_boxes = num_boxes_boxes.get_length(); - const auto num_classes = scores_ps[1].get_length(); + const auto num_boxes = boxes_ps[1].get_max_length(); + const auto num_classes = scores_ps[1].get_max_length(); + const auto batch = scores_ps[0].get_max_length(); + if (num_boxes != -1 && batch != -1 && num_classes != -1 && has_and_set_equal_bounds(input_value(2))) { const auto max_output_boxes_per_class = max_boxes_output_from_input(); - - out_shape[0] = - Dimension(0, std::min(num_boxes, max_output_boxes_per_class) * num_classes * scores_ps[0].get_length()); + out_shape[0] = Dimension(0, std::min(num_boxes, max_output_boxes_per_class) * num_classes * batch); } } diff --git a/src/core/tests/type_prop/non_max_suppression.cpp b/src/core/tests/type_prop/non_max_suppression.cpp index b7e23761a5c..69ed59caab7 100644 --- a/src/core/tests/type_prop/non_max_suppression.cpp +++ b/src/core/tests/type_prop/non_max_suppression.cpp @@ -595,6 +595,27 @@ TEST(type_prop, nms_v5_output_shape_3) { EXPECT_EQ(nms->get_output_shape(2), (Shape{1})); } +TEST(type_prop, nms_v5_output_shape_4) { + const auto boxes = make_shared(element::f32, PartialShape{{0, 2}, {0, 7}, 4}); + const auto scores = make_shared(element::f32, PartialShape{{0, 2}, {0, 5}, {0, 7}}); + const auto max_output_boxes_per_class = op::Constant::create(element::i16, Shape{}, {1000}); + const auto iou_threshold = make_shared(element::f32, Shape{}); + const auto score_threshold = make_shared(element::f32, Shape{}); + + const auto nms = make_shared(boxes, + scores, + max_output_boxes_per_class, + iou_threshold, + score_threshold); + + ASSERT_EQ(nms->get_output_element_type(0), element::i64); + ASSERT_EQ(nms->get_output_element_type(1), element::f32); + ASSERT_EQ(nms->get_output_element_type(2), element::i64); + EXPECT_EQ(nms->get_output_partial_shape(0), PartialShape({Dimension(0, 70), Dimension(3)})); + EXPECT_EQ(nms->get_output_partial_shape(1), PartialShape({Dimension(0, 70), Dimension(3)})); + EXPECT_EQ(nms->get_output_shape(2), (Shape{1})); +} + TEST(type_prop, nms_v5_output_shape_i32) { const auto boxes = make_shared(element::f32, Shape{2, 7, 4}); const auto scores = make_shared(element::f32, Shape{2, 5, 7}); diff --git a/src/inference/src/cnn_network_ngraph_impl.cpp b/src/inference/src/cnn_network_ngraph_impl.cpp index 46ad025933d..85572d8787e 100644 --- a/src/inference/src/cnn_network_ngraph_impl.cpp +++ b/src/inference/src/cnn_network_ngraph_impl.cpp @@ -423,7 +423,7 @@ void collect_dynamism_signature(const std::shared_ptr& ov_model, std::map>& signatures, bool obfuscate) { for (const auto& op : ov_model->get_ordered_ops()) { - const auto& type_name = string(op->get_type_info().name) + "_" + to_string(op->get_type_info().version); + const auto& type_name = string(op->get_type_info().name) + "_" + op->get_type_info().version_id; std::stringstream shape_representation; for (const auto& input : op->input_values()) {