MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / tester

Function tester

imperative/python/test/unit/xla/test_xla_trace.py:58–75  ·  view source on GitHub ↗
(inp, drop_prob)

Source from the content-addressed store, hash-verified

56@pytest.mark.skipif(not is_cuda_available(), reason="only support cuda now")
57def 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)

Callers 2

test_xla_grad_scalerFunction · 0.70

Calls 7

GradManagerClass · 0.90
trace_funcFunction · 0.85
allMethod · 0.80
assert_equalMethod · 0.80
funcFunction · 0.70
MyModuleClass · 0.70
numpyMethod · 0.45

Tested by

no test coverage detected