()
| 194 | |
| 195 | |
| 196 | def 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 | |
| 219 | def test_vm_if(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…