提交 a53d8ec3 authored 作者: rizar's avatar rizar

Always copy orphans

上级 e2ee93fc
...@@ -822,7 +822,7 @@ def clone(i, o, copy_inputs=True): ...@@ -822,7 +822,7 @@ def clone(i, o, copy_inputs=True):
return [equiv[input] for input in i], [equiv[output] for output in o] return [equiv[input] for input in i], [equiv[output] for output in o]
def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None): def clone_get_equiv(inputs, outputs, copy_inputs=True, copy_orphans=True, memo=None):
""" """
Return a dictionary that maps from Variable and Apply nodes in the Return a dictionary that maps from Variable and Apply nodes in the
original graph to a new node (a clone) in a new graph. original graph to a new node (a clone) in a new graph.
...@@ -850,7 +850,7 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None): ...@@ -850,7 +850,7 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None):
# clone the inputs if necessary # clone the inputs if necessary
for input in inputs: for input in inputs:
if copy_inputs_and_orphans: if copy_inputs:
cpy = input.clone() cpy = input.clone()
cpy.owner = None cpy.owner = None
cpy.index = None cpy.index = None
...@@ -862,7 +862,7 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None): ...@@ -862,7 +862,7 @@ def clone_get_equiv(inputs, outputs, copy_inputs_and_orphans=True, memo=None):
for apply in io_toposort(inputs, outputs): for apply in io_toposort(inputs, outputs):
for input in apply.inputs: for input in apply.inputs:
if input not in memo: if input not in memo:
if copy_inputs_and_orphans: if copy_orphans:
cpy = input.clone() cpy = input.clone()
memo[input] = cpy memo[input] = cpy
else: else:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论