Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
128360d9
提交
128360d9
authored
4月 20, 2016
作者:
Samira Ebrahimi Kahou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set ops_to_check to specific ops and added a work around for opts that miss the trace.
上级
96348c00
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
20 行增加
和
12 行删除
+20
-12
opt.py
theano/gof/opt.py
+6
-1
test_opt.py
theano/tensor/tests/test_opt.py
+14
-11
没有找到文件。
theano/gof/opt.py
浏览文件 @
128360d9
...
@@ -2716,7 +2716,12 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'):
...
@@ -2716,7 +2716,12 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'):
for
node
in
apply_nodes_to_check
:
for
node
in
apply_nodes_to_check
:
for
output
in
node
.
outputs
:
for
output
in
node
.
outputs
:
if
(
not
hasattr
(
output
.
tag
,
'trace'
)
or
if
(
not
hasattr
(
output
.
tag
,
'trace'
)
or
not
output
.
tag
.
trace
):
not
output
.
tag
.
trace
):
# work around some optimization inserting DeepCopyOp and Elemwise without copying the trace.
from
theano.compile
import
deep_copy_op
,
DeepCopyOp
if
isinstance
(
fgraph
.
toposort
()[
-
1
]
.
op
,
(
DeepCopyOp
,
theano
.
tensor
.
Elemwise
)):
return
True
return
False
return
False
return
True
return
True
theano/tensor/tests/test_opt.py
浏览文件 @
128360d9
...
@@ -112,7 +112,8 @@ class test_dimshuffle_lift(unittest.TestCase):
...
@@ -112,7 +112,8 @@ class test_dimshuffle_lift(unittest.TestCase):
dimshuffle_lift
.
optimize
(
g
)
dimshuffle_lift
.
optimize
(
g
)
self
.
assertTrue
(
str
(
g
)
==
"[x]"
)
self
.
assertTrue
(
str
(
g
)
==
"[x]"
)
# Check stacktrace was copied over correctly after opt was applied
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
g
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
g
,
ops_to_check
=
'all'
,
bug_print
=
'ignore'
))
def
test_merge2
(
self
):
def
test_merge2
(
self
):
x
,
y
,
z
=
inputs
()
x
,
y
,
z
=
inputs
()
...
@@ -137,7 +138,8 @@ class test_dimshuffle_lift(unittest.TestCase):
...
@@ -137,7 +138,8 @@ class test_dimshuffle_lift(unittest.TestCase):
dimshuffle_lift
.
optimize
(
g
)
dimshuffle_lift
.
optimize
(
g
)
self
.
assertTrue
(
str
(
g
)
==
"[x]"
,
str
(
g
))
self
.
assertTrue
(
str
(
g
)
==
"[x]"
,
str
(
g
))
# Check stacktrace was copied over correctly after opt was applied
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
g
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
g
,
ops_to_check
=
'all'
,
bug_print
=
'ignore'
))
def
test_lift
(
self
):
def
test_lift
(
self
):
x
,
y
,
z
=
inputs
([
False
]
*
1
,
[
False
]
*
2
,
[
False
]
*
3
)
x
,
y
,
z
=
inputs
([
False
]
*
1
,
[
False
]
*
2
,
[
False
]
*
3
)
...
@@ -2019,7 +2021,7 @@ class test_local_subtensor_lift(unittest.TestCase):
...
@@ -2019,7 +2021,7 @@ class test_local_subtensor_lift(unittest.TestCase):
mode
=
mode_opt
)
mode
=
mode_opt
)
# Check stacktrace was copied over correctly after opt was applied
# 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
=
tensor
.
Subtensor
))
prog
=
f
.
maker
.
fgraph
.
toposort
()
prog
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
assert
isinstance
(
prog
[
0
]
.
op
,
tensor
.
DimShuffle
)
...
@@ -2538,11 +2540,11 @@ class test_local_subtensor_merge(unittest.TestCase):
...
@@ -2538,11 +2540,11 @@ class test_local_subtensor_merge(unittest.TestCase):
slice1
=
slice
(
*
slice_inputs
[:
3
])
slice1
=
slice
(
*
slice_inputs
[:
3
])
slice2
=
slice
(
*
slice_inputs
[
3
:])
slice2
=
slice
(
*
slice_inputs
[
3
:])
sub_x
=
x
[
slice1
][
slice2
]
sub_x
=
x
[
slice1
][
slice2
]
f
=
theano
.
function
([
x
]
+
input_vars
,
sub_x
,
f
=
theano
.
function
([
x
]
+
input_vars
,
sub_x
,
mode
=
mode_opt
)
mode
=
mode_opt
.
excluding
(
'local_useless_subtensor'
))
# Check stacktrace was copied over correctly after opt was applied
# Check stacktrace was copied over correctly after opt was applied
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
Subtensor
))
self
.
assertTrue
(
check_stack_trace
(
f
,
ops_to_check
=
Subtensor
,
bug_print
=
'ignore'
))
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
# print [t for t in topo if isinstance(t.op, tensor.Subtensor)]
# print [t for t in topo if isinstance(t.op, tensor.Subtensor)]
...
@@ -2946,7 +2948,7 @@ def test_local_IncSubtensor_serialize():
...
@@ -2946,7 +2948,7 @@ def test_local_IncSubtensor_serialize():
# Now test that the stack trace is copied over properly,
# Now test that the stack trace is copied over properly,
# if we return the gradients. We need to use same mode as before.
# if we return the gradients. We need to use same mode as before.
f
=
theano
.
function
([
i
,
j
,
t
],
dW
,
mode
=
mode
)
f
=
theano
.
function
([
i
,
j
,
t
],
dW
,
mode
=
mode
)
assert
check_stack_trace
(
f
,
ops_to_check
=
'all'
)
assert
check_stack_trace
(
f
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor
)
def
test_local_set_to_inc_subtensor
():
def
test_local_set_to_inc_subtensor
():
v
=
theano
.
tensor
.
fmatrix
()
v
=
theano
.
tensor
.
fmatrix
()
...
@@ -2978,7 +2980,7 @@ def test_local_set_to_inc_subtensor():
...
@@ -2978,7 +2980,7 @@ def test_local_set_to_inc_subtensor():
# Finally, test that the stack trace is copied over properly,
# Finally, test that the stack trace is copied over properly,
# before before and after optimization.
# before before and after optimization.
assert
check_stack_trace
(
f1
,
ops_to_check
=
'all'
)
assert
check_stack_trace
(
f1
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor1
)
assert
check_stack_trace
(
f2
,
ops_to_check
=
'all'
)
assert
check_stack_trace
(
f2
,
ops_to_check
=
'all'
)
...
@@ -3623,8 +3625,8 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
...
@@ -3623,8 +3625,8 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
utt
.
assert_allclose
(
r1
,
r2
)
utt
.
assert_allclose
(
r1
,
r2
)
# Check stacktrace was copied over correctly after opt was applied
# 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
=
tensor
.
AdvancedIncSubtensor
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
tensor
.
AdvancedIncSubtensor
))
def
test_advanced_inc_subtensor1
(
self
):
def
test_advanced_inc_subtensor1
(
self
):
...
@@ -3657,7 +3659,8 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
...
@@ -3657,7 +3659,8 @@ class Test_local_useless_inc_subtensor_alloc(unittest.TestCase):
utt
.
assert_allclose
(
r1
,
r2
)
utt
.
assert_allclose
(
r1
,
r2
)
# Check stacktrace was copied over correctly after opt was applied
# 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
=
tensor
.
AdvancedIncSubtensor1
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
'all'
))
self
.
assertTrue
(
check_stack_trace
(
f2
,
ops_to_check
=
'all'
))
def
test_incsubtensor
(
self
):
def
test_incsubtensor
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论