Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4d6df670
提交
4d6df670
authored
3月 27, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small fixes after the release
- make CudaNdarray_SIZE return a size_t - more informative error messages for shape mismatches in Conv2D
上级
63b7b834
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
43 行增加
和
39 行删除
+43
-39
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+5
-5
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+4
-15
cuda_ndarray.cuh
theano/sandbox/cuda/cuda_ndarray.cuh
+1
-4
conv.py
theano/tensor/nnet/conv.py
+33
-15
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
4d6df670
...
...
@@ -1176,7 +1176,7 @@ class GpuCAReduce(GpuOp):
int verbose = 0;
dim3 n_threads(
std::min(CudaNdarray_SIZE(
%(x)
s),
NUM_VECTOR_OP_THREADS_PER_BLOCK));
(size_t)
NUM_VECTOR_OP_THREADS_PER_BLOCK));
dim3 n_blocks(1);
if (verbose) printf("running kernel_reduce_ccontig_
%(name)
s"
" n_threads.x=
%%
d, size=
%%
d, ndim=
%%
d
\\
n",
...
...
@@ -1739,7 +1739,7 @@ class GpuCAReduce(GpuOp):
"""
%
locals
()
def
c_code_cache_version_apply
(
self
,
node
):
version
=
[
1
1
]
# the version corresponding to the c code in this Op
version
=
[
1
2
]
# the version corresponding to the c code in this Op
# now we insert versions for the ops on which we depend...
scalar_node
=
Apply
(
self
.
scalar_op
,
...
...
@@ -3343,13 +3343,13 @@ class GpuAlloc(GpuOp):
if (
%(memset_0)
s && CudaNdarray_is_c_contiguous(
%(out)
s))
{
cudaError_t err = cudaMemset(
%(out)
s->devdata, 0,
CudaNdarray_SIZE
t
(
%(out)
s) * 4);
CudaNdarray_SIZE(
%(out)
s) * 4);
if (cudaSuccess != err)
{
PyErr_Format(PyExc_MemoryError,
"GpuAlloc: Error memsetting
%%
ld"
" bytes of device memory.
%%
s",
(long)(CudaNdarray_SIZE
t
(
%(out)
s) * 4),
(long)(CudaNdarray_SIZE(
%(out)
s) * 4),
cudaGetErrorString(err));
Py_XDECREF(
%(out)
s);
%(out)
s = NULL;
...
...
@@ -3374,7 +3374,7 @@ class GpuAlloc(GpuOp):
return
[
None
for
i
in
inputs
]
def
c_code_cache_version
(
self
):
return
(
9
,)
return
(
10
,)
def
do_constant_folding
(
self
,
node
):
for
client
in
node
.
outputs
[
0
]
.
clients
:
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
4d6df670
...
...
@@ -848,7 +848,7 @@ PyObject * CudaNdarray_Reshape(CudaNdarray * self, PyObject * shape)
// check shape tuple
unsigned
int
rval_nd
;
unsigned
int
*
rval_dims
;
unsigned
in
t
rval_size
=
1
;
size_
t
rval_size
=
1
;
if
(
PyTuple_Check
(
shape
)){
// copy shape to integer array
...
...
@@ -884,7 +884,7 @@ PyObject * CudaNdarray_Reshape(CudaNdarray * self, PyObject * shape)
// calculate new size, assert same as old size
if
(
rval_size
!=
CudaNdarray_SIZE
(
self
))
{
PyErr_Format
(
PyExc_ValueError
,
"size must remain unchanged, changed from %
i to %i
"
,
CudaNdarray_SIZE
(
self
),
rval_size
);
PyErr_Format
(
PyExc_ValueError
,
"size must remain unchanged, changed from %
lld to %lld
"
,
CudaNdarray_SIZE
(
self
),
rval_size
);
free
(
rval_dims
);
return
NULL
;
}
...
...
@@ -1309,7 +1309,7 @@ CudaNdarray_TakeFrom(CudaNdarray * self, PyObject *args){
if
(
cpu_err_var
!=
0
)
{
PyErr_Format
(
PyExc_IndexError
,
"CudaNdarray_TakeFrom: One of the index value is out of bound.
\n
"
,
"CudaNdarray_TakeFrom: One of the index value is out of bound.
Error code: %i.
\n
"
,
cpu_err_var
);
// Must reset it to 0 to don't reset it before each use.
err
=
cudaMemset
((
void
*
)
err_var
,
0
,
sizeof
(
int
));
...
...
@@ -5106,7 +5106,7 @@ CudaNdarray_DEV_DATA(const CudaNdarray * self)
/**
* Return the number of elements in the ndarray (product of the dimensions)
*/
in
t
size_
t
CudaNdarray_SIZE
(
const
CudaNdarray
*
self
)
{
if
(
self
->
nd
==
-
1
)
return
0
;
...
...
@@ -5117,17 +5117,6 @@ CudaNdarray_SIZE(const CudaNdarray *self)
}
return
size
;
}
size_t
CudaNdarray_SIZEt
(
const
CudaNdarray
*
self
)
{
if
(
self
->
nd
==
-
1
)
return
0
;
size_t
size
=
1
;
for
(
int
i
=
0
;
i
<
self
->
nd
;
++
i
)
{
size
*=
CudaNdarray_HOST_DIMS
(
self
)[
i
];
}
return
size
;
}
PyObject
*
CudaNdarray_SIZE_Object
(
const
CudaNdarray
*
self
,
void
*
closure
)
...
...
theano/sandbox/cuda/cuda_ndarray.cuh
浏览文件 @
4d6df670
...
...
@@ -285,10 +285,7 @@ DllExport float *CudaNdarray_DEV_DATA(const CudaNdarray * self);
/**
* Return the number of elements in the ndarray (product of the dimensions)
*/
DllExport
int
CudaNdarray_SIZE
(
const
CudaNdarray
*
self
);
// Useful as many cuda function use size_t as input. This make sure we use the
// most precission and not int.
DllExport
size_t
CudaNdarray_SIZEt
(
const
CudaNdarray
*
self
);
DllExport
size_t
CudaNdarray_SIZE
(
const
CudaNdarray
*
self
);
static
PyObject
*
CudaNdarray_SIZE_Object
(
const
CudaNdarray
*
self
,
void
*
closure
);
...
...
theano/tensor/nnet/conv.py
浏览文件 @
4d6df670
...
...
@@ -674,22 +674,30 @@ class ConvOp(OpenMPOp):
if
any
(
x
is
None
for
x
in
imshp
):
imshp
=
tuple
(
img2d
.
shape
[
1
:])
if
imshp
!=
img2d
.
shape
[
1
:]:
raise
ValueError
(
"bad shape"
,
imshp
,
img2d
.
shape
[
1
:])
raise
ValueError
(
"The image shape provided at build time "
"is different from the one passed at run time"
,
imshp
,
img2d
.
shape
[
1
:])
kshp
=
self
.
kshp
if
any
(
x
is
None
for
x
in
kshp
):
kshp
=
tuple
(
filtersflipped
.
shape
[
2
:])
if
kshp
!=
filtersflipped
.
shape
[
2
:]:
raise
ValueError
(
"bad shape"
,
kshp
,
filtersflipped
.
shape
[
2
:])
raise
ValueError
(
"The filter shape provided at build time "
"is different from the one passed at run time"
,
kshp
,
filtersflipped
.
shape
[
2
:])
bsize
=
self
.
bsize
if
bsize
is
None
:
bsize
=
img2d
.
shape
[
0
]
elif
bsize
!=
img2d
.
shape
[
0
]:
raise
ValueError
(
"bad shape"
,
bsize
,
img2d
.
shape
[
0
])
raise
ValueError
(
"The batch size provided at build time "
"is different from the one passed at run time"
,
bsize
,
img2d
.
shape
[
0
])
nkern
=
self
.
nkern
if
nkern
is
None
:
nkern
=
filtersflipped
.
shape
[
0
]
elif
nkern
!=
filtersflipped
.
shape
[
0
]:
raise
ValueError
(
"bad shape"
,
nkern
,
filtersflipped
.
shape
[
0
])
raise
ValueError
(
"The number of filters provided at build time "
"is different from the one passed at run time"
,
nkern
,
filtersflipped
.
shape
[
0
])
imshp_logical
=
self
.
imshp_logical
if
imshp_logical
[
0
]
is
None
:
...
...
@@ -984,7 +992,7 @@ class ConvOp(OpenMPOp):
return
[
'<numpy/noprefix.h>'
,
'<iostream>'
,
'<sstream>'
]
def
c_code_cache_version
(
self
):
return
(
1
4
,
self
.
openmp
,
blas
.
blas_header_version
())
return
(
1
5
,
self
.
openmp
,
blas
.
blas_header_version
())
def
c_support_code
(
self
):
return
"""
...
...
@@ -1088,7 +1096,8 @@ using namespace std;
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of rows in the filter "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1100,7 +1109,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of columns in the filter "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1112,7 +1122,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of rows in the output "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1124,7 +1135,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of columns in the output "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1136,7 +1148,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the image stack size (
%%
ld) "
"isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1146,7 +1159,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the kernel stack size (
%%
ld) "
"isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1158,7 +1172,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of rows in the image "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1170,7 +1185,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of columns in the image "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1182,7 +1198,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the batch size (
%%
ld) "
"isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
@@ -1194,7 +1211,8 @@ if(%(value)s != %(expected)s){
d
[
"assert_size"
]
+=
"""
if(
%(value)
s !=
%(expected)
s){
PyErr_Format(PyExc_ValueError,
"the hard coded shape (
%%
ld) isn't the run time shape (
%%
ld).",
"The hardcoded shape for the number of kernels in the filter "
"(
%%
ld) isn't the run time shape (
%%
ld).",
(long)
%(value)
s, (long)
%(expected)
s);
%(fail)
s;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论