@register_canonicalize('fast_compile', 'local_cut_useless_reduce')
@register_useless('local_cut_useless_reduce')
@gof.local_optimizer(ALL_REDUCE)
def local_useless_reduce(node):
 if isinstance(node.op, T.CAReduce):
  (summed,) = node.inputs
  if (summed.type == node.outputs[0].type):
   return [summed]

@ register_canonicalize ( 'fast_compile' , 'local_cut_useless_reduce' ) @ register_useless ( 'local_cut_useless_reduce' ) @ gof . local_optimizer ( ALL_REDUCE ) def local_useless_reduce ( node ) : if isinstance ( node . op , T . CAReduce ) : ( summed , ) = node . inputs if ( summed . type == node . outputs [ 0 ] . type ) : return [ summed ]
sum -> a .