You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by Michael via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/11/02 11:16:30 UTC
[Apache TVM Discuss] [Questions] Does TIR support cross-function
call?
Yes, TIR do support it. But you have to change your code a little bit.
```
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.is_entry_func", True)
main = main.with_attr("tir.noalias", True)
mod = tvm.IRModule({"main": main, "callee": callee})
tvm.build(mod)
```
After that, you need to modify the pass split_host_device.cc which lost the is_entry_func attribute. Then add your own codegen to check the global function or other functions.
---
[Visit Topic](https://discuss.tvm.apache.org/t/does-tir-support-cross-function-call/10338/3) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/d368393478c3eaab5a5a5a83ca7aea28bad4feb188d779b7bd06a50731b06cf1).