Skip to content

Commit 54bb60e

Browse files
authored
ggml : fix bug in ggml_compute_forward_sum_f32 (#1162)
The sum over all rows is now computed instead of just the last row
1 parent 8a0f867 commit 54bb60e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ggml.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6779,15 +6779,20 @@ static void ggml_compute_forward_sum_f32(
67796779
const size_t nb02 = src0->nb[2];
67806780
const size_t nb03 = src0->nb[3];
67816781

6782+
ggml_float sum = 0;
6783+
float row_sum = 0;
6784+
67826785
for (int64_t i03 = 0; i03 < ne03; i03++) {
67836786
for (int64_t i02 = 0; i02 < ne02; i02++) {
67846787
for (int64_t i01 = 0; i01 < ne01; i01++) {
67856788
ggml_vec_sum_f32(ne00,
6786-
(float *) (dst->data),
6789+
&row_sum,
67876790
(float *) ((char *) src0->data + i01*nb01 + i02*nb02 + i03*nb03));
6791+
sum += row_sum;
67886792
}
67896793
}
67906794
}
6795+
((float *) dst->data)[0] = sum;
67916796
}
67926797

67936798
static void ggml_compute_forward_sum(

0 commit comments

Comments
 (0)