[Fix][TVMScript] Fix LetStmt printing logic#13900
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 |
Thank you for the fix! Here is my small question for the example, does it shoud be |
|
Off the topic, in the future, we might want to change the syntax to: with T.LetStmt(a) as b: |
|
@wrongtest-intellif Oh, that is just an example of the case that a |
I prefer this. The current one looks a little bit confusing from the view of native python users. |
|
Sounds good! I am merging this bugfix in first given it seems non-controversial. Right now I am focusing on implementing TVMScript printer for Relax (coming soon). And after this is done, the syntax we mentioned above will be introduced with backward compatibility guarantee. |
This PR is the bug fix reported in #13892. Initially, we mix the logic of
LetStmtdocsifying method with and without concise scoping. For example, inxin theLetStmtworks as a right value, while inxin theLetStmtworks as a left value as result.Our old logic mixed them together to generate the wrong code for the first case.
Meanwhile, during the fix, we found another bug in concise scoping check. For example, we have
here we should not output
becase this will define a new
y_1: int32 = 0indeed, due the the variable shadowing logic of the parser, which is different from theywe define and refer to.Our concise scoping
v: ... = ...should launch if and only if thevis never defined before.Otherwise, we use
with T.let(v, ...):instead.