Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a924f75b
提交
a924f75b
authored
9月 05, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use PyArray_DESCR instead of var->descr
上级
98f066da
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
117 行增加
和
111 行删除
+117
-111
test_debugmode.py
theano/compile/tests/test_debugmode.py
+9
-9
blas.py
theano/sandbox/cuda/blas.py
+3
-3
rng_curand.py
theano/sandbox/cuda/rng_curand.py
+1
-1
rng_mrg.py
theano/sandbox/rng_mrg.py
+3
-3
basic.py
theano/sparse/basic.py
+14
-14
opt.py
theano/sparse/opt.py
+0
-0
basic.py
theano/tensor/basic.py
+2
-2
blas.py
theano/tensor/blas.py
+24
-24
blas_c.py
theano/tensor/blas_c.py
+20
-20
blas_headers.py
theano/tensor/blas_headers.py
+10
-10
elemwise.py
theano/tensor/elemwise.py
+8
-2
Conv3D.py
theano/tensor/nnet/Conv3D.py
+1
-1
ConvGrad3D.py
theano/tensor/nnet/ConvGrad3D.py
+1
-1
ConvTransp3D.py
theano/tensor/nnet/ConvTransp3D.py
+1
-1
nnet.py
theano/tensor/nnet/nnet.py
+20
-20
没有找到文件。
theano/compile/tests/test_debugmode.py
浏览文件 @
a924f75b
...
...
@@ -59,10 +59,10 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
if (PyArray_NDIM(
%(a)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(a) != 1");
%(fail)
s;}
if (PyArray_NDIM(
%(b)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(b) != 1");
%(fail)
s;}
if (
%(a)
s->descr
->type_num != NPY_DOUBLE)
if (
PyArray_DESCR(
%(a)
s)
->type_num != NPY_DOUBLE)
{PyErr_SetString(PyExc_NotImplementedError, "a dtype not NPY_DOUBLE");
%(fail)
s;}
if (
%(b)
s->descr
->type_num != NPY_DOUBLE)
if (
PyArray_DESCR(
%(b)
s)
->type_num != NPY_DOUBLE)
{PyErr_SetString(PyExc_NotImplementedError, "b's dtype not NPY_DOUBLE");
%(fail)
s;}
if (PyArray_DIMS(
%(a)
s)[0] != PyArray_DIMS(
%(b)
s)[0])
...
...
@@ -75,7 +75,7 @@ class BROKEN_ON_PURPOSE_Add(gof.Op):
{Py_XDECREF(
%(z)
s);}
npy_intp dims[] = {0};
dims[0] = PyArray_DIMS(
%(b)
s)[0];
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(1, dims,
%(b)
s->descr
->type_num);
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(1, dims,
PyArray_DESCR(
%(b)
s)
->type_num);
}
{
...
...
@@ -150,13 +150,13 @@ class WeirdBrokenOp(gof.Op):
else
:
z_code
=
"""
{Py_XDECREF(
%(z)
s);}
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(a)
s),
%(a)
s->descr
->type_num);
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(a)
s),
PyArray_DESCR(
%(a)
s)
->type_num);
"""
prep_vars
=
"""
//the output array has size M x N
npy_intp M = PyArray_DIMS(
%(a)
s)[0];
npy_intp Sa =
%(a)
s->strides[0] /
%(a)
s->descr
->elsize;
npy_intp Sz =
%(z)
s->strides[0] /
%(z)
s->descr
->elsize;
npy_intp Sa =
%(a)
s->strides[0] /
PyArray_DESCR(
%(a)
s)
->elsize;
npy_intp Sz =
%(z)
s->strides[0] /
PyArray_DESCR(
%(z)
s)
->elsize;
npy_double * Da = (npy_double*)
%(a)
s->data;
npy_double * Dz = (npy_double*)
%(z)
s->data;
...
...
@@ -606,10 +606,10 @@ class BrokenCImplementationAdd(gof.Op):
if (PyArray_NDIM(
%(a)
s) != 2) {PyErr_SetString(PyExc_NotImplementedError, "rank(a) != 2");
%(fail)
s;}
if (PyArray_NDIM(
%(b)
s) != 2) {PyErr_SetString(PyExc_NotImplementedError, "rank(b) != 2");
%(fail)
s;}
if (
%(a)
s->descr
->type_num != NPY_FLOAT)
if (
PyArray_DESCR(
%(a)
s)
->type_num != NPY_FLOAT)
{PyErr_SetString(PyExc_NotImplementedError, "a dtype not NPY_FLOAT");
%(fail)
s;}
if (
%(b)
s->descr
->type_num != NPY_FLOAT)
if (
PyArray_DESCR(
%(b)
s)
->type_num != NPY_FLOAT)
{PyErr_SetString(PyExc_NotImplementedError, "b's dtype not NPY_FLOAT");
%(fail)
s;}
if (PyArray_DIMS(
%(a)
s)[0] != PyArray_DIMS(
%(a)
s)[1])
...
...
@@ -643,7 +643,7 @@ class BrokenCImplementationAdd(gof.Op):
npy_intp dims[] = {0, 0};
dims[0] = PyArray_DIMS(
%(b)
s)[0];
dims[1] = PyArray_DIMS(
%(b)
s)[1];
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(2, dims,
%(b)
s->descr
->type_num);
%(z)
s = (PyArrayObject*) PyArray_SimpleNew(2, dims,
PyArray_DESCR(
%(b)
s)
->type_num);
}
// Let us assume that
%(z)
s is c_contiguous
...
...
theano/sandbox/cuda/blas.py
浏览文件 @
a924f75b
...
...
@@ -123,7 +123,7 @@ class GpuDot22Scalar(GpuOp):
fail
=
sub
[
'fail'
]
return
"""
#define REAL float
float
%(name)
s_a = (
%(a)
s->descr->type_num
== NPY_FLOAT)
float
%(name)
s_a = (
PyArray_TYPE(
%(a)
s)
== NPY_FLOAT)
? (REAL)(((float*)
%(a)
s->data)[0])
: (REAL)(((double*)
%(a)
s->data)[0]);
#undef REAL
...
...
@@ -231,11 +231,11 @@ class GpuGemm(GpuOp):
print
>>
sio
,
"""
#define REAL float
float
%(name)
s_a = (
%(a)
s->descr->type_num
== NPY_FLOAT)
float
%(name)
s_a = (
PyArray_TYPE(
%(a)
s)
== NPY_FLOAT)
? (REAL)(((float*)
%(a)
s->data)[0])
: (REAL)(((double*)
%(a)
s->data)[0]);
float
%(name)
s_b = (
%(b)
s->descr->type_num
== NPY_FLOAT) ?
float
%(name)
s_b = (
PyArray_TYPE(
%(b)
s)
== NPY_FLOAT) ?
(REAL)(((float*)
%(b)
s->data)[0])
: (REAL)(((double*)
%(b)
s->data)[0]);
#undef REAL
...
...
theano/sandbox/cuda/rng_curand.py
浏览文件 @
a924f75b
...
...
@@ -153,7 +153,7 @@ class CURAND_Base(GpuOp):
%(ndim)
s,
%(size)
s->dimensions[0]);
%(fail)
s
}
if (
%(size)
s->descr
->type_num != NPY_INT32)
if (
PyArray_DESCR(
%(size)
s)
->type_num != NPY_INT32)
{
PyErr_SetString(PyExc_ValueError, "size must be int32");
%(fail)
s
...
...
theano/sandbox/rng_mrg.py
浏览文件 @
a924f75b
...
...
@@ -272,7 +272,7 @@ class mrg_uniform(mrg_uniform_base):
%(ndim)
s, int(PyArray_DIMS(
%(size)
s)[0]));
%(fail)
s
}
if (
%(size)
s->descr
->type_num != NPY_INT32)
if (
PyArray_DESCR(
%(size)
s)
->type_num != NPY_INT32)
{
PyErr_SetString(PyExc_ValueError, "size must be int32");
%(fail)
s
...
...
@@ -306,7 +306,7 @@ class mrg_uniform(mrg_uniform_base):
PyErr_Format(PyExc_ValueError, "rstate must have 6 columns");
%(fail)
s
}
if (
%(o_rstate)
s->descr
->type_num != NPY_INT32)
if (
PyArray_DESCR(
%(o_rstate)
s)
->type_num != NPY_INT32)
{
PyErr_SetString(PyExc_ValueError, "rstate must be int32");
%(fail)
s
...
...
@@ -514,7 +514,7 @@ class GPU_mrg_uniform(mrg_uniform_base, GpuOp):
%(ndim)
s, PyArray_DIMS(
%(size)
s)[0]);
%(fail)
s
}
if (
%(size)
s->descr
->type_num != NPY_INT32)
if (
PyArray_DESCR(
%(size)
s)
->type_num != NPY_INT32)
{
PyErr_SetString(PyExc_ValueError, "size must be int32");
%(fail)
s
...
...
theano/sparse/basic.py
浏览文件 @
a924f75b
...
...
@@ -3011,10 +3011,10 @@ class StructuredDotGradCSC(gof.Op):
if (PyArray_NDIM(
%(_indices)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(indices) != 1");
%(fail)
s;}
if (PyArray_NDIM(
%(_indptr)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(indptr) != 1");
%(fail)
s;}
if(
%(_indices)
s->descr
->type_num != NPY_INT32) {
if(
PyArray_DESCR(
%(_indices)
s)
->type_num != NPY_INT32) {
PyErr_SetString(PyExc_NotImplementedError, "C");
%(fail)
s;}
if(
%(_indptr)
s->descr
->type_num != NPY_INT32)
if(
PyArray_DESCR(
%(_indptr)
s)
->type_num != NPY_INT32)
{PyErr_SetString(PyExc_NotImplementedError, "D");
%(fail)
s;}
if( PyArray_DIMS(
%(_d)
s)[1] != PyArray_DIMS(
%(_g)
s)[1])
...
...
@@ -3024,18 +3024,18 @@ class StructuredDotGradCSC(gof.Op):
|| (PyArray_DIMS(
%(_zout)
s)[0] != PyArray_DIMS(
%(_indices)
s)[0]))
{
Py_XDECREF(
%(_zout)
s);
%(_zout)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(_indices)
s),
%(_g)
s->descr
->type_num);
%(_zout)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(_indices)
s),
PyArray_DESCR(
%(_g)
s)
->type_num);
}
{ //makes it compile even though labels jump over variable definitions.
npy_intp nnz = PyArray_DIMS(
%(_indices)
s)[0];
npy_intp N = PyArray_DIMS(
%(_indptr)
s)[0]-1; //TODO: error checking with this
npy_intp Sindices =
%(_indices)
s->strides[0]/
%(_indices)
s->descr
->elsize;
npy_intp Sindptr =
%(_indptr)
s->strides[0]/
%(_indptr)
s->descr
->elsize;
npy_intp Sindices =
%(_indices)
s->strides[0]/
PyArray_DESCR(
%(_indices)
s)
->elsize;
npy_intp Sindptr =
%(_indptr)
s->strides[0]/
PyArray_DESCR(
%(_indptr)
s)
->elsize;
const npy_intp Sd1 =
%(_d)
s->strides[1]/
%(_d)
s->descr
->elsize;
const npy_intp Sg1 =
%(_g)
s->strides[1]/
%(_g)
s->descr
->elsize;
const npy_intp Sd1 =
%(_d)
s->strides[1]/
PyArray_DESCR(
%(_d)
s)
->elsize;
const npy_intp Sg1 =
%(_g)
s->strides[1]/
PyArray_DESCR(
%(_g)
s)
->elsize;
const npy_intp K = PyArray_DIMS(
%(_d)
s)[1];
...
...
@@ -3147,10 +3147,10 @@ class StructuredDotGradCSR(gof.Op):
if (PyArray_NDIM(
%(_indices)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(indices) != 1");
%(fail)
s;}
if (PyArray_NDIM(
%(_indptr)
s) != 1) {PyErr_SetString(PyExc_NotImplementedError, "rank(indptr) != 1");
%(fail)
s;}
if(
%(_indices)
s->descr
->type_num != NPY_INT32) {
if(
PyArray_DESCR(
%(_indices)
s)
->type_num != NPY_INT32) {
PyErr_SetString(PyExc_NotImplementedError, "C");
%(fail)
s;}
if(
%(_indptr)
s->descr
->type_num != NPY_INT32)
if(
PyArray_DESCR(
%(_indptr)
s)
->type_num != NPY_INT32)
{PyErr_SetString(PyExc_NotImplementedError, "D");
%(fail)
s;}
if( PyArray_DIMS(
%(_d)
s)[1] != PyArray_DIMS(
%(_g)
s)[1])
...
...
@@ -3160,7 +3160,7 @@ class StructuredDotGradCSR(gof.Op):
|| (PyArray_DIMS(
%(_zout)
s)[0] != PyArray_DIMS(
%(_indices)
s)[0]))
{
Py_XDECREF(
%(_zout)
s);
%(_zout)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(_indices)
s),
%(_g)
s->descr
->type_num);
%(_zout)
s = (PyArrayObject*) PyArray_SimpleNew(1, PyArray_DIMS(
%(_indices)
s),
PyArray_DESCR(
%(_g)
s)
->type_num);
}
{ //makes it compile even though labels jump over variable definitions.
...
...
@@ -3168,11 +3168,11 @@ class StructuredDotGradCSR(gof.Op):
// extract number of rows
npy_intp N = PyArray_DIMS(
%(_indptr)
s)[0]-1; //TODO: error checking with this
npy_intp Sindices =
%(_indices)
s->strides[0]/
%(_indices)
s->descr
->elsize;
npy_intp Sindptr =
%(_indptr)
s->strides[0]/
%(_indptr)
s->descr
->elsize;
npy_intp Sindices =
%(_indices)
s->strides[0]/
PyArray_DESCR(
%(_indices)
s)
->elsize;
npy_intp Sindptr =
%(_indptr)
s->strides[0]/
PyArray_DESCR(
%(_indptr)
s)
->elsize;
const npy_intp Sd1 =
%(_d)
s->strides[1]/
%(_d)
s->descr
->elsize;
const npy_intp Sg1 =
%(_g)
s->strides[1]/
%(_g)
s->descr
->elsize;
const npy_intp Sd1 =
%(_d)
s->strides[1]/
PyArray_DESCR(
%(_d)
s)
->elsize;
const npy_intp Sg1 =
%(_g)
s->strides[1]/
PyArray_DESCR(
%(_g)
s)
->elsize;
const npy_intp K = PyArray_DIMS(
%(_d)
s)[1];
...
...
theano/sparse/opt.py
浏览文件 @
a924f75b
差异被折叠。
点击展开。
theano/tensor/basic.py
浏览文件 @
a924f75b
...
...
@@ -4042,10 +4042,10 @@ class Subtensor(Op):
//TODO: give this Op a second output so that this view can be cached
//TODO: alternatively, fix the memory leak on failure
Py_INCREF(
%(x)
s->descr
);
Py_INCREF(
PyArray_DESCR(
%(x)
s)
);
PyArrayObject * xview = (PyArrayObject*)PyArray_NewFromDescr(
&PyArray_Type,
%(x)
s->descr
,
PyArray_DESCR(
%(x)
s)
,
%(view_ndim)
s,
PyArray_DIMS(
%(x)
s),
PyArray_STRIDES(
%(x)
s),
...
...
theano/tensor/blas.py
浏览文件 @
a924f75b
...
...
@@ -493,8 +493,8 @@ class GemmRelated(Op):
declare_NS
=
"""
int unit = 0;
int type_num =
%(_x)
s->descr
->type_num;
int type_size =
%(_x)
s->descr
->elsize; // in bytes
int type_num =
PyArray_DESCR(
%(_x)
s)
->type_num;
int type_size =
PyArray_DESCR(
%(_x)
s)
->elsize; // in bytes
npy_intp* Nx = PyArray_DIMS(
%(_x)
s);
npy_intp* Ny = PyArray_DIMS(
%(_y)
s);
...
...
@@ -529,31 +529,31 @@ class GemmRelated(Op):
}
"""
check_xyz_double_or_float
=
"""
if ((
%(_x)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_x)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_x)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_x)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError, "type(x) is not double or float");
%(fail)
s;}
if ((
%(_y)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_y)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_y)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_y)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError, "type(y) is not double or float");
%(fail)
s;}
if ((
%(_zout)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_zout)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_zout)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_zout)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError, "type(z) is not double or float");
%(fail)
s;}
if ((
%(_x)
s->descr->type_num !=
%(_y)
s->descr
->type_num)
||(
%(_x)
s->descr->type_num !=
%(_zout)
s->descr
->type_num))
if ((
PyArray_DESCR(
%(_x)
s)->type_num != PyArray_DESCR(
%(_y)
s)
->type_num)
||(
PyArray_DESCR(
%(_x)
s)->type_num != PyArray_DESCR(
%(_zout)
s)
->type_num))
{ PyErr_SetString(PyExc_NotImplementedError, "type(x), type(y), type(z) are not all the same");
%(fail)
s; }
"""
#it is not necessary that a or b have the same type as x,y,z
check_ab_double_or_float
=
"""
if ((
%(_a)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_a)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_a)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_a)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError, "type(a) is not double or float");
%(fail)
s;}
if ((
%(_b)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_b)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_b)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_b)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError, "type(b) is not double or float");
%(fail)
s;}
"""
...
...
@@ -919,7 +919,7 @@ class Gemm(GemmRelated):
Nz = PyArray_DIMS(
%(_zout)
s);
Sz = PyArray_STRIDES(
%(_zout)
s);
if (
%(_zout)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(_zout)
s)
->type_num == NPY_FLOAT)
{
float * zoutdata = (float*)PyArray_DATA(
%(_zout)
s);
int zoi = Sz[0] / sizeof(float);
...
...
@@ -935,7 +935,7 @@ class Gemm(GemmRelated):
}
}
}
else if (
%(_zout)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(_zout)
s)
->type_num == NPY_DOUBLE)
{
double * zoutdata = (double*) PyArray_DATA(
%(_zout)
s);
int zoi = Sz[0] / sizeof(double);
...
...
@@ -961,20 +961,20 @@ class Gemm(GemmRelated):
case_float_ab_constants
=
"""
#define REAL float
float a = (
%(_a)
s->descr
->type_num == NPY_FLOAT)
float a = (
PyArray_DESCR(
%(_a)
s)
->type_num == NPY_FLOAT)
? (REAL)(((float*)PyArray_DATA(
%(_a)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_a)
s))[0]);
float b = (
%(_b)
s->descr
->type_num == NPY_FLOAT) ?
float b = (
PyArray_DESCR(
%(_b)
s)
->type_num == NPY_FLOAT) ?
(REAL)(((float*)PyArray_DATA(
%(_b)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_b)
s))[0]);
#undef REAL
"""
case_double_ab_constants
=
"""
#define REAL double
double a = (
%(_a)
s->descr
->type_num == NPY_FLOAT)
double a = (
PyArray_DESCR(
%(_a)
s)
->type_num == NPY_FLOAT)
? (REAL)(((float*)PyArray_DATA(
%(_a)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_a)
s))[0]);
double b = (
%(_b)
s->descr
->type_num == NPY_FLOAT) ?
double b = (
PyArray_DESCR(
%(_b)
s)
->type_num == NPY_FLOAT) ?
(REAL)(((float*)PyArray_DATA(
%(_b)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_b)
s))[0]);
#undef REAL
...
...
@@ -1753,15 +1753,15 @@ class Dot22Scalar(GemmRelated):
setup_z_Nz_Sz
=
Dot22
.
setup_z_Nz_Sz
check_ab_double_or_float
=
"""
if ((
%(_a)
s->descr
->type_num != NPY_DOUBLE)
&& (
%(_a)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(_a)
s)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(
%(_a)
s)
->type_num != NPY_FLOAT))
{PyErr_SetString(PyExc_NotImplementedError,
"type(a) is not double or float");
%(fail)
s;}
"""
case_float_ab_constants
=
"""
#define REAL float
float a = (
%(_a)
s->descr
->type_num == NPY_FLOAT)
float a = (
PyArray_DESCR(
%(_a)
s)
->type_num == NPY_FLOAT)
? (REAL)(((float*)PyArray_DATA(
%(_a)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_a)
s))[0]);
#undef REAL
...
...
@@ -1770,7 +1770,7 @@ class Dot22Scalar(GemmRelated):
case_double_ab_constants
=
"""
#define REAL double
double a = (
%(_a)
s->descr
->type_num == NPY_FLOAT)
double a = (
PyArray_DESCR(
%(_a)
s)
->type_num == NPY_FLOAT)
? (REAL)(((float*)PyArray_DATA(
%(_a)
s))[0])
: (REAL)(((double*)PyArray_DATA(
%(_a)
s))[0]);
#undef REAL
...
...
theano/tensor/blas_c.py
浏览文件 @
a924f75b
...
...
@@ -42,9 +42,9 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
if (PyArray_NDIM(
%(a)
s) != 0)
{PyErr_SetString(PyExc_NotImplementedError, "rank(a) != 0");
%(fail)
s;}
if (
%(A)
s->descr->type_num !=
%(x)
s->descr
->type_num)
if (
PyArray_DESCR(
%(A)
s)->type_num != PyArray_DESCR(
%(x)
s)
->type_num)
{ PyErr_SetString(PyExc_TypeError, "A vs. x");
%(fail)
s; }
if (
%(A)
s->descr->type_num !=
%(y)
s->descr
->type_num)
if (
PyArray_DESCR(
%(A)
s)->type_num != PyArray_DESCR(
%(y)
s)
->type_num)
{ PyErr_SetString(PyExc_TypeError, "A vs. y");
%(fail)
s; }
if (PyArray_DIMS(
%(A)
s)[0] != PyArray_DIMS(
%(x)
s)[0])
...
...
@@ -60,8 +60,8 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
%(fail)
s;
}
if (
%(A)
s->descr
->type_num == NPY_DOUBLE) { elemsize = 8; }
else if (
%(A)
s->descr
->type_num == NPY_FLOAT) { elemsize = 4;}
if (
PyArray_DESCR(
%(A)
s)
->type_num == NPY_DOUBLE) { elemsize = 8; }
else if (
PyArray_DESCR(
%(A)
s)
->type_num == NPY_FLOAT) { elemsize = 4;}
else
{
PyErr_SetString(PyExc_NotImplementedError, "complex CGer");
...
...
@@ -101,7 +101,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
PyErr_SetString(PyExc_AssertionError, "
%(Z)
s !=
%(A)
s");
%(fail)
s
}
if (
%(Z)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_FLOAT)
{
float * zoutdata = (float*)PyArray_DATA(
%(Z)
s);
const float * zdata = (float*)PyArray_DATA(
%(A)
s);
...
...
@@ -117,7 +117,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
}
}
}
else if (
%(Z)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_DOUBLE)
{
double * zoutdata = (double*) PyArray_DATA(
%(Z)
s);
const double * zdata = (double*)PyArray_DATA(
%(A)
s);
...
...
@@ -178,7 +178,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
if (PyArray_STRIDES(
%(Z)
s)[0] == elemsize)
{
if (
%(Z)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_FLOAT)
{
//fprintf(stderr, "A
\\
n");
float alpha = ((dtype_
%(a)
s*)PyArray_DATA(
%(a)
s))[0];
...
...
@@ -187,7 +187,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
(float*)y_data, &Sy,
(float*)(PyArray_DATA(
%(Z)
s)), &Sz1);
}
else if (
%(Z)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_DOUBLE)
{
double alpha = ((dtype_
%(a)
s*)PyArray_DATA(
%(a)
s))[0];
dger_(&Nz0, &Nz1, &alpha,
...
...
@@ -203,7 +203,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
}
else if (PyArray_STRIDES(
%(Z)
s)[1] == elemsize)
{
if (
%(Z)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_FLOAT)
{
//fprintf(stderr, "B
%%
i
%%
i
%%
i
%%
i
\\
n", Nz0, Nz1, Sz0, Sz1);
float alpha = ((dtype_
%(a)
s*)(PyArray_DATA(
%(a)
s)))[0];
...
...
@@ -214,7 +214,7 @@ def ger_c_code(A, a, x, y, Z, destructive, fail):
(float*)x_data, &Sx,
(float*)(PyArray_DATA(
%(Z)
s)), &Sz0);
}
else if (
%(Z)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(Z)
s)
->type_num == NPY_DOUBLE)
{
double alpha = ((dtype_
%(a)
s*)PyArray_DATA(
%(a)
s))[0];
dger_(&Nz1, &Nz0, &alpha,
...
...
@@ -316,9 +316,9 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
%(fail)
s;
}
if (
%(aa)
s->descr->type_num !=
%(xx)
s->descr
->type_num)
if (
PyArray_DESCR(
%(aa)
s)->type_num != PyArray_DESCR(
%(xx)
s)
->type_num)
{ PyErr_SetString(PyExc_TypeError, "Gemv: aa vs. xx");
%(fail)
s; }
if (
%(aa)
s->descr->type_num !=
%(yy)
s->descr
->type_num)
if (
PyArray_DESCR(
%(aa)
s)->type_num != PyArray_DESCR(
%(yy)
s)
->type_num)
{ PyErr_SetString(PyExc_TypeError, "Gemv: aa vs. yy");
%(fail)
s; }
if (PyArray_DIMS(
%(xx)
s)[0] != PyArray_DIMS(
%(aa)
s)[0])
...
...
@@ -334,8 +334,8 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
%(fail)
s;
}
if (
%(aa)
s->descr
->type_num == NPY_DOUBLE) { elemsize = 8; }
else if (
%(aa)
s->descr
->type_num == NPY_FLOAT) { elemsize = 4;}
if (
PyArray_DESCR(
%(aa)
s)
->type_num == NPY_DOUBLE) { elemsize = 8; }
else if (
PyArray_DESCR(
%(aa)
s)
->type_num == NPY_FLOAT) { elemsize = 4;}
else {
PyErr_SetString(PyExc_NotImplementedError, "complex Gemv");
%(fail)
s;
...
...
@@ -365,7 +365,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
}
if (dbeta != 0)
{
if (
%(zz)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(zz)
s)
->type_num == NPY_FLOAT)
{
float * zoutdata = (float*)PyArray_DATA(
%(zz)
s);
const float * zdata = (float*)PyArray_DATA(
%(aa)
s);
...
...
@@ -376,7 +376,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
zoutdata[Zi*i] = fbeta * zdata[Ai*i];
}
}
else if (
%(xx)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(xx)
s)
->type_num == NPY_DOUBLE)
{
double * zoutdata = (double*) PyArray_DATA(
%(zz)
s);
const double * zdata = (double*)PyArray_DATA(
%(aa)
s);
...
...
@@ -460,7 +460,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
if (PyArray_STRIDES(
%(xx)
s)[0] == elemsize)
{
if (
%(xx)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(xx)
s)
->type_num == NPY_FLOAT)
{
//fprintf(stderr, "A
\\
n");
float alpha = ((dtype_
%(alpha)
s*)PyArray_DATA(
%(alpha)
s))[0];
...
...
@@ -471,7 +471,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
&fbeta,
(float*)zz_data, &Sz);
}
else if (
%(xx)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(xx)
s)
->type_num == NPY_DOUBLE)
{
double alpha = ((dtype_
%(alpha)
s*)PyArray_DATA(
%(alpha)
s))[0];
dgemv_(&NOTRANS, &Nx0, &Nx1,
...
...
@@ -490,7 +490,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
}
else if (PyArray_STRIDES(
%(xx)
s)[1] == elemsize)
{
if (
%(xx)
s->descr
->type_num == NPY_FLOAT)
if (
PyArray_DESCR(
%(xx)
s)
->type_num == NPY_FLOAT)
{
//fprintf(stderr, "B
%%
i
%%
i
%%
i
%%
i
\\
n",
// Nz0, Nz1, Sz0, Sz1);
...
...
@@ -504,7 +504,7 @@ def gemv_c_code(aa, xx, yy, zz, alpha, beta, destructive, fail):
&fbeta,
(float*)zz_data, &Sz);
}
else if (
%(xx)
s->descr
->type_num == NPY_DOUBLE)
else if (
PyArray_DESCR(
%(xx)
s)
->type_num == NPY_DOUBLE)
{
double alpha = ((dtype_
%(alpha)
s*)PyArray_DATA(
%(alpha)
s))[0];
dgemv_(&TRANS, &Nx1, &Nx0,
...
...
theano/tensor/blas_headers.py
浏览文件 @
a924f75b
...
...
@@ -794,8 +794,8 @@ def ____gemm_code(check_ab, a_init, b_init):
return
"""
const char * error_string = NULL;
int type_num =
_x->descr
->type_num;
int type_size =
_x->descr
->elsize; // in bytes
int type_num =
PyArray_DESCR(_x)
->type_num;
int type_size =
PyArray_DESCR(_x)
->elsize; // in bytes
npy_intp* Nx = PyArray_DIMS(_x);
npy_intp* Ny = PyArray_DIMS(_y);
...
...
@@ -815,20 +815,20 @@ def ____gemm_code(check_ab, a_init, b_init):
%(check_ab)
s
if ((
_x->descr
->type_num != NPY_DOUBLE)
&& (
_x->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(_x)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(_x)
->type_num != NPY_FLOAT))
goto _dot_execute_fallback;
if ((
_y->descr
->type_num != NPY_DOUBLE)
&& (
_y->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(_y)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(_y)
->type_num != NPY_FLOAT))
goto _dot_execute_fallback;
if ((
_y->descr
->type_num != NPY_DOUBLE)
&& (
_y->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(_y)
->type_num != NPY_DOUBLE)
&& (
PyArray_DESCR(_y)
->type_num != NPY_FLOAT))
goto _dot_execute_fallback;
if ((
_x->descr->type_num != _y->descr
->type_num)
||(
_x->descr->type_num != _z->descr
->type_num))
if ((
PyArray_DESCR(_x)->type_num != PyArray_DESCR(_y)
->type_num)
||(
PyArray_DESCR(_x)->type_num != PyArray_DESCR(_z)
->type_num))
goto _dot_execute_fallback;
...
...
theano/tensor/elemwise.py
浏览文件 @
a924f75b
...
...
@@ -311,7 +311,7 @@ class DimShuffle(Op):
str
(
nd_out
)
+
'-1] == 0) strides['
+
str
(
nd_out
)
+
'-1] =
%(basename)
s->descr
->elsize'
'-1] =
PyArray_DESCR(
%(basename)
s)
->elsize'
)
for
i
in
xrange
(
nd_out
-
2
,
-
1
,
-
1
):
strides_statements
.
append
(
...
...
@@ -333,7 +333,13 @@ class DimShuffle(Op):
#recalculate flags: CONTIGUOUS, FORTRAN, ALIGNED
'PyArray_UpdateFlags(
%(res)
s, NPY_ARRAY_UPDATE_ALL)'
,
#we are making a view in both inplace and non-inplace cases
'PyArray_BASE(
%(res)
s) = (PyObject*)
%(basename)
s'
,
"""
#if NPY_VERSION < 0x01000009
PyArray_BASE(
%(res)
s) = (PyObject*)
%(basename)
s;
#else
PyArray_SetBaseObject(
%(res)
s, (PyObject*)
%(basename)
s);
#endif
"""
'}'
]
full_code
=
statements
(
check_input_nd
...
...
theano/tensor/nnet/Conv3D.py
浏览文件 @
a924f75b
...
...
@@ -296,7 +296,7 @@ class Conv3D(theano.Op):
PyArray_DIMS(
%(H)
s)[3]!=dims[3] ||
PyArray_DIMS(
%(H)
s)[4]!=dims[4]){
Py_XDECREF(
%(H)
s);
%(H)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
%(V)
s->descr
->type_num);
%(H)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
PyArray_DESCR(
%(V)
s)
->type_num);
if (!(
%(H)
s)) {
PyErr_Format(PyExc_MemoryError,"Conv3D: Could not allocate output.");
%(fail)
s
...
...
theano/tensor/nnet/ConvGrad3D.py
浏览文件 @
a924f75b
...
...
@@ -217,7 +217,7 @@ class ConvGrad3D(theano.Op):
PyArray_DIMS(
%(dCdW)
s)[3]!=dims[3] ||
PyArray_DIMS(
%(dCdW)
s)[4]!=dims[4] ){
Py_XDECREF(
%(dCdW)
s);
%(dCdW)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
%(V)
s->descr
->type_num);
%(dCdW)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
PyArray_DESCR(
%(V)
s)
->type_num);
if (!(
%(dCdW)
s)) {
PyErr_Format(PyExc_MemoryError,"ConvGrad3D: Could not allocate dCdW");
...
...
theano/tensor/nnet/ConvTransp3D.py
浏览文件 @
a924f75b
...
...
@@ -228,7 +228,7 @@ class ConvTransp3D(theano.Op):
PyArray_DIMS(
%(R)
s)[4]!=dims[4])
{
Py_XDECREF(
%(R)
s);
%(R)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
%(H)
s->descr
->type_num);
%(R)
s = (PyArrayObject *) PyArray_SimpleNew(5, dims,
PyArray_DESCR(
%(H)
s)
->type_num);
if (!(
%(R)
s)) {
PyErr_Format(PyExc_MemoryError, "ConvTransp3D: could not allocate R");
%(fail)
s
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
a924f75b
...
...
@@ -117,14 +117,14 @@ class SoftmaxWithBias(gof.Op):
PyErr_SetString(PyExc_ValueError, "b not 1d tensor");
%(fail)
s;
}
if ((
%(x)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(x)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(x)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(x)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError, "a not float");
%(fail)
s;
}
if ((
%(b)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(b)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(b)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(b)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError, "b not float");
%(fail)
s;
...
...
@@ -263,15 +263,15 @@ class SoftmaxGrad(gof.Op):
dy
,
sm
=
inp
dx
,
=
out
return
'''
if ((
%(dy)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(dy)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(dy)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(dy)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError,
"types should be float or float64");
%(fail)
s;
}
if ((
%(sm)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(sm)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(sm)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(sm)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError,
"types should be float or float64");
...
...
@@ -778,10 +778,10 @@ class CrossentropySoftmaxArgmax1HotWithBias(gof.Op):
PyErr_SetString(PyExc_ValueError, "y_idx not 1d tensor");
%(fail)
s;
}
if ((
%(y_idx)
s->descr
->type_num != NPY_INT64)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT32)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT16)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT8))
if ((
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT64)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT32)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT16)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT8))
{
PyErr_SetString(PyExc_TypeError,
"y_idx not int8, int16, int32, or int64");
...
...
@@ -914,24 +914,24 @@ class CrossentropySoftmax1HotWithBiasDx (gof.Op):
y_idx_type
=
node
.
inputs
[
2
]
.
type
.
dtype_specs
()[
1
]
return
"""
if ((
%(dnll)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(dnll)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(dnll)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(dnll)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError,
"dnll type should be float32 or float64");
%(fail)
s;
}
if ((
%(sm)
s->descr
->type_num != NPY_DOUBLE) &&
(
%(sm)
s->descr
->type_num != NPY_FLOAT))
if ((
PyArray_DESCR(
%(sm)
s)
->type_num != NPY_DOUBLE) &&
(
PyArray_DESCR(
%(sm)
s)
->type_num != NPY_FLOAT))
{
PyErr_SetString(PyExc_TypeError,
"sm type should be float32 or float64");
%(fail)
s;
}
if ((
%(y_idx)
s->descr
->type_num != NPY_INT64)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT32)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT16)
&& (
%(y_idx)
s->descr
->type_num != NPY_INT8))
if ((
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT64)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT32)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT16)
&& (
PyArray_DESCR(
%(y_idx)
s)
->type_num != NPY_INT8))
{
PyErr_SetString(PyExc_TypeError,
"y_idx not int8, int16, int32, or int64");
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论