| 599 | } |
| 600 | |
| 601 | static void rmsnorm(float* o, float* x, float* weight, int size, float eps) { |
| 602 | float rms = 0.0f; |
| 603 | for (int i = 0; i < size; ++i) { |
| 604 | rms += x[i] * x[i]; |
| 605 | } |
| 606 | rms = sqrtf(rms / size + eps); |
| 607 | float scale = 1.0f / rms; |
| 608 | for (int i = 0; i < size; ++i) { |
| 609 | o[i] = x[i] * scale * weight[i]; |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | [[maybe_unused]] static void layernorm(float* o, float* x, float* weight, float* bias, int size, float eps) { |
| 614 | float mean = 0.0f; |
no outgoing calls
no test coverage detected