-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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]
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
sorry, I will have a look at this later, and probably in the ggml repo which I am using as a submodule |
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.