File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments