Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0fdce438
提交
0fdce438
authored
12月 01, 2016
作者:
Gijs van Tulder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Still merge identical Asserts while Assert merging is disabled.
Although the fancy merging of conditions is disabled, identical Asserts can still be combined. See #3344.
上级
89849eb7
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
1 行删除
+32
-1
opt.py
theano/gof/opt.py
+8
-1
test_opt.py
theano/gof/tests/test_opt.py
+24
-0
没有找到文件。
theano/gof/opt.py
浏览文件 @
0fdce438
...
...
@@ -615,6 +615,7 @@ class MergeFeature(object):
# Put all clients of Assert inputs (if exist) into merge_candidates
# TODO: Deactivated for now as this cause cycle in the graph.
# (There is a second deactivation part below.)
for
i
in
[]:
# node.inputs:
if
i
.
owner
and
isinstance
(
i
.
owner
.
op
,
theano
.
tensor
.
opt
.
Assert
):
...
...
@@ -647,7 +648,8 @@ class MergeFeature(object):
# Get input list of the candidate with assert removed
cand_inputs_assert_removed
=
[]
for
i
in
candidate
.
inputs
:
# TODO: Deactivated while Assert merging is disabled. (See above and below.)
for
i
in
[]:
# candidate.inputs:
if
i
.
owner
and
isinstance
(
i
.
owner
.
op
,
theano
.
tensor
.
opt
.
Assert
):
cand_has_assert
=
True
...
...
@@ -655,6 +657,11 @@ class MergeFeature(object):
else
:
cand_inputs_assert_removed
.
append
(
i
)
# TODO: Remove this when Assert merging is re-enabled. (See above.)
# Without Assert merging we can still look for identical Asserts,
# so we should not treat Asserts separately for now.
cand_inputs_assert_removed
=
candidate
.
inputs
# Get input list of the node with assert removed
if
node_has_assert
:
node_inputs_assert_removed
=
[]
...
...
theano/gof/tests/test_opt.py
浏览文件 @
0fdce438
...
...
@@ -399,6 +399,30 @@ class TestMergeOptimizer:
'''
assert
strg
==
strref
,
(
strg
,
strref
)
def
test_both_assert_merge_identical
(
self
):
# Merge two nodes, both have assert on the same node
# with the same conditions.
x1
=
T
.
matrix
(
'x1'
)
x2
=
T
.
matrix
(
'x2'
)
e
=
T
.
dot
(
T
.
opt
.
assert_op
(
x1
,
(
x1
>
x2
)
.
all
()),
x2
)
+
\
T
.
dot
(
T
.
opt
.
assert_op
(
x1
,
(
x1
>
x2
)
.
all
()),
x2
)
g
=
FunctionGraph
([
x1
,
x2
],
[
e
])
MergeOptimizer
()
.
optimize
(
g
)
strg
=
theano
.
printing
.
debugprint
(
g
,
file
=
'str'
)
strref
=
'''Elemwise{add,no_inplace} [id A] '' 4
|dot [id B] '' 3
| |Assert{msg='Theano Assert failed!'} [id C] '' 2
| | |x1 [id D]
| | |All [id E] '' 1
| | |Elemwise{gt,no_inplace} [id F] '' 0
| | |x1 [id D]
| | |x2 [id G]
| |x2 [id G]
|dot [id B] '' 3
'''
# print(strg)
assert
strg
==
strref
,
(
strg
,
strref
)
def
est_both_assert_merge_1
(
self
):
# Merge two nodes, both have assert on the same node
# with different conditions.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论