Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
069d112f
提交
069d112f
authored
9月 06, 2011
作者:
Razvan Pascanu
提交者:
David Warde-Farley
11月 16, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge together 'ifelse' ops that have the same condition
上级
6747ddf7
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
50 行增加
和
0 行删除
+50
-0
lazycond.py
theano/lazycond.py
+50
-0
没有找到文件。
theano/lazycond.py
浏览文件 @
069d112f
...
...
@@ -371,3 +371,53 @@ def cond_merge_ifs_false(node):
old_ins
[
pos
]
=
var
return
op
.
make_node
(
*
old_ins
)
.
outputs
class
CondMerge
(
gof
.
Optimizer
):
""" Graph Optimizer that merges different cond ops """
def
add_requirements
(
self
,
env
):
env
.
extend
(
gof
.
toolbox
.
ReplaceValidate
())
def
apply
(
self
,
env
):
nodelist
=
list
(
env
.
toposort
())
cond_nodes
=
filter
(
lambda
s
:
isinstance
(
s
.
op
,
IfElse
),
nodelist
)
if
len
(
cond_nodes
)
<
2
:
return
False
merging_node
=
cond_nodes
[
0
]
for
proposal
in
cond_nodes
[
1
:]:
if
(
proposal
.
inputs
[
0
]
==
merging_node
.
inputs
[
0
]
and
not
find_up
(
proposal
,
merging_node
)):
# Create a list of replacements for proposal
mn_ts
=
merging_node
.
inputs
[
1
:][:
merging_node
.
op
.
n_outs
]
mn_fs
=
merging_node
.
inputs
[
1
:][
merging_node
.
op
.
n_outs
:]
pl_ts
=
proposal
.
inputs
[
1
:][:
proposal
.
op
.
n_outs
]
pl_fs
=
proposal
.
inputs
[
1
:][
proposal
.
op
.
n_outs
:]
new_ins
=
([
merging_node
.
inputs
[
0
]]
+
mn_ts
+
pl_ts
+
mn_fs
+
pl_fs
)
mn_name
=
'?'
if
merging_node
.
op
.
name
:
mn_name
=
merging_node
.
op
.
name
pl_name
=
'?'
mn_n_ts
=
len
(
mn_ts
)
mn_n_fs
=
len
(
mn_fs
)
if
proposal
.
op
.
name
:
pl_name
=
proposal
.
op
.
name
new_ifelse
=
IfElse
(
n_outs
=
len
(
mn_ts
+
pl_ts
),
as_view
=
False
,
gpu
=
False
,
name
=
mn_name
+
'&'
+
pl_name
)
print
'here'
new_outs
=
new_ifelse
.
make_node
(
*
new_ins
)
.
outputs
new_outs
=
[
clone
(
x
)
for
x
in
new_outs
]
old_outs
=
[]
if
type
(
merging_node
.
outputs
)
not
in
(
list
,
tuple
):
old_outs
+=
[
merging_node
.
outputs
]
else
:
old_outs
+=
merging_node
.
outputs
if
type
(
proposal
.
outputs
)
not
in
(
list
,
tuple
):
old_outs
+=
[
proposal
.
outputs
]
else
:
old_outs
+=
proposal
.
outputs
pairs
=
zip
(
old_outs
,
new_outs
)
env
.
replace_all_validate
(
pairs
,
reason
=
'cond_merge'
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论