From af085006be050f75d5c807a94473e0d548d604c2 Mon Sep 17 00:00:00 2001 From: yaoxuefeng6 Date: Mon, 17 Aug 2020 12:11:41 +0800 Subject: [PATCH 1/2] fix Flatten api test=develop --- python/paddle/fluid/dygraph/nn.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index e56f26f1b1b94..acdeaa642728c 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -3226,19 +3226,6 @@ def __init__(self, start_axis=1, stop_axis=-1): self.stop_axis = stop_axis def forward(self, input): - out = self._helper.create_variable_for_type_inference(input.dtype) - x_shape = self._helper.create_variable_for_type_inference(input.dtype) - - if in_dygraph_mode(): - dy_out, _ = core.ops.flatten_contiguous_range( - input, 'start_axis', self.start_axis, 'stop_axis', - self.stop_axis) - return dy_out - self._helper.append_op( - type="flatten_contiguous_range", - inputs={"X": input}, - outputs={"Out": out, - "XShape": x_shape}, - attrs={"start_axis": self.start_axis, - "stop_axis": self.stop_axis}) + out = paddle.tensor.manipulation.flatten( + input, start_axis=self.start_axis, stop_axis=self.stop_axis) return out From cb8ff42d98efe7397b165bfbfcaa93ac13f48207 Mon Sep 17 00:00:00 2001 From: yaoxuefeng6 Date: Fri, 21 Aug 2020 15:49:04 +0800 Subject: [PATCH 2/2] fix class Flatten ut test=develop --- python/paddle/fluid/dygraph/nn.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/paddle/fluid/dygraph/nn.py b/python/paddle/fluid/dygraph/nn.py index 1f68db4dedffa..69d27e2c2341b 100644 --- a/python/paddle/fluid/dygraph/nn.py +++ b/python/paddle/fluid/dygraph/nn.py @@ -14,6 +14,7 @@ from __future__ import print_function +import paddle from six.moves import reduce from .. import core from ..layers import utils