MCPcopy Index your code
hub / github.com/apache/tvm / test_randint

Function test_randint

tests/python/contrib/test_random.py:32–54  ·  view source on GitHub ↗

Tests randint function

()

Source from the content-addressed store, hash-verified

30
31
32def test_randint():
33 """Tests randint function"""
34 m = 10240
35 n = 10240
36 A = random.randint(-127, 128, size=(m, n), dtype="int32")
37
38 def verify(target="llvm"):
39 if not tvm.testing.device_enabled(target):
40 print(f"skip because {target} is not enabled...")
41 return
42 if not tvm.get_global_func("tvm.contrib.random.randint", True):
43 print("skip because extern function is not available")
44 return
45 dev = tvm.cpu(0)
46 f = tvm.compile(te.create_prim_func([A]), target=target)
47 a = tvm.runtime.tensor(np.zeros((m, n), dtype=A.dtype), dev)
48 f(a)
49 na = a.numpy()
50 assert abs(np.mean(na)) < 0.3
51 assert np.min(na) == -127
52 assert np.max(na) == 127
53
54 verify()
55
56
57def test_uniform():

Callers 1

test_random.pyFile · 0.85

Calls 1

verifyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…