提交 1897f31d authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Detect potential cycles in shape optimization

上级 533f97d2
...@@ -1105,6 +1105,12 @@ class ShapeFeature(object): ...@@ -1105,6 +1105,12 @@ class ShapeFeature(object):
# replacement. # replacement.
continue continue
if shpnode.outputs[0] in theano.gof.graph.ancestors([repl]):
raise AssertionError(
"This substitution would insert a cycle in the graph:"
"node: %s, i: %i, r: %s, new_r: %s"
% (node, i, r, new_r))
self.scheduled[shpnode] = new_r self.scheduled[shpnode] = new_r
# In case 2, if r is a variable that we've scheduled for shape update, # In case 2, if r is a variable that we've scheduled for shape update,
# then we should cancel it. # then we should cancel it.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论