Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
565e235f
提交
565e235f
authored
10月 17, 2011
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test on the gpu that we raise en error when the compiled shape is not the same at runtime.
上级
8bde3d2f
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
56 行增加
和
8 行删除
+56
-8
blas.py
theano/sandbox/cuda/blas.py
+1
-1
conv.cu
theano/sandbox/cuda/conv.cu
+12
-2
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+43
-5
没有找到文件。
theano/sandbox/cuda/blas.py
浏览文件 @
565e235f
...
@@ -456,7 +456,7 @@ class GpuConv(Op):
...
@@ -456,7 +456,7 @@ class GpuConv(Op):
return
[
'cuda_ndarray.cuh'
,
'<stdio.h>'
]
return
[
'cuda_ndarray.cuh'
,
'<stdio.h>'
]
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
0
,
15
)
# raise this whenever modifying any of the support_code_files
return
(
0
,
16
)
# raise this whenever modifying any of the support_code_files
def
c_support_code_apply
(
self
,
node
,
nodename
):
def
c_support_code_apply
(
self
,
node
,
nodename
):
# REMEMBER TO RAISE c_code_cache_version when changing any of these files
# REMEMBER TO RAISE c_code_cache_version when changing any of these files
...
...
theano/sandbox/cuda/conv.cu
浏览文件 @
565e235f
...
@@ -82,7 +82,12 @@ CudaNdarray_conv_valid(const CudaNdarray *img, const CudaNdarray * kern,
...
@@ -82,7 +82,12 @@ CudaNdarray_conv_valid(const CudaNdarray *img, const CudaNdarray * kern,
const int img_size_byte = img_size*sizeof(float);
const int img_size_byte = img_size*sizeof(float);
const int kern_size_byte = kern_size*sizeof(float);
const int kern_size_byte = kern_size*sizeof(float);
const int out_size_byte = out_size*sizeof(float);
const int out_size_byte = out_size*sizeof(float);
assert((THEANO_KERN_WID == CudaNdarray_HOST_DIMS(kern)[3]) || (THEANO_KERN_WID==0));
if (!((THEANO_KERN_WID == CudaNdarray_HOST_DIMS(kern)[3]) || (THEANO_KERN_WID==0))){
PyErr_Format(PyExc_ValueError, "ERROR: This GpuConv code was compiled for"
" %d kernel columns, but the kernel we received had %d colums!",
THEANO_KERN_WID, CudaNdarray_HOST_DIMS(kern)[3]);
return -1;
}
bool subsample = subsample_rows!=1 || subsample_cols!=1;
bool subsample = subsample_rows!=1 || subsample_cols!=1;
bool img_contiguous = CudaNdarray_is_c_contiguous(img);
bool img_contiguous = CudaNdarray_is_c_contiguous(img);
...
@@ -761,7 +766,12 @@ CudaNdarray_conv_full(const CudaNdarray *img, const CudaNdarray * kern, CudaNdar
...
@@ -761,7 +766,12 @@ CudaNdarray_conv_full(const CudaNdarray *img, const CudaNdarray * kern, CudaNdar
//const int out_size_byte = out_size*sizeof(float); // unused
//const int out_size_byte = out_size*sizeof(float); // unused
assert((THEANO_KERN_WID == CudaNdarray_HOST_DIMS(kern)[3]) || (THEANO_KERN_WID==0));
if (!((THEANO_KERN_WID == CudaNdarray_HOST_DIMS(kern)[3]) || (THEANO_KERN_WID==0))){
PyErr_Format(PyExc_ValueError, "ERROR: This GpuConv code was compiled for"
" %d kernel columns, but the kernel we received had %d colums!",
THEANO_KERN_WID, CudaNdarray_HOST_DIMS(kern)[3]);
return -1;
}
bool subsample = subsample_rows!=1 || subsample_cols!=1;
bool subsample = subsample_rows!=1 || subsample_cols!=1;
bool img_contiguous = CudaNdarray_is_c_contiguous(img);
bool img_contiguous = CudaNdarray_is_c_contiguous(img);
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
565e235f
import
sys
,
time
import
sys
import
time
import
unittest
import
numpy
import
numpy
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
...
@@ -86,7 +90,7 @@ def _params_allgood_header():
...
@@ -86,7 +90,7 @@ def _params_allgood_header():
def
_params_allgood
(
ishape
,
kshape
,
mode
,
subsample
=
(
1
,
1
),
img_stride
=
(
1
,
1
),
def
_params_allgood
(
ishape
,
kshape
,
mode
,
subsample
=
(
1
,
1
),
img_stride
=
(
1
,
1
),
kern_stride
=
(
1
,
1
),
version
=-
1
,
verbose
=
0
,
random
=
True
,
print_
=
None
,
kern_stride
=
(
1
,
1
),
version
=-
1
,
verbose
=
0
,
random
=
True
,
print_
=
None
,
id
=
None
,
rtol
=
1e-5
,
atol
=
1e-8
,
nb_iter
=
0
,
ones
=
False
):
id
=
None
,
rtol
=
1e-5
,
atol
=
1e-8
,
nb_iter
=
0
,
ones
=
False
,
kshp
=
None
):
#
#
# This function is the core of several of the big unit-test drivers,
# This function is the core of several of the big unit-test drivers,
# but it can also be used very directly on its own to test a specific
# but it can also be used very directly on its own to test a specific
...
@@ -124,7 +128,10 @@ def _params_allgood(ishape, kshape, mode, subsample=(1,1), img_stride=(1,1),
...
@@ -124,7 +128,10 @@ def _params_allgood(ishape, kshape, mode, subsample=(1,1), img_stride=(1,1),
t1
=
time
.
time
()
t1
=
time
.
time
()
i
=
cuda_tensor4
()
i
=
cuda_tensor4
()
k
=
cuda_tensor4
()
k
=
cuda_tensor4
()
op
=
theano
.
sandbox
.
cuda
.
blas
.
GpuConv
(
border_mode
=
mode
,
subsample
=
subsample
,
version
=
version
,
verbose
=
verbose
)(
i
,
k
)
op
=
theano
.
sandbox
.
cuda
.
blas
.
GpuConv
(
border_mode
=
mode
,
subsample
=
subsample
,
version
=
version
,
verbose
=
verbose
,
kshp
=
kshp
)(
i
,
k
)
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
f
=
theano
.
function
([
i
,
k
],
op
,
mode
=
theano_mode
)
gpuval
=
f
(
img
,
kern
)
gpuval
=
f
(
img
,
kern
)
t2
=
time
.
time
()
t2
=
time
.
time
()
...
@@ -180,7 +187,8 @@ def _params_allgood(ishape, kshape, mode, subsample=(1,1), img_stride=(1,1),
...
@@ -180,7 +187,8 @@ def _params_allgood(ishape, kshape, mode, subsample=(1,1), img_stride=(1,1),
return
rval
return
rval
def
exec_conv
(
version
,
shapes
,
verbose
,
random
,
mode
,
print_
=
None
,
rtol
=
1e-5
,
ones
=
False
):
def
exec_conv
(
version
,
shapes
,
verbose
,
random
,
mode
,
print_
=
None
,
rtol
=
1e-5
,
ones
=
False
,
kshp
=
None
):
if
verbose
>
0
:
if
verbose
>
0
:
_params_allgood_header
()
_params_allgood_header
()
nb_failed
=
0
nb_failed
=
0
...
@@ -204,7 +212,8 @@ def exec_conv(version, shapes, verbose, random, mode, print_=None, rtol=1e-5, on
...
@@ -204,7 +212,8 @@ def exec_conv(version, shapes, verbose, random, mode, print_=None, rtol=1e-5, on
id
=
id
,
id
=
id
,
print_
=
print_
,
print_
=
print_
,
rtol
=
rtol
,
rtol
=
rtol
,
ones
=
ones
)
ones
=
ones
,
kshp
=
kshp
)
except
Exception
,
e
:
except
Exception
,
e
:
print
ver
,
id
,(
ishape
,
kshape
,
subshape
,
istride
,
kstride
)
print
ver
,
id
,(
ishape
,
kshape
,
subshape
,
istride
,
kstride
)
print
e
print
e
...
@@ -583,6 +592,35 @@ def test_subsample():
...
@@ -583,6 +592,35 @@ def test_subsample():
# print >> sys.stderr, "WARNING TODO: test_logical_shapes not implemented (i.e. imshp_logical, kshp_logical, kshp_logical_top_aligned)"
# print >> sys.stderr, "WARNING TODO: test_logical_shapes not implemented (i.e. imshp_logical, kshp_logical, kshp_logical_top_aligned)"
class
TestConv2DGPU
(
unittest
.
TestCase
):
def
test_invalid_input_shape
(
self
):
"""
Tests that when the shape gived at build time is not the same as
run time we raise an error
"""
verbose
=
0
random
=
True
print_
=
False
ones
=
False
if
ones
:
random
=
False
global
theano_mode
theano_mode_orig
=
theano_mode
try
:
if
theano
.
config
.
mode
in
[
'DebugMode'
,
'DEBUG_MODE'
]:
theano_mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpu'
)
for
mode
in
[
'valid'
,
'full'
]:
for
shapes
in
[((
3
,
2
,
8
,
8
),
(
4
,
2
,
5
,
5
),
(
8
,
8
)),
((
3
,
2
,
8
,
8
),
(
4
,
2
,
5
,
5
),
(
5
,
8
)),
#((3,2,8,8), (4,2,5,5), (8,5)),# We use only the number of columns.
]:
self
.
assertRaises
(
ValueError
,
_params_allgood
,
shapes
[
0
],
shapes
[
1
],
verbose
=
verbose
,
random
=
random
,
mode
=
mode
,
print_
=
print_
,
ones
=
ones
,
kshp
=
shapes
[
2
])
finally
:
theano_mode
=
theano_mode_orig
def
_test_dummy
():
def
_test_dummy
():
ishape
=
(
1
,
1
,
5
,
5
)
ishape
=
(
1
,
1
,
5
,
5
)
kshape
=
(
1
,
1
,
3
,
3
)
kshape
=
(
1
,
1
,
3
,
3
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论