[TVMScript] Comments and docstrings printing#13839
Merged
junrushao merged 2 commits intoapache:mainfrom Jan 26, 2023
Merged
Conversation
Collaborator
|
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 |
junrushao
reviewed
Jan 25, 2023
Member
junrushao
left a comment
There was a problem hiding this comment.
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()
junrushao
reviewed
Jan 25, 2023
junrushao
approved these changes
Jan 25, 2023
Member
junrushao
left a comment
There was a problem hiding this comment.
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
fzi-peccia
pushed a commit
to fzi-peccia/tvm
that referenced
this pull request
Mar 27, 2023
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the
CommentDocfor comments printing andDocStringDocfor docstring printing. It enables to add free comments and docstring asstmtin printing, e.g.The free here means to not be bound to any
stmt, but acts as a singlestmt, similar toExprStmtDocforExprDoc.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_usageandprint_headersinto the printer configuration, to support the printing of headers forIRModuleandPrimFunc. For example,