@@ -232,19 +232,19 @@ typedef double ggml_float;
232
232
//
233
233
234
234
// precomputed gelu table for f16 (128 KB)
235
- static ggml_fp16_t table_gelu_f16 [1 << 16];
235
+ static ggml_fp16_t ggml_table_gelu_f16 [1 << 16];
236
236
237
237
// precomputed quick gelu table for f16 (128 KB)
238
- static ggml_fp16_t table_gelu_quick_f16 [1 << 16];
238
+ static ggml_fp16_t ggml_table_gelu_quick_f16 [1 << 16];
239
239
240
240
// precomputed silu table for f16 (128 KB)
241
- static ggml_fp16_t table_silu_f16 [1 << 16];
241
+ static ggml_fp16_t ggml_table_silu_f16 [1 << 16];
242
242
243
243
// precomputed exp table for f16 (128 KB)
244
- static ggml_fp16_t table_exp_f16 [1 << 16];
244
+ static ggml_fp16_t ggml_table_exp_f16 [1 << 16];
245
245
246
246
// precomputed f32 table for f16 (256 KB) (ggml-impl.h)
247
- float table_f32_f16 [1 << 16];
247
+ float ggml_table_f32_f16 [1 << 16];
248
248
249
249
// note: do not use these inside ggml.c
250
250
// these are meant to be used via the ggml.h API
@@ -1363,7 +1363,7 @@ inline static float ggml_gelu_f32(float x) {
1363
1363
inline static void ggml_vec_gelu_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
1364
1364
const uint16_t * i16 = (const uint16_t *) x;
1365
1365
for (int i = 0; i < n; ++i) {
1366
- y[i] = table_gelu_f16 [i16[i]];
1366
+ y[i] = ggml_table_gelu_f16 [i16[i]];
1367
1367
}
1368
1368
}
1369
1369
@@ -1373,7 +1373,7 @@ inline static void ggml_vec_gelu_f32(const int n, float * y, const float * x) {
1373
1373
for (int i = 0; i < n; ++i) {
1374
1374
ggml_fp16_t fp16 = GGML_FP32_TO_FP16(x[i]);
1375
1375
memcpy(&t, &fp16, sizeof(uint16_t));
1376
- y[i] = GGML_FP16_TO_FP32(table_gelu_f16 [t]);
1376
+ y[i] = GGML_FP16_TO_FP32(ggml_table_gelu_f16 [t]);
1377
1377
}
1378
1378
}
1379
1379
#else
@@ -1391,7 +1391,7 @@ inline static float ggml_gelu_quick_f32(float x) {
1391
1391
//inline static void ggml_vec_gelu_quick_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
1392
1392
// const uint16_t * i16 = (const uint16_t *) x;
1393
1393
// for (int i = 0; i < n; ++i) {
1394
- // y[i] = table_gelu_quick_f16 [i16[i]];
1394
+ // y[i] = ggml_table_gelu_quick_f16 [i16[i]];
1395
1395
// }
1396
1396
//}
1397
1397
@@ -1401,7 +1401,7 @@ inline static void ggml_vec_gelu_quick_f32(const int n, float * y, const float *
1401
1401
for (int i = 0; i < n; ++i) {
1402
1402
ggml_fp16_t fp16 = GGML_FP32_TO_FP16(x[i]);
1403
1403
memcpy(&t, &fp16, sizeof(uint16_t));
1404
- y[i] = GGML_FP16_TO_FP32(table_gelu_quick_f16 [t]);
1404
+ y[i] = GGML_FP16_TO_FP32(ggml_table_gelu_quick_f16 [t]);
1405
1405
}
1406
1406
}
1407
1407
#else
@@ -1420,7 +1420,7 @@ inline static float ggml_silu_f32(float x) {
1420
1420
//inline static void ggml_vec_silu_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
1421
1421
// const uint16_t * i16 = (const uint16_t *) x;
1422
1422
// for (int i = 0; i < n; ++i) {
1423
- // y[i] = table_silu_f16 [i16[i]];
1423
+ // y[i] = ggml_table_silu_f16 [i16[i]];
1424
1424
// }
1425
1425
//}
1426
1426
@@ -1430,7 +1430,7 @@ inline static void ggml_vec_silu_f32(const int n, float * y, const float * x) {
1430
1430
for (int i = 0; i < n; ++i) {
1431
1431
ggml_fp16_t fp16 = GGML_FP32_TO_FP16(x[i]);
1432
1432
memcpy(&t, &fp16, sizeof(uint16_t));
1433
- y[i] = GGML_FP16_TO_FP32(table_silu_f16 [t]);
1433
+ y[i] = GGML_FP16_TO_FP32(ggml_table_silu_f16 [t]);
1434
1434
}
1435
1435
}
1436
1436
#else
@@ -2146,11 +2146,11 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
2146
2146
for (int i = 0; i < (1 << 16); ++i) {
2147
2147
uint16_t ui = i;
2148
2148
memcpy(&ii, &ui, sizeof(ii));
2149
- const float f = table_f32_f16 [i] = GGML_COMPUTE_FP16_TO_FP32(ii);
2150
- table_gelu_f16 [i] = GGML_FP32_TO_FP16(ggml_gelu_f32(f));
2151
- table_gelu_quick_f16 [i] = GGML_FP32_TO_FP16(ggml_gelu_quick_f32(f));
2152
- table_silu_f16 [i] = GGML_FP32_TO_FP16(ggml_silu_f32(f));
2153
- table_exp_f16 [i] = GGML_FP32_TO_FP16(expf(f));
2149
+ const float f = ggml_table_f32_f16 [i] = GGML_COMPUTE_FP16_TO_FP32(ii);
2150
+ ggml_table_gelu_f16 [i] = GGML_FP32_TO_FP16(ggml_gelu_f32(f));
2151
+ ggml_table_gelu_quick_f16 [i] = GGML_FP32_TO_FP16(ggml_gelu_quick_f32(f));
2152
+ ggml_table_silu_f16 [i] = GGML_FP32_TO_FP16(ggml_silu_f32(f));
2153
+ ggml_table_exp_f16 [i] = GGML_FP32_TO_FP16(expf(f));
2154
2154
}
2155
2155
2156
2156
const uint64_t t_end = ggml_time_us(); UNUSED(t_end);
@@ -10513,7 +10513,7 @@ static void ggml_compute_forward_soft_max_f32(
10513
10513
// const float val = (sp[i] == -INFINITY) ? 0.0 : exp(sp[i] - max);
10514
10514
ggml_fp16_t s = GGML_FP32_TO_FP16(sp[i] - max);
10515
10515
memcpy(&scvt, &s, sizeof(scvt));
10516
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt]);
10516
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt]);
10517
10517
sum += (ggml_float)val;
10518
10518
dp[i] = val;
10519
10519
}
@@ -12802,7 +12802,7 @@ static void ggml_compute_forward_flash_attn_f32(
12802
12802
#else
12803
12803
ggml_fp16_t s = GGML_FP32_TO_FP16(SS[j] - max);
12804
12804
memcpy(&scvt[j], &s, sizeof(uint16_t));
12805
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt[j]]);
12805
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt[j]]);
12806
12806
#endif
12807
12807
sump[j] += (ggml_float)val;
12808
12808
SS[j] = val;
@@ -13004,7 +13004,7 @@ static void ggml_compute_forward_flash_attn_f16(
13004
13004
} else {
13005
13005
ggml_fp16_t s = GGML_FP32_TO_FP16(SS[j] - max);
13006
13006
memcpy(&scvt[j], &s, sizeof(uint16_t));
13007
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt[j]]);
13007
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt[j]]);
13008
13008
sump[j] += (ggml_float)val;
13009
13009
SS[j] = val;
13010
13010
}
@@ -13455,7 +13455,7 @@ static void ggml_compute_forward_flash_attn_back_f32(
13455
13455
#else
13456
13456
ggml_fp16_t s = GGML_FP32_TO_FP16(SR[j] - max);
13457
13457
memcpy(&scvt[j], &s, sizeof(uint16_t));
13458
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt[j]]);
13458
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt[j]]);
13459
13459
#endif
13460
13460
sump[j] += (ggml_float)val;
13461
13461
SW[j] = val;
@@ -14205,7 +14205,7 @@ static void ggml_compute_forward_cross_entropy_loss_f32(
14205
14205
#else
14206
14206
ggml_fp16_t s = GGML_FP32_TO_FP16(s0[i] - max);
14207
14207
memcpy(&scvt, &s, sizeof(scvt));
14208
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt]);
14208
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt]);
14209
14209
#endif
14210
14210
sum += (ggml_float)val;
14211
14211
st[i] = val;
@@ -14319,7 +14319,7 @@ static void ggml_compute_forward_cross_entropy_loss_back_f32(
14319
14319
#else
14320
14320
ggml_fp16_t s = GGML_FP32_TO_FP16(s0[i] - max);
14321
14321
memcpy(&scvt, &s, sizeof(scvt));
14322
- const float val = GGML_FP16_TO_FP32(table_exp_f16 [scvt]);
14322
+ const float val = GGML_FP16_TO_FP32(ggml_table_exp_f16 [scvt]);
14323
14323
#endif
14324
14324
sum += (ggml_float)val;
14325
14325
ds0[i] = val;
0 commit comments