提交 d149e674 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add "base" property to CudaNdarray, similar to numpy ndarray's one.

上级 6cbeca31
...@@ -1790,6 +1790,19 @@ CudaNdarray_get_ndim(CudaNdarray *self, void *closure) ...@@ -1790,6 +1790,19 @@ CudaNdarray_get_ndim(CudaNdarray *self, void *closure)
return PyInt_FromLong(self->nd); return PyInt_FromLong(self->nd);
} }
static PyObject *
CudaNdarray_get_base(CudaNdarray *self, void *closure)
{
PyObject * base = self->base;
if (!base)
{
// We cannot return a NULL pointer, use None instead
base = Py_None;
}
Py_INCREF(base);
return base;
}
static PyGetSetDef CudaNdarray_getset[] = { static PyGetSetDef CudaNdarray_getset[] = {
{"shape", {"shape",
(getter)CudaNdarray_get_shape, (getter)CudaNdarray_get_shape,
...@@ -1833,6 +1846,11 @@ static PyGetSetDef CudaNdarray_getset[] = { ...@@ -1833,6 +1846,11 @@ static PyGetSetDef CudaNdarray_getset[] = {
NULL, NULL,
"The number of dimensions in this object.", "The number of dimensions in this object.",
NULL}, NULL},
{"base",
(getter)CudaNdarray_get_base,
NULL,
"If this ndarray is a view, base is the original ndarray.",
NULL},
{NULL, NULL, NULL, NULL} /* Sentinel */ {NULL, NULL, NULL, NULL} /* Sentinel */
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论