Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f5c7aa57
提交
f5c7aa57
authored
2月 25, 2016
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow callers of io_toposort to get a dictionary of clients as a side effect.
上级
0aa5ff77
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
6 行删除
+15
-6
graph.py
theano/gof/graph.py
+15
-6
没有找到文件。
theano/gof/graph.py
浏览文件 @
f5c7aa57
...
@@ -873,7 +873,8 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None):
...
@@ -873,7 +873,8 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None):
def
general_toposort
(
r_out
,
deps
,
debug_print
=
False
,
def
general_toposort
(
r_out
,
deps
,
debug_print
=
False
,
compute_deps_cache
=
None
,
deps_cache
=
None
):
compute_deps_cache
=
None
,
deps_cache
=
None
,
clients
=
None
):
"""
"""
WRITEME
WRITEME
...
@@ -886,6 +887,9 @@ def general_toposort(r_out, deps, debug_print=False,
...
@@ -886,6 +887,9 @@ def general_toposort(r_out, deps, debug_print=False,
deps, but that also cache its results in a dict passed as deps_cache.
deps, but that also cache its results in a dict passed as deps_cache.
deps_cache : dict
deps_cache : dict
Must be used with compute_deps_cache.
Must be used with compute_deps_cache.
clients : dict
If a dict is passed it will be filled with a mapping of node
-> clients for each node in the subgraph.
Notes
Notes
-----
-----
...
@@ -924,8 +928,10 @@ def general_toposort(r_out, deps, debug_print=False,
...
@@ -924,8 +928,10 @@ def general_toposort(r_out, deps, debug_print=False,
assert
isinstance
(
r_out
,
(
tuple
,
list
,
deque
))
assert
isinstance
(
r_out
,
(
tuple
,
list
,
deque
))
reachable
,
clients
=
stack_search
(
deque
(
r_out
),
compute_deps_cache
,
reachable
,
_
clients
=
stack_search
(
deque
(
r_out
),
compute_deps_cache
,
'dfs'
,
True
)
'dfs'
,
True
)
if
clients
is
not
None
:
clients
.
update
(
_clients
)
sources
=
deque
([
r
for
r
in
reachable
if
not
deps_cache
.
get
(
r
,
None
)])
sources
=
deque
([
r
for
r
in
reachable
if
not
deps_cache
.
get
(
r
,
None
)])
rset
=
set
()
rset
=
set
()
...
@@ -935,7 +941,7 @@ def general_toposort(r_out, deps, debug_print=False,
...
@@ -935,7 +941,7 @@ def general_toposort(r_out, deps, debug_print=False,
if
node
not
in
rset
:
if
node
not
in
rset
:
rlist
.
append
(
node
)
rlist
.
append
(
node
)
rset
.
add
(
node
)
rset
.
add
(
node
)
for
client
in
clients
.
get
(
node
,
[]):
for
client
in
_
clients
.
get
(
node
,
[]):
deps_cache
[
client
]
=
[
a
for
a
in
deps_cache
[
client
]
deps_cache
[
client
]
=
[
a
for
a
in
deps_cache
[
client
]
if
a
is
not
node
]
if
a
is
not
node
]
if
not
deps_cache
[
client
]:
if
not
deps_cache
[
client
]:
...
@@ -951,7 +957,7 @@ def general_toposort(r_out, deps, debug_print=False,
...
@@ -951,7 +957,7 @@ def general_toposort(r_out, deps, debug_print=False,
return
rlist
return
rlist
def
io_toposort
(
inputs
,
outputs
,
orderings
=
None
):
def
io_toposort
(
inputs
,
outputs
,
orderings
=
None
,
clients
=
None
):
"""
"""
WRITEME
WRITEME
...
@@ -959,10 +965,13 @@ def io_toposort(inputs, outputs, orderings=None):
...
@@ -959,10 +965,13 @@ def io_toposort(inputs, outputs, orderings=None):
----------
----------
inputs : list or tuple of Variable instances
inputs : list or tuple of Variable instances
outputs : list or tuple of Apply instances
outputs : list or tuple of Apply instances
orderings: dict
orderings
: dict
Key: Apply instance. Value: list of Apply instance.
Key: Apply instance. Value: list of Apply instance.
It is important that the value be a container with a deterministic
It is important that the value be a container with a deterministic
iteration order. No sets allowed!
iteration order. No sets allowed!
clients : dict
If a dict is provided it will be filled with mappings of
node->clients for each node in the subgraph that is sorted
"""
"""
# the inputs are used only here in the function that decides what 'predecessors' to explore
# the inputs are used only here in the function that decides what 'predecessors' to explore
...
@@ -1013,7 +1022,7 @@ def io_toposort(inputs, outputs, orderings=None):
...
@@ -1013,7 +1022,7 @@ def io_toposort(inputs, outputs, orderings=None):
topo
=
general_toposort
(
outputs
,
deps
=
compute_deps
,
topo
=
general_toposort
(
outputs
,
deps
=
compute_deps
,
compute_deps_cache
=
compute_deps_cache
,
compute_deps_cache
=
compute_deps_cache
,
deps_cache
=
deps_cache
)
deps_cache
=
deps_cache
,
clients
=
clients
)
return
[
o
for
o
in
topo
if
isinstance
(
o
,
Apply
)]
return
[
o
for
o
in
topo
if
isinstance
(
o
,
Apply
)]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论