def _bc_adjust_shape_strides(context, builder, shapes, strides, target_shape):
 bc_shapes = []
 bc_strides = []
 zero = context.get_constant(types.uintp, 0)
 one = context.get_constant(types.uintp, 1)
 mismatch = [builder.icmp_signed('!=', tar, old) for (tar, old) in zip(target_shape, shapes)]
 src_is_one = [builder.icmp_signed('==', old, one) for old in shapes]
 preds = [builder.and_(x, y) for (x, y) in zip(mismatch, src_is_one)]
 bc_shapes = [builder.select(p, tar, old) for (p, tar, old) in zip(preds, target_shape, shapes)]
 bc_strides = [builder.select(p, zero, old) for (p, old) in zip(preds, strides)]
 return (bc_shapes, bc_strides)

def _bc_adjust_shape_strides ( context , builder , shapes , strides , target_shape ) : bc_shapes = [ ] bc_strides = [ ] zero = context . get_constant ( types . uintp , 0 ) one = context . get_constant ( types . uintp , 1 ) mismatch = [ builder . icmp_signed ( '!=' , tar , old ) for ( tar , old ) in zip ( target_shape , shapes ) ] src_is_one = [ builder . icmp_signed ( '==' , old , one ) for old in shapes ] preds = [ builder . and_ ( x , y ) for ( x , y ) in zip ( mismatch , src_is_one ) ] bc_shapes = [ builder . select ( p , tar , old ) for ( p , tar , old ) in zip ( preds , target_shape , shapes ) ] bc_strides = [ builder . select ( p , zero , old ) for ( p , old ) in zip ( preds , strides ) ] return ( bc_shapes , bc_strides )
broadcast shapes and strides to target_shape given that their ndim already matches .