'cupy/numpy, replacing cupy.tile with as_strided
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),
)
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 "aha!, 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])
)
Alas! This does not work at all. I'm a doofus! A pleb! A goof! Can someone enlighten me as to 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 use case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
