-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix][TVMScript] Fix
LetStmt
printing logic (#13900)
This PR is the bug fix reported in #13892. Initially, we mix the logic of `LetStmt` docsifying method with and without concise scoping. For example, in ```python x = T.var("int32") with T.let(x, 0): ``` `x` in the `LetStmt` works as a right value, while in ```python x: T.int32 = 0 ``` `x` in the `LetStmt` works 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 ```python x = T.var("int32") y = T.var("int32") with T.let(x, y): with T.let(y, 0): ``` here we should not output ```python x = T.var("int32") y = T.var("int32") with T.let(x, y): y: int32 = 0 ``` becase this will define a new `y_1: int32 = 0` indeed, due the the variable shadowing logic of the parser, which is different from the `y` we define and refer to. Our concise scoping `v: ... = ...` should launch if and only if the `v` is never defined before. Otherwise, we use `with T.let(v, ...):` instead.
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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