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

Function test_vm_multiple_func

tests/python/relax/test_vm_execbuilder.py:51–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49
50
51def test_vm_multiple_func():
52 ib = relax.ExecBuilder()
53 with ib.function("func0", num_inputs=2):
54 ib.emit_call("test.vm.add", args=[ib.r(0), ib.r(1)], dst=ib.r(2))
55 ib.emit_ret(ib.r(2))
56 with ib.function("func1", num_inputs=2):
57 ib.emit_call("test.vm.mul", args=[ib.r(0), ib.r(1)], dst=ib.r(2))
58 ib.emit_ret(ib.r(2))
59 ex = ib.get()
60 vm = relax.VirtualMachine(ex, tvm.cpu())
61 a = tvm.runtime.tensor(
62 np.random.rand(
63 4,
64 )
65 )
66 b = tvm.runtime.tensor(
67 np.random.rand(
68 4,
69 )
70 )
71 mul_res = check_saved_func(vm, "func1", a, b)
72 add_res = check_saved_func(vm, "func0", a, b)
73 tvm.testing.assert_allclose(add_res.numpy(), a.numpy() + b.numpy(), rtol=1e-7, atol=1e-7)
74 tvm.testing.assert_allclose(mul_res.numpy(), a.numpy() * b.numpy(), rtol=1e-7, atol=1e-7)
75
76
77def test_vm_checker():

Callers

nothing calls this directly

Calls 8

functionMethod · 0.95
emit_callMethod · 0.95
rMethod · 0.95
emit_retMethod · 0.95
getMethod · 0.95
check_saved_funcFunction · 0.90
numpyMethod · 0.80
cpuMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…