Skip to content

Conversation

@Lunderberg
Copy link
Contributor

The TIR equivalent of python's return statement is the tir::builtin::ret() operator. Prior to this commit, this was printed as T.ret(value), and any use of return statement in TVMScript produced an error while parsing.

This commit updates the TVMScript parsing to produce T.ret(value) for the python return value statement. If syntax sugar is enabled, the TIR T.ret(value) will be printed as return value.

The TIR equivalent of python's `return` statement is the
`tir::builtin::ret()` operator.  Prior to this commit, this was
printed as `T.ret(value)`, and any use of `return` statement in
TVMScript produced an error while parsing.

This commit updates the TVMScript parsing to produce `T.ret(value)`
for the python `return value` statement.  If syntax sugar is enabled,
the TIR `T.ret(value)` will be printed as `return value`.
Copy link
Contributor

@slyubomirsky slyubomirsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nice parsing improvement 🙂

@tqchen tqchen merged commit ff3716b into apache:main Feb 27, 2024
@Lunderberg Lunderberg deleted the tvmscript_allow_python_return_stmt branch February 27, 2024 21:44
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Mar 12, 2024
…he#16640)

The TIR equivalent of python's `return` statement is the
`tir::builtin::ret()` operator.  Prior to this commit, this was
printed as `T.ret(value)`, and any use of `return` statement in
TVMScript produced an error while parsing.

This commit updates the TVMScript parsing to produce `T.ret(value)`
for the python `return value` statement.  If syntax sugar is enabled,
the TIR `T.ret(value)` will be printed as `return value`.
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