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

remove useless fill op in FAST_COMPILE mode to make the graph more readable.

上级 39dc64fe
...@@ -1078,6 +1078,25 @@ def local_fill_to_alloc(node): ...@@ -1078,6 +1078,25 @@ def local_fill_to_alloc(node):
return rval return rval
@gof.local_optimizer([T.fill])
def local_useless_fill(node):
"""fill(s,v) -> v
This optimization is only needed in FAST_COMPILE to make the code
more readable. Normally, it is done by the local_fill_to_alloc
opt.
"""
if node.op == T.fill:
r, v = node.inputs
if v.type == node.outputs[0].type:
# this is a useless fill, erase it.
return [v]
compile.optdb['canonicalize'].register('local_useless_fill',
in2out(local_useless_fill),
1.1, 'fast_compile')
@register_specialize @register_specialize
@register_stabilize @register_stabilize
@register_canonicalize @register_canonicalize
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论