From 5aa43d560a6d25350c6eaa2a774cf76ab5b1e575 Mon Sep 17 00:00:00 2001 From: Evgenya Stepyreva Date: Fri, 21 Jan 2022 00:32:04 +0300 Subject: [PATCH] 51145 (#9795) * 51145 - PriorBox dynamic shape propagation * code style --- src/core/src/op/prior_box.cpp | 32 ++++++++++++++------------------ src/core/src/op/roi_pooling.cpp | 4 ++-- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/core/src/op/prior_box.cpp b/src/core/src/op/prior_box.cpp index bc5727417b1..39663714a7b 100644 --- a/src/core/src/op/prior_box.cpp +++ b/src/core/src/op/prior_box.cpp @@ -51,18 +51,16 @@ void op::v0::PriorBox::validate_and_infer_types() { set_input_is_relevant_to_shape(0); - if (auto const_shape = get_constant_from_source(input_value(0))) { + PartialShape spatials; + if (evaluate_as_partial_shape(input_value(0), spatials)) { NODE_VALIDATION_CHECK(this, - shape_size(const_shape->get_shape()) == 2, + spatials.rank().is_static() && spatials.size() == 2, "Layer shape must have rank 2", - const_shape->get_shape()); + spatials); - auto layer_shape = const_shape->get_shape_val(); - - set_output_type( - 0, - element::f32, - ov::Shape{2, 4 * layer_shape[0] * layer_shape[1] * static_cast(number_of_priors(m_attrs))}); + set_output_type(0, + element::f32, + ov::PartialShape{2, spatials[0] * spatials[1] * Dimension(4 * number_of_priors(m_attrs))}); } else { set_output_type(0, element::f32, ov::PartialShape{2, Dimension::dynamic()}); } @@ -243,18 +241,16 @@ void op::v8::PriorBox::validate_and_infer_types() { set_input_is_relevant_to_shape(0); - if (auto const_shape = get_constant_from_source(input_value(0))) { + PartialShape spatials; + if (evaluate_as_partial_shape(input_value(0), spatials)) { NODE_VALIDATION_CHECK(this, - shape_size(const_shape->get_shape()) == 2, + spatials.rank().is_static() && spatials.size() == 2, "Layer shape must have rank 2", - const_shape->get_shape()); + spatials); - auto layer_shape = const_shape->get_shape_val(); - - set_output_type( - 0, - element::f32, - ov::Shape{2, 4 * layer_shape[0] * layer_shape[1] * static_cast(number_of_priors(m_attrs))}); + set_output_type(0, + element::f32, + ov::PartialShape{2, spatials[0] * spatials[1] * Dimension(4 * number_of_priors(m_attrs))}); } else { set_output_type(0, element::f32, ov::PartialShape{2, Dimension::dynamic()}); } diff --git a/src/core/src/op/roi_pooling.cpp b/src/core/src/op/roi_pooling.cpp index ac1df732d2b..fc87763f884 100644 --- a/src/core/src/op/roi_pooling.cpp +++ b/src/core/src/op/roi_pooling.cpp @@ -92,11 +92,11 @@ void op::ROIPooling::validate_and_infer_types() { Dimension{static_cast(m_output_size[0])}, Dimension{static_cast(m_output_size[1])}}}; - if (coords_ps.rank().is_static() && coords_ps[0].is_static()) { + if (coords_ps.rank().is_static()) { output_shape[0] = coords_ps[0]; } - if (feat_maps_ps.rank().is_static() && feat_maps_ps[1].is_static()) { + if (feat_maps_ps.rank().is_static()) { output_shape[1] = feat_maps_ps[1]; }