From ffcb7fab2d96b12b8e30fc1d19cc1b402bc8e24e Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 28 Jul 2020 05:47:43 +0300 Subject: [PATCH] Fixed incorrect logic in detection of result shape for convolution (#1444) * Fixed incorrect logic in detection of result shape for convolution * Added test --- ngraph/src/ngraph/op/convolution.cpp | 8 ++++---- ngraph/test/type_prop/convolution.cpp | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ngraph/src/ngraph/op/convolution.cpp b/ngraph/src/ngraph/op/convolution.cpp index b88668529a1..afd6670eb29 100644 --- a/ngraph/src/ngraph/op/convolution.cpp +++ b/ngraph/src/ngraph/op/convolution.cpp @@ -72,10 +72,10 @@ void op::v1::Convolution::validate_and_infer_types() { result_shape[0] = data_batch_shape[0]; // batch size } - } - if (filters_shape.rank().is_static() && filters_shape.rank().get_length() > 1) - { - result_shape[1] = filters_shape[0]; // filter channel size + if (filters_shape.rank().is_static() && filters_shape.rank().get_length() > 1) + { + result_shape[1] = filters_shape[0]; // filter channel size + } } element::Type result_et; diff --git a/ngraph/test/type_prop/convolution.cpp b/ngraph/test/type_prop/convolution.cpp index 6fe10653320..29fd93ec0d8 100644 --- a/ngraph/test/type_prop/convolution.cpp +++ b/ngraph/test/type_prop/convolution.cpp @@ -2642,6 +2642,27 @@ TEST(type_prop, conv_v1_partial_auto_padding_same_spatial_dims_dynamic) ASSERT_EQ(conv->get_pads_end(), (CoordinateDiff{})); } +TEST(type_prop, conv_v1_partial_data_shape_dynamic) +{ + const PartialShape data_batch_shape{PartialShape::dynamic()}; + const PartialShape filters_shape{1, 1, 3, 3}; + Strides strides{1, 1}; + CoordinateDiff pads_begin{0, 0}; + CoordinateDiff pads_end{0, 0}; + Strides dilations{1, 1}; + const auto auto_pad = op::PadType::SAME_LOWER; + + auto data_batch = make_shared(element::f32, data_batch_shape); + auto filters = make_shared(element::f32, filters_shape); + + auto conv = make_shared( + data_batch, filters, strides, pads_begin, pads_end, dilations, auto_pad); + + ASSERT_TRUE(conv->get_output_partial_shape(0).same_scheme({PartialShape::dynamic()})); + ASSERT_EQ(conv->get_pads_begin(), (CoordinateDiff{})); + ASSERT_EQ(conv->get_pads_end(), (CoordinateDiff{})); +} + TEST(type_prop, deformable_conv_incorrect_group) { const PartialShape data_batch_shape{1, 3, 96, 96};