@register_specialize
@gof.local_optimizer([T.mul])
def local_mul_to_sqr(node):
 if (node.op == T.mul):
  if (len(node.inputs) == 2):
   if (node.inputs[0] is node.inputs[1]):
    return [T.sqr(node.inputs[0])]

@ register_specialize @ gof . local_optimizer ( [ T . mul ] ) def local_mul_to_sqr ( node ) : if ( node . op == T . mul ) : if ( len ( node . inputs ) == 2 ) : if ( node . inputs [ 0 ] is node . inputs [ 1 ] ) : return [ T . sqr ( node . inputs [ 0 ] ) ]
x*x -> sqr(x) this is faster on the gpu when memory fetching is a big part of the computation time .