Skip to content

Commit 4d01953

Browse files
committed
will this fix cpu?
1 parent 0e51a0a commit 4d01953

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ggml/src/ggml-cpu/ops.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4666,12 +4666,22 @@ static void ggml_compute_forward_scale_f32(
46664666

46674667
const size_t nb1 = dst->nb[1];
46684668

4669-
for (int i1 = ir0; i1 < ir1; i1++) {
4670-
if (dst->data != src0->data) {
4671-
// src0 is same shape as dst => same indices
4672-
memcpy((char *)dst->data + i1*nb1, (char *)src0->data + i1*nb01, nc * sizeof(float));
4669+
if (b == 0.0f) {
4670+
for (int i1 = ir0; i1 < ir1; i1++) {
4671+
if (dst->data != src0->data) {
4672+
// src0 is same shape as dst => same indices
4673+
memcpy((char *)dst->data + i1*nb1, (char *)src0->data + i1*nb01, nc * sizeof(float));
4674+
}
4675+
ggml_vec_scale_f32(nc, (float *) ((char *) dst->data + i1*nb1), s);
4676+
}
4677+
} else {
4678+
for (int i1 = ir0; i1 < ir1; i1++) {
4679+
if (dst->data != src0->data) {
4680+
// src0 is same shape as dst => same indices
4681+
memcpy((char *)dst->data + i1*nb1, (char *)src0->data + i1*nb01, nc * sizeof(float));
4682+
}
4683+
ggml_vec_mad1_f32(nc, (float *) ((char *) dst->data + i1*nb1), s, b);
46734684
}
4674-
ggml_vec_mad1_f32(nc, (float *) ((char *) dst->data + i1*nb1), s, b);
46754685
}
46764686
}
46774687

0 commit comments

Comments
 (0)