Skip to content
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][Fix] Correct round-trip of explicit root block #12673

Merged
merged 3 commits into from
Sep 21, 2022

Conversation

Lunderberg
Copy link
Contributor

Prior to this commit, when converting TIR to TVMScript, the root tir::Block is typically hidden. When parsing, however, tvm::tir::ScriptComplete will wrap the function body in a root block if the primfunc if the contains at least one block and does not already have a root block. As a result, if the root block is the only block present, it would be stripped by a round-trip.

This commit tightens the condition for hiding the root tir::Block when converting to TVMScript, so that it is printed in cases where the autocompleter would reinsert it when parsing.

Prior to this commit, when converting TIR to TVMScript, the root
`tir::Block` is typically hidden.  When parsing, however,
`tvm::tir::ScriptComplete` will wrap the function body in a root block
if the primfunc if the contains at least one block and does not
already have a root block.  As a result, if the root block is the only
block present, it would be stripped by a round-trip.

This commit tightens the condition for hiding the root `tir::Block`
when converting to TVMScript, so that it is printed in cases where
the autocompleter would reinsert it when parsing.
src/printer/tvmscript_printer.cc Outdated Show resolved Hide resolved
@shingjan
Copy link
Contributor

LGTM. Thanks for sending this!

@Lunderberg Lunderberg merged commit fdc6894 into apache:main Sep 21, 2022
@Lunderberg Lunderberg deleted the tvmscript_roundtrip_empty_root branch September 21, 2022 13:04
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
)

* [TVMScript][Fix] Correct round-trip of explicit root block

Prior to this commit, when converting TIR to TVMScript, the root
`tir::Block` is typically hidden.  When parsing, however,
`tvm::tir::ScriptComplete` will wrap the function body in a root block
if the primfunc if the contains at least one block and does not
already have a root block.  As a result, if the root block is the only
block present, it would be stripped by a round-trip.

This commit tightens the condition for hiding the root `tir::Block`
when converting to TVMScript, so that it is printed in cases where
the autocompleter would reinsert it when parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants