def tile_array(a, b1, b2): r, c = a.shape rs, cs = a.strides x = as_strided(a, (r, b1, c, b2), (rs, 0, cs, 0)) return x.reshape(r*b1, c*b2)