提交 463c13e7 authored 作者: Frederic's avatar Frederic

move costly check later

上级 9c6930f5
...@@ -411,10 +411,6 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None): ...@@ -411,10 +411,6 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None):
if _x.type != _y.type: if _x.type != _y.type:
return False return False
nds_x = gof.graph.io_toposort(in_xs, xs)
nds_y = gof.graph.io_toposort(in_ys, ys)
if len(nds_x) != len(nds_y):
return False
common = set(zip(in_xs, in_ys)) common = set(zip(in_xs, in_ys))
for dx, dy in izip(xs, ys): for dx, dy in izip(xs, ys):
# We checked above that both dx and dy have an owner or not # We checked above that both dx and dy have an owner or not
...@@ -428,6 +424,11 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None): ...@@ -428,6 +424,11 @@ def equal_computations(xs, ys, in_xs=None, in_ys=None):
elif (dx, dy) not in common and dx != dy: elif (dx, dy) not in common and dx != dy:
return False return False
nds_x = gof.graph.io_toposort(in_xs, xs)
nds_y = gof.graph.io_toposort(in_ys, ys)
if len(nds_x) != len(nds_y):
return False
n_nodes = len(nds_x) n_nodes = len(nds_x)
idx = 0 idx = 0
while idx < n_nodes: while idx < n_nodes:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论