From 5413fd79938d2e0c71e9140ac98073f88b6ef9eb Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Wed, 8 Jun 2022 14:14:15 +0800 Subject: [PATCH] [Dy2Stat]Make convert_shape return List type (#43302) --- .../fluid/dygraph/dygraph_to_static/convert_operators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py b/python/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py index 7933ddfe59..78cf8f3b85 100644 --- a/python/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py +++ b/python/paddle/fluid/dygraph/dygraph_to_static/convert_operators.py @@ -320,7 +320,7 @@ def convert_var_shape(x, idx=None, in_control_flow=False): or has_negative(x.shape, idx)): return nn.shape(x) if idx is None else nn.shape(x)[idx] else: - return x.shape if idx is None else x.shape[idx] + return list(x.shape) if idx is None else x.shape[idx] def convert_var_shape_simple(x): @@ -330,7 +330,8 @@ def convert_var_shape_simple(x): if isinstance(x, Variable): return nn.shape(x) else: - return x.shape + # Use list() to make returned type consistant with dygraph + return list(x.shape) def eval_if_exist_else_none(name, global_symbol_table): -- GitLab