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

Function test_vm_execute

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

Source from the content-addressed store, hash-verified

27
28
29def test_vm_execute():
30 ib = relax.ExecBuilder()
31 with ib.function("func0", num_inputs=2):
32 ib.emit_call("test.vm.add", args=[ib.r(0), ib.r(1)], dst=ib.r(2))
33 ib.emit_ret(ib.r(2))
34 ex = ib.get()
35 vm = relax.VirtualMachine(ex, tvm.cpu())
36 a = tvm.runtime.tensor(
37 np.random.rand(
38 4,
39 )
40 )
41 b = tvm.runtime.tensor(
42 np.random.rand(
43 4,
44 )
45 )
46
47 add_res = check_saved_func(vm, "func0", a, b)
48 tvm.testing.assert_allclose(add_res.numpy(), a.numpy() + b.numpy(), rtol=1e-7, atol=1e-7)
49
50
51def test_vm_multiple_func():

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…