提交 3ebe0748 authored 作者: Ian Goodfellow's avatar Ian Goodfellow

whitespace

上级 177e02c4
...@@ -2127,7 +2127,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value) ...@@ -2127,7 +2127,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value)
} }
PyObject * intobj = NULL; PyObject * intobj = NULL;
if(CudaNdarray_Check(o) && PyArray_Check(value)){ if (CudaNdarray_Check(o) && PyArray_Check(value)){
if (verbose) if (verbose)
fprintf(stderr, fprintf(stderr,
"CudaNdarray_setitem dest is a CudaNdarray and" "CudaNdarray_setitem dest is a CudaNdarray and"
...@@ -2137,7 +2137,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value) ...@@ -2137,7 +2137,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value)
{ {
return -1; return -1;
} }
if(CudaNdarray_CopyFromArray(new_value, (PyArrayObject *) value)) if (CudaNdarray_CopyFromArray(new_value, (PyArrayObject *) value))
{ {
Py_XDECREF(new_value); Py_XDECREF(new_value);
Py_XDECREF(rval); Py_XDECREF(rval);
...@@ -2214,7 +2214,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value) ...@@ -2214,7 +2214,7 @@ CudaNdarray_setitem(PyObject *o, PyObject *key, PyObject *value)
PyObject *baseSavedForComparison = rval->base; PyObject *baseSavedForComparison = rval->base;
if(CudaNdarray_CopyFromCudaNdarray(rval, (CudaNdarray*)value, true)) if (CudaNdarray_CopyFromCudaNdarray(rval, (CudaNdarray*)value, true))
{ {
Py_DECREF((PyObject*)rval); Py_DECREF((PyObject*)rval);
Py_XDECREF(new_value); Py_XDECREF(new_value);
...@@ -3190,14 +3190,21 @@ static __global__ void k_copy_1d(const int N, const float * x, const int sx, flo ...@@ -3190,14 +3190,21 @@ static __global__ void k_copy_1d(const int N, const float * x, const int sx, flo
} }
} }
static __global__ void k_copy_4d(const int N1, N2, N3, N4, const float // N1 through N4 are the size of y
* x, const int sx1, sx2, sx3, sx4, float * y, const int sy1, ...) static __global__ void k_copy_4d(const int N1,
const int N2, const int N3, const int N4,
const float * x, const int sx1, const int sx2, const int sx3,
const int sx4, float * y, const int sy1, const int sy2,
const int sy3, const int sy4)
{ {
// N1 and N2 are kept in case a future implementation needs to
// loop on the first two dimensions if there are not enough blocks
for (int i = threadIdx.x; i < N3; i += blockDim.x) for (int i = threadIdx.x; i < N3; i += blockDim.x)
{ {
for (int j = threadIdx.y; j < N4; j += blockDim.y) for (int j = threadIdx.y; j < N4; j += blockDim.y)
{ {
y[gridDim.x*sy1 + gridDim.y*sy2 + i*sy3 + j*sy4] = x[...]; y[gridIdx.x*sy1 + gridIdx.y*sy2 + i*sy3 + j*sy4] =
x[gridIdx.x*sx1 + gridIdx.y*sx2 + i*sx3 + j*sx4];
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论