0

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.

Ali_Sh
  • 2,667
  • 3
  • 43
  • 66
Mackie Messer
  • 1,126
  • 2
  • 8
  • 22
  • tiling increases the size of the data buffer. as_strided uses the original. – hpaulj Apr 30 '21 at 14:12
  • Got it. So I should use the original strides? – Mackie Messer Apr 30 '21 at 15:29
  • I don't think it can be done, at least not directly. `as_strided` usually is used to add a dimension (or more). You could try adding a `chunksize` dimension between 1 and 2, with strides of 0. But you'll be limited in what can do with the 5d array - many actions will blow it up to the full tiled size. – hpaulj Apr 30 '21 at 16:56
  • Aw bummer. It doesn't seem like a complicated problem to create a repeated view into an array, but i guess there's more to it than I can appreciate. By the way, the `vertices_shape[2]` is 1, and I am just adding a `chunk_size` dimension. Right before this i expanded dimensions, but it sounds like i shouldn't have? – Mackie Messer May 01 '21 at 00:10
  • That would account for the repeated 24 in rhe strides. With a size 1, that dimension can be broadcast. Look at `broadcast_to`. – hpaulj May 01 '21 at 00:39

0 Answers0