提交 cb15c1c6 authored 作者: Frederic Bastien's avatar Frederic Bastien

implement CudaNdarray.ndim to have the same interface as ndarray.ndim.

上级 dbf290a9
...@@ -1751,6 +1751,12 @@ CudaNdarray_get_dtype(CudaNdarray *self, void *closure) ...@@ -1751,6 +1751,12 @@ CudaNdarray_get_dtype(CudaNdarray *self, void *closure)
return PyString_FromString("float32"); return PyString_FromString("float32");
} }
static PyObject *
CudaNdarray_get_ndim(CudaNdarray *self, void *closure)
{
return PyInt_FromLong(self->nd);
}
static PyGetSetDef CudaNdarray_getset[] = { static PyGetSetDef CudaNdarray_getset[] = {
{"shape", {"shape",
(getter)CudaNdarray_get_shape, (getter)CudaNdarray_get_shape,
...@@ -1765,7 +1771,7 @@ static PyGetSetDef CudaNdarray_getset[] = { ...@@ -1765,7 +1771,7 @@ static PyGetSetDef CudaNdarray_getset[] = {
//gpudata is needed to allow calling pycuda fct with CudaNdarray input. //gpudata is needed to allow calling pycuda fct with CudaNdarray input.
{"gpudata", {"gpudata",
(getter)CudaNdarray_get_dev_data, (getter)CudaNdarray_get_dev_data,
NULL,//setter)CudaNdarray_set_dev_data, NULL,
"device data pointer", "device data pointer",
NULL}, NULL},
{"_dev_data", {"_dev_data",
...@@ -1789,6 +1795,11 @@ static PyGetSetDef CudaNdarray_getset[] = { ...@@ -1789,6 +1795,11 @@ static PyGetSetDef CudaNdarray_getset[] = {
NULL, NULL,
"Return the number of element in this objects.", "Return the number of element in this objects.",
NULL}, NULL},
{"ndim",
(getter)CudaNdarray_get_ndim,
NULL,
"The number of dimensions in this objects",
NULL},
{NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL} /* Sentinel */
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论