Skip to content

Commit

Permalink
use precise::tanh
Browse files Browse the repository at this point in the history
  • Loading branch information
slaren committed Aug 26, 2024
1 parent 054203a commit edc2e27
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ggml/src/ggml-metal.metal
Original file line number Diff line number Diff line change
Expand Up @@ -2149,8 +2149,8 @@ kernel void kernel_flash_attn_ext_f16(
ss[8*cc + ty*TF + 2*tx + 1] *= scale;

if (logit_softcap != 0.0f) {
ss[8*cc + ty*TF + 2*tx + 0] = logit_softcap*tanh(ss[8*cc + ty*TF + 2*tx + 0]);
ss[8*cc + ty*TF + 2*tx + 1] = logit_softcap*tanh(ss[8*cc + ty*TF + 2*tx + 1]);
ss[8*cc + ty*TF + 2*tx + 0] = logit_softcap*precise::tanh(ss[8*cc + ty*TF + 2*tx + 0]);
ss[8*cc + ty*TF + 2*tx + 1] = logit_softcap*precise::tanh(ss[8*cc + ty*TF + 2*tx + 1]);
}

if (mask != q) {
Expand Down Expand Up @@ -2490,7 +2490,7 @@ kernel void kernel_flash_attn_ext_vec_f16(
mqk *= scale;

if (logit_softcap != 0.0f) {
mqk = logit_softcap*tanh(mqk);
mqk = logit_softcap*precise::tanh(mqk);
}

mqk += (mask != q) ? ((float4) mp4[ic/4 + cc])*slope : (float4) 0.0f;
Expand Down

0 comments on commit edc2e27

Please sign in to comment.