diff --git a/python/paddle/fluid/layer_helper_base.py b/python/paddle/fluid/layer_helper_base.py index cb604b1ce89a838f6bf25a3465a67541485d203a..18b594d899c4c48a0eecac36479e5c1ef3969bf6 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 8affa851b008f852405436c4287f063f833b69fa..a33cfa055c5b935687ae3ea3dadddb33025cd92f 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):