未验证 提交 49752074 编写于 作者: C CollaborativeFiltering 提交者: GitHub

[bug fix] fix fp16 dtype checking for cumsum op (#50973)

上级 ab1b6303
......@@ -461,5 +461,21 @@ class TestTensorAxis(unittest.TestCase):
np.testing.assert_allclose(static_out[0], infer_out)
class TestCumSumOpFp16(unittest.TestCase):
def test_fp16(self):
x_np = np.random.random((100, 100)).astype('float16')
with paddle.static.program_guard(paddle.static.Program()):
x = paddle.static.data(shape=[100, 100], name='x', dtype='float16')
y1 = paddle.cumsum(x)
y2 = paddle.cumsum(x, axis=0)
y3 = paddle.cumsum(x, axis=-1)
y4 = paddle.cumsum(x, axis=-2)
if core.is_compiled_with_cuda():
place = paddle.CUDAPlace(0)
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
out = exe.run(feed={'x': x_np}, fetch_list=[y1, y2, y3, y4])
if __name__ == '__main__':
unittest.main()
......@@ -3208,6 +3208,12 @@ def cumsum(x, axis=None, dtype=None, name=None):
axis = -1
return _C_ops.cumsum(x, axis, flatten, False, False)
else:
check_variable_and_dtype(
x,
'x',
['float16', 'float32', 'float64', 'int32', 'int64'],
'cumsum',
)
check_type(x, 'x', (Variable), 'cumsum')
locals_var = locals().copy()
kwargs = dict()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册