未验证 提交 d43c972c 编写于 作者: O OccupyMars2025 提交者: GitHub

[hidden trouble] Update test_sparse_transpose_op.py to get rid of a hidden trouble. (#47017)

* Update test_sparse_transpose_op.py

* Update test_sparse_transpose_op.py
上级 13284437
...@@ -23,7 +23,9 @@ class TestTranspose(unittest.TestCase): ...@@ -23,7 +23,9 @@ class TestTranspose(unittest.TestCase):
def check_result(self, x_shape, dims, format): def check_result(self, x_shape, dims, format):
with _test_eager_guard(): with _test_eager_guard():
mask = paddle.randint(0, 2, x_shape).astype("float32") mask = paddle.randint(0, 2, x_shape).astype("float32")
origin_x = paddle.rand(x_shape, dtype='float32') * mask # "+ 1" to make sure that all zero elements in "origin_x" is caused by multiplying by "mask",
# or the backward checks may fail.
origin_x = (paddle.rand(x_shape, dtype='float32') + 1) * mask
dense_x = origin_x.detach() dense_x = origin_x.detach()
dense_x.stop_gradient = False dense_x.stop_gradient = False
dense_out = paddle.transpose(dense_x, dims) dense_out = paddle.transpose(dense_x, dims)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册