cupy/numpy, replacing cupy.tile with as_strided

133 Views Asked by At

I didn't think this would be as irritating as it has proven to be. I have the following tile call:

vertices = cp.tile(
    vertices, 
    (1, 1, chunk_size, 1), 
)

I found that, when I printed out the the strides with chunk_size=5, I found that before tiling it is:

vertices.strides=(72, 24, 24, 8)

and after tiling it is:

vertices.strides=(360, 120, 24, 8)

So, I thought "I just multiply the first two strides by chunk_size":

s = vertices.strides
vertices = cupy.lib.stride_tricks.as_strided(
    vertices,
    shape=(
        vertices.shape[0],
        vertices.shape[1],
        vertices.shape[2] * chunk_size,
        vertices.shape[3]
    ),
    strides=(chunk_size*s[0], chunk_size*s[1], s[2], s[3])
)

This does not work at all. Can someone enlighten me about how I should actually go about this?

I found some other posts, but I couldn't decipher how to transfer what they were saying to my case.

0

There are 0 best solutions below