提交 5c901d61 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

add error handling to fprint_CudaNdarray

Conflicts: theano/sandbox/cuda/cuda_ndarray.cu
上级 e718539f
...@@ -3325,7 +3325,14 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self, ...@@ -3325,7 +3325,14 @@ int CudaNdarray_CopyFromCudaNdarray(CudaNdarray * self,
}; break; }; break;
case 4: // 4-tensor case 4: // 4-tensor
{ {
if (verbose) fprint_CudaNdarray(stderr, other); if (verbose)
{
if (0 != fprint_CudaNdarray(stderr, other))
{
Py_XDECREF(new_other);
return -1;
}
}
// The blocks implement the looping over the first two axes so // The blocks implement the looping over the first two axes so
// this needs to be (N1, N2) // this needs to be (N1, N2)
...@@ -4558,8 +4565,17 @@ PyObject * CudaNdarray_IS_C_Contiguous(CudaNdarray * self) ...@@ -4558,8 +4565,17 @@ PyObject * CudaNdarray_IS_C_Contiguous(CudaNdarray * self)
return PyBool_FromLong(CudaNdarray_is_c_contiguous(self)); return PyBool_FromLong(CudaNdarray_is_c_contiguous(self));
} }
void fprint_CudaNdarray(FILE * fd, const CudaNdarray *self) int fprint_CudaNdarray(FILE * fd, const CudaNdarray *self)
{ {
cudaError_t err = cudaGetLastError();
if( cudaSuccess != err)
{
PyErr_Format(PyExc_RuntimeError,
"Cuda error: %s: %s.",
"fprint_CudaNdarray was called with an uncleared error",
cudaGetErrorString(err));
return -1;
}
fprintf(fd, "CudaNdarray <%p, %p> nd=%i dev_structure_fresh=%d data_allocated=%d\n", fprintf(fd, "CudaNdarray <%p, %p> nd=%i dev_structure_fresh=%d data_allocated=%d\n",
self, self->devdata, self->nd, self->dev_structure_fresh, self->data_allocated); self, self->devdata, self->nd, self->dev_structure_fresh, self->data_allocated);
fprintf(fd, "\tHOST_DIMS: "); fprintf(fd, "\tHOST_DIMS: ");
...@@ -4598,6 +4614,17 @@ void fprint_CudaNdarray(FILE * fd, const CudaNdarray *self) ...@@ -4598,6 +4614,17 @@ void fprint_CudaNdarray(FILE * fd, const CudaNdarray *self)
{ {
fprintf(fd, "\n\tdev_structure not allocated\n"); fprintf(fd, "\n\tdev_structure not allocated\n");
} }
err = cudaGetLastError();
if( cudaSuccess != err)
{
PyErr_Format(PyExc_RuntimeError,
"Cuda error: %s: %s.",
"fprint_CudaNdarray",
cudaGetErrorString(err));
return -1;
}
return 0;
} }
/* /*
......
...@@ -437,7 +437,7 @@ DllExport int CudaNdarray_dimshuffle(CudaNdarray * self, unsigned int len, const ...@@ -437,7 +437,7 @@ DllExport int CudaNdarray_dimshuffle(CudaNdarray * self, unsigned int len, const
DllExport PyObject* DllExport PyObject*
CudaNdarray_TakeFrom(CudaNdarray * self, PyObject *args); CudaNdarray_TakeFrom(CudaNdarray * self, PyObject *args);
static void fprint_CudaNdarray(FILE * fd, const CudaNdarray *self); static int fprint_CudaNdarray(FILE * fd, const CudaNdarray *self);
#endif #endif
/* /*
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论