| 220 | |
| 221 | |
| 222 | def test_emit_te_primfunc_attrs(): |
| 223 | @I.ir_module(s_tir=True) |
| 224 | class TestModule: |
| 225 | @T.prim_func(private=True, s_tir=True) |
| 226 | def plus_one( |
| 227 | x: T.Buffer((T.int64(128), T.int64(128)), "float32"), |
| 228 | y: T.Buffer((T.int64(128), T.int64(128)), "float32"), |
| 229 | ): |
| 230 | T.func_attr({"some_attr": "foo", "another_attr": True, "tirx.noalias": True}) |
| 231 | for i, j in T.grid(T.int64(128), T.int64(128)): |
| 232 | with T.sblock(): |
| 233 | vi, vj = T.axis.remap("SS", [i, j]) |
| 234 | y[vi, vj] = x[vi, vj] + 1.0 |
| 235 | |
| 236 | @R.function |
| 237 | def foo(x: R.Tensor((128, 128), "float32")) -> R.Tensor((128, 128), "float32"): |
| 238 | cls = TestModule |
| 239 | gv0 = R.call_tir(cls.plus_one, x, R.Tensor((128, 128), dtype="float32")) |
| 240 | return gv0 |
| 241 | |
| 242 | x = relax.Var("x", R.Tensor((128, 128), "float32")) |
| 243 | bb = relax.BlockBuilder() |
| 244 | with bb.function("foo", (x,), {"global_symbol": "foo"}): |
| 245 | out = bb.emit_te( |
| 246 | lambda x: x + 1, |
| 247 | x, |
| 248 | primfunc_name_hint="plus_one", |
| 249 | primfunc_attrs={"some_attr": "foo", "another_attr": True}, |
| 250 | ) |
| 251 | bb.emit_func_output(out) |
| 252 | _check(TestModule, bb.get()) |
| 253 | |
| 254 | |
| 255 | def test_emit_te(): |