Skip to content

Conversation

@junrushao
Copy link
Member

This PR introduces some minor restructuring of the python/tvm/script
folder structure to make it more convenient for future upstreaming.

CC: @Hzfengsy @cyx-6

@junrushao junrushao marked this pull request as ready for review August 19, 2022 04:50
Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Hzfengsy Hzfengsy left a comment

Choose a reason for hiding this comment

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

I think a better approach is renaming the new parser rather than the old one. i.e. we upstream at python/tvm/script/new_parser for now. Once the new parser is fully upstreamed, we rename it back

@junrushao
Copy link
Member Author

Okay either way works

@areusch areusch added needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it and removed needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it labels Oct 19, 2022
@junrushao junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch 3 times, most recently from b2eceac to 2a199e4 Compare October 25, 2022 17:15
@junrushao junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch 19 times, most recently from 52afa15 to c26ced4 Compare November 10, 2022 20:24
@junrushao junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch 2 times, most recently from 0c71ac1 to f13c52b Compare November 10, 2022 21:12
@junrushao junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch 4 times, most recently from 75f1bcc to 53ead89 Compare November 11, 2022 04:33
@tvm-bot
Copy link
Collaborator

tvm-bot commented Nov 11, 2022

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 junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch 4 times, most recently from 71df867 to 61ba89b Compare November 11, 2022 19:11
This PR introduces some minor restructuring of the `python/tvm/script`
folder structure to make it more convenient for future upstreaming.

Co-authored-by: Yaxing Cai <caiyaxing666@gmail.com>
@junrushao junrushao force-pushed the feature/2022-08-18/organize-tvmscript branch from 61ba89b to 23b8b0b Compare November 12, 2022 00:26
Copy link
Contributor

@MasterJH5574 MasterJH5574 left a comment

Choose a reason for hiding this comment

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

Thanks for resolving my comments! LGTM.

@MasterJH5574 MasterJH5574 merged commit b20b7c4 into apache:main Nov 12, 2022
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Nov 15, 2022
For the previous version of the parser, this was special-cased for
some intrinsic operators.  After the new TVMScript was enabled in
apache#12496, any `PrimExpr` that appears
in the body of a statement is silently ignored.  This commit updates
the parser to instead wrap the bare `PrimExpr` in a `tir::Evaluate`
node.

This change effectively allows [expression
statements](https://docs.python.org/3/reference/simple_stmts.html#expression-statements)
in TVMScript, which are converted to `tir::Evaluate` nodes during
parsing.

from .parser import ir_module, from_source
"""TVM Script APIs of TVM Python Package"""
from .parser import ir, ir_module, parse as from_source, tir
Copy link
Contributor

Choose a reason for hiding this comment

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

@junrushao it appears this line, combined with the movement of the old parser from parser/ to /parser_v1 means that this PR implicitly switches things over to using the new parser. Am I interpreting this correctly, and was that intentional?

Hzfengsy pushed a commit that referenced this pull request Nov 16, 2022
…13396)

* [TVMScript] Use tir::Evaluate if expression is in statement context

For the previous version of the parser, this was special-cased for
some intrinsic operators.  After the new TVMScript was enabled in
#12496, any `PrimExpr` that appears
in the body of a statement is silently ignored.  This commit updates
the parser to instead wrap the bare `PrimExpr` in a `tir::Evaluate`
node.

