| 133 | |
| 134 | |
| 135 | def test_vm_operand(): |
| 136 | ib0 = relax.ExecBuilder() |
| 137 | with ib0.function("func0", num_inputs=2): |
| 138 | ib0.emit_call("test.vm.add_scalar", args=[ib0.r(0), ib0.r(1)], dst=ib0.r(2)) |
| 139 | ib0.emit_ret(ib0.r(2)) |
| 140 | exec0 = ib0.get() |
| 141 | vm = relax.VirtualMachine(exec0, tvm.cpu()) |
| 142 | res = vm["func0"](2, 3) |
| 143 | assert res == 5 |
| 144 | |
| 145 | ib1 = relax.ExecBuilder() |
| 146 | with ib1.function("func1", num_inputs=1): |
| 147 | ib1.emit_call("test.vm.get_device_id", args=[ib1.r(0)], dst=ib1.r(1)) |
| 148 | ib1.emit_ret(ib1.r(1)) |
| 149 | exec1 = ib1.get() |
| 150 | vm = relax.VirtualMachine(exec1, tvm.cpu()) |
| 151 | res = vm["func1"](tvm.cpu(3)) |
| 152 | assert res == 3 |
| 153 | |
| 154 | |
| 155 | def test_vm_shapeof(): |