summaryrefslogtreecommitdiff
path: root/ggml.c
diff options
context:
space:
mode:
authorJustine Tunney <jtunney@mozilla.com>2024-04-22 15:00:36 -0400
committerGitHub <noreply@github.com>2024-04-22 22:00:36 +0300
commit192090bae47960f0d38d4967abe398a5d190057e (patch)
tree7298f6be91a04fd962adfaf307ace4a862272860 /ggml.c
parente931888d5024de814ce7119a18d6a959bfff3821 (diff)
llamafile : improve sgemm.cpp (#6796)
* llamafile : improve sgemm.cpp - Re-enable by default - Fix issue described in #6716 - Make code more abstract, elegant, and maintainable - Faster handling of weirdly shaped `m` an `n` edge cases * Address review comments * Help clang produce fma instructions * Address review comments
Diffstat (limited to 'ggml.c')
-rw-r--r--ggml.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ggml.c b/ggml.c
index a3b312e4..086db96a 100644
--- a/ggml.c
+++ b/ggml.c
@@ -10825,7 +10825,7 @@ static void ggml_compute_forward_mul_mat(
#endif
#if GGML_USE_LLAMAFILE
- if (nb10 == ggml_type_size(src1->type)) {
+ if (src1_cont) {
for (int64_t i13 = 0; i13 < ne13; i13++)
for (int64_t i12 = 0; i12 < ne12; i12++)
if (!llamafile_sgemm(ne01, ne11, ne00/ggml_blck_size(src0->type),
@@ -10878,15 +10878,13 @@ UseGgmlGemm1:;
const size_t row_size = ggml_row_size(vec_dot_type, ne10);
#if GGML_USE_LLAMAFILE
- if (nb10 == ggml_type_size(src1->type) || src1->type != vec_dot_type) {
+ if (src1->type != vec_dot_type) {
for (int64_t i13 = 0; i13 < ne13; i13++)
for (int64_t i12 = 0; i12 < ne12; i12++)
if (!llamafile_sgemm(ne01, ne11, ne00/ggml_blck_size(src0->type),
(const char *)src0->data + i12/r2*nb02 + i13/r3*nb03,
nb01/ggml_type_size(src0->type),
- (const char *)wdata + ggml_row_size(vec_dot_type,
- nb12/ggml_type_size(src1->type)*i12 +
- nb13/ggml_type_size(src1->type)*i13),
+ (const char *)wdata + (i12*ne11 + i13*ne12*ne11)*row_size,
row_size/ggml_type_size(vec_dot_type),
(char *)dst->data + i12*nb2 + i13*nb3,
nb1/ggml_type_size(dst->type),