ExperimentalDetectron* dynamic shape propagation (#5872)

This commit is contained in:
Evgenya Stepyreva 2021-05-28 12:15:53 +03:00 committed by GitHub
parent d05c3c63b5
commit 749fed6805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 19 deletions

View File

@ -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())

View File

@ -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],

View File

@ -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<op::Parameter>(element::f32, PartialShape::dynamic(2));
deltas = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(2));
scores = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(2));
im_info = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(2));
detection = std::make_shared<ExperimentalDetection>(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)

View File

@ -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<op::Parameter>(element::f32, PartialShape::dynamic(1));
anchors = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(2));
deltas = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(3));
scores = std::make_shared<op::Parameter>(element::f32, PartialShape::dynamic(3));
proposals = std::make_shared<ExperimentalProposals>(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)