提交 74d2d21a authored 作者: Ramana.S's avatar Ramana.S

Raises error when removed nodes are added back

上级 bc6770cc
...@@ -481,14 +481,13 @@ class FunctionGraph(utils.object2): ...@@ -481,14 +481,13 @@ class FunctionGraph(utils.object2):
for node in new_nodes: for node in new_nodes:
assert node not in self.apply_nodes assert node not in self.apply_nodes
prevent_addition = False prevent_addition = node in self._removed_nodes
for n in self._removed_nodes :
if node is n :
prevent_addition = True
if not prevent_addition : if prevent_addition :
self.__setup_node__(node) raise InconsistencyError
self.apply_nodes.add(node) ("Trying to reintroduce an old nodes in the graph. This should not happen")
self.__setup_node__(node)
self.apply_nodes.add(node)
for output in node.outputs: for output in node.outputs:
self.__setup_r__(output) self.__setup_r__(output)
self.variables.add(output) self.variables.add(output)
...@@ -497,9 +496,8 @@ class FunctionGraph(utils.object2): ...@@ -497,9 +496,8 @@ class FunctionGraph(utils.object2):
self.__setup_r__(input) self.__setup_r__(input)
self.variables.add(input) self.variables.add(input)
self.__add_clients__(input, [(node, i)]) self.__add_clients__(input, [(node, i)])
if not prevent_addition : assert node.fgraph is self
assert node.fgraph is self self.execute_callbacks('on_import', node, reason)
self.execute_callbacks('on_import', node, reason)
# change input # # change input #
def change_input(self, node, i, new_r, reason=None): def change_input(self, node, i, new_r, reason=None):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论