提交 80d3b56a authored 作者: Frederic Bastien's avatar Frederic Bastien

Don't clone the variable if it isn't in a graph.

上级 abcfa04e
...@@ -876,19 +876,20 @@ class Validator(object): ...@@ -876,19 +876,20 @@ class Validator(object):
if out.owner is None: if out.owner is None:
if isinstance(out, tensor.TensorConstant): if isinstance(out, tensor.TensorConstant):
# This might be a constant from the outer graph or a constant if hasattr(out, 'fgraph'):
# from the inner graph. In all cases, we can clone it to be # If out have an fgraph, we aren't sure if it
# certain we have a valid constant # is from the inner graph or outer graph, so
# clone it.
# TODO: FRED I think the clone is not needed. cloned_out = out.clone()
cloned_out = out.clone() self.valid.add(cloned_out)
self.valid.add(cloned_out) self.invalid.add(out)
self.invalid.add(out) self.valid_equivalent[out] = cloned_out
self.valid_equivalent[out] = cloned_out else:
self.valid.add(out)
continue continue
else: else:
# This is an input node and it has not been explicitly marked # This is an input node and it has not been
# as invalid so we can use it # explicitly marked as invalid so we can use it
self.valid.add(out) self.valid.add(out)
continue continue
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论