Skip to content

Commit

Permalink
fix div 0 error in conv1_transpose (#50000)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liyulingyue authored Jan 31, 2023
1 parent 52672ea commit 1755a15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions paddle/phi/kernels/funcs/concat_and_split_functor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ struct ConcatFunctor<phi::CPUContext, T> {
}
int64_t out_rows = rows, out_cols = 0;

PADDLE_ENFORCE_NE(
rows,
0,
phi::errors::InvalidArgument("The input size should not be 0."));

std::vector<int64_t> input_cols(input.size());
for (size_t i = 0; i < num; ++i) {
int64_t t_cols = input[i].numel() / rows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,17 @@ def setUp(self):
self.data_format = "NCL"


class TestFunctionalConv1DErrorCase3(TestFunctionalConv1DError):
def setUp(self):
self.input = np.random.randn(6, 0, 6)
self.filter = np.random.randn(6, 0, 0)
self.bias = None
self.padding = 0
self.stride = 1
self.dilation = 1
self.groups = 1
self.data_format = "NCL"


if __name__ == "__main__":
unittest.main()

0 comments on commit 1755a15

Please sign in to comment.