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

ggml: add map_ternary_f32() #1482

Closed
wants to merge 1 commit into from
Closed

ggml: add map_ternary_f32() #1482

wants to merge 1 commit into from

Conversation

cztomsik
Copy link
Contributor

@cztomsik cztomsik commented May 16, 2023

Adding the ability to use custom ternary functions as described here: ggerganov/ggml#128

I have checked that it works both with this repo and also in the https://github.com/cztomsik/ggml-js where it's supposed to be used (as an optimization).

It seems to have very little perf. impact (1% at most) so I'm not sure if it's worth adding, but at least it opens some door for 3-var custom kernels.

It seems to work but I have no prior experience with this project, so please check carefully. Thanks :)

EDIT: Maybe there's at least a memory usage improvement, but it's hard for me to check that precisely because I'm using ggml with node.js.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

struct ggml_tensor * a,
struct ggml_tensor * b,
struct ggml_tensor * c,
const ggml_ternary_op_f32_t fun);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'fun' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
const ggml_ternary_op_f32_t fun);
ggml_ternary_op_f32_t fun);

@@ -4034,6 +4035,7 @@ struct ggml_tensor * ggml_new_tensor_impl(
/*.grad =*/ NULL,
/*.src0 =*/ NULL,
/*.src1 =*/ NULL,
/*.src2 =*/ NULL,
Copy link
Owner

Choose a reason for hiding this comment

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

Can you make it use opt instead of src2?

The problem with src2 is that there is logic for constructing computation graphs that currently considers src0, src1 and opt. So it would need to be updated if we introduce src2, but I want to do that at a later stage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I will change that

@cztomsik
Copy link
Contributor Author

cztomsik commented Jul 1, 2023

sorry, I will have a look at this later, and probably in the ggml repo which I am using as a submodule

@cztomsik cztomsik closed this Jul 1, 2023
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

Successfully merging this pull request may close these issues.

2 participants