How to slice a ggml tensor ? #10442
Answered
by
marty1885
Jianhua-Cui
asked this question in
Q&A
-
For example, I have a torch code like this: # x is a torch.Tensor with shape [1, 1025, 1024]
x = x[:, 1:, :] I want do the same operation in ggml: embeddings = ggml_norm(ctx0, embeddings, eps);
// hot to slice embeddings in it's second dim Could you please guide me on how to perform this slicing operation in GGML? Any advice would be appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
marty1885
Nov 21, 2024
Replies: 1 comment 5 replies
-
What you are looking for is x = ggml_view_3d(ctx. x, x->ne[0], x->ne[1] - 1, x->ne[3], x->nb[1], x->nb[2], x->nb[1]); |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
Jianhua-Cui
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What you are looking for is
ggml_view_*
. For the specific examplex = x[:, 1:, :]
should equivalent to the following (note that GGML stores the shape (ne
) and strides (nb
) in reverse order.