# from tvm.script import ir as I
# from tvm.script import tir as T
@I.ir_module
class Module:
@T.prim_func
def main(A: T.Buffer((64,), "float32"), B: T.Buffer((64,), "float32"), C: T.Buffer((64,), "float32")):
T.func_attr({"from_legacy_te_schedule": True, "global_symbol": "main", "tir.noalias": True})
for i in range(64):
C_1 = T.Buffer((64,), data=C.data)
A_1 = T.Buffer((64,), data=A.data)
B_1 = T.Buffer((64,), data=B.data)
C_1[i] = A_1[i] + B_1[i]
Is this tir? or it’s tvm script?
I didn’t find some introduction documents about tir, any help? thank you!
TVMScript is a general term to describe the Python interface of TVM IR family (TensorIR/Relax/etc).
A TensorIR program can be constructed from TVMScript, or converted from TE, or constructed manually with IR builders.
As @junrushao mentioned, TIR is short for TensorIR, not target ir. Tensor program is more general term, Tensor Expression is also tensor program, TensorIR is another abstraction for tensor programs.
TE is a higher-level abstraction (it has its own data structure, which is not TensorIR AST) that still need to be lowered to TensorIR.
TVMScript can parsed to TensorIR directly, like a 1-to-1 mapping.
No, you don’t need a schedule for lowering TE to TIR, just use create_prim_func function. The schedule is used to describe how to optimize programs, in TensorIR, all schedules are compiler passes.