提交 3359b999 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Don't forget to decref output vars.

上级 9d85152a
...@@ -62,6 +62,7 @@ class HostFromGpu(Op): ...@@ -62,6 +62,7 @@ class HostFromGpu(Op):
%(name)s_ga = &%(inp)s->ga; %(name)s_ga = &%(inp)s->ga;
} }
%(name)s_dtype = typecode_to_dtype(%(inp)s->ga.typecode); %(name)s_dtype = typecode_to_dtype(%(inp)s->ga.typecode);
Py_XDECREF(%(out)s);
// PyArray_Empty below steals a reference to the dtype we pass it // PyArray_Empty below steals a reference to the dtype we pass it
// so we need an extra one to spare. // so we need an extra one to spare.
Py_INCREF(%(name)s_dtype); Py_INCREF(%(name)s_dtype);
...@@ -156,6 +157,7 @@ class GpuFromHost(Op): ...@@ -156,6 +157,7 @@ class GpuFromHost(Op):
// PyArray_GETCONTIGUOUS sets an error message if it fails // PyArray_GETCONTIGUOUS sets an error message if it fails
%(fail)s %(fail)s
} }
Py_XDECREF(%(out)s);
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context); %(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context);
if (%(out)s == NULL) { if (%(out)s == NULL) {
Py_DECREF(%(name)s_tmp); Py_DECREF(%(name)s_tmp);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论