未验证 提交 1252f4bb 编写于 作者: 0 0x45f 提交者: GitHub

[Dy2St]Handle `a, b = paddle.shape(x)` in Static Analysis (#39245)

* refine Assign

* add UT
上级 383de295
......@@ -334,6 +334,13 @@ class StaticAnalysisVisitor(object):
if isinstance(target, gast.Name):
self.node_to_wrapper_map[target].node_var_type = ret_type
self.var_env.set_var_type(target.id, ret_type)
# Handle statements like `a, b = paddle.shape(x)`
elif isinstance(target, gast.Tuple):
for sub_target in target.elts:
if isinstance(sub_target, gast.Name):
self.node_to_wrapper_map[
sub_target].node_var_type = ret_type
self.var_env.set_var_type(sub_target.id, ret_type)
return ret_type
if isinstance(node, gast.AnnAssign):
......
......@@ -146,13 +146,16 @@ result_var_type6 = {
def func_to_test7(a: int, b: float, c: paddle.Tensor, d: float='diff'):
a = True
e, f = paddle.shape(c)
result_var_type7 = {
'a': {NodeVarType.BOOLEAN},
'b': {NodeVarType.FLOAT},
'c': {NodeVarType.TENSOR},
'd': {NodeVarType.STRING}
'd': {NodeVarType.STRING},
'e': {NodeVarType.PADDLE_RETURN_TYPES},
'f': {NodeVarType.PADDLE_RETURN_TYPES}
}
test_funcs = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册