Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in ggml_permute #957

Closed
bernerprzemek opened this issue Sep 11, 2024 · 2 comments
Closed

Possible bug in ggml_permute #957

bernerprzemek opened this issue Sep 11, 2024 · 2 comments

Comments

@bernerprzemek
Copy link

I found this issue, when I permutate tensor without changing axis:
struct ggml_tensor * t = ggml_new_tensor_4d(ctx, type, 4, 3, 1, 1); struct ggml_tensor * resultt = ggml_permute(ctx, t, 0, 1, 2, 3);
result is as expected:
nb = {4, 16, 48, 48}
but doing this:
struct ggml_tensor * resultt = ggml_permute(ctx, t, 0, 1, 2, 3);
result is:
nb = {16, 4, 48, 48}
I'm not very familiar with gglm but in that case type of tensor is no longer float because nb[0]!=sizeof(float), and further operations giving assertion error like:
ggml.c:10636: GGML_ASSERT(src0->nb[0] == sizeof(float)) failed

@JohannesGaessler
Copy link
Collaborator

nb is the stride between elements in bytes. ggml_permute changes the ne and nb values in such a way that the order in which data is iterated over is changed without touching the actual data. nb[0] == sizeof(float) means that the tensor is contiguous in memory in its first dimension which is needed for some operations. This has nothing to do with the data type and is only due to non-contiguous input tensors not being supported. You should be able to fix the problem by inserting ggml_cont after ggml_permute.

@bernerprzemek
Copy link
Author

Thanks somehow I missed this part (inserting ggml_cont)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants