提交 481bd2ef authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Enable CudaNdarray.zeros to return scalar arrays, and empty arrays.

上级 79a8fb46
...@@ -397,9 +397,7 @@ PyObject* CudaNdarray_Zeros(PyObject* dummy, PyObject* shape) ...@@ -397,9 +397,7 @@ PyObject* CudaNdarray_Zeros(PyObject* dummy, PyObject* shape)
if (shplen == 0) if (shplen == 0)
{ {
PyErr_SetString(PyExc_ValueError, return CudaNdarray_ZEROS(0, NULL);
"CudaNdarray_Zeros: empty shape not allowed");
return NULL;
} }
int* newdims = (int *)malloc(sizeof(int) * shplen); int* newdims = (int *)malloc(sizeof(int) * shplen);
...@@ -426,9 +424,9 @@ PyObject* CudaNdarray_Zeros(PyObject* dummy, PyObject* shape) ...@@ -426,9 +424,9 @@ PyObject* CudaNdarray_Zeros(PyObject* dummy, PyObject* shape)
int shp_el = PyInt_AsLong(shp_el_obj); int shp_el = PyInt_AsLong(shp_el_obj);
Py_DECREF(shp_el_obj); Py_DECREF(shp_el_obj);
if (shp_el <= 0) if (shp_el < 0)
{ {
PyErr_SetString(PyExc_ValueError, "CudaNdarray_Zeros: shape must not contain 0 (or negative value) for size of a dimension"); PyErr_SetString(PyExc_ValueError, "CudaNdarray_Zeros: shape must contain only non-negative values for size of a dimension");
free(newdims); free(newdims);
return NULL; return NULL;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论