提交 a175ebf2 authored 作者: James Bergstra's avatar James Bergstra

added scalar.identity to local_useless_elemwise

I am not sure why this is necessary now. One guess is that the canonicalizer or something else has been modified to put in identity(), and now it is more obvious that we need an optimization to take it out again. I'm hoping that this improves the slowdown recently observed in convolutional net benchmark.
上级 72a2ad6a
...@@ -764,10 +764,12 @@ def local_subtensor_make_vector(node): ...@@ -764,10 +764,12 @@ def local_subtensor_make_vector(node):
@gof.local_optimizer([T.Elemwise]) @gof.local_optimizer([T.Elemwise])
def local_useless_elemwise(node): def local_useless_elemwise(node):
""" """
eq(x,x) -> 1
neq(x,x) -> 0 eq(x,x) -> 1
mul(x) -> x neq(x,x) -> 0
add(x) -> x mul(x) -> x
add(x) -> x
identity(x) -> x
""" """
if isinstance(node.op, T.Elemwise): if isinstance(node.op, T.Elemwise):
...@@ -783,6 +785,8 @@ add(x) -> x ...@@ -783,6 +785,8 @@ add(x) -> x
return [node.inputs[0]] return [node.inputs[0]]
if node.op.scalar_op == theano.scalar.add and len(node.inputs)==1: if node.op.scalar_op == theano.scalar.add and len(node.inputs)==1:
return [node.inputs[0]] return [node.inputs[0]]
if node.op.scalar_op == theano.scalar.identity and len(node.inputs)==1:
return [node.inputs[0]]
@register_specialize @register_specialize
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论