diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py b/python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py index 45a42d481b5a98f38445b9ed471f06e0267a3e73..368a01de81efc5dbfc2561f8a0023e0774e12f69 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/static_analysis.py @@ -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): diff --git a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py index afccaca69383cda48531e0031e29ed9199987e44..eb545e5ca26add0be3f61a6025833ddc8b376012 100644 --- a/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py +++ b/python/paddle/fluid/tests/unittests/dygraph_to_static/test_static_analysis.py @@ -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 = [