From e868762057fd800e28419fc9684b08692ee474d8 Mon Sep 17 00:00:00 2001 From: ghostxsl <451323469@qq.com> Date: Fri, 6 Aug 2021 16:31:34 +0800 Subject: [PATCH] [bug fix] fix unfold fpe bug --- paddle/fluid/operators/unfold_op.cc | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/paddle/fluid/operators/unfold_op.cc b/paddle/fluid/operators/unfold_op.cc index 0a36b6ef840887..5c0eb64993b556 100644 --- a/paddle/fluid/operators/unfold_op.cc +++ b/paddle/fluid/operators/unfold_op.cc @@ -107,6 +107,42 @@ class UnfoldOp : public framework::OperatorWithKernel { "But recieved dims(strides: %u) != dims(dilations: %u).", strides.size(), dilations.size())); + // check kernel_sizes + PADDLE_ENFORCE_GT(kernel_sizes[0], 0, + platform::errors::InvalidArgument( + "The `kernel_sizes` should be greater than zero, " + "but recieved kernel_height: %d kernel_width: %d.", + kernel_sizes[0], kernel_sizes[1])); + PADDLE_ENFORCE_GT(kernel_sizes[1], 0, + platform::errors::InvalidArgument( + "The `kernel_sizes` should be greater than zero, " + "but recieved kernel_height: %d kernel_width: %d.", + kernel_sizes[0], kernel_sizes[1])); + // check strides + PADDLE_ENFORCE_GT(strides[0], 0, + platform::errors::InvalidArgument( + "The `strides` should be greater than zero, " + "but recieved strides_height: %d strides_width: %d.", + strides[0], strides[1])); + PADDLE_ENFORCE_GT(strides[1], 0, + platform::errors::InvalidArgument( + "The `strides` should be greater than zero, " + "but recieved strides_height: %d strides_width: %d.", + strides[0], strides[1])); + // check dilations + PADDLE_ENFORCE_GT( + dilations[0], 0, + platform::errors::InvalidArgument( + "The `dilations` should be greater than zero, " + "but recieved dilations_height: %d dilations_width: %d.", + dilations[0], dilations[1])); + PADDLE_ENFORCE_GT( + dilations[1], 0, + platform::errors::InvalidArgument( + "The `dilations` should be greater than zero, " + "but recieved dilations_height: %d dilations_width: %d.", + dilations[0], dilations[1])); + std::vector out_dims; out_dims.push_back(in_dims[0]);