NMS-5 calculate upper-bound (#17332)
* NMS-5 calculate upper-bound * Test
This commit is contained in:
committed by
GitHub
parent
1141e90435
commit
bf829eead4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<op::Parameter>(element::f32, PartialShape{{0, 2}, {0, 7}, 4});
|
||||
const auto scores = make_shared<op::Parameter>(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<op::Parameter>(element::f32, Shape{});
|
||||
const auto score_threshold = make_shared<op::Parameter>(element::f32, Shape{});
|
||||
|
||||
const auto nms = make_shared<op::v5::NonMaxSuppression>(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<op::Parameter>(element::f32, Shape{2, 7, 4});
|
||||
const auto scores = make_shared<op::Parameter>(element::f32, Shape{2, 5, 7});
|
||||
|
||||
@@ -423,7 +423,7 @@ void collect_dynamism_signature(const std::shared_ptr<ov::Model>& ov_model,
|
||||
std::map<std::string, std::map<std::string, size_t>>& 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()) {
|
||||
|
||||
Reference in New Issue
Block a user