提交 e5a29ece authored 作者: Ian Goodfellow's avatar Ian Goodfellow

doc io_toposort

上级 b40fe366
...@@ -752,13 +752,26 @@ def general_toposort(r_out, deps, debug_print=False): ...@@ -752,13 +752,26 @@ def general_toposort(r_out, deps, debug_print=False):
return rlist return rlist
def io_toposort(i, o, orderings=None): def io_toposort(inputs, outputs, orderings=None):
"""WRITEME """WRITEME
inputs: a list or tuple of Variable instances
outputs: a list or tuple of Variable instances
orderings: a dictionary
key: Apply instance
value: list of Apply instance
it is important that the value be
a container with a deterministic iteration
order. no sets allowed!
""" """
if orderings is None: if orderings is None:
orderings = {} orderings = {}
#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
iset = set(i) iset = set(inputs)
def deps(obj): def deps(obj):
rval = [] rval = []
...@@ -773,7 +786,7 @@ def io_toposort(i, o, orderings=None): ...@@ -773,7 +786,7 @@ def io_toposort(i, o, orderings=None):
assert not orderings.get(obj, []) assert not orderings.get(obj, [])
return rval return rval
topo = general_toposort(o, deps) topo = general_toposort(outputs, deps)
return [o for o in topo if isinstance(o, Apply)] return [o for o in topo if isinstance(o, Apply)]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论