From fa3e4745b5f248bc0f94951203a471f376c8753b Mon Sep 17 00:00:00 2001 From: zhaoyinglia Date: Thu, 29 Dec 2022 21:59:14 +0800 Subject: [PATCH] update paddle.full --- .../fluid/tests/unittests/test_zero_dim_tensor.py | 12 ++++++------ .../tests/unittests/xpu/test_zero_dim_tensor_xpu.py | 13 ++----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py b/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py index 8313d4487accdd..cabecdf447ab2f 100644 --- a/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py +++ b/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py @@ -785,14 +785,14 @@ def test_reshape_tensor(self): self.assertEqual(out.shape, []) self.assertEqual(out.grad.shape, []) - new_shape = paddle.full([], 1, "int32") + new_shape = paddle.full([1], 1, "int32") out = paddle.reshape(x, new_shape) out.backward() self.assertEqual(x.grad.shape, [1, 1]) self.assertEqual(out.shape, [1]) self.assertEqual(out.grad.shape, [1]) - new_shape = paddle.full([], -1, "int32") + new_shape = paddle.full([1], -1, "int32") out = paddle.reshape(x, new_shape) out.backward() self.assertEqual(x.grad.shape, [1, 1]) @@ -825,11 +825,11 @@ def test_reshape__tensor(self): out = paddle.reshape_(x, []) self.assertEqual(out.shape, []) - new_shape = paddle.full([], 1, "int32") + new_shape = paddle.full([1], 1, "int32") out = paddle.reshape_(x, new_shape) self.assertEqual(out.shape, [1]) - new_shape = paddle.full([], -1, "int32") + new_shape = paddle.full([1], -1, "int32") out = paddle.reshape_(x, new_shape) self.assertEqual(out.shape, [1]) @@ -1130,11 +1130,11 @@ def test_reshape_tensor(self): x2.stop_gradient = False x3.stop_gradient = False - new_shape = paddle.full([], 1, "int32") + new_shape = paddle.full([1], 1, "int32") out1 = paddle.reshape(x1, new_shape) paddle.static.append_backward(out1) - new_shape = paddle.full([], -1, "int32") + new_shape = paddle.full([1], -1, "int32") out2 = paddle.reshape(x2, new_shape) paddle.static.append_backward(out2) diff --git a/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py index cb1e3b211f7b12..8ceee04c206b10 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_zero_dim_tensor_xpu.py @@ -634,11 +634,11 @@ def test_reshape__tensor(self): out = paddle.reshape_(x, []) self.assertEqual(out.shape, []) - new_shape = paddle.full([], 1, "int32") + new_shape = paddle.full([1], 1, "int32") out = paddle.reshape_(x, new_shape) self.assertEqual(out.shape, [1]) - new_shape = paddle.full([], -1, "int32") + new_shape = paddle.full([1], -1, "int32") out = paddle.reshape_(x, new_shape) self.assertEqual(out.shape, [1]) @@ -646,15 +646,6 @@ def test_reshape__tensor(self): out = paddle.reshape_(x, new_shape) self.assertEqual(out.shape, [1, 1]) - def test_reverse(self): - x = paddle.rand([]) - x.stop_gradient = False - out = paddle.reverse(x, axis=[]) - out.backward() - self.assertEqual(x.shape, []) - self.assertEqual(out.shape, []) - self.assertEqual(out.grad.shape, []) - # Use to test API whose zero-dim input tensors don't have grad and not need to test backward in OpTest. class TestNoBackwardAPI(unittest.TestCase):