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

Is there interest in ggml_reduce or ggml_add_ext? #868

Open
balisujohn opened this issue Jun 22, 2024 · 2 comments
Open

Is there interest in ggml_reduce or ggml_add_ext? #868

balisujohn opened this issue Jun 22, 2024 · 2 comments

Comments

@balisujohn
Copy link
Contributor

So I need to reduce a 4d tensor along a dimension with the operation addition. I can either add ggml_add_ext that lets you specify a dimension for reduction, or I can add a new op ggml_reduce that lets you specify a dimension and an op as an argument (maybe +,/,-,* to start) and reduces along that dimension with that op. Which of these would be preferable?

In the meantime, I can implement this in tortoise.cpp with view slices and and a for loop, but I think a inbuilt reduction op will probably be faster.

@balisujohn
Copy link
Contributor Author

it occurs to me ggml_add isn't a unary op, so I'd lean towards the ggml_reduce idea.

@ggerganov
Copy link
Owner

ggerganov commented Jun 25, 2024

There is already ggml_sum_rows(). A ggml_sum_dim() should be possible to implement via ggml_permute() + ggml_sum_rows() + ggml_reshape() I think, without having to write new kernels

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