diff --git a/paddle/fluid/pybind/op_function_generator.h b/paddle/fluid/pybind/op_function_generator.h index d9aab3dbb04ce4a129ef2d5407ec18a8219c42a2..c348e04e6c7acbecdd36099bc9dbeceba8262229 100644 --- a/paddle/fluid/pybind/op_function_generator.h +++ b/paddle/fluid/pybind/op_function_generator.h @@ -227,7 +227,6 @@ std::map> op_passing_outs_map = { {"c_reduce", {"Out"}}, {"c_scatter", {"Out"}}, {"barrier", {"Out"}}, - {"assign", {"Out"}}, {"fake_quantize_dequantize_moving_average_abs_max", {"Out", "OutScale", "OutAccum", "OutState"}}, {"fake_quantize_dequantize_abs_max", {"Out", "OutScale"}}, @@ -243,6 +242,8 @@ std::map> op_passing_outs_map = { {"get_float_status", {"FloatStatusOut"}}, {"assign", {"Out"}}, {"assign_value", {"Out"}}, + {"split", {"Out"}}, + {"concat", {"Out"}}, }; // NOTE(pangyoki): Tensor View Strategy. diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 7dc0d0af68c16359854915236a1d2aed71c34c77..9be15d23bb371a977c3f78cd178dbe5bd2cccc24 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5026,7 +5026,9 @@ def split(input, num_or_sections, dim=-1, name=None): raise TypeError( "The type of 'num_or_sections' in split must be int, list or tuple in imperative mode, but " "received %s." % (type(num_or_sections))) - return _C_ops.split(input, num, *attrs) + out = [_varbase_creator() for n in range(num)] + _C_ops.split(input, out, *attrs) + return out check_variable_and_dtype( input, 'input', diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index a49b4b79fbf0ccef4d5075dd286fbd92c1891388..1cac55170476fd85e45932788ff9db288faf4b84 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -337,7 +337,9 @@ def concat(input, axis=0, name=None): axis = axis.item(0) if not isinstance(input, Variable): input = [t for t in input if t.shape.count(0) == 0] - return _C_ops.concat(input, 'axis', axis) + out = _varbase_creator() + _C_ops.concat(input, out, 'axis', axis) + return out check_type(input, 'input', (list, tuple, Variable), 'concat') if not isinstance(input, Variable): diff --git a/python/paddle/nn/utils/transform_parameters.py b/python/paddle/nn/utils/transform_parameters.py index ef5cd8700761f8c5c2ab73c2ec4c88d5475f831d..99870ce29a138dab7bd52e76fd1e582a8ffc045e 100644 --- a/python/paddle/nn/utils/transform_parameters.py +++ b/python/paddle/nn/utils/transform_parameters.py @@ -69,7 +69,9 @@ def parameters_to_vector(parameters, name=None): out = _varbase_creator(dtype=dtype) if in_dygraph_mode(): with paddle.fluid.dygraph.no_grad(): - _C_ops.concat(parameters, 'axis', 0)._share_underline_tensor_to(out) + tmp = _varbase_creator() + _C_ops.concat(parameters, tmp, 'axis', 0) + tmp._share_underline_tensor_to(out) else: _dygraph_tracer().trace_op( type='concat', @@ -120,8 +122,8 @@ def vector_to_parameters(vec, parameters, name=None): if in_dygraph_mode(): with paddle.fluid.dygraph.no_grad(): - res = _C_ops.split(vec, - len(parameters), 'axis', 0, 'sections', sections) + res = [_varbase_creator() for n in range(len(parameters))] + _C_ops.split(vec, res, 'axis', 0, 'sections', sections) for i in range(0, len(res)): res[i]._share_underline_tensor_to(parameters[i]) else: diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 5376d393ea4325ed8ce70bd439fd5dd0e0b85caf..c6cbb533c4453e6495ead305877eeafc0fc15f4c 100755 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -3911,7 +3911,8 @@ def diff(x, n=1, axis=-1, prepend=None, append=None, name=None): input_list = [x, append] has_pend = True if has_pend: - new_input = _C_ops.concat(input_list, 'axis', axis) + new_input = _varbase_creator() + _C_ops.concat(input_list, new_input, 'axis', axis) else: new_input = x