Skip to content

Commit 5be39c1

Browse files
committed
Revert "ggml: move ggml_table_f32_f16 to ggml-cpu"
This reverts commit 9e40d98. Signed-off-by: Aaron Teo <[email protected]>
1 parent 827fce9 commit 5be39c1

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3479,7 +3479,6 @@ void ggml_cpu_init(void) {
34793479
ggml_fp16_t fp16;
34803480
} u = {i};
34813481
float f = GGML_CPU_FP16_TO_FP32(u.fp16);
3482-
ggml_table_f32_f16[i] = GGML_COMPUTE_FP16_TO_FP32(u.fp16);
34833482
ggml_table_gelu_f16[i] = GGML_CPU_FP32_TO_FP16(ggml_gelu_f32(f));
34843483
ggml_table_gelu_quick_f16[i] = GGML_CPU_FP32_TO_FP16(ggml_gelu_quick_f32(f));
34853484
}

ggml/src/ggml-cpu/simd-mappings.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@
137137
}
138138
#endif
139139

140-
// precomputed f32 table for f16 (256 KB)
141-
// defined in ggml.c, initialized in ggml_init()
142-
GGML_API float ggml_table_f32_f16[1 << 16];
143-
144140
// On ARM NEON, it's quicker to directly convert x -> x instead of calling into ggml_lookup_fp16_to_fp32,
145141
// so we define GGML_CPU_FP16_TO_FP32 and GGML_CPU_FP32_TO_FP16 elsewhere for NEON.
146142
// This is also true for POWER9.

ggml/src/ggml-impl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@ static inline ggml_fp16_t ggml_compute_fp32_to_fp16(float f) {
393393
#define GGML_FP16_TO_FP32(x) GGML_COMPUTE_FP16_TO_FP32(x)
394394
#define GGML_FP32_TO_FP16(x) GGML_COMPUTE_FP32_TO_FP16(x)
395395

396+
// precomputed f32 table for f16 (256 KB)
397+
// defined in ggml.c, initialized in ggml_init()
398+
GGML_API float ggml_table_f32_f16[1 << 16];
399+
396400
/**
397401
* Converts brain16 to float32.
398402
*

ggml/src/ggml.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,27 @@ static inline bool ggml_can_repeat_rows(const struct ggml_tensor * t0, const str
14141414
////////////////////////////////////////////////////////////////////////////////
14151415

14161416
struct ggml_context * ggml_init(struct ggml_init_params params) {
1417+
static bool is_first_call = true;
1418+
1419+
ggml_critical_section_start();
1420+
1421+
if (is_first_call) {
1422+
// initialize time system (required on Windows)
1423+
ggml_time_init();
1424+
1425+
for (int i = 0; i < (1 << 16); ++i) {
1426+
union {
1427+
uint16_t u16;
1428+
ggml_fp16_t fp16;
1429+
} u = {i};
1430+
ggml_table_f32_f16[i] = GGML_COMPUTE_FP16_TO_FP32(u.fp16);
1431+
}
1432+
1433+
is_first_call = false;
1434+
}
1435+
1436+
ggml_critical_section_end();
1437+
14171438
struct ggml_context * ctx = GGML_MALLOC(sizeof(struct ggml_context));
14181439

14191440
// allow to call ggml_init with 0 size

0 commit comments

Comments
 (0)