Skip to content

Commit 49100a8

Browse files
committed
Remove bf16 luts
1 parent 700db7d commit 49100a8

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

ggml.c

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,6 @@ static ggml_fp16_t ggml_table_exp_f16[1 << 16];
322322
// precomputed f32 table for f16 (256 KB) (ggml-impl.h)
323323
float ggml_table_f32_f16[1 << 16];
324324

325-
// precomputed gelu table for bf16 (128 KB)
326-
static ggml_bf16_t ggml_table_gelu_bf16[1 << 16];
327-
328-
// precomputed exp table for bf16 (128 KB)
329-
static ggml_bf16_t ggml_table_exp_bf16[1 << 16];
330-
331325
GGML_CALL const char * ggml_status_to_string(enum ggml_status status) {
332326
switch (status) {
333327
case GGML_STATUS_ALLOC_FAILED: return "GGML status: error (failed to allocate memory)";
@@ -1622,14 +1616,13 @@ static void ggml_vec_dot_bf16(int n, float * restrict s, size_t bs, ggml_bf16_t
16221616
__m512 c2 = _mm512_setzero_ps();
16231617
for (; i + 64 <= n; i += 64) {
16241618
c1 = _mm512_dpbf16_ps(c1, (__m512bh)_mm512_loadu_ps((const float *)(x + i)),
1625-
(__m512bh)_mm512_loadu_ps((const float *)(y + i)));
1619+
(__m512bh)_mm512_loadu_ps((const float *)(y + i)));
16261620
c2 = _mm512_dpbf16_ps(c2, (__m512bh)_mm512_loadu_ps((const float *)(x + i + 32)),
1627-
(__m512bh)_mm512_loadu_ps((const float *)(y + i + 32)));
1621+
(__m512bh)_mm512_loadu_ps((const float *)(y + i + 32)));
16281622
}
16291623
sumf += (ggml_float)_mm512_reduce_add_ps(c1);
16301624
sumf += (ggml_float)_mm512_reduce_add_ps(c2);
16311625

1632-
#undef LOAD
16331626
#elif defined(__AVX512F__)
16341627
#define LOAD(p) _mm512_castsi512_ps(_mm512_slli_epi32(_mm512_cvtepu16_epi32(_mm256_loadu_si256((const __m256i *)(p))), 16))
16351628
__m512 c1 = _mm512_setzero_ps();
@@ -1915,16 +1908,6 @@ inline static void ggml_vec_gelu_f16(const int n, ggml_fp16_t * y, const ggml_fp
19151908
}
19161909
}
19171910

1918-
inline static void ggml_vec_gelu_bf16(const int n, ggml_bf16_t * y, const ggml_bf16_t * x) {
1919-
for (int i = 0; i < n; ++i) {
1920-
union {
1921-
ggml_bf16_t f;
1922-
uint16_t i;
1923-
} u = {x[i]};
1924-
y[i] = ggml_table_gelu_bf16[u.i];
1925-
}
1926-
}
1927-
19281911
#ifdef GGML_GELU_FP16
19291912
inline static void ggml_vec_gelu_f32(const int n, float * y, const float * x) {
19301913
uint16_t t;
@@ -2827,18 +2810,14 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
28272810

28282811
for (int i = 0; i < (1 << 16); ++i) {
28292812
union {
2830-
uint16_t i;
2813+
uint16_t u16;
28312814
ggml_fp16_t fp16;
2832-
ggml_bf16_t bf16;
28332815
} u = {i};
28342816
float f = ggml_table_f32_f16[i] = GGML_COMPUTE_FP16_TO_FP32(u.fp16);
28352817
ggml_table_gelu_f16[i] = GGML_FP32_TO_FP16(ggml_gelu_f32(f));
28362818
ggml_table_gelu_quick_f16[i] = GGML_FP32_TO_FP16(ggml_gelu_quick_f32(f));
28372819
ggml_table_silu_f16[i] = GGML_FP32_TO_FP16(ggml_silu_f32(f));
28382820
ggml_table_exp_f16[i] = GGML_FP32_TO_FP16(expf(f));
2839-
f = GGML_BF16_TO_FP32(u.bf16);
2840-
ggml_table_gelu_bf16[i] = GGML_FP32_TO_BF16(ggml_gelu_f32(f));
2841-
ggml_table_exp_bf16[i] = GGML_FP32_TO_BF16(expf(f));
28422821
}
28432822

28442823
const uint64_t t_end = ggml_time_us(); UNUSED(t_end);

0 commit comments

Comments
 (0)