| 98 | |
| 99 | |
| 100 | def test_emit_cache(): |
| 101 | ib = relax.ExecBuilder() |
| 102 | |
| 103 | with ib.function("func0", num_inputs=1): |
| 104 | x0 = ib.convert_constant("str0") |
| 105 | x1 = ib.convert_constant("str0") |
| 106 | # cache constant str |
| 107 | assert x0 == x1 |
| 108 | s0 = ib.convert_constant(tvm_ffi.Shape([1, 2])) |
| 109 | s1 = ib.convert_constant(tvm_ffi.Shape([1, 2])) |
| 110 | s2 = ib.convert_constant(tvm_ffi.Shape([1, 3])) |
| 111 | assert s0 == s1 |
| 112 | assert s1 != s2 |
| 113 | y0 = ib.convert_constant(tvm.runtime.tensor(np.array([1, 2, 3]).astype("int32"))) |
| 114 | y1 = ib.convert_constant(tvm.runtime.tensor(np.array([1, 2, 3]).astype("int32"))) |
| 115 | assert y0 == y1 |
| 116 | ib.emit_ret(ib.r(0)) |
| 117 | |
| 118 | |
| 119 | def test_vm_formalize(): |