Three Ways to add IR Pass


wdaRecently,I just want to know how to add a Pass in TVM , so I read the docs about TVM and I found there were there ways to add a pass in TVM1:https://docs.tvm.ai/tutorials/dev/low_level_custom_pass.htmlI think we can use tvm.ir_pass.PostOrderVisit(stmt, func) and tvm.ir_pass.IRTransform to create a pass in Python Frontend。2:https://docs.tvm.ai/dev/relay_pass_infra.html1I think we can build a pass through decoration in Python Frontend,like@relay.transform.function_pass(opt_level=1)3:https://docs.tvm.ai/dev/relay_add_pass.htmlI think we can Create ExprVisitor subclass and ExprMutator subclass ,then register a pass with the pass manager. this method are used in C++ backend.So Am I right?@zhiics@tqchen@vinx13

zhiicsYour understanding to each of them are pretty much right, but I wouldn’t say they are different ways to adding passes.Passes undertvm.ir_passare working on TVM IR which is the lower level IR.The relay_add_pass tutorial provides a guidance on how we can write a Relay optimization/analysis pass.The relay_pass_infra tutorial is mainly about how you can use the Relay pass infra (i.e. pass manager) to integrate the pass you write and systematically manage them.