@@ -4851,9 +4851,7 @@ static void ggml_compute_forward_soft_max_f32(
4851
4851
const int ith = params->ith ;
4852
4852
const int nth = params->nth ;
4853
4853
4854
- GGML_TENSOR_UNARY_OP_LOCALS
4855
-
4856
- // const int64_t ne11 = src1 ? src1->ne[1] : 1;
4854
+ GGML_TENSOR_BINARY_OP_LOCALS
4857
4855
4858
4856
// TODO: is this supposed to be ceil instead of floor?
4859
4857
// https://huggingface.co/mosaicml/mpt-7b/blob/main/attention.py#L370
@@ -4878,6 +4876,10 @@ static void ggml_compute_forward_soft_max_f32(
4878
4876
const bool use_f16 = (src1 && src1->type == GGML_TYPE_F16);
4879
4877
4880
4878
for (int i1 = ir0; i1 < ir1; i1++) {
4879
+ const int64_t i11 = (i1%ne01);
4880
+ // const int64_t i12 = (i1/ne01)%ne02;
4881
+ const int64_t i13 = (i1/ne01)/ne02;
4882
+
4881
4883
// ALiBi
4882
4884
const uint32_t h = (i1/ne01)%ne02; // head
4883
4885
const float slope = (max_bias > 0 .0f ) ? h < n_head_log2 ? powf (m0, h + 1 ) : powf (m1, 2 *(h - n_head_log2) + 1 ) : 1 .0f ;
@@ -4886,8 +4888,8 @@ static void ggml_compute_forward_soft_max_f32(
4886
4888
float * dp = (float *)((char *) dst->data + i1*dst->nb [1 ]);
4887
4889
4888
4890
// broadcast the mask across rows
4889
- ggml_fp16_t * mp_f16 = src1 ? (ggml_fp16_t *)((char *) src1->data ) + (i1%ne01)*ne00 : NULL ;
4890
- float * mp_f32 = src1 ? (float *)((char *) src1->data ) + (i1%ne01)*ne00 : NULL ;
4891
+ ggml_fp16_t * mp_f16 = src1 ? (ggml_fp16_t *)((char *) src1->data + i11*nb11 + i13*nb12) : NULL ;
4892
+ float * mp_f32 = src1 ? (float *)((char *) src1->data + i11*nb11 + i13*nb12) : NULL ;
4891
4893
4892
4894
ggml_vec_cpy_f32 (nc, wp, sp);
4893
4895
ggml_vec_scale_f32 (nc, wp, scale);
@@ -7227,7 +7229,7 @@ static void ggml_compute_forward_flash_attn_ext_f16(
7227
7229
memset (VKQ32, 0 , DV*sizeof (float ));
7228
7230
}
7229
7231
7230
- const ggml_fp16_t * mp = mask ? (ggml_fp16_t *)((char *) mask->data + iq1*mask->nb [1 ]) : NULL ;
7232
+ const ggml_fp16_t * mp = mask ? (ggml_fp16_t *)((char *) mask->data + iq1*mask->nb [1 ] + iq3*mask-> nb [ 2 ] ) : NULL ;
7231
7233
7232
7234
// k indices
7233
7235
const int ik3 = iq3 / rk3;
0 commit comments