@register_canonicalize
@gof.local_optimizer([Elemwise])
def local_useless_composite(node):
 if ((not isinstance(node.op, Elemwise)) or (not isinstance(node.op.scalar_op, scalar.Composite))):
  return
 comp = node.op.scalar_op
 idx = [i for (i, o_extern) in enumerate(node.outputs) if o_extern.clients]
 if (len(idx) < len(node.outputs)):
  new_outputs = [comp.outputs[i] for i in idx]
  c = scalar.Composite(inputs=comp.inputs, outputs=new_outputs)
  e = Elemwise(scalar_op=c)(return_list=True, *node.inputs)
  return dict(zip([node.outputs[i] for i in idx], e))

@ register_canonicalize @ gof . local_optimizer ( [ Elemwise ] ) def local_useless_composite ( node ) : if ( ( not isinstance ( node . op , Elemwise ) ) or ( not isinstance ( node . op . scalar_op , scalar . Composite ) ) ) : return comp = node . op . scalar_op idx = [ i for ( i , o_extern ) in enumerate ( node . outputs ) if o_extern . clients ] if ( len ( idx ) < len ( node . outputs ) ) : new_outputs = [ comp . outputs [ i ] for i in idx ] c = scalar . Composite ( inputs = comp . inputs , outputs = new_outputs ) e = Elemwise ( scalar_op = c ) ( return_list = True , * node . inputs ) return dict ( zip ( [ node . outputs [ i ] for i in idx ] , e ) )
for elemwise composite that have multiple outputs .