提交 2dc64c84 authored 作者: Frederic Bastien's avatar Frederic Bastien

Register in useless opt the opt that remove node from the graph.

上级 a0a112b4
...@@ -7490,29 +7490,20 @@ def local_useless_composite(node): ...@@ -7490,29 +7490,20 @@ def local_useless_composite(node):
# Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad # Although the ops ConsiderConstant, ZeroGrad and DisconnectedGrad
# just returns the input, it should be removed from the graph to # just returns the input, it should be removed from the graph to
# make sure all possible optimizations can be applied. # make sure all possible optimizations can be applied.
# TODO: Add in useless too! for opt, name in [(gof.OpRemove(theano.gradient.consider_constant_),
register_canonicalize(gof.OpRemove(theano.gradient.consider_constant_), "remove_consider_constant"),
'fast_compile', 'fast_run', (gof.OpRemove(theano.gradient.zero_grad_),
name='remove_consider_constant') 'remove_zero_grad'),
(gof.OpRemove(theano.gradient.disconnected_grad_),
register_canonicalize(gof.OpRemove(theano.gradient.zero_grad_), 'remove_disconnected_grad'),
'fast_compile', 'fast_run', name='remove_zero_grad') (gof.OpRemove(theano.gradient.undefined_grad_),
'remove_undefined_grad'),
register_canonicalize(gof.OpRemove(theano.gradient.disconnected_grad_), (gof.OpRemove(theano.gradient.GradClip),
'fast_compile', 'fast_run', 'remove_grad_clip'),
name='remove_disconnected_grad') (gof.OpRemove(theano.gradient.GradScale),
'remove_grad_scale')]:
register_canonicalize(gof.OpRemove(theano.gradient.undefined_grad_), register_canonicalize(opt, 'fast_compile', 'fast_run', name=name)
'fast_compile', 'fast_run', register_useless(opt, 'fast_compile', 'fast_run', name=name)
name='remove_undefined_grad')
register_canonicalize(gof.OpRemove(theano.gradient.GradClip),
'fast_compile', 'fast_run',
name='remove_grad_clip')
register_canonicalize(gof.OpRemove(theano.gradient.GradScale),
'fast_compile', 'fast_run',
name='remove_grad_scale')
@register_useless @register_useless
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论