Hi all, I’m a new user of TVM and am learning TIR. Now I want to define my own operator using TIR interface, which means I’d create a PrimFunc
at the top level, initialize an IRModule
from it and build this IRModule
.
The problem is that I also want to define multiple PrimFunc
s called by the top-level PrimFunc
, but I could not. I know I may simply put all things into one PrimFunc
, but I just want to know whether cross-function call is possible.
The following minimal working example demonstrate my purpose:
A = te.var('A')
B = te.var('B')
callee = tir.PrimFunc([A, B], tir.Evaluate(tir.Add(A, B)))
callee = callee.with_attr('global_symbol', 'callee')
main = tir.PrimFunc([A, B], tir.Evaluate(tir.Call('int32', callee, [A, B])))
# OR main = tir.PrimFunc([A, B], tir.Evaluate(tir.Call('int32', GlobalVar('callee'), [A, B])))
main = main.with_attr("global_symbol", "main")
main = main.with_attr("tir.noalias", True)
mod = tvm.IRModule({"main": main, "callee": callee})
tvm.build(mod)