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

fix pylayer forward memleak (#44826)

上级 92d14840
...@@ -31,6 +31,7 @@ class GradNodePyLayer : public GradNodeBase { ...@@ -31,6 +31,7 @@ class GradNodePyLayer : public GradNodeBase {
size_t bwd_out_slot_num) size_t bwd_out_slot_num)
: GradNodeBase(bwd_in_slot_num, bwd_out_slot_num) { : GradNodeBase(bwd_in_slot_num, bwd_out_slot_num) {
ctx_ = ctx; ctx_ = ctx;
Py_INCREF(ctx_);
} }
~GradNodePyLayer() override { Py_XDECREF(ctx_); }; ~GradNodePyLayer() override { Py_XDECREF(ctx_); };
......
...@@ -383,6 +383,7 @@ PyObject* pylayer_method_apply(PyObject* cls, ...@@ -383,6 +383,7 @@ PyObject* pylayer_method_apply(PyObject* cls,
Py_XDECREF(kwargs_value_list); Py_XDECREF(kwargs_value_list);
Py_XDECREF(backward_function); Py_XDECREF(backward_function);
Py_XDECREF(forward_fn); Py_XDECREF(forward_fn);
Py_XDECREF(ctx);
return outputs; return outputs;
EAGER_CATCH_AND_THROW_RETURN_NULL EAGER_CATCH_AND_THROW_RETURN_NULL
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册