Hi @jroesch @Mousius , I think having Pass'es (instead of functions) could also work.
I guess what we are after is the ability to assemble and re-use TVM's compilation passes on a target basis. https://github.com/apache/tvm/pull/8110#discussion_r639559530 Continuing the above comment, this also removes various places otherwise devs need to insert custom passes. Therefore, centralizing them closer to the target seems much cleaner to me. Therefore, it becomes straightforward to follow what passes are being run in the lowering for a given target while also not running passes that are not relevant (that are currently run anyway due to them having identity effect on IRModule in the absense of special attr/nodes/vars in the IRModule). > I believe the tenants should be customization of the compiler happens via > passes, passes only can produce IRModules, and all data is stored in the > IRModule. Today's compiler requires a little more work to get to this world, > but I think we should push in this direction. I think we broadly agrees on this. @Mousius ? > The proliferation of customizations in the old compile engine for example > makes it nearly impossible to refactor the compiler in its current state, and > has lead to the world where we need lots of per-flow customization because > the compiler is insufficiently factored into a common prefix of code. While we agree that its better to share the many passes that are required, but does it need to mandate a monolith of TIR passes being applied irrespective of the target ? We'd like to hear you thoughts (I think this has a connection to the so-called phases in lower implementation, right ?). While we could codify the requirement, is it absolutely necessary ? Also will it (having target based pass pipeline) preclude us from having the code factored into a common prefix ? > but I think instead of overriding the lowering code with arbitrary functions > we could provide hooks that allow the insertion of target specific passes at > the "correct" time in the compiler flow. The arbitrary function mentioned here could be a pass pipeline (and we could make it a requirement by making it a Pass as you suggested). However, it is interesting know if we can define a universally 'correct' time for the flow considering targets beyond CPUs and GPUs (w/o needing to do inverse lowering to recreate high-level abstraction that was forced lowered due to mandatory passes). We would love to hear if you have an alternative suggestion to support target-based lowering -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/apache/tvm-rfcs/pull/10#issuecomment-892594559