Skip to content

Commit b744683

Browse files
committed
Fix crash due to excessive decref of 1
Do not decref borrowed references.
1 parent 9f1aaac commit b744683

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

theano/gpuarray/reduction.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def c_code(self, node, name, input_names, output_names, sub):
6666
for (unsigned i = 0; i < %(name)s_redux_len; ++i) {
6767
PyObject* axis_object = PyTuple_GET_ITEM(%(axes)s, i);
6868
%(name)s_axes_to_reduce[i] = (unsigned) PyInt_AS_LONG(axis_object);
69-
Py_XDECREF(axis_object);
7069
}
7170
7271
size_t %(name)s_input_ndim = PyGpuArray_NDIM(%(X)s);
@@ -136,3 +135,6 @@ def c_code_cleanup(self, node, name, inputs, outputs, sub):
136135
free(%(name)s_output_dims);
137136
free(%(name)s_axes_to_reduce);
138137
""" % {'name': name, 'X': inputs[0]}
138+
139+
def c_code_cache_version(self):
140+
return (1,)

theano/tensor/basic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,6 @@ def c_code(self, node, name, inp, out, sub):
12591259
} else if(PyTuple_GET_SIZE(%(axis)s) == 1) {
12601260
PyObject* axis_object = PyTuple_GET_ITEM(%(axis)s, 0);
12611261
axis = (int)PyInt_AS_LONG(axis_object);
1262-
Py_XDECREF(axis_object);
12631262
if (axis > PyArray_NDIM(%(x)s)-1 || axis < -PyArray_NDIM(%(x)s)) {
12641263
PyErr_SetString(PyExc_ValueError,
12651264
"MaxAndArgmax: bad axis argument");
@@ -1308,7 +1307,7 @@ def c_code(self, node, name, inp, out, sub):
13081307
return ret % locals()
13091308

13101309
def c_code_cache_version(self):
1311-
return (4,)
1310+
return (5,)
13121311

13131312
def infer_shape(self, node, shapes):
13141313
ishape = shapes[0]

0 commit comments

Comments
 (0)