Skip to content
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
3 changes: 3 additions & 0 deletions paddle/phi/kernels/cpu/flip_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ void FlipKernel(const Context& dev_ctx,
auto numel = x.numel();
const T* x_data = x.data<T>();
T* out_data = dev_ctx.template Alloc<T>(out);
if (out->numel() == 0) {
return;
}
#ifdef PADDLE_WITH_MKLML
#pragma omp parallel for
#endif
Expand Down
3 changes: 3 additions & 0 deletions paddle/phi/kernels/gpu/flip_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ void FlipKernel(const Context& dev_ctx,
DenseTensor* out) {
auto* in_data = x.data<T>();
auto* out_data = dev_ctx.template Alloc<T>(out);
if (out->numel() == 0) {
return;
}

auto x_dims = x.dims();
const int rank = x_dims.size();
Expand Down
20 changes: 20 additions & 0 deletions test/legacy_test/test_reverse_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ def initTestCase(self):
self.axis = [-1, -2]


class TestCase4(TestReverseOp):
def initTestCase(self):
self.x = np.random.random((3, 0, 10)).astype('float64')
self.axis = [1, 2]


class TestCase5(TestReverseOp):
def initTestCase(self):
self.x = np.random.random((2, 0, 3)).astype('float32')
self.axis = [0]


class TestCase6(TestReverseOp):
def initTestCase(self):
self.x = np.random.random((2, 0, 0)).astype('float32')
self.axis = [
0,
]


if __name__ == '__main__':
paddle.enable_static()
unittest.main()
Loading