def test_normal(): m = 10240 n = 10240 A = random.normal(3, 4, size=(m, n)) s = te.create_schedule(A.op) def verify(target="llvm"): if not tvm.runtime.enabled(target): print("skip because %s is not enabled..." % target) return if not tvm.get_global_func("tvm.contrib.random.normal", True): print("skip because extern function is not available") return ctx = tvm.cpu(0) f = tvm.build(s, [A], target) a = tvm.nd.array(np.zeros((m, n), dtype=A.dtype), ctx) f(a) na = a.asnumpy() assert abs(np.mean(na) - 3) < 1e-1 assert abs(np.std(na) - 4) < 1e-2 verify()
def test_normal(): m = 1024 n = 1024 A = random.normal(3, 4, size=(m, n)) s = tvm.create_schedule(A.op) def verify(target="llvm"): if not tvm.module.enabled(target): print("skip because %s is not enabled..." % target) return if not tvm.get_global_func("tvm.contrib.random.normal", True): print("skip because extern function is not available") return ctx = tvm.cpu(0) f = tvm.build(s, [A], target) a = tvm.nd.array(np.zeros((m, n), dtype=A.dtype), ctx) f(a) na = a.asnumpy() assert abs(np.mean(na) - 3) < 1e-2 assert abs(np.std(na) - 4) < 1e-2 verify()