Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
46adff86
提交
46adff86
authored
11月 03, 2020
作者:
Brandon T. Willard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Turn speed tests into actual unit tests
These tests now assume that the C VM versions of scan Ops should be faster than their standard Python counterparts.
上级
abc69153
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
12 行删除
+14
-12
test_basic.py
tests/scan/test_basic.py
+14
-12
没有找到文件。
tests/scan/test_basic.py
浏览文件 @
46adff86
...
@@ -4838,7 +4838,8 @@ def test_speed_rnn():
...
@@ -4838,7 +4838,8 @@ def test_speed_rnn():
for
i
in
range
(
1
,
L
):
for
i
in
range
(
1
,
L
):
r
[
i
]
=
np
.
tanh
(
np
.
dot
(
r
[
i
-
1
],
w
))
r
[
i
]
=
np
.
tanh
(
np
.
dot
(
r
[
i
-
1
],
w
))
t1
=
time
.
time
()
t1
=
time
.
time
()
print
(
"python"
,
t1
-
t0
)
python_duration
=
t1
-
t0
print
(
"python"
,
python_duration
)
r
=
np
.
arange
(
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
N
)
r
=
np
.
arange
(
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
N
)
s_r
=
tensor
.
matrix
()
s_r
=
tensor
.
matrix
()
...
@@ -4854,7 +4855,8 @@ def test_speed_rnn():
...
@@ -4854,7 +4855,8 @@ def test_speed_rnn():
t2
=
time
.
time
()
t2
=
time
.
time
()
f
(
r
)
f
(
r
)
t3
=
time
.
time
()
t3
=
time
.
time
()
print
(
"theano (cvm)"
,
t1
-
t0
)
cvm_duration
=
t3
-
t2
print
(
"theano (cvm)"
,
cvm_duration
)
r
=
np
.
arange
(
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
N
)
r
=
np
.
arange
(
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
N
)
shared_r
=
theano
.
shared
(
r
)
shared_r
=
theano
.
shared
(
r
)
...
@@ -4872,11 +4874,14 @@ def test_speed_rnn():
...
@@ -4872,11 +4874,14 @@ def test_speed_rnn():
)
)
f_fn
=
f
.
fn
f_fn
=
f
.
fn
t
2
=
time
.
time
()
t
4
=
time
.
time
()
f_fn
(
n_calls
=
L
-
2
)
f_fn
(
n_calls
=
L
-
2
)
f
()
# 999 to update the profiling timers
f
()
# 999 to update the profiling timers
t3
=
time
.
time
()
t5
=
time
.
time
()
print
(
"theano (updates, cvm)"
,
t3
-
t2
)
cvm_shared_duration
=
t5
-
t4
print
(
"theano (updates, cvm)"
,
cvm_shared_duration
)
assert
cvm_shared_duration
<
python_duration
@pytest.mark.skipif
(
@pytest.mark.skipif
(
...
@@ -4892,9 +4897,6 @@ def test_speed_batchrnn():
...
@@ -4892,9 +4897,6 @@ def test_speed_batchrnn():
of the optimizations applied, but generally correctness-testing
of the optimizations applied, but generally correctness-testing
is not the goal of this test.
is not the goal of this test.
To be honest, it isn't really a unit test so much as a tool for testing
approaches to scan.
The computation being tested here is a repeated tanh of a matrix-vector
The computation being tested here is a repeated tanh of a matrix-vector
multiplication - the heart of an ESN or RNN.
multiplication - the heart of an ESN or RNN.
"""
"""
...
@@ -4910,7 +4912,7 @@ def test_speed_batchrnn():
...
@@ -4910,7 +4912,7 @@ def test_speed_batchrnn():
for
i
in
range
(
1
,
L
):
for
i
in
range
(
1
,
L
):
r
[
i
]
=
np
.
tanh
(
np
.
dot
(
r
[
i
-
1
],
w
))
r
[
i
]
=
np
.
tanh
(
np
.
dot
(
r
[
i
-
1
],
w
))
t1
=
time
.
time
()
t1
=
time
.
time
()
p
rint
(
"python"
,
t1
-
t0
)
p
ython_duration
=
t1
-
t0
r
=
np
.
arange
(
B
*
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
B
,
N
)
r
=
np
.
arange
(
B
*
L
*
N
)
.
astype
(
config
.
floatX
)
.
reshape
(
L
,
B
,
N
)
shared_r
=
theano
.
shared
(
r
)
shared_r
=
theano
.
shared
(
r
)
...
@@ -4926,14 +4928,14 @@ def test_speed_batchrnn():
...
@@ -4926,14 +4928,14 @@ def test_speed_batchrnn():
updates
=
[(
s_i
,
s_i
+
1
),
(
shared_r
,
s_rinc
)],
updates
=
[(
s_i
,
s_i
+
1
),
(
shared_r
,
s_rinc
)],
mode
=
theano
.
Mode
(
linker
=
"cvm"
),
mode
=
theano
.
Mode
(
linker
=
"cvm"
),
)
)
# theano.printing.debugprint(f)
f_fn
=
f
.
fn
f_fn
=
f
.
fn
# print f_fn
t2
=
time
.
time
()
t2
=
time
.
time
()
f_fn
(
n_calls
=
L
-
2
)
f_fn
(
n_calls
=
L
-
2
)
f
()
# 999 to update the profiling timers
f
()
# 999 to update the profiling timers
t3
=
time
.
time
()
t3
=
time
.
time
()
print
(
"theano (updates, cvm)"
,
t3
-
t2
)
cvm_duration
=
t3
-
t2
assert
cvm_duration
<
python_duration
def
test_compute_test_value
():
def
test_compute_test_value
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论