提交 90b5a114 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1823 from caglar/cuda_ndarray_fix

Cuda ndarray fix
...@@ -363,9 +363,9 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd, ...@@ -363,9 +363,9 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd,
CudaNdarray_set_stride(self, i, (dim[i] == 1) ? 0 : size); CudaNdarray_set_stride(self, i, (dim[i] == 1) ? 0 : size);
CudaNdarray_set_dim(self, i, dim[i]); CudaNdarray_set_dim(self, i, dim[i]);
//Detect overflow on unsigned integer //Detect overflow on unsigned integer
if (size > (SIZE_MAX / dim[i])) { if (dim[i] != 0 && size > (SIZE_MAX / dim[i])) {
PyErr_Format(PyExc_AssertionError, PyErr_Format(PyExc_AssertionError,
"Can't store in size_t the bytes resquested", "Can't store in size_t for the bytes requested",
size); size);
return -1; return -1;
} }
...@@ -380,9 +380,9 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd, ...@@ -380,9 +380,9 @@ static int CudaNdarray_alloc_contiguous(CudaNdarray *self, const int nd,
CudaNdarray_set_dim(self, i, dim[i]); CudaNdarray_set_dim(self, i, dim[i]);
//Detect overflow on unsigned integer //Detect overflow on unsigned integer
if (size > (SIZE_MAX / dim[i])) { if (dim[i] != 0 && size > (SIZE_MAX / dim[i])) {
PyErr_Format(PyExc_AssertionError, PyErr_Format(PyExc_AssertionError,
"Can't store in size_t the bytes resquested", "Can't store in size_t for the bytes requested",
size); size);
return -1; return -1;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论