Skip to content

Commit

Permalink
add dilation check for conv (#35894)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrywgz authored Sep 23, 2021
1 parent 95c100c commit 91f25ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions paddle/fluid/operators/conv_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ std::vector<int64_t> ConvOp::ComputeOutputShape(
ctx->Attrs().Get<std::string>("padding_algorithm");
int groups = ctx->Attrs().Get<int>("groups");
std::vector<int> dilations = ctx->Attrs().Get<std::vector<int>>("dilations");
int dilation_size = dilations.size();
for (int i = 0; i < dilation_size; ++i) {
PADDLE_ENFORCE_GT(
dilations[i], 0,
platform::errors::InvalidArgument(
"The dilation of Op(Conv) should be larget than 0, but received "
"dilation is %d.",
dilations[i]));
}
const std::string data_format = ctx->Attrs().Get<std::string>("data_format");

// MKL-DNN Kernels are using NCHW order of dims description
Expand Down
1 change: 1 addition & 0 deletions python/paddle/fluid/tests/unittests/test_conv1d_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def add_error_cases(suite):
suite.addTest(
Conv1DErrorTestCase(
methodName='runTest', padding=[1, 2, 3, 4, 5]))
suite.addTest(Conv1DErrorTestCase(methodName='runTest', dilation=-10))


def load_tests(loader, standard_tests, pattern):
Expand Down

0 comments on commit 91f25ee

Please sign in to comment.