Skip to content

Commit 27018cc

Browse files
committed
fix
1 parent 3a4ae3d commit 27018cc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

paddle/phi/kernels/xpu/cum_kernel.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ void CumsumKernel(const Context& dev_ctx,
2929
DenseTensor* out) {
3030
using XPUType = typename XPUTypeTrait<T>::Type;
3131
dev_ctx.template Alloc<T>(out);
32-
32+
if (out->numel() == 0) {
33+
return;
34+
}
3335
if (x.numel() == 1) {
3436
int r = xpu::copy<XPUType>(dev_ctx.x_context(),
3537
reinterpret_cast<const XPUType*>(x.data<T>()),

test/legacy_test/test_cumsum_op.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def set_attrs_input_output(self):
215215

216216
class TestSumOpZeroSize(TestSumOp1):
217217
def set_attrs_input_output(self):
218-
self.x = np.random.random((1, 0, 4)).astype(self._dtype)
218+
self.x = np.random.random((1, 0, 4)).astype(self.dtype_)
219219
self.out = self.x.cumsum(axis=0)
220220

221221

@@ -764,7 +764,6 @@ def setUp(self):
764764
paddle.int64,
765765
paddle.float32,
766766
paddle.float64,
767-
paddle.bool,
768767
]
769768

770769
def test_dygraph(self):

test/xpu/test_cumsum_op_xpu.py

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ def init_config(self):
101101
self.input_shape = [2, 3, 5, 255]
102102
self.axis = 2
103103

104+
class XPUTestCumsum6(TestCumsumOPBase):
105+
def init_config(self):
106+
self.input_shape = [1, 0, 2]
107+
self.axis = 0
108+
104109

105110
support_types = get_xpu_op_support_types('cumsum')
106111
for stype in support_types:

0 commit comments

Comments
 (0)