This change effectively allows [expression
statements](https://docs.python.org/3/reference/simple_stmts.html#expression-statements)
in TVMScript, which are converted to `tir::Evaluate` nodes during
parsing.

* Update to print T.evaluate() for readability, except for CallNode
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
This PR introduces some minor restructuring of the `python/tvm/script`
folder structure to make it more convenient for future upstreaming.

Co-authored-by: Yaxing Cai <caiyaxing666@gmail.com>
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…pache#13396)

* [TVMScript] Use tir::Evaluate if expression is in statement context

For the previous version of the parser, this was special-cased for
some intrinsic operators.  After the new TVMScript was enabled in
apache#12496, any `PrimExpr` that appears
in the body of a statement is silently ignored.  This commit updates
the parser to instead wrap the bare `PrimExpr` in a `tir::Evaluate`
node.

This change effectively allows [expression
statements](https://docs.python.org/3/reference/simple_stmts.html#expression-statements)
in TVMScript, which are converted to `tir::Evaluate` nodes during
parsing.

* Update to print T.evaluate() for readability, except for CallNode
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Mar 16, 2023
Usually, when using TVMScript to represent a `PrimFunc` variable
definition `var_name = expr` defines `LetStmt` with a variable named
`var_name` bound to the expression `expr`.  However, prior to this
commit, if `expr` is a `tir::Var`, the TVMScript parser would instead
silently omit the `LetStmt`, and rename all instances of that variable
to `var_name`.

The root cause was in the `VarTable.exist` check, which erroneously
returned False in all cases.  This was due to a `value is v` check,
which checked if the value was the same as the stack of
maybe-shadowing values that share the same name.  Replacing the
'value is v` check with a `value in v` check resolves this issue.

This bug dates to the initial implementation of the new TVMScript
parser in apache#12496.
junrushao pushed a commit that referenced this pull request Apr 2, 2023
)

* [Bugfix][TVMScript] Handle LetStmt for `var1 = var2` expressions

Usually, when using TVMScript to represent a `PrimFunc` variable
definition `var_name = expr` defines `LetStmt` with a variable named
`var_name` bound to the expression `expr`.  However, prior to this
commit, if `expr` is a `tir::Var`, the TVMScript parser would instead
silently omit the `LetStmt`, and rename all instances of that variable
to `var_name`.

The root cause was in the `VarTable.exist` check, which erroneously
returned False in all cases.  This was due to a `value is v` check,
which checked if the value was the same as the stack of
maybe-shadowing values that share the same name.  Replacing the
'value is v` check with a `value in v` check resolves this issue.

This bug dates to the initial implementation of the new TVMScript
parser in #12496.

* Avoid implicit `PrimExpr.__bool__` from `if value in value_stack`

* Use T.meta_var where variable renaming is required.
zxybazh pushed a commit to zxybazh/tvm that referenced this pull request Apr 4, 2023
…che#14320)

* [Bugfix][TVMScript] Handle LetStmt for `var1 = var2` expressions

Usually, when using TVMScript to represent a `PrimFunc` variable
definition `var_name = expr` defines `LetStmt` with a variable named
`var_name` bound to the expression `expr`.  However, prior to this
commit, if `expr` is a `tir::Var`, the TVMScript parser would instead
silently omit the `LetStmt`, and rename all instances of that variable
to `var_name`.

The root cause was in the `VarTable.exist` check, which erroneously
returned False in all cases.  This was due to a `value is v` check,
which checked if the value was the same as the stack of
maybe-shadowing values that share the same name.  Replacing the
'value is v` check with a `value in v` check resolves this issue.

This bug dates to the initial implementation of the new TVMScript
parser in apache#12496.

* Avoid implicit `PrimExpr.__bool__` from `if value in value_stack`

* Use T.meta_var where variable renaming is required.
zxybazh pushed a commit to zxybazh/tvm that referenced this pull request Apr 6, 2023
…che#14320)

* [Bugfix][TVMScript] Handle LetStmt for `var1 = var2` expressions

Usually, when using TVMScript to represent a `PrimFunc` variable
definition `var_name = expr` defines `LetStmt` with a variable named
`var_name` bound to the expression `expr`.  However, prior to this
commit, if `expr` is a `tir::Var`, the TVMScript parser would instead
silently omit the `LetStmt`, and rename all instances of that variable
to `var_name`.

The root cause was in the `VarTable.exist` check, which erroneously
returned False in all cases.  This was due to a `value is v` check,
which checked if the value was the same as the stack of
maybe-shadowing values that share the same name.  Replacing the
'value is v` check with a `value in v` check resolves this issue.

This bug dates to the initial implementation of the new TVMScript
parser in apache#12496.

* Avoid implicit `PrimExpr.__bool__` from `if value in value_stack`

* Use T.meta_var where variable renaming is required.
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.

6 participants