-
Hi, I am seekign help with implementing a chunk op using ggml_view_*d. In particular, say I have a 3D tensor a with dim [10,3,3,1]. I'd like to split a into 2 equal chunks along dim 0 such that the two chunks each has dim [5,3,3,1]. Presumbaly this can be done using ggml_view_3d op but I couldn't make it work. Thanks in adavance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
For the lower chunk you only need to change the dimensions of the tensor. For the higher chunk, additionally you also have to skip the first 5 elements, which can be done with an offset. Eg.: tlo = ggml_view_4d(5, 3, 3, 1, t->nb[1], t->nb[2], t->nb[3], 0);
thi = ggml_view_4d(5, 3, 3, 1, t->nb[1], t->nb[2], t->nb[3], t->nb[0]*5); |
Beta Was this translation helpful? Give feedback.
-
On a second thought and after a bug was found, I realize that the stride parameters (nb[i]) should also be changed for two result tensors since the number of elements are changed. Using the original tensors strides is wrong, especially if later the strides are used for computing array indices. This is not the way how ggml_view is typically used. |
Beta Was this translation helpful? Give feedback.
For the lower chunk you only need to change the dimensions of the tensor. For the higher chunk, additionally you also have to skip the first 5 elements, which can be done with an offset. Eg.: