MCPcopy Index your code
hub / github.com/apache/tvm / DynamicModule

Class DynamicModule

docs/how_to/tutorials/mix_python_and_tvm_with_pymodule.py:405–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403
404 @I.ir_module
405 class DynamicModule(BasePyModule):
406 @T.prim_func(s_tir=True)
407 def scale_tir(var_x: T.handle, var_out: T.handle):
408 n = T.int64()
409 x = T.match_buffer(var_x, (n,), "float32")
410 out = T.match_buffer(var_out, (n,), "float32")
411 for i in T.serial(n):
412 out[i] = x[i] * T.float32(2.0)
413
414 @R.function
415 def add_relax(
416 x: R.Tensor(("n",), "float32"),
417 y: R.Tensor(("n",), "float32"),
418 ) -> R.Tensor(("n",), "float32"):
419 return R.add(x, y)
420
421 mod = DynamicModule(device=tvm.cpu(0), target="llvm")
422

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…