@register_canonicalize
@gof.local_optimizer([AdvancedIncSubtensor1])
def local_set_to_inc_subtensor(node):
 if (isinstance(node.op, AdvancedIncSubtensor1) and node.op.set_instead_of_inc and node.inputs[1].owner and isinstance(node.inputs[1].owner.op, Elemwise) and isinstance(node.inputs[1].owner.op.scalar_op, scalar.Add)):
  addn = node.inputs[1].owner
  subn = None
  other = None
  if (addn.inputs[0].owner and isinstance(addn.inputs[0].owner.op, AdvancedSubtensor1)):
   subn = addn.inputs[0].owner
   other = addn.inputs[1]
  elif (addn.inputs[1].owner and isinstance(addn.inputs[1].owner.op, AdvancedSubtensor1)):
   subn = addn.inputs[1].owner
   other = addn.inputs[0]
  else:
   return
  if ((subn.inputs[1] != node.inputs[2]) or (subn.inputs[0] != node.inputs[0])):
   return
  ret = advanced_inc_subtensor1(node.inputs[0], other, node.inputs[2])
  copy_stack_trace(node.outputs, ret)
  return [ret]

@ register_canonicalize @ gof . local_optimizer ( [ AdvancedIncSubtensor1 ] ) def local_set_to_inc_subtensor ( node ) : if ( isinstance ( node . op , AdvancedIncSubtensor1 ) and node . op . set_instead_of_inc and node . inputs [ 1 ] . owner and isinstance ( node . inputs [ 1 ] . owner . op , Elemwise ) and isinstance ( node . inputs [ 1 ] . owner . op . scalar_op , scalar . Add ) ) : addn = node . inputs [ 1 ] . owner subn = None other = None if ( addn . inputs [ 0 ] . owner and isinstance ( addn . inputs [ 0 ] . owner . op , AdvancedSubtensor1 ) ) : subn = addn . inputs [ 0 ] . owner other = addn . inputs [ 1 ] elif ( addn . inputs [ 1 ] . owner and isinstance ( addn . inputs [ 1 ] . owner . op , AdvancedSubtensor1 ) ) : subn = addn . inputs [ 1 ] . owner other = addn . inputs [ 0 ] else : return if ( ( subn . inputs [ 1 ] != node . inputs [ 2 ] ) or ( subn . inputs [ 0 ] != node . inputs [ 0 ] ) ) : return ret = advanced_inc_subtensor1 ( node . inputs [ 0 ] , other , node . inputs [ 2 ] ) copy_stack_trace ( node . outputs , ret ) return [ ret ]
advancedincsubtensor1 -> advancedincsubtensor1 .