(inp, drop_prob)
| 56 | @pytest.mark.skipif(not is_cuda_available(), reason="only support cuda now") |
| 57 | def test_xla_trace_random_seed_update(): |
| 58 | def tester(inp, drop_prob): |
| 59 | @xla_trace(without_host=True) |
| 60 | def func(x): |
| 61 | a = F.dropout(x, drop_prob, True) |
| 62 | b = F.dropout(x, drop_prob, True) |
| 63 | return a, b |
| 64 | |
| 65 | _ = func(inp) |
| 66 | a0, b0 = func(inp) |
| 67 | seed_0 = func.random_seed |
| 68 | a1, b1 = func(inp) |
| 69 | seed_1 = func.random_seed |
| 70 | |
| 71 | assert not np.all(a0.numpy() == b0.numpy()) |
| 72 | assert not np.all(a1.numpy() == b1.numpy()) |
| 73 | assert not np.all(a0.numpy() == a1.numpy()) |
| 74 | assert not np.all(seed_0.numpy() == seed_1.numpy()) |
| 75 | return a0, b0, seed_0, seed_1 |
| 76 | |
| 77 | inp = megengine.tensor(np.random.randn(4, 8), dtype="float32") |
| 78 | megengine.random.seed(123) |
no test coverage detected