diff --git a/paddle/fluid/pybind/eager_py_layer.cc b/paddle/fluid/pybind/eager_py_layer.cc index 294da6956abc57c6871d50b5757d3b0fef5fb017..f80a39f9f0a9ba72b229df68222df1347ce3b010 100644 --- a/paddle/fluid/pybind/eager_py_layer.cc +++ b/paddle/fluid/pybind/eager_py_layer.cc @@ -445,11 +445,14 @@ PyObject* pylayer_method_apply(PyObject* cls, } if (outputs_size == 1) { - Py_XDECREF(outputs); - outputs = PyTuple_GetItem(outputs_tuple, 0); - Py_INCREF(outputs); - Py_XDECREF(outputs_tuple); + if (!PyTuple_Check(outputs) && !PyList_Check(outputs)) { + Py_XDECREF(outputs); + outputs = PyTuple_GetItem(outputs_tuple, 0); + Py_INCREF(outputs); + Py_XDECREF(outputs_tuple); + } } + Py_XDECREF(forward_args); Py_XDECREF(kwargs_value_list); Py_XDECREF(backward_function);