提交 2e2081fc authored 作者: Ian Goodfellow's avatar Ian Goodfellow

inlined _build_doort_impact

上级 95b0c9a0
...@@ -727,37 +727,31 @@ class DestroyHandler(toolbox.Bookkeeper): ...@@ -727,37 +727,31 @@ class DestroyHandler(toolbox.Bookkeeper):
(see docstrings for these properties above) (see docstrings for these properties above)
""" """
if self.stale_droot: if self.stale_droot:
self.droot, self.impact, self.root_destroyer = self._build_droot_impact() droot = {} # destroyed view + nonview variables -> foundation
self.stale_droot = False impact = {} # destroyed nonview variable -> it + all views of it
return self.droot, self.impact, self.root_destroyer root_destroyer = {} # root -> destroyer apply
def _build_droot_impact(self): for app in self.destroyers:
droot = {} # destroyed view + nonview variables -> foundation for output_idx, input_idx_list in app.op.destroy_map.items():
impact = {} # destroyed nonview variable -> it + all views of it if len(input_idx_list) != 1:
root_destroyer = {} # root -> destroyer apply raise NotImplementedError()
input_idx = input_idx_list[0]
input = app.inputs[input_idx]
input_root = getroot(input, self.view_i)
if input_root in droot:
raise InconsistencyError("Multiple destroyers of %s" % input_root)
droot[input_root] = input_root
root_destroyer[input_root] = app
input_impact = get_impact(input_root, self.view_o)
for v in input_impact:
assert v not in droot
droot[v] = input_root
for app in self.destroyers: impact[input_root] = input_impact
for output_idx, input_idx_list in app.op.destroy_map.items(): impact[input_root].add(input_root)
if len(input_idx_list) != 1: self.droot, self.impact, self.root_destroyer = droot, impact, root_destroyer
raise NotImplementedError() self.stale_droot = False
input_idx = input_idx_list[0] return self.droot, self.impact, self.root_destroyer
input = app.inputs[input_idx]
input_root = getroot(input, self.view_i)
if input_root in droot:
raise InconsistencyError("Multiple destroyers of %s" % input_root)
droot[input_root] = input_root
root_destroyer[input_root] = app
#input_impact = set([input_root])
#add_impact(input_root, self.view_o, input_impact)
input_impact = get_impact(input_root, self.view_o)
for v in input_impact:
assert v not in droot
droot[v] = input_root
impact[input_root] = input_impact
impact[input_root].add(input_root)
return droot, impact, root_destroyer
def on_detach(self, fgraph): def on_detach(self, fgraph):
if fgraph is not self.fgraph: if fgraph is not self.fgraph:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论