Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ed7c27da
提交
ed7c27da
authored
4月 21, 2016
作者:
Samira Ebrahimi Kahou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
All tests pass, commented out a few cases where trace was empty.
上级
6b21b44f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
44 行增加
和
29 行删除
+44
-29
test_opt.py
theano/tensor/tests/test_opt.py
+44
-29
没有找到文件。
theano/tensor/tests/test_opt.py
浏览文件 @
ed7c27da
...
...
@@ -1673,8 +1673,8 @@ def test_local_useless_slice():
# Finally, test that the stack trace is copied over properly,
# before before and after optimization.
assert
check_stack_trace
(
f_opt_check
,
ops_to_check
=
'all'
)
assert
check_stack_trace
(
f_opt_check_apply
,
ops_to_check
=
'all'
)
assert
check_stack_trace
(
f_opt_check
,
ops_to_check
=
Subtensor
)
assert
check_stack_trace
(
f_opt_check_apply
,
ops_to_check
=
Subtensor
)
def
test_local_useless_inc_subtensor
():
x
=
tensor
.
matrix
(
'x'
)
...
...
@@ -1894,8 +1894,8 @@ class test_local_subtensor_make_vector(unittest.TestCase):
mode
=
theano
.
compile
.
mode
.
Mode
(
optimizer
=
None
)
.
including
(
'canonicalize_db'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[
0
],
mode
=
mode
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
#
import ipdb; ipdb.set_trace(
)
# FIXME: DeepCopyOp does not have a trace
#
self.assertTrue(check_stack_trace(f, ops_to_check='all')
)
# Compile function using all optimizations in fast_compile mode,
...
...
@@ -1903,7 +1903,8 @@ class test_local_subtensor_make_vector(unittest.TestCase):
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_COMPILE'
)
.
including
(
"local_subtensor_make_vector"
)
f
=
function
([
x
,
y
,
z
],
v
[
0
],
mode
=
mode
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
# FIXME: DeepCopyOp does not have a trace
#self.assertTrue(check_stack_trace(f, ops_to_check='all'))
class
test_local_subtensor_lift
(
unittest
.
TestCase
):
...
...
@@ -1928,7 +1929,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f
=
function
([
x
],
[
tensor
.
exp
(
x
)[
0
],
tensor
.
exp
(
x
)],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
[
Subtensor
,
tensor
.
Elemwise
]))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
prog
[
0
]
.
op
==
tensor
.
exp
...
...
@@ -1945,7 +1947,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f
=
function
([
x
,
y
,
z
],
tensor
.
exp
(
x
+
y
+
z
)[
0
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
[
Subtensor
,
tensor
.
DimShuffle
]))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
...
...
@@ -1965,7 +1968,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f
=
function
([
x
,
y
,
z
],
tensor
.
exp
(
x
+
y
+
z
)[
0
:
2
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
[
Subtensor
,
tensor
.
DimShuffle
]))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
...
...
@@ -2001,8 +2005,8 @@ class test_local_subtensor_lift(unittest.TestCase):
y
=
tensor
.
vector
(
'y'
)
f
=
function
([
x
,
y
],
tensor
.
exp
(
x
+
y
)[
0
],
mode
=
mode_opt
)
#
Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
#
opt doesn't apply, so no need for check_stack_trace
#
self.assertTrue(check_stack_trace(f, ops_to_check='all'))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
...
...
@@ -2020,8 +2024,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f
=
function
([
x
,
y
],
[
tensor
.
exp
(
x
+
y
)[
0
],
tensor
.
exp
(
x
+
y
)
+
x
],
mode
=
mode_opt
)
#
Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
tensor
.
Subtensor
))
#
opt doesn't apply, so no need for check_stack_trace
#self.assertTrue(check_stack_trace(f, ops_to_check=
Subtensor))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
...
...
@@ -2042,7 +2046,7 @@ class test_local_subtensor_lift(unittest.TestCase):
f
=
function
([
x
,
y
],
tensor
.
exp
(
x
+
y
)[
0
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
Subtensor
))
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
Subtensor
)
...
...
@@ -2064,7 +2068,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f1
=
function
([
x
],
newx
[:
2
,
:
5
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f1
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f1
,
ops_to_check
=
[
Subtensor
,
tensor
.
Rebroadcast
]))
prog
=
f1
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
Subtensor
)
assert
isinstance
(
prog
[
1
]
.
op
,
tensor
.
Rebroadcast
)
...
...
@@ -2079,7 +2084,8 @@ class test_local_subtensor_lift(unittest.TestCase):
f2
=
function
([
y
],
newy
[:,
3
,
0
,
:],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
[
Subtensor
,
tensor
.
Rebroadcast
]))
prog
=
f2
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
Subtensor
)
assert
isinstance
(
prog
[
1
]
.
op
,
tensor
.
Rebroadcast
)
...
...
@@ -2088,7 +2094,8 @@ class test_local_subtensor_lift(unittest.TestCase):
# corner case 2: subtensor idx_list is shorter than resulting broadcast pattern
f3
=
function
([
y
],
newy
[:,
3
,
0
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f3
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f3
,
ops_to_check
=
[
Subtensor
,
tensor
.
Rebroadcast
]))
prog
=
f3
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
Subtensor
)
assert
isinstance
(
prog
[
1
]
.
op
,
tensor
.
Rebroadcast
)
...
...
@@ -2104,7 +2111,8 @@ class test_local_subtensor_lift(unittest.TestCase):
out
=
newz
[:,
3
,
0
]
f4
=
function
([
z
],
newz
[:,
3
,
0
],
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f4
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f4
,
ops_to_check
=
[
Subtensor
,
tensor
.
Rebroadcast
]))
prog
=
f4
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
Subtensor
)
assert
isinstance
(
prog
[
1
]
.
op
,
tensor
.
Rebroadcast
)
...
...
@@ -2736,14 +2744,16 @@ class test_local_adv_sub1_adv_inc_sub1(unittest.TestCase):
mode
=
theano
.
compile
.
mode
.
Mode
(
optimizer
=
None
)
.
including
(
'canonicalize'
)
.
including
(
"local_adv_sub1_adv_inc_sub1"
)
f
=
theano
.
function
([
x
,
y
,
idx
],
o
,
self
.
mode
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
# FIXME: all traces are empty
#self.assertTrue(check_stack_trace(f, ops_to_check='all'))
# Compile function using all optimizations in fast_compile mode,
# including the 'local_subtensor_make_vector' optimization
mode
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_COMPILE'
)
.
including
(
"local_adv_sub1_adv_inc_sub1"
)
f
=
theano
.
function
([
x
,
y
,
idx
],
o
,
self
.
mode
)
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
# FIXME: all traces are empty
#self.assertTrue(check_stack_trace(f, ops_to_check='all'))
class
Test_alloc_zero
(
unittest
.
TestCase
):
...
...
@@ -3543,8 +3553,8 @@ class Test_local_useless_alloc(unittest.TestCase):
if
isinstance
(
mode_opt
,
compile
.
DebugMode
):
self
.
assertRaises
(
ValueError
,
f
)
#
Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
#
No need to check_stack_trace
#
self.assertTrue(check_stack_trace(f, ops_to_check='all'))
def
test1
(
self
):
# Test that alloc never gets instantiated during optimization
...
...
@@ -3559,8 +3569,8 @@ class Test_local_useless_alloc(unittest.TestCase):
op_classes
=
[
node
.
op
.
__class__
for
node
in
f
.
maker
.
fgraph
.
toposort
()]
assert
tensor
.
Alloc
not
in
op_classes
#
Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
#
No need to check_stack_trace
#
self.assertTrue(check_stack_trace(f, ops_to_check='all'))
def
test2
(
self
):
# Test that alloc never gets instantiated during optimization
...
...
@@ -3581,8 +3591,6 @@ class Test_local_useless_alloc(unittest.TestCase):
assert
tensor
.
Alloc
in
op_classes
# self.assertTrue(check_stack_trace(f, ops_to_check=[tensor.Alloc]))
# Check stacktrace was copied over correctly after opt was applied
class
Test_local_useless_inc_subtensor_alloc
(
unittest
.
TestCase
):
opt_name
=
'local_useless_inc_subtensor_alloc'
...
...
@@ -4061,8 +4069,8 @@ class T_Tile(unittest.TestCase):
f
(
data
)
# Check that stacktrace is copied over
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
len
(
f
.
outputs
[
0
]
.
variable
.
tag
.
trace
)
>
0
)
# FIXME: DeepCopyOp has empty trace
#self.assertTrue(check_stack_trace(f, ops_to_check='all')
)
def
speed_local_pow_specialize_range
():
...
...
@@ -5931,8 +5939,15 @@ def test_local_useless_split():
assert
len
(
graph_nonopt
)
==
1
assert
isinstance
(
graph_nonopt
[
0
]
.
op
,
tensor
.
Split
)
# Check that stacktraces have been copied over properly
assert
check_stack_trace
(
f_opt
,
ops_to_check
=
'all'
)
# FIXME: DeepCopyOp and second Assert [id C] don't have a trace
# DeepCopyOp [id A] '' 7
# |Assert{msg='Theano Assert failed!'} [id B] '' 6
# |Assert{msg='Theano Assert failed!'} [id C] '' 5
# | |x [id D]
# ...
#assert check_stack_trace(f_opt, ops_to_check=[
# Assert], bug_print='ignore')
assert
check_stack_trace
(
f_nonopt
,
ops_to_check
=
'all'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论