Skip to content

Instantly share code, notes, and snippets.

@gangmul12
Last active August 25, 2022 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gangmul12/083f71d86bad9d4943c216f88a5cc32e to your computer and use it in GitHub Desktop.
Save gangmul12/083f71d86bad9d4943c216f88a5cc32e to your computer and use it in GitHub Desktop.
relay to tir without any schedule
"""
target "lwc" is custom lwc, with only definition, and without any implementation.
"""
def get_lowered_tir(mod):
"""
Argument
========
mod : IRModule that contains RelayOp only
Returns
========
ret : IRModule that contains TIR only
"""
LowerTE = tvm._ffi.get_global_func("relay.tec.LowerTE")
host_target = tvm.target.Target("llvm")
prim_target = tvm.target.Target("lwc", host=host_target)
ctxt = tvm.transform.PassContext()
config = tvm.target.make_compilation_config(ctxt, prim_target)
mod = tvm.relay.transform.PlanDevices(config)(mod)
mod = tvm.relay.transform.FuseOps(fuse_opt_level=0)(mod)
mod = tvm.relay.transform.InferType()(mod)
mod = LowerTE("default", config)(mod)
return mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment