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