|
241 | 241 | #define GGML_ROPE_TYPE_MROPE 8
|
242 | 242 | #define GGML_ROPE_TYPE_VISION 24
|
243 | 243 |
|
244 |
| -#define GGUF_MAGIC "GGUF" |
245 |
| - |
246 |
| -#define GGUF_VERSION 3 |
247 |
| - |
248 |
| -#define GGUF_DEFAULT_ALIGNMENT 32 |
249 |
| - |
250 | 244 | #define GGML_UNUSED(x) (void)(x)
|
251 | 245 |
|
252 | 246 | #define GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
|
@@ -403,12 +397,6 @@ extern "C" {
|
403 | 397 | GGML_PREC_F32,
|
404 | 398 | };
|
405 | 399 |
|
406 |
| - enum ggml_backend_type { |
407 |
| - GGML_BACKEND_TYPE_CPU = 0, |
408 |
| - GGML_BACKEND_TYPE_GPU = 10, |
409 |
| - GGML_BACKEND_TYPE_GPU_SPLIT = 20, |
410 |
| - }; |
411 |
| - |
412 | 400 | // model file types
|
413 | 401 | enum ggml_ftype {
|
414 | 402 | GGML_FTYPE_UNKNOWN = -1,
|
@@ -587,8 +575,6 @@ extern "C" {
|
587 | 575 | struct ggml_tensor {
|
588 | 576 | enum ggml_type type;
|
589 | 577 |
|
590 |
| - GGML_DEPRECATED(enum ggml_backend_type backend, "use the buffer type to find the storage location of the tensor"); |
591 |
| - |
592 | 578 | struct ggml_backend_buffer * buffer;
|
593 | 579 |
|
594 | 580 | int64_t ne[GGML_MAX_DIMS]; // number of elements
|
@@ -2111,132 +2097,6 @@ extern "C" {
|
2111 | 2097 | int64_t n_per_row,
|
2112 | 2098 | const float * imatrix);
|
2113 | 2099 |
|
2114 |
| - // |
2115 |
| - // gguf |
2116 |
| - // |
2117 |
| - |
2118 |
| - enum gguf_type { |
2119 |
| - GGUF_TYPE_UINT8 = 0, |
2120 |
| - GGUF_TYPE_INT8 = 1, |
2121 |
| - GGUF_TYPE_UINT16 = 2, |
2122 |
| - GGUF_TYPE_INT16 = 3, |
2123 |
| - GGUF_TYPE_UINT32 = 4, |
2124 |
| - GGUF_TYPE_INT32 = 5, |
2125 |
| - GGUF_TYPE_FLOAT32 = 6, |
2126 |
| - GGUF_TYPE_BOOL = 7, |
2127 |
| - GGUF_TYPE_STRING = 8, |
2128 |
| - GGUF_TYPE_ARRAY = 9, |
2129 |
| - GGUF_TYPE_UINT64 = 10, |
2130 |
| - GGUF_TYPE_INT64 = 11, |
2131 |
| - GGUF_TYPE_FLOAT64 = 12, |
2132 |
| - GGUF_TYPE_COUNT, // marks the end of the enum |
2133 |
| - }; |
2134 |
| - |
2135 |
| - struct gguf_context; |
2136 |
| - |
2137 |
| - struct gguf_init_params { |
2138 |
| - bool no_alloc; |
2139 |
| - |
2140 |
| - // if not NULL, create a ggml_context and allocate the tensor data in it |
2141 |
| - struct ggml_context ** ctx; |
2142 |
| - }; |
2143 |
| - |
2144 |
| - GGML_API struct gguf_context * gguf_init_empty(void); |
2145 |
| - GGML_API struct gguf_context * gguf_init_from_file(const char * fname, struct gguf_init_params params); |
2146 |
| - //GGML_API struct gguf_context * gguf_init_from_buffer(..); |
2147 |
| - |
2148 |
| - GGML_API void gguf_free(struct gguf_context * ctx); |
2149 |
| - |
2150 |
| - GGML_API const char * gguf_type_name(enum gguf_type type); |
2151 |
| - |
2152 |
| - GGML_API int gguf_get_version (const struct gguf_context * ctx); |
2153 |
| - GGML_API size_t gguf_get_alignment (const struct gguf_context * ctx); |
2154 |
| - GGML_API size_t gguf_get_data_offset(const struct gguf_context * ctx); |
2155 |
| - GGML_API void * gguf_get_data (const struct gguf_context * ctx); |
2156 |
| - |
2157 |
| - GGML_API int gguf_get_n_kv(const struct gguf_context * ctx); |
2158 |
| - GGML_API int gguf_find_key(const struct gguf_context * ctx, const char * key); |
2159 |
| - GGML_API const char * gguf_get_key (const struct gguf_context * ctx, int key_id); |
2160 |
| - |
2161 |
| - GGML_API enum gguf_type gguf_get_kv_type (const struct gguf_context * ctx, int key_id); |
2162 |
| - GGML_API enum gguf_type gguf_get_arr_type(const struct gguf_context * ctx, int key_id); |
2163 |
| - |
2164 |
| - // will abort if the wrong type is used for the key |
2165 |
| - GGML_API uint8_t gguf_get_val_u8 (const struct gguf_context * ctx, int key_id); |
2166 |
| - GGML_API int8_t gguf_get_val_i8 (const struct gguf_context * ctx, int key_id); |
2167 |
| - GGML_API uint16_t gguf_get_val_u16 (const struct gguf_context * ctx, int key_id); |
2168 |
| - GGML_API int16_t gguf_get_val_i16 (const struct gguf_context * ctx, int key_id); |
2169 |
| - GGML_API uint32_t gguf_get_val_u32 (const struct gguf_context * ctx, int key_id); |
2170 |
| - GGML_API int32_t gguf_get_val_i32 (const struct gguf_context * ctx, int key_id); |
2171 |
| - GGML_API float gguf_get_val_f32 (const struct gguf_context * ctx, int key_id); |
2172 |
| - GGML_API uint64_t gguf_get_val_u64 (const struct gguf_context * ctx, int key_id); |
2173 |
| - GGML_API int64_t gguf_get_val_i64 (const struct gguf_context * ctx, int key_id); |
2174 |
| - GGML_API double gguf_get_val_f64 (const struct gguf_context * ctx, int key_id); |
2175 |
| - GGML_API bool gguf_get_val_bool(const struct gguf_context * ctx, int key_id); |
2176 |
| - GGML_API const char * gguf_get_val_str (const struct gguf_context * ctx, int key_id); |
2177 |
| - GGML_API const void * gguf_get_val_data(const struct gguf_context * ctx, int key_id); |
2178 |
| - GGML_API int gguf_get_arr_n (const struct gguf_context * ctx, int key_id); |
2179 |
| - GGML_API const void * gguf_get_arr_data(const struct gguf_context * ctx, int key_id); |
2180 |
| - GGML_API const char * gguf_get_arr_str (const struct gguf_context * ctx, int key_id, int i); |
2181 |
| - |
2182 |
| - GGML_API int gguf_get_n_tensors (const struct gguf_context * ctx); |
2183 |
| - GGML_API int gguf_find_tensor (const struct gguf_context * ctx, const char * name); |
2184 |
| - GGML_API size_t gguf_get_tensor_offset(const struct gguf_context * ctx, int i); |
2185 |
| - GGML_API char * gguf_get_tensor_name (const struct gguf_context * ctx, int i); |
2186 |
| - GGML_API enum ggml_type gguf_get_tensor_type (const struct gguf_context * ctx, int i); |
2187 |
| - |
2188 |
| - // removes key if it exists |
2189 |
| - GGML_API void gguf_remove_key(struct gguf_context * ctx, const char * key); |
2190 |
| - |
2191 |
| - // overrides existing values or adds a new one |
2192 |
| - GGML_API void gguf_set_val_u8 (struct gguf_context * ctx, const char * key, uint8_t val); |
2193 |
| - GGML_API void gguf_set_val_i8 (struct gguf_context * ctx, const char * key, int8_t val); |
2194 |
| - GGML_API void gguf_set_val_u16 (struct gguf_context * ctx, const char * key, uint16_t val); |
2195 |
| - GGML_API void gguf_set_val_i16 (struct gguf_context * ctx, const char * key, int16_t val); |
2196 |
| - GGML_API void gguf_set_val_u32 (struct gguf_context * ctx, const char * key, uint32_t val); |
2197 |
| - GGML_API void gguf_set_val_i32 (struct gguf_context * ctx, const char * key, int32_t val); |
2198 |
| - GGML_API void gguf_set_val_f32 (struct gguf_context * ctx, const char * key, float val); |
2199 |
| - GGML_API void gguf_set_val_u64 (struct gguf_context * ctx, const char * key, uint64_t val); |
2200 |
| - GGML_API void gguf_set_val_i64 (struct gguf_context * ctx, const char * key, int64_t val); |
2201 |
| - GGML_API void gguf_set_val_f64 (struct gguf_context * ctx, const char * key, double val); |
2202 |
| - GGML_API void gguf_set_val_bool(struct gguf_context * ctx, const char * key, bool val); |
2203 |
| - GGML_API void gguf_set_val_str (struct gguf_context * ctx, const char * key, const char * val); |
2204 |
| - GGML_API void gguf_set_arr_data(struct gguf_context * ctx, const char * key, enum gguf_type type, const void * data, int n); |
2205 |
| - GGML_API void gguf_set_arr_str (struct gguf_context * ctx, const char * key, const char ** data, int n); |
2206 |
| - |
2207 |
| - // set or add KV pairs from another context |
2208 |
| - GGML_API void gguf_set_kv(struct gguf_context * ctx, struct gguf_context * src); |
2209 |
| - |
2210 |
| - // manage tensor info |
2211 |
| - GGML_API void gguf_add_tensor(struct gguf_context * ctx, const struct ggml_tensor * tensor); |
2212 |
| - GGML_API void gguf_set_tensor_type(struct gguf_context * ctx, const char * name, enum ggml_type type); |
2213 |
| - GGML_API void gguf_set_tensor_data(struct gguf_context * ctx, const char * name, const void * data, size_t size); |
2214 |
| - |
2215 |
| - // writing gguf files can be done in 2 ways: |
2216 |
| - // |
2217 |
| - // - write the entire gguf_context to a binary file in a single pass: |
2218 |
| - // |
2219 |
| - // gguf_write_to_file(ctx, fname); |
2220 |
| - // |
2221 |
| - // - first prepare a file with a placeholder for the meta data, write the tensor data, then write the meta data: |
2222 |
| - // |
2223 |
| - // FILE * f = fopen(fname, "wb"); |
2224 |
| - // fseek(f, gguf_get_meta_size(ctx), SEEK_SET); |
2225 |
| - // fwrite(f, ...); |
2226 |
| - // void * data = gguf_meta_get_meta_data(ctx); |
2227 |
| - // fseek(f, 0, SEEK_SET); |
2228 |
| - // fwrite(f, data, gguf_get_meta_size(ctx)); |
2229 |
| - // free(data); |
2230 |
| - // fclose(f); |
2231 |
| - // |
2232 |
| - |
2233 |
| - // write the entire context to a binary file |
2234 |
| - GGML_API void gguf_write_to_file(const struct gguf_context * ctx, const char * fname, bool only_meta); |
2235 |
| - |
2236 |
| - // get the size in bytes of the meta data (header, kv pairs, tensor info) including padding |
2237 |
| - GGML_API size_t gguf_get_meta_size(const struct gguf_context * ctx); |
2238 |
| - GGML_API void gguf_get_meta_data(const struct gguf_context * ctx, void * data); |
2239 |
| - |
2240 | 2100 | #ifdef __cplusplus
|
2241 | 2101 | // restrict not standard in C++
|
2242 | 2102 | # if defined(__GNUC__)
|
|
0 commit comments