-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TVMScript] Comments and docstrings printing #13839
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.
Generated by tvm-bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for brining in this change!
BTW, for IRModule and PrimFunc printing, would you like to add a couple of lines of comments for clarify:
# from tvm.script import ir as I # if `IR(...)` is ever used
# from tvm.script import tir as T # if `TIR(...)` is ever used
@I.ir_module
class Module()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect. Please address my comment above and fix the lint, and we are good to go!
b9ee9cc
to
816a663
Compare
headers as comment
816a663
to
02c2172
Compare
This PR introduces the `CommentDoc` for comments printing and `DocStringDoc` for docstring printing. It enables to add free comments and docstring as `stmt` in printing, e.g. ```python # comment 1 # comment 2 """ docstring 1 docstring 2 """ ``` The free here means to not be bound to any `stmt`, but acts as a single `stmt`, similar to `ExprStmtDoc` for `ExprDoc`. This PR also introduces an example for the `CommentDoc`, as follow up of apache#13819. In the old printer, we always print a `# with T.block("root"):`, when there is an implicit root block skipped when printing. For example, ``` @T.prim_func def main(): # with T.block("root"): a = T.alloc_buffer((128, 128)) for i, j in T.grid(128, 128): with T.block(""): ... ``` We bring this syntax reminder back in this PR. In addition, we introduce a field of `ir_usage` and `print_headers` into the printer configuration, to support the printing of headers for `IRModule` and `PrimFunc`. For example, ```python # from tvm.script import ir as I # from tvm.script import tir as T @I.ir_module class Module(): @T.prim_func def func(): ... ```
This PR introduces the
CommentDoc
for comments printing andDocStringDoc
for docstring printing. It enables to add free comments and docstring asstmt
in printing, e.g.The free here means to not be bound to any
stmt
, but acts as a singlestmt
, similar toExprStmtDoc
forExprDoc
.This PR also introduces an example for the
CommentDoc
, as follow up of #13819.In the old printer, we always print a
# with T.block("root"):
, when there is an implicit root block skipped when printing. For example,We bring this syntax reminder back in this PR.
In addition, we introduce a field of
ir_usage
andprint_headers
into the printer configuration, to support the printing of headers forIRModule
andPrimFunc
. For example,