diff options
Diffstat (limited to 'libffwd/act.c')
| -rw-r--r-- | libffwd/act.c | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/libffwd/act.c b/libffwd/act.c deleted file mode 100644 index 3912f2f..0000000 --- a/libffwd/act.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "kernels.h" - -#include <math.h> - -void gelu_inplace(float *x, int n) { - /* Exact erf GeLU; 0.70710678... = 1/sqrt(2). */ - for (int i = 0; i < n; i++) - x[i] = 0.5f * x[i] * (1.0f + erff(x[i] * 0.70710678118654752f)); -} - -void softmax(float *x, int rows, int cols) { - for (int r = 0; r < rows; r++) { - float *row = x + r * cols; - float max_val = row[0]; - for (int c = 1; c < cols; c++) { - if (row[c] > max_val) - max_val = row[c]; - } - float sum = 0.0f; - for (int c = 0; c < cols; c++) { - row[c] = expf(row[c] - max_val); - sum += row[c]; - } - float inv_sum = 1.0f / sum; - for (int c = 0; c < cols; c++) { - row[c] *= inv_sum; - } - } -} |
