diff --git a/ngraph/core/src/op/experimental_detectron_detection_output.cpp b/ngraph/core/src/op/experimental_detectron_detection_output.cpp index 87f4df82c44..b51d282f434 100644 --- a/ngraph/core/src/op/experimental_detectron_detection_output.cpp +++ b/ngraph/core/src/op/experimental_detectron_detection_output.cpp @@ -64,7 +64,7 @@ void op::v6::ExperimentalDetectronDetectionOutput::validate_and_infer_types() this, rois_shape.rank().get_length() == 2, "Input rois rank must be equal to 2."); NODE_VALIDATION_CHECK(this, - rois_shape[1].is_static() && rois_shape[1].get_length() == 4u, + rois_shape[1].is_dynamic() || rois_shape[1].get_length() == 4u, "The last dimension of the 'input_rois' input must be equal to 4. " "Got: ", rois_shape[1]); @@ -75,14 +75,12 @@ void op::v6::ExperimentalDetectronDetectionOutput::validate_and_infer_types() NODE_VALIDATION_CHECK( this, deltas_shape.rank().get_length() == 2, "Input deltas rank must be equal to 2."); - if (deltas_shape[1].is_static()) - { - NODE_VALIDATION_CHECK(this, + NODE_VALIDATION_CHECK(this, + deltas_shape[1].is_dynamic() || deltas_shape[1].get_length() == m_attrs.num_classes * 4, - "The last dimension of the 'input_deltas' input must be equal to " - "the value of the attribute 'num_classes' * 4. Got: ", - deltas_shape[1]); - } + "The last dimension of the 'input_deltas' input must be equal to " + "the value of the attribute 'num_classes' * 4. Got: ", + deltas_shape[1]); } if (scores_shape.rank().is_static()) @@ -90,14 +88,12 @@ void op::v6::ExperimentalDetectronDetectionOutput::validate_and_infer_types() NODE_VALIDATION_CHECK( this, scores_shape.rank().get_length() == 2, "Input scores rank must be equal to 2."); - if (scores_shape[1].is_static()) - { - NODE_VALIDATION_CHECK(this, + NODE_VALIDATION_CHECK(this, + scores_shape[1].is_dynamic() || scores_shape[1].get_length() == m_attrs.num_classes, - "The last dimension of the 'input_scores' input must be equal to " - "the value of the attribute 'num_classes'. Got: ", - scores_shape[1]); - } + "The last dimension of the 'input_scores' input must be equal to " + "the value of the attribute 'num_classes'. Got: ", + scores_shape[1]); } if (im_info_shape.rank().is_static()) diff --git a/ngraph/core/src/op/experimental_detectron_generate_proposals.cpp b/ngraph/core/src/op/experimental_detectron_generate_proposals.cpp index 90a9424cd77..dbece9e0170 100644 --- a/ngraph/core/src/op/experimental_detectron_generate_proposals.cpp +++ b/ngraph/core/src/op/experimental_detectron_generate_proposals.cpp @@ -70,7 +70,7 @@ void op::v6::ExperimentalDetectronGenerateProposalsSingleImage::validate_and_inf im_info_shape); NODE_VALIDATION_CHECK(this, - im_info_shape[0] == 3, + im_info_shape[0].is_dynamic() || im_info_shape[0] == 3, "The 'input_im_info' shape is expected to be a [3]. Got: ", im_info_shape); } @@ -83,7 +83,7 @@ void op::v6::ExperimentalDetectronGenerateProposalsSingleImage::validate_and_inf anchors_shape); NODE_VALIDATION_CHECK(this, - anchors_shape[1] == 4, + anchors_shape[1].is_dynamic() || anchors_shape[1] == 4, "The second dimension of 'input_anchors' should be 4. Got: ", anchors_shape[1]); } @@ -105,14 +105,16 @@ void op::v6::ExperimentalDetectronGenerateProposalsSingleImage::validate_and_inf if (deltas_shape.rank().is_static() && scores_shape.rank().is_static()) { NODE_VALIDATION_CHECK(this, - deltas_shape[1] == scores_shape[1], + deltas_shape[1].is_dynamic() || scores_shape[1].is_dynamic() || + deltas_shape[1] == scores_shape[1], "Heights for inputs 'input_deltas' and 'input_scores' should be " "equal. Got: ", deltas_shape[1], scores_shape[1]); NODE_VALIDATION_CHECK(this, - deltas_shape[2] == scores_shape[2], + deltas_shape[2].is_dynamic() || scores_shape[2].is_dynamic() || + deltas_shape[2] == scores_shape[2], "Width for inputs 'input_deltas' and 'input_scores' should be " "equal. Got: ", deltas_shape[2], diff --git a/ngraph/test/type_prop/experimental_detectron_detection_output.cpp b/ngraph/test/type_prop/experimental_detectron_detection_output.cpp index fe00f7e7cf9..29498ddbdfc 100644 --- a/ngraph/test/type_prop/experimental_detectron_detection_output.cpp +++ b/ngraph/test/type_prop/experimental_detectron_detection_output.cpp @@ -41,6 +41,25 @@ TEST(type_prop, detectron_detection_output) EXPECT_EQ(detection->get_output_shape(0), (Shape{rois_num, 4})); EXPECT_EQ(detection->get_output_shape(1), (Shape{rois_num})); EXPECT_EQ(detection->get_output_shape(2), (Shape{rois_num})); + + + rois = std::make_shared(element::f32, PartialShape::dynamic(2)); + deltas = std::make_shared(element::f32, PartialShape::dynamic(2)); + scores = std::make_shared(element::f32, PartialShape::dynamic(2)); + im_info = std::make_shared(element::f32, PartialShape::dynamic(2)); + + detection = std::make_shared(rois, deltas, scores, im_info, attrs); + + ASSERT_EQ(detection->get_output_element_type(0), element::f32); + ASSERT_EQ(detection->get_output_element_type(1), element::i32); + ASSERT_EQ(detection->get_output_element_type(2), element::f32); + + EXPECT_EQ(detection->get_output_shape(0), (Shape{rois_num, 4})); + EXPECT_EQ(detection->get_output_shape(1), (Shape{rois_num})); + EXPECT_EQ(detection->get_output_shape(2), (Shape{rois_num})); + + + } TEST(type_prop, detectron_detection_output_dynamic_input_shapes) diff --git a/ngraph/test/type_prop/experimental_detectron_generate_proposals.cpp b/ngraph/test/type_prop/experimental_detectron_generate_proposals.cpp index 86afea80b1b..65ff2be2ddc 100644 --- a/ngraph/test/type_prop/experimental_detectron_generate_proposals.cpp +++ b/ngraph/test/type_prop/experimental_detectron_generate_proposals.cpp @@ -35,6 +35,21 @@ TEST(type_prop, detectron_proposals) ASSERT_EQ(proposals->get_output_element_type(1), element::f32); EXPECT_EQ(proposals->get_output_shape(0), (Shape{post_nms_count, 4})); EXPECT_EQ(proposals->get_output_shape(1), (Shape{post_nms_count})); + + im_info = std::make_shared(element::f32, PartialShape::dynamic(1)); + anchors = std::make_shared(element::f32, PartialShape::dynamic(2)); + deltas = std::make_shared(element::f32, PartialShape::dynamic(3)); + scores = std::make_shared(element::f32, PartialShape::dynamic(3)); + + proposals = std::make_shared(im_info, anchors, deltas, scores, attrs); + + ASSERT_EQ(proposals->get_output_element_type(0), element::f32); + ASSERT_EQ(proposals->get_output_element_type(1), element::f32); + EXPECT_EQ(proposals->get_output_shape(0), (Shape{post_nms_count, 4})); + EXPECT_EQ(proposals->get_output_shape(1), (Shape{post_nms_count})); + + + } TEST(type_prop, detectron_proposals_dynamic)