MCPcopy Create free account
hub / github.com/apache/tvm / test_emit_te_primfunc_attrs

Function test_emit_te_primfunc_attrs

tests/python/relax/test_tvmscript_parser.py:222–252  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

220
221
222def 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
255def test_emit_te():

Callers

nothing calls this directly

Calls 6

functionMethod · 0.95
emit_teMethod · 0.95
emit_func_outputMethod · 0.95
getMethod · 0.95
TensorMethod · 0.80
_checkFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…