@register_canonicalize('local_setsubtensor_of_allocs')
@register_stabilize('local_setsubtensor_of_allocs')
@gof.local_optimizer([IncSubtensor])
def local_setsubtensor_of_constants(node):
 if (isinstance(node.op, IncSubtensor) and node.op.set_instead_of_inc):
  x = node.inputs[0]
  y = node.inputs[1]
  try:
   replace_x = get_scalar_constant_value(x, elemwise=False)
  except NotScalarConstantError:
   return
  try:
   replace_y = get_scalar_constant_value(y, elemwise=False)
  except NotScalarConstantError:
   return
  if (replace_x == replace_y):
   return [x]
  else:
   return False

@ register_canonicalize ( 'local_setsubtensor_of_allocs' ) @ register_stabilize ( 'local_setsubtensor_of_allocs' ) @ gof . local_optimizer ( [ IncSubtensor ] ) def local_setsubtensor_of_constants ( node ) : if ( isinstance ( node . op , IncSubtensor ) and node . op . set_instead_of_inc ) : x = node . inputs [ 0 ] y = node . inputs [ 1 ] try : replace_x = get_scalar_constant_value ( x , elemwise = False ) except NotScalarConstantError : return try : replace_y = get_scalar_constant_value ( y , elemwise = False ) except NotScalarConstantError : return if ( replace_x == replace_y ) : return [ x ] else : return False
setsubtensor -> x when x is constant or alloc .