libggml-python 0.2.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
libggml/include/gguf.h ADDED
@@ -0,0 +1,202 @@
1
+ // This file contains functionality related to "GGUF" files, the binary file format used by ggml.
2
+ // GGUF files have the following structure:
3
+ //
4
+ // 1. File magic "GGUF" (4 bytes).
5
+ // 2. File version (uint32_t).
6
+ // 3. Number of ggml tensors in file (int64_t).
7
+ // 4. Number of key-value-pairs in file (int64_t).
8
+ // 5. For each KV pair:
9
+ // 1. The key (string).
10
+ // 2. The value type (gguf_type).
11
+ // 3a. If the value type is GGUF_TYPE_ARRAY:
12
+ // 1. The type of the array (gguf_type).
13
+ // 2. The number of elements in the array (uint64_t).
14
+ // 3. The binary representation of each element in the array.
15
+ // 3b. Otherwise:
16
+ // 1. The binary representation of the value.
17
+ // 6. For each ggml tensor:
18
+ // 1. The tensor name (string).
19
+ // 2. The number of dimensions of the tensor (uint32_t).
20
+ // 3. For each dimension:
21
+ // 1. The size of the tensor in the dimension (int64_t).
22
+ // 4. The tensor data type (ggml_type).
23
+ // 5. The tensor data offset in the tensor data binary blob (uint64_t).
24
+ // 7. The tensor data binary blob (optional, aligned).
25
+ //
26
+ // Strings are serialized as the string length (uint64_t) followed by the C string without the null terminator.
27
+ // All enums are stored as int32_t.
28
+ // All bool values are stored as int8_t.
29
+ // If the special key "general.alignment" (uint32_t) is defined it is used for alignment,
30
+ // otherwise GGUF_DEFAULT_ALIGNMENT is used.
31
+ //
32
+ // Module maintainer: Johannes Gäßler (@JohannesGaessler, johannesg@5d6.de)
33
+
34
+ #pragma once
35
+
36
+ #include "ggml.h"
37
+
38
+ #include <stdbool.h>
39
+ #include <stdint.h>
40
+
41
+ #define GGUF_MAGIC "GGUF"
42
+ #define GGUF_VERSION 3
43
+
44
+ #define GGUF_KEY_GENERAL_ALIGNMENT "general.alignment"
45
+
46
+ #define GGUF_DEFAULT_ALIGNMENT 32
47
+
48
+ #ifdef __cplusplus
49
+ extern "C" {
50
+ #endif
51
+
52
+ // types that can be stored as GGUF KV data
53
+ enum gguf_type {
54
+ GGUF_TYPE_UINT8 = 0,
55
+ GGUF_TYPE_INT8 = 1,
56
+ GGUF_TYPE_UINT16 = 2,
57
+ GGUF_TYPE_INT16 = 3,
58
+ GGUF_TYPE_UINT32 = 4,
59
+ GGUF_TYPE_INT32 = 5,
60
+ GGUF_TYPE_FLOAT32 = 6,
61
+ GGUF_TYPE_BOOL = 7,
62
+ GGUF_TYPE_STRING = 8,
63
+ GGUF_TYPE_ARRAY = 9,
64
+ GGUF_TYPE_UINT64 = 10,
65
+ GGUF_TYPE_INT64 = 11,
66
+ GGUF_TYPE_FLOAT64 = 12,
67
+ GGUF_TYPE_COUNT, // marks the end of the enum
68
+ };
69
+
70
+ struct gguf_context;
71
+
72
+ struct gguf_init_params {
73
+ bool no_alloc;
74
+
75
+ // if not NULL, create a ggml_context and allocate the tensor data in it
76
+ struct ggml_context ** ctx;
77
+ };
78
+
79
+ GGML_API struct gguf_context * gguf_init_empty(void);
80
+ GGML_API struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_params params);
81
+ //GGML_API struct gguf_context * gguf_init_from_buffer(..);
82
+
83
+ GGML_API void gguf_free(struct gguf_context * ctx);
84
+
85
+ GGML_API const char * gguf_type_name(enum gguf_type type);
86
+
87
+ GGML_API uint32_t gguf_get_version (const struct gguf_context * ctx);
88
+ GGML_API size_t gguf_get_alignment (const struct gguf_context * ctx);
89
+ GGML_API size_t gguf_get_data_offset(const struct gguf_context * ctx);
90
+
91
+ GGML_API int64_t gguf_get_n_kv(const struct gguf_context * ctx);
92
+ GGML_API int64_t gguf_find_key(const struct gguf_context * ctx, const char * key); // returns -1 if key is not found
93
+ GGML_API const char * gguf_get_key (const struct gguf_context * ctx, int64_t key_id);
94
+
95
+ GGML_API enum gguf_type gguf_get_kv_type (const struct gguf_context * ctx, int64_t key_id);
96
+ GGML_API enum gguf_type gguf_get_arr_type(const struct gguf_context * ctx, int64_t key_id);
97
+
98
+ // will abort if the wrong type is used for the key
99
+ GGML_API uint8_t gguf_get_val_u8 (const struct gguf_context * ctx, int64_t key_id);
100
+ GGML_API int8_t gguf_get_val_i8 (const struct gguf_context * ctx, int64_t key_id);
101
+ GGML_API uint16_t gguf_get_val_u16 (const struct gguf_context * ctx, int64_t key_id);
102
+ GGML_API int16_t gguf_get_val_i16 (const struct gguf_context * ctx, int64_t key_id);
103
+ GGML_API uint32_t gguf_get_val_u32 (const struct gguf_context * ctx, int64_t key_id);
104
+ GGML_API int32_t gguf_get_val_i32 (const struct gguf_context * ctx, int64_t key_id);
105
+ GGML_API float gguf_get_val_f32 (const struct gguf_context * ctx, int64_t key_id);
106
+ GGML_API uint64_t gguf_get_val_u64 (const struct gguf_context * ctx, int64_t key_id);
107
+ GGML_API int64_t gguf_get_val_i64 (const struct gguf_context * ctx, int64_t key_id);
108
+ GGML_API double gguf_get_val_f64 (const struct gguf_context * ctx, int64_t key_id);
109
+ GGML_API bool gguf_get_val_bool(const struct gguf_context * ctx, int64_t key_id);
110
+ GGML_API const char * gguf_get_val_str (const struct gguf_context * ctx, int64_t key_id);
111
+ GGML_API const void * gguf_get_val_data(const struct gguf_context * ctx, int64_t key_id);
112
+ GGML_API size_t gguf_get_arr_n (const struct gguf_context * ctx, int64_t key_id);
113
+
114
+ // get raw pointer to the first element of the array with the given key_id
115
+ // for bool arrays, note that they are always stored as int8 on all platforms (usually this makes no difference)
116
+ GGML_API const void * gguf_get_arr_data(const struct gguf_context * ctx, int64_t key_id);
117
+
118
+ // get ith C string from array with given key_id
119
+ GGML_API const char * gguf_get_arr_str (const struct gguf_context * ctx, int64_t key_id, size_t i);
120
+
121
+ GGML_API int64_t gguf_get_n_tensors (const struct gguf_context * ctx);
122
+ GGML_API int64_t gguf_find_tensor (const struct gguf_context * ctx, const char * name); // returns -1 if the tensor is not found
123
+ GGML_API size_t gguf_get_tensor_offset(const struct gguf_context * ctx, int64_t tensor_id);
124
+ GGML_API const char * gguf_get_tensor_name (const struct gguf_context * ctx, int64_t tensor_id);
125
+ GGML_API enum ggml_type gguf_get_tensor_type (const struct gguf_context * ctx, int64_t tensor_id);
126
+ GGML_API size_t gguf_get_tensor_size (const struct gguf_context * ctx, int64_t tensor_id);
127
+
128
+ // removes key if it exists, returns id that the key had prior to removal (-1 if it didn't exist)
129
+ GGML_API int64_t gguf_remove_key(struct gguf_context * ctx, const char * key);
130
+
131
+ // overrides an existing KV pair or adds a new one, the new KV pair is always at the back
132
+ GGML_API void gguf_set_val_u8 (struct gguf_context * ctx, const char * key, uint8_t val);
133
+ GGML_API void gguf_set_val_i8 (struct gguf_context * ctx, const char * key, int8_t val);
134
+ GGML_API void gguf_set_val_u16 (struct gguf_context * ctx, const char * key, uint16_t val);
135
+ GGML_API void gguf_set_val_i16 (struct gguf_context * ctx, const char * key, int16_t val);
136
+ GGML_API void gguf_set_val_u32 (struct gguf_context * ctx, const char * key, uint32_t val);
137
+ GGML_API void gguf_set_val_i32 (struct gguf_context * ctx, const char * key, int32_t val);
138
+ GGML_API void gguf_set_val_f32 (struct gguf_context * ctx, const char * key, float val);
139
+ GGML_API void gguf_set_val_u64 (struct gguf_context * ctx, const char * key, uint64_t val);
140
+ GGML_API void gguf_set_val_i64 (struct gguf_context * ctx, const char * key, int64_t val);
141
+ GGML_API void gguf_set_val_f64 (struct gguf_context * ctx, const char * key, double val);
142
+ GGML_API void gguf_set_val_bool(struct gguf_context * ctx, const char * key, bool val);
143
+ GGML_API void gguf_set_val_str (struct gguf_context * ctx, const char * key, const char * val);
144
+
145
+ // creates a new array with n elements of the given type and copies the corresponding number of bytes from data
146
+ GGML_API void gguf_set_arr_data(struct gguf_context * ctx, const char * key, enum gguf_type type, const void * data, size_t n);
147
+
148
+ // creates a new array with n strings and copies the corresponding strings from data
149
+ GGML_API void gguf_set_arr_str (struct gguf_context * ctx, const char * key, const char ** data, size_t n);
150
+
151
+ // set or add KV pairs from another context
152
+ GGML_API void gguf_set_kv(struct gguf_context * ctx, const struct gguf_context * src);
153
+
154
+ // add tensor to GGUF context, tensor name must be unique
155
+ GGML_API void gguf_add_tensor(struct gguf_context * ctx, const struct ggml_tensor * tensor);
156
+
157
+ // after changing a tensor's type, the offsets of all tensors with higher indices are immediately recalculated
158
+ // in such a way that the tensor data remains as one contiguous block (except for padding)
159
+ GGML_API void gguf_set_tensor_type(struct gguf_context * ctx, const char * name, enum ggml_type type);
160
+
161
+ // assumes that at least gguf_get_tensor_size bytes can be read from data
162
+ GGML_API void gguf_set_tensor_data(struct gguf_context * ctx, const char * name, const void * data);
163
+
164
+ // writing gguf files can be done in 3 ways:
165
+ //
166
+ // - write the entire gguf_context to a binary file in a single pass:
167
+ //
168
+ // gguf_write_to_file(ctx, fname, /*only_meta =*/ false);
169
+ //
170
+ // - write only the meta data to a file, then re-open the file and append the tensor data:
171
+ //
172
+ // gguf_write_to_file(ctx, fname, /*only_meta =*/ true);
173
+ // FILE * f = fopen(fname, "ab");
174
+ // fwrite(f, ...); // write tensor data
175
+ // fclose(f);
176
+ //
177
+ // - first prepare a file with a placeholder for the meta data, write the tensor data, then write the meta data:
178
+ //
179
+ // FILE * f = fopen(fname, "wb");
180
+ // const size_t size_meta = gguf_get_meta_size(ctx);
181
+ // fseek(f, size_meta, SEEK_SET);
182
+ // fwrite(f, ...); // write tensor data
183
+ // void * data = malloc(size_meta);
184
+ // gguf_get_meta_data(ctx, data);
185
+ // rewind(f);
186
+ // fwrite(data, 1, data, f);
187
+ // free(data);
188
+ // fclose(f);
189
+ //
190
+
191
+ // write the entire context to a binary file
192
+ GGML_API bool gguf_write_to_file(const struct gguf_context * ctx, const char * fname, bool only_meta);
193
+
194
+ // get the size in bytes of the meta data (header, kv pairs, tensor info) including padding
195
+ GGML_API size_t gguf_get_meta_size(const struct gguf_context * ctx);
196
+
197
+ // writes the meta data to pointer "data"
198
+ GGML_API void gguf_get_meta_data(const struct gguf_context * ctx, void * data);
199
+
200
+ #ifdef __cplusplus
201
+ }
202
+ #endif
@@ -0,0 +1,281 @@
1
+
2
+
3
+ ####### Expanded from @GGML_VARIABLES_EXPANED@ by configure_package_config_file() #######
4
+ ####### Any changes to this file will be overwritten by the next CMake run #######
5
+
6
+ set(GGML_ACCELERATE "ON")
7
+ set(GGML_ALL_WARNINGS "ON")
8
+ set(GGML_ALL_WARNINGS_3RD_PARTY "OFF")
9
+ set(GGML_AVAILABLE_BACKENDS "ggml-cpu")
10
+ set(GGML_AVX "OFF")
11
+ set(GGML_AVX2 "OFF")
12
+ set(GGML_AVX512 "OFF")
13
+ set(GGML_AVX512_BF16 "OFF")
14
+ set(GGML_AVX512_VBMI "OFF")
15
+ set(GGML_AVX512_VNNI "OFF")
16
+ set(GGML_AVX_VNNI "OFF")
17
+ set(GGML_BACKEND_DL "OFF")
18
+ set(GGML_BLAS "OFF")
19
+ set(GGML_BLAS_DEFAULT "OFF")
20
+ set(GGML_BLAS_VENDOR "Generic")
21
+ set(GGML_BLAS_VENDOR_DEFAULT "Generic")
22
+ set(GGML_BMI2 "OFF")
23
+ set(GGML_BUILD_COMMIT "d62df60")
24
+ set(GGML_BUILD_EXAMPLES "OFF")
25
+ set(GGML_BUILD_NUMBER "1")
26
+ set(GGML_BUILD_TESTS "OFF")
27
+ set(GGML_CCACHE "ON")
28
+ set(GGML_CCACHE_FOUND "GGML_CCACHE_FOUND-NOTFOUND")
29
+ set(GGML_CPU "ON")
30
+ set(GGML_CPU_ALL_VARIANTS "OFF")
31
+ set(GGML_CPU_ARM_ARCH "")
32
+ set(GGML_CPU_HBM "OFF")
33
+ set(GGML_CPU_KLEIDIAI "OFF")
34
+ set(GGML_CPU_POWERPC_CPUTYPE "")
35
+ set(GGML_CPU_REPACK "ON")
36
+ set(GGML_CUDA "OFF")
37
+ set(GGML_CUDA_COMPRESSION_MODE "size")
38
+ set(GGML_CUDA_F16 "OFF")
39
+ set(GGML_CUDA_FA "ON")
40
+ set(GGML_CUDA_FA_ALL_QUANTS "OFF")
41
+ set(GGML_CUDA_FORCE_CUBLAS "OFF")
42
+ set(GGML_CUDA_FORCE_MMQ "OFF")
43
+ set(GGML_CUDA_GRAPHS "OFF")
44
+ set(GGML_CUDA_GRAPHS_DEFAULT "OFF")
45
+ set(GGML_CUDA_NO_PEER_COPY "OFF")
46
+ set(GGML_CUDA_NO_VMM "OFF")
47
+ set(GGML_CUDA_PEER_MAX_BATCH_SIZE "128")
48
+ set(GGML_FATAL_WARNINGS "OFF")
49
+ set(GGML_GPROF "OFF")
50
+ set(GGML_HIP "OFF")
51
+ set(GGML_HIP_FORCE_ROCWMMA_FATTN_GFX12 "OFF")
52
+ set(GGML_HIP_GRAPHS "OFF")
53
+ set(GGML_HIP_NO_VMM "ON")
54
+ set(GGML_HIP_ROCWMMA_FATTN "OFF")
55
+ set(GGML_LASX "ON")
56
+ set(GGML_LLAMAFILE "OFF")
57
+ set(GGML_LLAMAFILE_DEFAULT "OFF")
58
+ set(GGML_LSX "ON")
59
+ set(GGML_LTO "OFF")
60
+ set(GGML_METAL "OFF")
61
+ set(GGML_METAL_DEFAULT "OFF")
62
+ set(GGML_METAL_EMBED_LIBRARY "OFF")
63
+ set(GGML_METAL_MACOSX_VERSION_MIN "")
64
+ set(GGML_METAL_NDEBUG "OFF")
65
+ set(GGML_METAL_SHADER_DEBUG "OFF")
66
+ set(GGML_METAL_STD "")
67
+ set(GGML_METAL_USE_BF16 "OFF")
68
+ set(GGML_MUSA "OFF")
69
+ set(GGML_NATIVE "ON")
70
+ set(GGML_NATIVE_DEFAULT "ON")
71
+ set(GGML_NNPA "ON")
72
+ set(GGML_OPENCL "OFF")
73
+ set(GGML_OPENCL_EMBED_KERNELS "ON")
74
+ set(GGML_OPENCL_PROFILING "OFF")
75
+ set(GGML_OPENCL_TARGET_VERSION "300")
76
+ set(GGML_OPENCL_USE_ADRENO_KERNELS "ON")
77
+ set(GGML_OPENMP "ON")
78
+ set(GGML_PUBLIC_HEADERS "include/ggml.h;include/ggml-cpu.h;include/ggml-alloc.h;include/ggml-backend.h;include/ggml-blas.h;include/ggml-cann.h;include/ggml-cpp.h;include/ggml-cuda.h;include/ggml-opt.h;include/ggml-metal.h;include/ggml-rpc.h;include/ggml-sycl.h;include/ggml-vulkan.h;include/gguf.h")
79
+ set(GGML_RPC "OFF")
80
+ set(GGML_RVV "ON")
81
+ set(GGML_RV_ZFH "OFF")
82
+ set(GGML_SANITIZE_ADDRESS "OFF")
83
+ set(GGML_SANITIZE_THREAD "OFF")
84
+ set(GGML_SANITIZE_UNDEFINED "OFF")
85
+ set(GGML_SCCACHE_FOUND "GGML_SCCACHE_FOUND-NOTFOUND")
86
+ set(GGML_SCHED_MAX_COPIES "4")
87
+ set(GGML_SHARED_LIB "ON")
88
+ set(GGML_SSE42 "OFF")
89
+ set(GGML_STANDALONE "OFF")
90
+ set(GGML_STATIC "OFF")
91
+ set(GGML_SYCL "OFF")
92
+ set(GGML_SYCL_DEVICE_ARCH "")
93
+ set(GGML_SYCL_DNN "ON")
94
+ set(GGML_SYCL_F16 "OFF")
95
+ set(GGML_SYCL_GRAPH "ON")
96
+ set(GGML_SYCL_TARGET "INTEL")
97
+ set(GGML_VULKAN "OFF")
98
+ set(GGML_VULKAN_CHECK_RESULTS "OFF")
99
+ set(GGML_VULKAN_DEBUG "OFF")
100
+ set(GGML_VULKAN_MEMORY_DEBUG "OFF")
101
+ set(GGML_VULKAN_RUN_TESTS "OFF")
102
+ set(GGML_VULKAN_SHADERS_GEN_TOOLCHAIN "")
103
+ set(GGML_VULKAN_SHADER_DEBUG_INFO "OFF")
104
+ set(GGML_VULKAN_VALIDATE "OFF")
105
+ set(GGML_VXE "ON")
106
+ set(GGML_XTHEADVECTOR "OFF")
107
+
108
+
109
+
110
+ ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
111
+ ####### Any changes to this file will be overwritten by the next CMake run ####
112
+ ####### The input file was ggml-config.cmake.in ########
113
+
114
+ get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
115
+
116
+ macro(set_and_check _var _file)
117
+ set(${_var} "${_file}")
118
+ if(NOT EXISTS "${_file}")
119
+ message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
120
+ endif()
121
+ endmacro()
122
+
123
+ macro(check_required_components _NAME)
124
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
125
+ if(NOT ${_NAME}_${comp}_FOUND)
126
+ if(${_NAME}_FIND_REQUIRED_${comp})
127
+ set(${_NAME}_FOUND FALSE)
128
+ endif()
129
+ endif()
130
+ endforeach()
131
+ endmacro()
132
+
133
+ ####################################################################################
134
+
135
+ set_and_check(GGML_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
136
+ set_and_check(GGML_LIB_DIR "${PACKAGE_PREFIX_DIR}/lib")
137
+ #set_and_check(GGML_BIN_DIR "${PACKAGE_PREFIX_DIR}/bin")
138
+
139
+ find_package(Threads REQUIRED)
140
+
141
+ find_library(GGML_LIBRARY ggml
142
+ REQUIRED
143
+ HINTS ${GGML_LIB_DIR}
144
+ NO_CMAKE_FIND_ROOT_PATH)
145
+
146
+ add_library(ggml::ggml UNKNOWN IMPORTED)
147
+ set_target_properties(ggml::ggml
148
+ PROPERTIES
149
+ IMPORTED_LOCATION "${GGML_LIBRARY}")
150
+
151
+ find_library(GGML_BASE_LIBRARY ggml-base
152
+ REQUIRED
153
+ HINTS ${GGML_LIB_DIR}
154
+ NO_CMAKE_FIND_ROOT_PATH)
155
+
156
+ add_library(ggml::ggml-base UNKNOWN IMPORTED)
157
+ set_target_properties(ggml::ggml-base
158
+ PROPERTIES
159
+ IMPORTED_LOCATION "${GGML_BASE_LIBRARY}")
160
+
161
+ if (NOT GGML_SHARED_LIB)
162
+ if (APPLE AND GGML_ACCELERATE)
163
+ find_library(ACCELERATE_FRAMEWORK Accelerate REQUIRED)
164
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${ACCELERATE_FRAMEWORK})
165
+ endif()
166
+
167
+ if (GGML_OPENMP)
168
+ find_package(OpenMP REQUIRED)
169
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_C OpenMP::OpenMP_CXX)
170
+ endif()
171
+
172
+ if (GGML_CPU_HBM)
173
+ find_library(memkind memkind REQUIRED)
174
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES memkind)
175
+ endif()
176
+
177
+ if (GGML_BLAS)
178
+ find_package(BLAS REQUIRED)
179
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES})
180
+ list(APPEND GGML_CPU_INTERFACE_LINK_OPTIONS ${BLAS_LINKER_FLAGS})
181
+ endif()
182
+
183
+ if (GGML_CUDA)
184
+ find_package(CUDAToolkit REQUIRED)
185
+ endif()
186
+
187
+ if (GGML_METAL)
188
+ find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
189
+ find_library(METAL_FRAMEWORK Metal REQUIRED)
190
+ find_library(METALKIT_FRAMEWORK MetalKit REQUIRED)
191
+
192
+ list(APPEND GGML_METAL_INTERFACE_LINK_LIBRARIES
193
+ ${FOUNDATION_LIBRARY} ${METAL_FRAMEWORK} ${METALKIT_FRAMEWORK})
194
+ endif()
195
+
196
+ if (GGML_VULKAN)
197
+ find_package(Vulkan REQUIRED)
198
+ list(APPEND GGML_VULKAN_INTERFACE_LINK_LIBRARIES Vulkan::Vulkan)
199
+ endif()
200
+
201
+ if (GGML_HIP)
202
+ find_package(hip REQUIRED)
203
+ find_package(hipblas REQUIRED)
204
+ find_package(rocblas REQUIRED)
205
+ list(APPEND GGML_HIP_INTERFACE_LINK_LIBRARIES hip::host roc::rocblas roc::hipblas)
206
+ endif()
207
+
208
+ if (GGML_SYCL)
209
+ find_package(DNNL)
210
+ if (${DNNL_FOUND} AND GGML_SYCL_TARGET STREQUAL "INTEL")
211
+ list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES DNNL::dnnl)
212
+ endif()
213
+ if (WIN32)
214
+ find_package(IntelSYCL REQUIRED)
215
+ find_package(MKL REQUIRED)
216
+ list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
217
+ endif()
218
+ endif()
219
+ endif()
220
+
221
+ set(_ggml_all_targets "")
222
+ foreach(_ggml_backend ${GGML_AVAILABLE_BACKENDS})
223
+ string(REPLACE "-" "_" _ggml_backend_pfx "${_ggml_backend}")
224
+ string(TOUPPER "${_ggml_backend_pfx}" _ggml_backend_pfx)
225
+
226
+ find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend}
227
+ REQUIRED
228
+ HINTS ${GGML_LIB_DIR}
229
+ NO_CMAKE_FIND_ROOT_PATH)
230
+
231
+ message(STATUS "Found ${${_ggml_backend_pfx}_LIBRARY}")
232
+
233
+ add_library(ggml::${_ggml_backend} UNKNOWN IMPORTED)
234
+ set_target_properties(ggml::${_ggml_backend}
235
+ PROPERTIES
236
+ INTERFACE_INCLUDE_DIRECTORIES "${GGML_INCLUDE_DIR}"
237
+ IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
238
+ IMPORTED_LOCATION "${${_ggml_backend_pfx}_LIBRARY}"
239
+ INTERFACE_COMPILE_FEATURES c_std_90
240
+ POSITION_INDEPENDENT_CODE ON)
241
+
242
+ string(REGEX MATCH "^ggml-cpu" is_cpu_variant "${_ggml_backend}")
243
+ if(is_cpu_variant)
244
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES "ggml::ggml-base")
245
+ set_target_properties(ggml::${_ggml_backend}
246
+ PROPERTIES
247
+ INTERFACE_LINK_LIBRARIES "${GGML_CPU_INTERFACE_LINK_LIBRARIES}")
248
+
249
+ if(GGML_CPU_INTERFACE_LINK_OPTIONS)
250
+ set_target_properties(ggml::${_ggml_backend}
251
+ PROPERTIES
252
+ INTERFACE_LINK_OPTIONS "${GGML_CPU_INTERFACE_LINK_OPTIONS}")
253
+ endif()
254
+
255
+ else()
256
+ list(APPEND ${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES "ggml::ggml-base")
257
+ set_target_properties(ggml::${_ggml_backend}
258
+ PROPERTIES
259
+ INTERFACE_LINK_LIBRARIES "${${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES}")
260
+
261
+ if(${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS)
262
+ set_target_properties(ggml::${_ggml_backend}
263
+ PROPERTIES
264
+ INTERFACE_LINK_OPTIONS "${${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS}")
265
+ endif()
266
+ endif()
267
+
268
+ list(APPEND _ggml_all_targets ggml::${_ggml_backend})
269
+ endforeach()
270
+
271
+ list(APPEND GGML_INTERFACE_LINK_LIBRARIES ggml::ggml-base "${_ggml_all_targets}")
272
+ set_target_properties(ggml::ggml
273
+ PROPERTIES
274
+ INTERFACE_LINK_LIBRARIES "${GGML_INTERFACE_LINK_LIBRARIES}")
275
+
276
+ add_library(ggml::all INTERFACE IMPORTED)
277
+ set_target_properties(ggml::all
278
+ PROPERTIES
279
+ INTERFACE_LINK_LIBRARIES "${_ggml_all_targets}")
280
+
281
+ check_required_components(ggml)
@@ -0,0 +1,65 @@
1
+ # This is a basic version file for the Config-mode of find_package().
2
+ # It is used by write_basic_package_version_file() as input file for configure_file()
3
+ # to create a version-file which can be installed along a config.cmake file.
4
+ #
5
+ # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6
+ # the requested version string are exactly the same and it sets
7
+ # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
8
+ # but only if the requested major version is the same as the current one.
9
+ # The variable CVF_VERSION must be set before calling configure_file().
10
+
11
+
12
+ set(PACKAGE_VERSION "0.0.1")
13
+
14
+ if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
15
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
16
+ else()
17
+
18
+ if("0.0.1" MATCHES "^([0-9]+)\\.")
19
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
20
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
21
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
22
+ endif()
23
+ else()
24
+ set(CVF_VERSION_MAJOR "0.0.1")
25
+ endif()
26
+
27
+ if(PACKAGE_FIND_VERSION_RANGE)
28
+ # both endpoints of the range must have the expected major version
29
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
30
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
31
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
32
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
33
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
34
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
35
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
36
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
37
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
38
+ else()
39
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
40
+ endif()
41
+ else()
42
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
43
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
44
+ else()
45
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
46
+ endif()
47
+
48
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
49
+ set(PACKAGE_VERSION_EXACT TRUE)
50
+ endif()
51
+ endif()
52
+ endif()
53
+
54
+
55
+ # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
56
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
57
+ return()
58
+ endif()
59
+
60
+ # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
61
+ if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
62
+ math(EXPR installedBits "8 * 8")
63
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
64
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
65
+ endif()
Binary file
Binary file
libggml/lib/ggml.lib ADDED
Binary file
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: libggml-python
3
+ Version: 0.2.0
4
+ Summary: Prebuilt ggml libraries
5
+ Author: benniekiss
6
+ License-Expression: MIT
7
+ Project-URL: Source, https://github.com/benniekiss/libggml-python
8
+ Project-URL: Tracker, https://github.com/benniekiss/libggml-python/issues
9
+ Project-URL: Upstream, https://github.com/ggml-org/ggml
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+
13
+ # libggml-python
14
+
15
+ Python package containing prebuilt [ggml](https://github.com/ggml-org/ggml) libraries.
16
+
17
+ To build additional backends, see the [llama.cpp documentation](https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md)
@@ -0,0 +1,28 @@
1
+ libggml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ libggml/bin/ggml-base.dll,sha256=G2hlkZWJbwmqNc5NXchfun4CD6KGz1XotRXggkAtb4A,508416
3
+ libggml/bin/ggml-cpu.dll,sha256=_vBonItYAwYcuUMabaa6ATB-ECAFVNYLTjhH75fLsys,527872
4
+ libggml/bin/ggml.dll,sha256=EyEzPd_CzIzVwynK6jlbsH-TAVdKH8SKotQRLNsnusg,67072
5
+ libggml/include/ggml-alloc.h,sha256=ICeUcaLveAHSwwX5Y35fLGBS5wLvKrzniGkfkg5Leo4,3087
6
+ libggml/include/ggml-backend.h,sha256=0iybX30rKkCt42nHF5did5K07AMIM8sSm-7oufQ48cQ,20350
7
+ libggml/include/ggml-blas.h,sha256=XGbWYj60VJBBaYGwpd8u6REiwJLQx5wg4SE5-fM4M4E,611
8
+ libggml/include/ggml-cann.h,sha256=dc2nq-Z7-_9UZbJln2t1o6maduJqgCe1pCJPQ1ziMOg,4676
9
+ libggml/include/ggml-cpp.h,sha256=7tG7ys4Uqvre6aJ7t0CgofIDzmWilcv1M8fn3vD6yd4,1691
10
+ libggml/include/ggml-cpu.h,sha256=z_d8qoyFEcCnjX_diehjwr0iLuPBmkRm_ezwQTjuDtg,7551
11
+ libggml/include/ggml-cuda.h,sha256=qqFiJffdn4w6MVhOOw6g0Uo54GFnmZsjBWYZLSvNxZ0,1632
12
+ libggml/include/ggml-metal.h,sha256=CamVFQjraw7iEZg5hMpDmw5eA0x3X_qUWdsBZZmFFHk,2504
13
+ libggml/include/ggml-opt.h,sha256=_8RUQGNz7Ie9lnSTfza1WGeSt1bu5nOsHrY0N9Gkxt8,13577
14
+ libggml/include/ggml-rpc.h,sha256=jqx_LOITVt4b0_BQL-9mQMZeBgoT6ltxCG-77Nrp0Yk,1102
15
+ libggml/include/ggml-sycl.h,sha256=WJW-Sk6poGXcMmXuwPCcmpJG3fJy5uyx4bB12oNHrKo,1812
16
+ libggml/include/ggml-vulkan.h,sha256=C29iUCGwR5B9JLYLPKRB6Kl9RCNfDTKr6yZlESw1QY4,981
17
+ libggml/include/ggml.h,sha256=jeKOWGUupvSwuKAqsPGBZ4jNN53KCMuYUGKdx3IFEjo,92104
18
+ libggml/include/gguf.h,sha256=dGmizdUtMG2dBzbEiu0ebZfF2Abz5smJuCXuEpMFToc,10426
19
+ libggml/lib/cmake/ggml/ggml-config.cmake,sha256=Vp0oaWGgKvphbwiCCaBazGGe-mm6NS12i9tsrFatDZc,9588
20
+ libggml/lib/cmake/ggml/ggml-version.cmake,sha256=jjwF150EMFhlH_ygLSpa0A15L5mJli5tLK1Dor6fSz0,2827
21
+ libggml/lib/ggml-base.lib,sha256=68Kz6jG0ARadxMBpQFfGIFH2a2jc6fmiuR-3Xs5kxW0,133100
22
+ libggml/lib/ggml-cpu.lib,sha256=fTnwITiVyRba7dqkS19OSH9wG3P3sbnWWpKUyc04bmA,15020
23
+ libggml/lib/ggml.lib,sha256=P4rqn4DrmJtjZyZwpg_opaehAYkvBajuYZS8Mmbr6Vo,5288
24
+ libggml_python-0.2.0.dist-info/METADATA,sha256=L0bGAS7SXKnEcjY8Z3Ize7spqqDmGVr2xufyMUsABVs,630
25
+ libggml_python-0.2.0.dist-info/WHEEL,sha256=_PdgJ-W7uMAsWwnGnEdiicDU_PKcobRdffEM23gmN6g,106
26
+ libggml_python-0.2.0.dist-info/entry_points.txt,sha256=C9z2RuQmgnIDl7scr60jjJSXCHGZoJyRnKJ2yXtCm6c,60
27
+ libggml_python-0.2.0.dist-info/licenses/LICENSE,sha256=EI2VwYOftOCg5XVymLE1PFa8_lyHADezZvq5-aA4k08,1088
28
+ libggml_python-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.11.5
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1,6 @@
1
+ [cmake.root]
2
+ ggml = libggml
3
+
4
+ [cmake.prefix]
5
+ ggml = libggml
6
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 benniekiss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.