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