提交 2e6b6819 authored 作者: Frederic Bastien's avatar Frederic Bastien

Remove segmentation faul when the CudaNdarray base is not a CudaNdarray.

上级 88adfe51
...@@ -2509,12 +2509,15 @@ int CudaNdarray_set_device_data(CudaNdarray * self, float * data, PyObject * bas ...@@ -2509,12 +2509,15 @@ int CudaNdarray_set_device_data(CudaNdarray * self, float * data, PyObject * bas
} }
} }
// Get the original base object (base.base.base...) // Get the original base object (base.base.base...)
// TODO: check that base is indeed a CudaNdarray?
PyObject * orig_base = base; PyObject * orig_base = base;
while (((CudaNdarray*) orig_base)->base) // base is not always a CudaNdarray. It can be a GpuArray from pycuda, ...
if (orig_base && CudaNdarray_Check(orig_base))
{ {
// base_base is itself a view while (((CudaNdarray*) orig_base)->base)
orig_base = ((CudaNdarray*) orig_base)->base; {
// base_base is itself a view
orig_base = ((CudaNdarray*) orig_base)->base;
}
} }
//N.B. XDECREF and XINCREF are no-ops for NULL pointers //N.B. XDECREF and XINCREF are no-ops for NULL pointers
if (self->base != orig_base) if (self->base != orig_base)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论