metal : add GGML_UNARY_OP_ELU kernel (ggml/1018)

This commit is contained in:
PAB 2024-11-18 10:02:49 +01:00 committed by Georgi Gerganov
parent 342397dc7e
commit 12b0ad953a
2 changed files with 23 additions and 0 deletions

View file

@ -782,6 +782,14 @@ kernel void kernel_silu_4(
dst[tpig] = x / (1.0f + exp(-x));
}
kernel void kernel_elu(
device const float * src0,
device float * dst,
uint tpig[[thread_position_in_grid]]) {
device const float & x = src0[tpig];
dst[tpig] = (x > 0.0f) ? x : (exp(x) - 1.0f);
}
kernel void kernel_sqr(
device const float * src0,
device float * dst,