Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1e3505b4
提交
1e3505b4
authored
9月 10, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ability to merge apply nodes without inputs
上级
94c6aff4
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
2 行删除
+15
-2
opt.py
theano/gof/opt.py
+15
-2
没有找到文件。
theano/gof/opt.py
浏览文件 @
1e3505b4
...
@@ -484,9 +484,11 @@ class MergeFeature(object):
...
@@ -484,9 +484,11 @@ class MergeFeature(object):
# signature -> variable (for constants)
# signature -> variable (for constants)
self
.
const_sig_inv
=
_metadict
()
self
.
const_sig_inv
=
_metadict
()
# For all
variabl
es
# For all
Apply nod
es
# Set of distinct (not mergeable) nodes
# Set of distinct (not mergeable) nodes
self
.
nodes_seen
=
set
()
self
.
nodes_seen
=
set
()
# Ordered set of distinct (not mergeable) nodes without any input
self
.
noinput_nodes
=
OrderedSet
()
# Each element of scheduled is a list of list of (out, new_out) pairs.
# Each element of scheduled is a list of list of (out, new_out) pairs.
# Each list of pairs represent the substitution needed to replace all
# Each list of pairs represent the substitution needed to replace all
...
@@ -514,6 +516,10 @@ class MergeFeature(object):
...
@@ -514,6 +516,10 @@ class MergeFeature(object):
self
.
nodes_seen
.
discard
(
node
)
self
.
nodes_seen
.
discard
(
node
)
self
.
process_node
(
fgraph
,
node
)
self
.
process_node
(
fgraph
,
node
)
# Since we are in on_change_input, node should have inputs.
if
not
isinstance
(
node
,
string_types
):
assert
node
.
inputs
if
isinstance
(
new_r
,
graph
.
Constant
):
if
isinstance
(
new_r
,
graph
.
Constant
):
self
.
process_constant
(
fgraph
,
new_r
)
self
.
process_constant
(
fgraph
,
new_r
)
...
@@ -526,6 +532,8 @@ class MergeFeature(object):
...
@@ -526,6 +532,8 @@ class MergeFeature(object):
def
on_prune
(
self
,
fgraph
,
node
,
reason
):
def
on_prune
(
self
,
fgraph
,
node
,
reason
):
self
.
nodes_seen
.
discard
(
node
)
self
.
nodes_seen
.
discard
(
node
)
if
not
node
.
inputs
:
self
.
noinput_nodes
.
discard
(
node
)
for
c
in
node
.
inputs
:
for
c
in
node
.
inputs
:
if
isinstance
(
c
,
graph
.
Constant
)
and
(
len
(
c
.
clients
)
<=
1
):
if
isinstance
(
c
,
graph
.
Constant
)
and
(
len
(
c
.
clients
)
<=
1
):
# This was the last node using this constant
# This was the last node using this constant
...
@@ -592,7 +600,10 @@ class MergeFeature(object):
...
@@ -592,7 +600,10 @@ class MergeFeature(object):
merge_candidates
.
extend
(
assert_clients
)
merge_candidates
.
extend
(
assert_clients
)
else
:
else
:
merge_candidates
=
[]
# If two nodes have no input, but perform the same operation,
# they are not always constant-folded, so we want to merge them.
# In that case, the candidates are all the nodes without inputs.
merge_candidates
=
self
.
noinput_nodes
replacement_candidates
=
[]
replacement_candidates
=
[]
for
candidate
in
merge_candidates
:
for
candidate
in
merge_candidates
:
...
@@ -672,6 +683,8 @@ class MergeFeature(object):
...
@@ -672,6 +683,8 @@ class MergeFeature(object):
self
.
scheduled
.
append
(
replacement_candidates
)
self
.
scheduled
.
append
(
replacement_candidates
)
else
:
else
:
self
.
nodes_seen
.
add
(
node
)
self
.
nodes_seen
.
add
(
node
)
if
not
node
.
inputs
:
self
.
noinput_nodes
.
add
(
node
)
def
get_merged_assert_input
(
self
,
node
,
candidate
):
def
get_merged_assert_input
(
self
,
node
,
candidate
):
new_inputs
=
[]
new_inputs
=
[]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论