提交 52ce429f authored 作者: Frederic Bastien's avatar Frederic Bastien

Make LocalOptGroup able to register tracks of None and simplify the opt related to ViewOp.

上级 77842662
......@@ -1333,8 +1333,11 @@ class LocalOptGroup(LocalOptimizer):
self.process_count.setdefault(o, 0)
self.applied_true.setdefault(o, 0)
self.node_created.setdefault(o, 0)
for c in o.tracks():
tracks = o.tracks()
if tracks is None:
self.track_map[None].append(o)
else:
for c in tracks:
self.track_map[c].append(o)
def __str__(self):
......
......@@ -7487,23 +7487,15 @@ def local_useless_composite(node):
# # Remove consider_constant #
# ############################
# 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.
for o, 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(o, 'fast_compile', 'fast_run', name=name)
register_useless(o, 'fast_compile', 'fast_run', name=name)
@register_canonicalize('fast_compile')
@register_useless('fast_compile')
@gof.local_optimizer(None)
def local_view_op(node):
if isinstance(node.op, theano.compile.ops.ViewOp):
return node.inputs
@register_useless
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论