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

[Dy2St]Refine AnnAssign in static_analysis (#39572)

上级 d4144616
......@@ -349,7 +349,11 @@ class StaticAnalysisVisitor(object):
ret_type = {NodeVarType.type_from_annotation(node.annotation)}
# if annotation and value(Constant) are diffent type, we use value type
if node.value:
ret_type = self.node_to_wrapper_map[node.value].node_var_type
node_value_type = self.node_to_wrapper_map[
node.value].node_var_type
if not (node_value_type &
{NodeVarType.UNKNOWN, NodeVarType.STATEMENT}):
ret_type = node_value_type
if isinstance(node.target, gast.Name):
self.node_to_wrapper_map[node.target].node_var_type = ret_type
self.var_env.set_var_type(node.target.id, ret_type)
......
......@@ -147,6 +147,7 @@ result_var_type6 = {
def func_to_test7(a: int, b: float, c: paddle.Tensor, d: float='diff'):
a = True
e, f = paddle.shape(c)
g: paddle.Tensor = len(c)
result_var_type7 = {
......@@ -155,7 +156,8 @@ result_var_type7 = {
'c': {NodeVarType.TENSOR},
'd': {NodeVarType.STRING},
'e': {NodeVarType.PADDLE_RETURN_TYPES},
'f': {NodeVarType.PADDLE_RETURN_TYPES}
'f': {NodeVarType.PADDLE_RETURN_TYPES},
'g': {NodeVarType.TENSOR}
}
test_funcs = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册