Hi @jroesch, It'd be great to discuss this further, as there's some interesting points you've raised.
> The lowering process should be a straight forward mapping from TE -> TIR, and > then any necessary customization should be possible in resulting passes which > are allowed to view the entire program including both the Relay code and TIR > code. In the case of library adaptations such as [CMSIS-NN](https://github.com/apache/tvm-rfcs/pull/15), translating through Relay->TE->TIR isn't required as we can do a more straight forward translation directly from Relay->TIR without any of the other pass overheads. In effect, our hook here is a single `Pass` to run over any marked functions rather than aggregating other `Pass`es so conceptually they're similar. > The goal is to remove the need for many slightly different code paths through > the central parts of the compiler and instead provide standard interfaces > that allow targets, and users to customize the compiler without having to > touch any of the flows or modify the data structures. I believe we're on the same page here, the eventual goal being to register and use the hooks directly as target properties that can be accessed as part of a standard flow. The hooks proposed here are slightly larger than you envisaged but should allow a standard and straight forward interface for users to customise the flow of the compiler. The initial implementation isn't as clean as I'd like due to the issues you've raised already with the current compile engine. > I plan on providing a longer form document on this hopefully this week that > argues this more in depth but 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. The hooks proposed could in fact be such `Pass`es, going `IRModule` -> `IRModule` rather than taking a Relay `Function`. As stated above, it would be more optimal to be given a `IRModule` without TIR, just with the Relay attached. > Now that doesn't mean the desire to have per target behavior is necessarily > bad, 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. In this world the proposed > hooks should return a Pass object which can be inserted after the appropriate > phases. I'm interested to understand how this would appear to users in a way that allows them to compose the compiler passes efficiently, being able to write a pipeline of passes seems more intuitive than providing many hooks to insert at different times? Potentially the hooks should return an array of passes or one aggregate pass to ensure the contract is upheld? -- 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-892208845