!6772 Add seed for gpu operator testcase

Merge pull request !6772 from chenweifeng/test-case-seed
This commit is contained in:
mindspore-ci-bot 2020-09-23 16:56:09 +08:00 committed by Gitee
commit 8d20d1b8e6
1 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,7 @@ from mindspore.ops import operations as P
def test_nobroadcast():
context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
np.random.seed(42)
x1_np = np.random.rand(10, 20).astype(np.float32)
x2_np = np.random.rand(10, 20).astype(np.float32)
x1_np_int32 = np.random.randint(0, 100, (10, 20)).astype(np.int32)
@ -77,6 +78,7 @@ def test_nobroadcast():
def test_nobroadcast_fp16():
context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
np.random.seed(42)
x1_np = np.random.rand(10, 20).astype(np.float16)
x2_np = np.random.rand(10, 20).astype(np.float16)
@ -119,6 +121,7 @@ def test_nobroadcast_fp16():
def test_broadcast():
context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
np.random.seed(42)
x1_np = np.random.rand(3, 1, 5, 1).astype(np.float32)
x2_np = np.random.rand(1, 4, 1, 6).astype(np.float32)
x1_np_int32 = np.random.randint(0, 100, (3, 1, 5, 1)).astype(np.int32)
@ -169,6 +172,7 @@ def test_broadcast():
def test_broadcast_diff_dims():
context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
np.random.seed(42)
x1_np = np.random.rand(2).astype(np.float32)
x2_np = np.random.rand(2, 1).astype(np.float32)
x1_np_int32 = np.random.randint(0, 100, (2)).astype(np.int32)
@ -219,6 +223,7 @@ def test_broadcast_diff_dims():
def test_broadcast_fp16():
context.set_context(mode=context.GRAPH_MODE, device_target='GPU')
np.random.seed(42)
x1_np = np.random.rand(3, 1, 5, 1).astype(np.float16)
x2_np = np.random.rand(1, 4, 1, 6).astype(np.float16)