yelite commented on code in PR #74: URL: https://github.com/apache/tvm-rfcs/pull/74#discussion_r885790649
########## rfcs/0074-tvmscript-unified-printer.md: ########## @@ -0,0 +1,475 @@ +- Feature Name: TUNIP: TVMScript Unified Printer +- Start Date: 05/25/2022 +- RFC PR: [apache/tvm-rfcs#74](https://github.com/apache/tvm-rfcs/pull/74) +- GitHub Issue: [apache/tvm#0000](https://github.com/apache/tvm/issues/0000) +- Co-Authors: Lite Ye ([**@yelite**](https://github.com/yelite)), Yong Wu + ([**@yongwww**](https://github.com/yongwww)), Yuchen Jin + ([**@YuchenJin**](https://github.com/YuchenJin)) + +# Summary +[summary]: #summary + +This RFC proposes to modularize and infrastructuralize the existing TVMScript +printer, to develop unified printing mechanism across TVM stack, where TIR, +Relax and any future vendor-specific IR are all treated equally as dialects and +could be printed together without potential conflict in engineering. + +# Motivation +[motivation]: #motivation + +TVMScript, as a roundtrippable python-based text format, is +the central piece of TVM performance productivity. As the frontend of TVM, it +enables end users to directly construct the TVM IR, either TIR or Relax, in a +pragmatic approach. From Relax to MetaSchedule and TIR, TVMScript enables +inspectability and reproducibility at any level of compilation and +optimization. Furthermore, based on TVMScript, developers are empowered to +intercept, manipulate and customize the compiler behavior in a principled way. + +While TVMScript is gaining traction and buy-in from the open source community, +the TVMScript printer suffers from multiple profound design issues: +- Not supporting IR fragment printing requires users to jump in-between + TVMScript syntax and TIRText syntax +- The lack of modularity leads to practical inability to scale up to and + maintain multiple IRs without engineering conflicts +- Enhancing co-existence of multi-level IRs often leads to re-engineering of + existing features. + +**Goal.** This RFC introduces Tvmscript UNIfied Printer (TUNIP), a systematic +redesign to +address those engineering, usability and scalability issues above. The goal of +this re-design includes: + +**Goal 1 [Unified Representation].** Become the unified roundtrippable +representation of TIR and Relax, allowing systematic mixing of IRs or IR +fragments (Relax + TIR) in the same IRModule in the target language (for +example, python, C++). + +Currently TVMScript priner is designed specifically for TIR, and printing +multiple dialects together was not a design goal at that time. Therefore, +supporting Relax requires ad-hoc hack around the system (for +instance, [relax#149](https://github.com/tlc-pack/relax/pull/149) added support +of printing `T.cast` and `T.max` in an ad-hoc way, without reusing the printing +code for TIR). The unified printer in this RFC addresses this issue by having a +unified approach for printing IR tree to TVMScript. Engineers will be able to +implement a fully-fledged printer for Relax, TIR and any potential IR in the Review Comment: No, for now we don't have a concrete third-party IR that needs to be supported. We will focus on TIR and Relax while keep the possibility of third-party IR open. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
