Skip to content

Commit 669b75d

Browse files
authored
Merge pull request ggml-org#43 from krzysztof-jusiak/rmsnorm
Speed up rmsnorm by using sqrtf/expf
2 parents 687473c + c9b1f10 commit 669b75d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

run.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void rmsnorm(float* o, float* x, float* weight, int size) {
184184
}
185185
ss /= size;
186186
ss += 1e-5f;
187-
ss = 1.0f / sqrt(ss);
187+
ss = 1.0f / sqrtf(ss);
188188
// normalize and scale
189189
for (int j = 0; j < size; j++) {
190190
o[j] = weight[j] * (ss * x[j]);
@@ -202,7 +202,7 @@ void softmax(float* x, int size) {
202202
// exp and sum
203203
float sum = 0.0f;
204204
for (int i = 0; i < size; i++) {
205-
x[i] = exp(x[i] - max_val);
205+
x[i] = expf(x[i] - max_val);
206206
sum += x[i];
207207
}
208208
// normalize

0 commit comments

Comments
 (0)