Commit c6c2aafb authored by Pruthvi's avatar Pruthvi Committed by Scott Cyphers

Fallback to ref convolution for negative padding (#2640)

* i) added support to handle default convolution kernels

* - added test case for rotated convolution

* added debug info for conv exception

* disbale handling conv exception

* WIP onnx unit test reproducer

* - Fallback to reference kernel if its negative padding for convolution

* - corrected the conditional check for -ve padding in conv
parent 2bb5bd50
......@@ -103,6 +103,23 @@ namespace ngraph
if (s != 1)
return false;
}
// MKLDNN doesnt support negative padding
for (auto s : convolution->get_padding_above())
{
if (s < 0)
{
return false;
}
}
for (auto s : convolution->get_padding_below())
{
if (s < 0)
{
return false;
}
}
if (arg0_rank != 4 && arg0_rank != 5)
{
return false;
......
......@@ -390,6 +390,7 @@ namespace ngraph
mkldnn_arg1_shape, et_weights, memory::format::any);
const memory::desc result_desc(
mkldnn_result_shape, et_result, memory::format::any);
std::unique_ptr<convolution_forward::desc> fwd_desc{nullptr};
auto convolution_algo = mkldnn_utils::get_conv_algo();
if (use_bias)
......
......@@ -989,3 +989,23 @@ TEST(cpu_test, conv_test_winograd)
}
auto cpu_results = execute(cpu_f, args, "CPU");
}
TEST(cpu_test, conv_negative_padding)
{
auto make_f = [&]() {
Shape shape_a{1, 16, 2, 2};
auto A = make_shared<op::Parameter>(element::f32, shape_a);
Shape shape_b{32, 16, 1, 1};
auto B = make_shared<op::Parameter>(element::f32, shape_b);
auto conv1 = make_shared<op::Convolution>(A,
B,
Strides{1, 1},
Strides{1, 1},
CoordinateDiff{-1, -1},
CoordinateDiff{0, 0},
Strides{1, 1});
return make_shared<Function>(conv1, ParameterVector{A, B});
};
compare_backends(make_f(), make_f(), "CPU", "INTERPRETER");
}
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