def _bc_adjust_dimension(context, builder, shapes, strides, target_shape):
 zero = context.get_constant(types.uintp, 0)
 one = context.get_constant(types.uintp, 1)
 if (len(target_shape) > len(shapes)):
  nd_diff = (len(target_shape) - len(shapes))
  shapes = (([one] * nd_diff) + shapes)
  strides = (([zero] * nd_diff) + strides)
 elif (len(target_shape) < len(shapes)):
  nd_diff = (len(shapes) - len(target_shape))
  dim_is_one = [builder.icmp_unsigned('==', sh, one) for sh in shapes[:nd_diff]]
  accepted = functools.reduce(builder.and_, dim_is_one, cgutils.true_bit)
  with builder.if_then(builder.not_(accepted), likely=False):
   msg = 'cannot broadcast source array for assignment'
   context.call_conv.return_user_exc(builder, ValueError, (msg,))
  shapes = shapes[nd_diff:]
  strides = strides[nd_diff:]
 return (shapes, strides)

def _bc_adjust_dimension ( context , builder , shapes , strides , target_shape ) : zero = context . get_constant ( types . uintp , 0 ) one = context . get_constant ( types . uintp , 1 ) if ( len ( target_shape ) > len ( shapes ) ) : nd_diff = ( len ( target_shape ) - len ( shapes ) ) shapes = ( ( [ one ] * nd_diff ) + shapes ) strides = ( ( [ zero ] * nd_diff ) + strides ) elif ( len ( target_shape ) < len ( shapes ) ) : nd_diff = ( len ( shapes ) - len ( target_shape ) ) dim_is_one = [ builder . icmp_unsigned ( '==' , sh , one ) for sh in shapes [ : nd_diff ] ] accepted = functools . reduce ( builder . and_ , dim_is_one , cgutils . true_bit ) with builder . if_then ( builder . not_ ( accepted ) , likely = False ) : msg = 'cannot broadcast source array for assignment' context . call_conv . return_user_exc ( builder , ValueError , ( msg , ) ) shapes = shapes [ nd_diff : ] strides = strides [ nd_diff : ] return ( shapes , strides )
preprocess dimension for broadcasting .