提交 b65803fa authored 作者: Frederic's avatar Frederic

Fix memory leak of MaxAndArgmax when allow_gc=False

上级 9ad7030e
...@@ -1369,6 +1369,9 @@ class MaxAndArgmax(Op): ...@@ -1369,6 +1369,9 @@ class MaxAndArgmax(Op):
""" % locals() """ % locals()
ret = """ ret = """
int axis; int axis;
Py_CLEAR(%(max)s);
Py_CLEAR(%(argmax)s);//todo pass them as out parameter.
%(axis_code)s %(axis_code)s
%(max)s = (PyArrayObject*)PyArray_Max(%(x)s, axis, NULL); %(max)s = (PyArrayObject*)PyArray_Max(%(x)s, axis, NULL);
if(%(max)s == NULL){ if(%(max)s == NULL){
...@@ -1407,7 +1410,7 @@ class MaxAndArgmax(Op): ...@@ -1407,7 +1410,7 @@ class MaxAndArgmax(Op):
return ret % locals() return ret % locals()
def c_code_cache_version(self): def c_code_cache_version(self):
return (2,) return (3,)
def infer_shape(self, node, shapes): def infer_shape(self, node, shapes):
ishape, axis_shape = shapes ishape, axis_shape = shapes
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论