Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3be32835
提交
3be32835
authored
6月 03, 2009
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Faster version to test all combination of unroll param. We do only once each case.
上级
2b124ebb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
20 行增加
和
9 行删除
+20
-9
test_conv.py
theano/sandbox/test_conv.py
+20
-9
没有找到文件。
theano/sandbox/test_conv.py
浏览文件 @
3be32835
...
@@ -334,10 +334,10 @@ class TestConvOp(unittest.TestCase):
...
@@ -334,10 +334,10 @@ class TestConvOp(unittest.TestCase):
validate
=
False
# we don't validate the result to have it much faster!
validate
=
False
# we don't validate the result to have it much faster!
unroll_batch
=
[
0
,
1
,
2
,
4
,
5
,
10
,
20
]
unroll_batch
=
[
1
,
2
,
4
,
5
,
10
,
20
]
unroll_kern
=
[
0
,
2
,
4
,
5
,
10
,
20
]
unroll_kern
=
[
1
,
2
,
4
,
5
,
10
,
20
]
# unroll_batch = [
0
,2,5]
# unroll_batch = [
1
,2,5]
# unroll_kern = [
0
,2,5]
# unroll_kern = [
1
,2,5]
bsize
=
20
# batch size
bsize
=
20
# batch size
imshp_start
=
(
1
,
50
,
49
)
#un square shape to test more corner case.
imshp_start
=
(
1
,
50
,
49
)
#un square shape to test more corner case.
...
@@ -353,9 +353,10 @@ class TestConvOp(unittest.TestCase):
...
@@ -353,9 +353,10 @@ class TestConvOp(unittest.TestCase):
timing
=
N
.
zeros
((
len
(
unroll_batch
),
len
(
unroll_kern
),
3
))
timing
=
N
.
zeros
((
len
(
unroll_batch
),
len
(
unroll_kern
),
3
))
t_b_k
=
[]
t_b_k
=
[]
#calculate the timing with unrolling
for
unroll_b
,
n_b
in
zip
(
unroll_batch
,
range
(
len
(
unroll_batch
))):
for
unroll_b
,
n_b
in
zip
(
unroll_batch
,
range
(
len
(
unroll_batch
))):
for
unroll_k
,
n_k
in
zip
(
unroll_kern
,
range
(
len
(
unroll_kern
))):
for
unroll_k
,
n_k
in
zip
(
unroll_kern
,
range
(
len
(
unroll_kern
))):
t_b_k
+=
[
str
(
unroll_b
)
+
"/"
+
str
(
unroll_k
)]
t_b_k
.
append
(
str
(
unroll_b
)
+
"/"
+
str
(
unroll_k
))
tctot
,
tpytot
,
ntot
=
[],[],[]
tctot
,
tpytot
,
ntot
=
[],[],[]
for
conv_mode
,
n_mode
in
zip
(
convmodes
,
range
(
len
(
convmodes
))):
for
conv_mode
,
n_mode
in
zip
(
convmodes
,
range
(
len
(
convmodes
))):
for
ss
,
n_ss
in
zip
(
ssizes
,
range
(
len
(
ssizes
))):
for
ss
,
n_ss
in
zip
(
ssizes
,
range
(
len
(
ssizes
))):
...
@@ -365,14 +366,24 @@ class TestConvOp(unittest.TestCase):
...
@@ -365,14 +366,24 @@ class TestConvOp(unittest.TestCase):
ntot
+=
[
ntot_
]
ntot
+=
[
ntot_
]
timing
[
n_b
,
n_k
]
=
[
sum
(
tctot
),
sum
(
tpytot
),
sum
(
ntot
)]
timing
[
n_b
,
n_k
]
=
[
sum
(
tctot
),
sum
(
tpytot
),
sum
(
ntot
)]
#calculate the old timing
tctot
,
tpytot
,
ntot
=
0
,
0
,
0
for
conv_mode
,
n_mode
in
zip
(
convmodes
,
range
(
len
(
convmodes
))):
for
ss
,
n_ss
in
zip
(
ssizes
,
range
(
len
(
ssizes
))):
tctot_
,
tpytot_
,
ntot_
=
do_test
(
conv_mode
,
ss
,
unroll_batch
=
0
,
unroll_kern
=
0
,
validate
=
validate
)
tctot
+=
tctot_
tpytot
+=
tpytot_
ntot
+=
ntot_
print
"old code timing
%.3
fs"
%
tctot
# print timing
# print timing
t
=
timing
[:,:,
0
]
#We select only the c timing.
t
=
timing
[:,:,
0
]
#We select only the c timing.
print
"timing for unrolled version"
print
t_b_k
print
t_b_k
print
t
print
t
print
"max
%.3
fs"
%
t
.
max
(),
"max param(batch unloop size/kernel unloop size)"
,
t_b_k
[
t
.
argmax
()]
print
"max
%.3
fs"
%
t
.
max
(),
"max param(batch unloop size/kernel unloop size)"
,
t_b_k
[
t
.
argmax
()]
print
"min
%.3
fs"
%
t
.
min
(),
"min param(batch unloop size/kernel unloop size)"
,
t_b_k
[
t
.
argmin
()]
print
"min
%.3
fs"
%
t
.
min
(),
"min param(batch unloop size/kernel unloop size)"
,
t_b_k
[
t
.
argmin
()]
print
"speedup
%.3
fx"
%
(
t
.
max
()
/
t
.
min
())
print
"speedup
vs (1/1)
%.3
fx, vs old
%.3
fx"
%
(
t
.
max
()
/
t
.
min
(),
tctot
/
t
.
min
())
return
return
for
conv_mode
,
n_mode
in
zip
(
convmodes
,
range
(
len
(
convmodes
))):
for
conv_mode
,
n_mode
in
zip
(
convmodes
,
range
(
len
(
convmodes
))):
...
@@ -387,9 +398,9 @@ class TestConvOp(unittest.TestCase):
...
@@ -387,9 +398,9 @@ class TestConvOp(unittest.TestCase):
print
'c Theano(ConvOp) processing time:
%.3
fs'
%
sum
(
tctot
),
tctot
print
'c Theano(ConvOp) processing time:
%.3
fs'
%
sum
(
tctot
),
tctot
print
'py Theano(ConvOp) processing time:
%.3
fs'
%
sum
(
tpytot
),
tpytot
print
'py Theano(ConvOp) processing time:
%.3
fs'
%
sum
(
tpytot
),
tpytot
d
=
N
.
asarray
(
ntot
)
/
tctot
d
=
N
.
asarray
(
ntot
)
/
tctot
print
'speed up c theano(ConvOp) vs convolve2d:
%.3
f'
%
d
.
mean
(),
d
print
'speed up c theano(ConvOp) vs convolve2d:
%.3
f
x
'
%
d
.
mean
(),
d
d
=
N
.
asarray
(
ntot
)
/
tpytot
d
=
N
.
asarray
(
ntot
)
/
tpytot
print
'speed up py theano(ConvOp) vs convolve2d:
%.3
f'
%
d
.
mean
(),
d
print
'speed up py theano(ConvOp) vs convolve2d:
%.3
f
x
'
%
d
.
mean
(),
d
def
test_ConvOpGrad
(
self
):
def
test_ConvOpGrad
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论