[Dy2Stat]BugFix StaticAanlysis with gast.Subscript #32969
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Describe
1. PR内容
BugFix StaticAanlysis with gast.Subscript
2. 复现样例
在有关
for-loop
的语法转换中,依赖的变量如果是从上游tensor slice出来的,则在StaticAnalysis阶段无法被解析为Tensor
类型。原因是因为StaticAnalysis中缺少对gast.Subscript
语法的处理。此PR添加此类处理:如果node.value
是个Variable,则slice出来的类型也是Variable,否则返回为statement
类型Before this PR,
a = []
will not be converted becauseiter_num
is not considered asVariable
. The transformed codes is:After this PR, The transformed codes is as expected: