Skip to content

Commit a30f0b2

Browse files
committed
ggml : build backends as libraries
1 parent 4b3a921 commit a30f0b2

File tree

143 files changed

+16442
-16022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+16442
-16022
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "kompute"]
2-
path = ggml/src/kompute
2+
path = ggml/src/ggml-kompute/kompute
33
url = https://github.com/nomic-ai/kompute.git

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ set(LLAMA_INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Location o
140140
set(LLAMA_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Location of library files")
141141
set(LLAMA_BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Location of binary files")
142142

143-
144143
# At the moment some compile definitions are placed within the ggml/src
145144
# directory but not exported on the `ggml` target. This could be improved by
146145
# determining _precisely_ which defines are necessary for the llama-config

common/common.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,18 +1967,13 @@ void yaml_dump_non_result_info(FILE * stream, const common_params & params, cons
19671967
fprintf(stream, "cpu_has_avx512: %s\n", ggml_cpu_has_avx512() ? "true" : "false");
19681968
fprintf(stream, "cpu_has_avx512_vbmi: %s\n", ggml_cpu_has_avx512_vbmi() ? "true" : "false");
19691969
fprintf(stream, "cpu_has_avx512_vnni: %s\n", ggml_cpu_has_avx512_vnni() ? "true" : "false");
1970-
fprintf(stream, "cpu_has_cuda: %s\n", ggml_cpu_has_cuda() ? "true" : "false");
1971-
fprintf(stream, "cpu_has_vulkan: %s\n", ggml_cpu_has_vulkan() ? "true" : "false");
1972-
fprintf(stream, "cpu_has_kompute: %s\n", ggml_cpu_has_kompute() ? "true" : "false");
19731970
fprintf(stream, "cpu_has_fma: %s\n", ggml_cpu_has_fma() ? "true" : "false");
1974-
fprintf(stream, "cpu_has_gpublas: %s\n", ggml_cpu_has_gpublas() ? "true" : "false");
19751971
fprintf(stream, "cpu_has_neon: %s\n", ggml_cpu_has_neon() ? "true" : "false");
19761972
fprintf(stream, "cpu_has_sve: %s\n", ggml_cpu_has_sve() ? "true" : "false");
19771973
fprintf(stream, "cpu_has_f16c: %s\n", ggml_cpu_has_f16c() ? "true" : "false");
19781974
fprintf(stream, "cpu_has_fp16_va: %s\n", ggml_cpu_has_fp16_va() ? "true" : "false");
19791975
fprintf(stream, "cpu_has_riscv_v: %s\n", ggml_cpu_has_riscv_v() ? "true" : "false");
19801976
fprintf(stream, "cpu_has_wasm_simd: %s\n", ggml_cpu_has_wasm_simd() ? "true" : "false");
1981-
fprintf(stream, "cpu_has_blas: %s\n", ggml_cpu_has_blas() ? "true" : "false");
19821977
fprintf(stream, "cpu_has_sse3: %s\n", ggml_cpu_has_sse3() ? "true" : "false");
19831978
fprintf(stream, "cpu_has_vsx: %s\n", ggml_cpu_has_vsx() ? "true" : "false");
19841979
fprintf(stream, "cpu_has_matmul_int8: %s\n", ggml_cpu_has_matmul_int8() ? "true" : "false");

ggml/include/ggml-cpu.h

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,35 @@ extern "C" {
9696
// note: the drawback of this API is that you must have ensured that the context has enough memory for the work data
9797
GGML_API enum ggml_status ggml_graph_compute_with_ctx(struct ggml_context * ctx, struct ggml_cgraph * cgraph, int n_threads);
9898

99-
// TODO: move to backend interface
99+
//
100+
// system info
101+
//
102+
103+
// x86
104+
GGML_API int ggml_cpu_has_sse3 (void);
105+
GGML_API int ggml_cpu_has_ssse3 (void);
106+
GGML_API int ggml_cpu_has_avx (void);
107+
GGML_API int ggml_cpu_has_avx2 (void);
108+
GGML_API int ggml_cpu_has_f16c (void);
109+
GGML_API int ggml_cpu_has_fma (void);
110+
GGML_API int ggml_cpu_has_avx_vnni (void);
111+
GGML_API int ggml_cpu_has_avx512 (void);
112+
GGML_API int ggml_cpu_has_avx512_vbmi(void);
113+
GGML_API int ggml_cpu_has_avx512_vnni(void);
114+
GGML_API int ggml_cpu_has_avx512_bf16(void);
115+
GGML_API int ggml_cpu_has_amx_int8 (void);
116+
// ARM
100117
GGML_API int ggml_cpu_has_neon (void);
101-
GGML_API int ggml_cpu_has_sve (void);
118+
GGML_API int ggml_cpu_has_arm_fma (void);
119+
GGML_API int ggml_cpu_has_fp16_va (void);
102120
GGML_API int ggml_cpu_has_matmul_int8(void);
103-
// get the sve vector length in bytes
104-
GGML_API int ggml_cpu_get_sve_cnt(void);
121+
GGML_API int ggml_cpu_has_sve (void);
122+
GGML_API int ggml_cpu_get_sve_cnt (void); // sve vector length in bytes
123+
// other
124+
GGML_API int ggml_cpu_has_riscv_v (void);
125+
GGML_API int ggml_cpu_has_vsx (void);
126+
GGML_API int ggml_cpu_has_wasm_simd (void);
127+
GGML_API int ggml_cpu_has_llamafile (void);
105128

106129
// Internal types and functions exposed for tests and benchmarks
107130

@@ -115,6 +138,7 @@ extern "C" {
115138
const void * GGML_RESTRICT y, int nr, int nc);
116139

117140
struct ggml_type_traits_cpu {
141+
ggml_from_float_t from_float;
118142
ggml_from_float_to_mat_t from_float_to_mat;
119143
ggml_vec_dot_t vec_dot;
120144
enum ggml_type vec_dot_type;

ggml/include/ggml.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,38 +2384,6 @@ extern "C" {
23842384
GGML_API size_t gguf_get_meta_size(const struct gguf_context * ctx);
23852385
GGML_API void gguf_get_meta_data(const struct gguf_context * ctx, void * data);
23862386

2387-
//
2388-
// system info
2389-
//
2390-
2391-
GGML_API int ggml_cpu_has_avx (void);
2392-
GGML_API int ggml_cpu_has_avx_vnni (void);
2393-
GGML_API int ggml_cpu_has_avx2 (void);
2394-
GGML_API int ggml_cpu_has_avx512 (void);
2395-
GGML_API int ggml_cpu_has_avx512_vbmi(void);
2396-
GGML_API int ggml_cpu_has_avx512_vnni(void);
2397-
GGML_API int ggml_cpu_has_avx512_bf16(void);
2398-
GGML_API int ggml_cpu_has_amx_int8 (void);
2399-
GGML_API int ggml_cpu_has_fma (void);
2400-
GGML_API int ggml_cpu_has_arm_fma (void);
2401-
GGML_API int ggml_cpu_has_metal (void);
2402-
GGML_API int ggml_cpu_has_f16c (void);
2403-
GGML_API int ggml_cpu_has_fp16_va (void);
2404-
GGML_API int ggml_cpu_has_wasm_simd (void);
2405-
GGML_API int ggml_cpu_has_blas (void);
2406-
GGML_API int ggml_cpu_has_cuda (void);
2407-
GGML_API int ggml_cpu_has_vulkan (void);
2408-
GGML_API int ggml_cpu_has_kompute (void);
2409-
GGML_API int ggml_cpu_has_gpublas (void);
2410-
GGML_API int ggml_cpu_has_sse3 (void);
2411-
GGML_API int ggml_cpu_has_ssse3 (void);
2412-
GGML_API int ggml_cpu_has_riscv_v (void);
2413-
GGML_API int ggml_cpu_has_sycl (void);
2414-
GGML_API int ggml_cpu_has_rpc (void);
2415-
GGML_API int ggml_cpu_has_vsx (void);
2416-
GGML_API int ggml_cpu_has_cann (void);
2417-
GGML_API int ggml_cpu_has_llamafile (void);
2418-
24192387
#ifdef __cplusplus
24202388
// restrict not standard in C++
24212389
#define GGML_RESTRICT
@@ -2432,7 +2400,6 @@ extern "C" {
24322400
size_t type_size;
24332401
bool is_quantized;
24342402
ggml_to_float_t to_float;
2435-
ggml_from_float_t from_float;
24362403
ggml_from_float_t from_float_ref;
24372404
};
24382405

0 commit comments

Comments
 (0)