Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix div 0 error in conv1_transpose #50000

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()