提交 dc91b8f5 authored 作者: Frederic's avatar Frederic

Code simplication

上级 801dcefb
......@@ -2983,23 +2983,19 @@ class Canonizer(gof.LocalOptimizer):
if op not in [self.main, self.inverse, self.reciprocal]:
return False
out = node.outputs[0]
assert len(node.outputs) == 1
out = node.outputs[0]
# check if any of the clients of this node would be part of
# this canonized graph... if so, we do nothing and wait for
# them to be transformed.
def _bypass_dimshuffle(n):
if (isinstance(getattr(n, 'op', None), DimShuffle) and
len(n.outputs[0].clients) <= 1):
return _bypass_dimshuffle(n.outputs[0].clients[0][0])
else:
return n
for c, c_idx in out.clients:
if c == 'output':
continue
if getattr(_bypass_dimshuffle(c), 'op', '') in [
self.main, self.inverse, self.reciprocal]:
while (isinstance(c.op, DimShuffle) and
len(c.outputs[0].clients) <= 1):
c = c.outputs[0].clients[0][0]
if c.op in [self.main, self.inverse, self.reciprocal]:
return False
# Here we make the canonical version of the graph around this node
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论