-
Notifications
You must be signed in to change notification settings - Fork 22.6k
ggml : update ggml_prec specification #26675
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
base: master
Are you sure you want to change the base?
Changes from all commits
83d5ed8
9b970f6
7f05174
76c0f1e
bddf805
9372029
7886f52
085ae2d
81cce78
5851394
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3265,6 +3265,57 @@ struct ggml_tensor * ggml_l2_norm_inplace( | |||||
| return ggml_l2_norm_impl(ctx, a, eps, true); | ||||||
| } | ||||||
|
|
||||||
| // ggml_prec | ||||||
|
|
||||||
| bool ggml_prec_set_acc( | ||||||
| struct ggml_tensor * a, | ||||||
| enum ggml_prec prec) { | ||||||
| switch (a->op) { | ||||||
| case GGML_OP_MUL_MAT: | ||||||
| case GGML_OP_MUL_MAT_ID: | ||||||
| { | ||||||
| const int32_t prec_i32 = (int32_t) prec; | ||||||
| ggml_set_op_params_i32(a, 0, prec_i32); | ||||||
| } | ||||||
| break; | ||||||
| case GGML_OP_FLASH_ATTN_EXT: | ||||||
| { | ||||||
| const int32_t prec_i32 = (int32_t) prec; | ||||||
| ggml_set_op_params_i32(a, 3, prec_i32); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a search tag |
||||||
| } | ||||||
| break; | ||||||
| default: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also handle MUL_MAT_ID here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||||||
| return false; | ||||||
| }; | ||||||
|
|
||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| bool ggml_prec_set_src( | ||||||
| struct ggml_tensor * a, | ||||||
| enum ggml_prec prec, | ||||||
| int idx) { | ||||||
| GGML_ASSERT(idx >= 0 && idx < GGML_MAX_SRC); | ||||||
|
|
||||||
| switch (a->op) { | ||||||
| case GGML_OP_MUL_MAT: | ||||||
| case GGML_OP_MUL_MAT_ID: | ||||||
| { | ||||||
| if (idx != 1) { | ||||||
| return false; | ||||||
| } | ||||||
|
|
||||||
|
ggerganov marked this conversation as resolved.
|
||||||
| const int32_t prec_i32 = (int32_t) prec; | ||||||
| ggml_set_op_params_i32(a, 2 + idx, prec_i32); | ||||||
| } | ||||||
| break; | ||||||
| default: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, can we handle MUL_MAT_ID here as well |
||||||
| return false; | ||||||
| }; | ||||||
|
|
||||||
| return true; | ||||||
| } | ||||||
|
|
||||||
| // ggml_mul_mat | ||||||
|
|
||||||
| static inline bool ggml_can_mul_mat(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { | ||||||
|
|
||||||
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.
In the docs we say only
are supported. If the other values are truly not allowed, we should check
prechere and error if the other values are suppliedThere 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.
Yes, I was think that we should actually make this function return a
booland returnfalseon failure. Also returnfalsewhen applied to unsupported op, etc.