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

Function test_vm_goto

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

Source from the content-addressed store, hash-verified

194
195
196def test_vm_goto():
197 ib = relax.ExecBuilder()
198 with ib.function("main", num_inputs=2):
199 ib.emit_call("test.vm.add", args=[ib.r(0), ib.r(1)], dst=ib.r(2))
200 ib.emit_goto(2)
201 ib.emit_call("test.vm.mul", args=[ib.r(2), ib.r(1)], dst=ib.r(2))
202 ib.emit_ret(ib.r(2))
203 ex = ib.get()
204 vm = relax.VirtualMachine(ex, tvm.cpu())
205 a = tvm.runtime.tensor(
206 np.random.rand(
207 4,
208 )
209 )
210 b = tvm.runtime.tensor(
211 np.random.rand(
212 4,
213 )
214 )
215 res = check_saved_func(vm, "main", a, b)
216 tvm.testing.assert_allclose(res.numpy(), a.numpy() + b.numpy(), rtol=1e-7, atol=1e-7)
217
218
219def test_vm_if():

Callers

nothing calls this directly

Calls 9

functionMethod · 0.95
emit_callMethod · 0.95
rMethod · 0.95
emit_gotoMethod · 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…