| 191 | |
| 192 | |
| 193 | def test_simple_module(): |
| 194 | @I.ir_module(s_tir=True) |
| 195 | class TestModule: |
| 196 | @T.prim_func(private=True, s_tir=True) |
| 197 | def tir_func( |
| 198 | x: T.Buffer((T.int64(128), T.int64(128)), "float32"), |
| 199 | y: T.Buffer((T.int64(128), T.int64(128)), "float32"), |
| 200 | ): |
| 201 | T.func_attr({"tirx.noalias": True}) |
| 202 | for i, j in T.grid(T.int64(128), T.int64(128)): |
| 203 | with T.sblock(): |
| 204 | vi, vj = T.axis.remap("SS", [i, j]) |
| 205 | y[vi, vj] = x[vi, vj] + 1.0 |
| 206 | |
| 207 | @R.function |
| 208 | def foo(x: R.Tensor((128, 128), "float32")) -> R.Tensor((128, 128), "float32"): |
| 209 | cls = TestModule |
| 210 | gv0 = R.call_tir(cls.tir_func, x, R.Tensor((128, 128), dtype="float32")) |
| 211 | return gv0 |
| 212 | |
| 213 | x = relax.Var("x", R.Tensor((128, 128), "float32")) |
| 214 | bb = relax.BlockBuilder() |
| 215 | with bb.function("foo", (x,), {"global_symbol": "foo"}): |
| 216 | out = bb.emit_te(lambda x: x + 1, x, primfunc_name_hint="tir_func") |
| 217 | bb.emit_func_output(out) |
| 218 | |
| 219 | _check(TestModule, bb.get()) |
| 220 | |
| 221 | |
| 222 | def test_emit_te_primfunc_attrs(): |