From d8a09e2592127cc4734562886e6fbe493b638f5a Mon Sep 17 00:00:00 2001 From: Charles-hit <56987902+Charles-hit@users.noreply.github.com> Date: Tue, 6 Sep 2022 16:02:04 +0800 Subject: [PATCH] replace reshape op with reshape2 op (#45735) --- python/paddle/fluid/layer_helper_base.py | 10 +++++++--- python/paddle/fluid/layers/tensor.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/paddle/fluid/layer_helper_base.py b/python/paddle/fluid/layer_helper_base.py index cb604b1ce89..18b594d899c 100644 --- a/python/paddle/fluid/layer_helper_base.py +++ b/python/paddle/fluid/layer_helper_base.py @@ -163,10 +163,14 @@ class LayerHelperBase(object): [self.name, 'weight_norm_reshape'])), dtype=dtype, persistable=False) - block.append_op(type='reshape', + x_shape = block.create_var(name="Xshape", dtype=x.dtype) + block.append_op(type="reshape2", inputs={'X': x}, - outputs={'Out': out}, - attrs={'shape': shape}) + attrs={'shape': shape}, + outputs={ + "Out": out, + "XShape": x_shape + }) return out def __transpose_op(x, diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index 8affa851b00..a33cfa055c5 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -1833,7 +1833,7 @@ def eye(num_rows, re_shape = re_shape + [num_rows, num_columns] expand_times = batch_shape + [1, 1] if _non_static_mode(): - out = _legacy_C_ops.reshape(out, 'shape', re_shape) + out, _ = _legacy_C_ops.reshape2(out, None, 'shape', re_shape) return _legacy_C_ops.expand(out, None, 'expand_times', expand_times) if not isinstance(batch_shape, list): -- GitLab