提交 5be14f49 authored 作者: Frederic's avatar Frederic

use new numpy interface

上级 74a47a54
...@@ -125,7 +125,7 @@ class GpuConvGrad3D(GpuOp): ...@@ -125,7 +125,7 @@ class GpuConvGrad3D(GpuOp):
} }
{ //for fail { //for fail
dtype_%(WShape)s * WShape = (dtype_%(WShape)s *) %(WShape)s->data; dtype_%(WShape)s * WShape = (dtype_%(WShape)s *) PyArray_DATA(%(WShape)s);
const int outputChannels = WShape[0]; const int outputChannels = WShape[0];
const int inputChannels = CudaNdarray_HOST_DIMS(%(V)s)[4]; const int inputChannels = CudaNdarray_HOST_DIMS(%(V)s)[4];
if (WShape[4] != inputChannels) if (WShape[4] != inputChannels)
......
...@@ -124,8 +124,8 @@ class GpuDot22Scalar(GpuOp): ...@@ -124,8 +124,8 @@ class GpuDot22Scalar(GpuOp):
return """ return """
#define REAL float #define REAL float
float %(name)s_a = (PyArray_TYPE(%(a)s) == NPY_FLOAT) float %(name)s_a = (PyArray_TYPE(%(a)s) == NPY_FLOAT)
? (REAL)(((float*)%(a)s->data)[0]) ? (REAL)(((float*)PyArray_DATA(%(a)s))[0])
: (REAL)(((double*)%(a)s->data)[0]); : (REAL)(((double*)PyArray_DATA(%(a)s))[0]);
#undef REAL #undef REAL
if (%(x)s->nd != 2) if (%(x)s->nd != 2)
{ {
...@@ -232,12 +232,12 @@ class GpuGemm(GpuOp): ...@@ -232,12 +232,12 @@ class GpuGemm(GpuOp):
#define REAL float #define REAL float
float %(name)s_a = (PyArray_TYPE(%(a)s) == NPY_FLOAT) float %(name)s_a = (PyArray_TYPE(%(a)s) == NPY_FLOAT)
? (REAL)(((float*)%(a)s->data)[0]) ? (REAL)(((float*)PyArray_DATA(%(a)s))[0])
: (REAL)(((double*)%(a)s->data)[0]); : (REAL)(((double*)PyArray_DATA(%(a)s))[0]);
float %(name)s_b = (PyArray_TYPE(%(b)s) == NPY_FLOAT) ? float %(name)s_b = (PyArray_TYPE(%(b)s) == NPY_FLOAT) ?
(REAL)(((float*)%(b)s->data)[0]) (REAL)(((float*)PyArray_DATA(%(b)s))[0])
: (REAL)(((double*)%(b)s->data)[0]); : (REAL)(((double*)PyArray_DATA(%(b)s))[0]);
#undef REAL #undef REAL
if (%(inplace)s if (%(inplace)s
...@@ -344,8 +344,8 @@ class GpuGemv(GpuOp): ...@@ -344,8 +344,8 @@ class GpuGemv(GpuOp):
sio = StringIO() sio = StringIO()
print >> sio, """ print >> sio, """
float %(name)s_alpha = ((dtype_%(a)s*)(%(a)s->data))[0]; float %(name)s_alpha = ((dtype_%(a)s*)(PyArray_DATA(%(a)s)))[0];
float %(name)s_beta = ((dtype_%(b)s*)(%(b)s->data))[0]; float %(name)s_beta = ((dtype_%(b)s*)(PyArray_DATA(%(b)s)))[0];
if (%(inplace)s if (%(inplace)s
&& ((CudaNdarray_HOST_STRIDES(%(z_in)s)[0] > 0) && ((CudaNdarray_HOST_STRIDES(%(z_in)s)[0] > 0)
...@@ -441,7 +441,7 @@ class GpuGer(GpuOp): ...@@ -441,7 +441,7 @@ class GpuGer(GpuOp):
sio = StringIO() sio = StringIO()
print >> sio, """ print >> sio, """
float %(name)s_alpha = ((dtype_%(a)s*)(%(a)s->data))[0]; float %(name)s_alpha = ((dtype_%(a)s*)(PyArray_DATA(%(a)s)))[0];
if (%(inplace)s if (%(inplace)s
&& (CudaNdarray_HOST_STRIDES(%(z_in)s)[0] >= 0) && (CudaNdarray_HOST_STRIDES(%(z_in)s)[0] >= 0)
......
...@@ -168,7 +168,8 @@ class CURAND_Base(GpuOp): ...@@ -168,7 +168,8 @@ class CURAND_Base(GpuOp):
} }
for (int i = 0; i < %(ndim)s; ++i) for (int i = 0; i < %(ndim)s; ++i)
{ {
odims[i] = ((npy_int32*)(%(size)s->data + %(size)s->strides[0] * i))[0]; odims[i] = ((npy_int32*)(PyArray_DATA(%(size)s) +
PyArray_STRIDES(%(size)s)[0] * i))[0];
n_elements *= odims[i]; n_elements *= odims[i];
must_alloc_sample = (must_alloc_sample must_alloc_sample = (must_alloc_sample
|| CudaNdarray_HOST_DIMS(%(o_sample)s)[i] != odims[i]); || CudaNdarray_HOST_DIMS(%(o_sample)s)[i] != odims[i]);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论