i wanna find way to automative single op accuracy testing. I use another way to extract single op ir definition, then run the single op ir func def. not using tir.
It is possible to insert your own tir pass into the pass context to print out the tir at the end of the transformation phase.
@tvm.tir.transform.prim_func_pass(opt_level=0)
def dump_tir(f, mod, ctx):
print(f)
return f
Then when issuing the relay build command, make sure to append your new pass onto the end of the pass sequence
with tvm.transform.PassContext(opt_level=3, config={"tir.add_lower_pass": [(3, dump_tir)]}):
lib = tvm.relay.build(mod, target=target, params=params)
The “tir.add_lower_pass”: [{3, dump_tir)]} part is just stating which phase of the tir transformation passes you want to insert your pass into, i.e. after which phase of optimization you’d like to output the tir.
You can find more information in gallery/how_to/extend_tvm/low_level_custom_pass.py