提交 0844dcb4 authored 作者: Frederic's avatar Frederic

Fix crash

上级 c6d90a7b
...@@ -135,16 +135,20 @@ def c_set_tensor4d(var, desc, err, fail): ...@@ -135,16 +135,20 @@ def c_set_tensor4d(var, desc, err, fail):
return -1; return -1;
} }
ds = gpuarray_get_elsize(%(var)s->ga.typecode); ds = gpuarray_get_elsize(%(var)s->ga.typecode);
int str0, str1, str2, str3;
// cudnn do not like 0s in strides
str3 = PyGpuArray_STRIDES(%(var)s)[3]?PyGpuArray_STRIDES(%(var)s)[3]/ds:1;
str2 = PyGpuArray_STRIDES(%(var)s)[2]?PyGpuArray_STRIDES(%(var)s)[2]/ds:PyGpuArray_DIMS(%(var)s)[3];
str1 = PyGpuArray_STRIDES(%(var)s)[1]?PyGpuArray_STRIDES(%(var)s)[1]/ds:PyGpuArray_DIMS(%(var)s)[2]*PyGpuArray_DIMS(%(var)s)[3];
str0 = PyGpuArray_STRIDES(%(var)s)[0]?PyGpuArray_STRIDES(%(var)s)[0]/ds:PyGpuArray_DIMS(%(var)s)[2]*PyGpuArray_DIMS(%(var)s)[3]*PyGpuArray_DIMS(%(var)s)[1];
%(err)s = cudnnSetTensor4dDescriptorEx( %(err)s = cudnnSetTensor4dDescriptorEx(
%(desc)s, dt, %(desc)s, dt,
PyGpuArray_DIMS(%(var)s)[0], PyGpuArray_DIMS(%(var)s)[0],
PyGpuArray_DIMS(%(var)s)[1], PyGpuArray_DIMS(%(var)s)[1],
PyGpuArray_DIMS(%(var)s)[2], PyGpuArray_DIMS(%(var)s)[2],
PyGpuArray_DIMS(%(var)s)[3], PyGpuArray_DIMS(%(var)s)[3],
PyGpuArray_STRIDES(%(var)s)[0] / ds, str0, str1, str2, str3);
PyGpuArray_STRIDES(%(var)s)[1] / ds,
PyGpuArray_STRIDES(%(var)s)[2] / ds,
PyGpuArray_STRIDES(%(var)s)[3] / ds);
if (%(err)s != CUDNN_STATUS_SUCCESS) { if (%(err)s != CUDNN_STATUS_SUCCESS) {
PyErr_Format(PyExc_RuntimeError, PyErr_Format(PyExc_RuntimeError,
...@@ -1365,7 +1369,7 @@ if (theano_prep_output(&%(outs)s, PyGpuArray_NDIM(%(ins)s), ...@@ -1365,7 +1369,7 @@ if (theano_prep_output(&%(outs)s, PyGpuArray_NDIM(%(ins)s),
return result return result
def c_code_cache_version(self): def c_code_cache_version(self):
return (0, 6, version()) return (0, 7, version())
def method(self): def method(self):
raise NotImplementedError('GpuDnnSoftmaxBase::method') raise NotImplementedError('GpuDnnSoftmaxBase::method')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论