提交 edeb4be8 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

If named variables are replaced by unnamed ones, keep the name.

上级 13014460
...@@ -149,6 +149,9 @@ def std_env(input_specs, output_specs, accept_inplace = False): ...@@ -149,6 +149,9 @@ def std_env(input_specs, output_specs, accept_inplace = False):
# We need to protect all immutable inputs from inplace operations. # We need to protect all immutable inputs from inplace operations.
env.extend(Supervisor(input for spec, input in zip(input_specs, inputs) if not (spec.mutable or (hasattr(env, 'destroyers') and env.destroyers(input))))) env.extend(Supervisor(input for spec, input in zip(input_specs, inputs) if not (spec.mutable or (hasattr(env, 'destroyers') and env.destroyers(input)))))
# If named nodes are replaced, keep the name
env.extend(gof.toolbox.PreserveNames())
return env, map(SymbolicOutput, updates) return env, map(SymbolicOutput, updates)
class AliasedMemoryError(Exception): class AliasedMemoryError(Exception):
......
...@@ -194,4 +194,7 @@ class PrintListener(object): ...@@ -194,4 +194,7 @@ class PrintListener(object):
print "-- changing (%s.inputs[%s]) from %s to %s" % (node, i, r, new_r) print "-- changing (%s.inputs[%s]) from %s to %s" % (node, i, r, new_r)
class PreserveNames:
def on_change_input(self, env, mode, i, r, new_r):
if r.name is not None and new_r.name is None:
new_r.name = r.name
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论