提交 05573157 authored 作者: sentient07's avatar sentient07

Applying all possible optimizers to a node

上级 e8bf9c1f
...@@ -1267,19 +1267,28 @@ class LocalOptGroup(LocalOptimizer): ...@@ -1267,19 +1267,28 @@ class LocalOptGroup(LocalOptimizer):
def transform(self, node): def transform(self, node):
repl = False repl = False
counter = 0 counter = 0
for opt in self.opts: def apply_mult_opts(opt_list, node, single_opts=True):
repl = False
assert isinstance(opt_list, tuple)
if len(opt_list) == 0:
return
for opt in opt_list:
repl = opt.transform(node) repl = opt.transform(node)
if repl: if not repl:
counter += 1
if self.apply_all_opts:
assert len(repl) == 1
node = repl[0].owner
continue continue
else:
if single_opts or not repl[0].owner:
return repl return repl
if counter >=2: assert len(repl) == 1
print("No of times the node is optimized : " + str(counter)) # Ensuring not the input of graph
assert repl[0].owner
new_node = repl[0].owner
apply_mult_opts(opt_list, repl[0].owner, False)
return repl return repl
return apply_mult_opts(self.opts, node, self.apply_all_opts)
def print_summary(self, stream=sys.stdout, level=0, depth=-1): def print_summary(self, stream=sys.stdout, level=0, depth=-1):
print("%s%s id=%i" % ( print("%s%s id=%i" % (
(' ' * level), self.__class__.__name__, id(self)), file=stream) (' ' * level), self.__class__.__name__, id(self)), file=stream)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论