Skip to content

ggml : add ggml_repeat_4d #13824

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

Merged
merged 1 commit into from
May 27, 2025
Merged

ggml : add ggml_repeat_4d #13824

merged 1 commit into from
May 27, 2025

Conversation

ngxson
Copy link
Collaborator

@ngxson ngxson commented May 27, 2025

Add a variant of ggml_repeat which allow arbitrary target shape

@ngxson ngxson requested a review from ggerganov May 27, 2025 12:11
struct ggml_context * ctx,
struct ggml_tensor * a,
int64_t ne0, int64_t ne1, int64_t ne2, int64_t ne3) {
const bool can_repeat = ggml_is_empty(a) || (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of repeating empty tensors?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to match the behavior of ggml_can_repeat, I think it prevents division by 0 (ne%0) in the conditions below.

In practice, I think it can be useful for one particular use case: in llama.cpp, when we do a warmup, IIRC we have 0 output tokens, so the embedding tensor right before output head has ne[1] == 0

@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label May 27, 2025
@ngxson ngxson merged commit a8ea03d into ggml-org:master May 27, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants