()
| 49 | |
| 50 | |
| 51 | def 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 | |
| 77 | def test_vm_checker(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…