()
| 27 | |
| 28 | |
| 29 | def 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 | |
| 51 | def test_vm_multiple_func(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…