Skip to content

Commit

Permalink
[hidden trouble] Update test_sparse_transpose_op.py to get rid of a h…
Browse files Browse the repository at this point in the history
…idden trouble. (PaddlePaddle#47017)

* Update test_sparse_transpose_op.py

* Update test_sparse_transpose_op.py
  • Loading branch information
OccupyMars2025 authored and zhwesky2010 committed Oct 17, 2022
1 parent fb838c5 commit 507cf31
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -23,7 +23,9 @@ class TestTranspose(unittest.TestCase):
def check_result(self, x_shape, dims, format):
with _test_eager_guard():
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.stop_gradient = False
dense_out = paddle.transpose(dense_x, dims)
Expand Down

0 comments on commit 507cf31

Please sign in to comment.