Unverified Commit 2a8487e4 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Change pad mode to explicit if pad values are set in validation (#4509)

Co-authored-by: 's avatarEvgenya Stepyreva <evgenya.stepyreva@intel.com>
parent 37d37314
......@@ -42,24 +42,6 @@ op::v1::Convolution::Convolution(const Output<Node>& data_batch,
, m_pads_end(pads_end)
, m_auto_pad(auto_pad)
{
if (auto_pad != PadType::EXPLICIT)
{
NODE_VALIDATION_CHECK(this,
std::all_of(pads_begin.begin(),
pads_begin.end(),
[](std::ptrdiff_t i) { return (i == 0); }),
"pads_begin: (",
pads_begin,
") Non-zero padding should not be used along with auto pad modes.");
NODE_VALIDATION_CHECK(this,
std::all_of(pads_end.begin(),
pads_end.end(),
[](std::ptrdiff_t i) { return (i == 0); }),
"pads_end: (",
pads_end,
") Non-zero padding should not be used along with auto pad modes.");
}
constructor_validate_and_infer_types();
}
......@@ -75,6 +57,25 @@ bool op::v1::Convolution::visit_attributes(AttributeVisitor& visitor)
void op::v1::Convolution::validate_and_infer_types()
{
if (m_auto_pad != PadType::EXPLICIT)
{
NODE_VALIDATION_CHECK(this,
std::all_of(m_pads_begin.begin(),
m_pads_begin.end(),
[](std::ptrdiff_t i) { return (i == 0); }),
" ",
"pads_begin: (",
m_pads_begin,
") Non-zero padding should not be used along with auto pad modes.");
NODE_VALIDATION_CHECK(this,
std::all_of(m_pads_end.begin(),
m_pads_end.end(),
[](std::ptrdiff_t i) { return (i == 0); }),
" ",
"pads_end: (",
m_pads_end,
") Non-zero padding should not be used along with auto pad modes.");
}
const PartialShape& data_batch_shape = get_input_partial_shape(0);
element::Type data_batch_et = get_input_element_type(0);
const PartialShape& filters_shape = get_input_partial_shape(1);
......@@ -115,6 +116,8 @@ void op::v1::Convolution::validate_and_infer_types()
m_auto_pad,
m_pads_end,
m_pads_begin);
// auto padding has now been made explicit, so set to explicit for future validations
m_auto_pad = PadType::EXPLICIT;
}
}
......
......@@ -2923,6 +2923,38 @@ TEST(type_prop, conv_v1_incorrect_auto_pad)
}
}
TEST(type_prop, conv_double_validate_with_pad)
{
PartialShape data_batch_shape{1, 3, 64, 64};
PartialShape filters_shape{4, 3, 5, 5};
Strides window_movement_strides{1, 1};
Strides window_dilation_strides{1, 1};
CoordinateDiff pads_begin{0, 0};
CoordinateDiff pads_end{0, 0};
auto param0 = make_shared<op::Parameter>(element::f32, data_batch_shape);
auto param1 = make_shared<op::Parameter>(element::f32, filters_shape);
auto conv = make_shared<op::v1::Convolution>(param0,
param1,
window_movement_strides,
pads_begin,
pads_end,
window_dilation_strides,
op::PadType::SAME_UPPER);
ASSERT_EQ(conv->get_pads_begin()[0], 2);
ASSERT_EQ(conv->get_pads_begin()[1], 2);
ASSERT_EQ(conv->get_pads_end()[0], 2);
ASSERT_EQ(conv->get_pads_end()[1], 2);
try
{
conv->validate_and_infer_types();
}
catch (...)
{
FAIL() << "Double validate failure";
}
}
TEST(type_prop, deformable_conv_incorrect_group)
{
const PartialShape data_batch_shape{1, 3, 96, 96};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment