未验证 提交 aa1aac9d 编写于 作者: W wanghuancoder 提交者: GitHub

fix bug about deallocating None (#33723)

* fix bug about deallocating None, test=develop
上级 0722297d
......@@ -268,7 +268,7 @@ static PyObject * %s(PyObject *self, PyObject *args, PyObject *kwargs)
imperative::GetCurrentTracer()->TraceOp("%s", ins, outs, attrs, {%s});
PyEval_RestoreThread(tstate);
tstate = nullptr;
return %s;
%s
}
catch(...) {
if (tstate) {
......@@ -488,13 +488,13 @@ std::string GenerateOpFunctionsBody(
viwe_input_name, viwe_output_name);
}
if (outs_num == 0) {
return_str = "Py_None";
return_str = "Py_INCREF(Py_None);\n return Py_None;";
} else if (outs_num == 1) {
return_str = "MakeReturnPyObject(" + return_str + ")";
return_str = "return MakeReturnPyObject(" + return_str + ");";
} else {
return_str = "MakeReturnPyObject(" +
return_str = "return MakeReturnPyObject(" +
paddle::string::Sprintf(RETURN_TUPLE_TEMPLATE, return_str) +
")";
");";
}
std::string function_args = "";
if (input_args == "") {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册