Skip to content

Commit 6af7435

Browse files
author
katsu560
committed
ggml : add namedobject to GGUF_TYPE for adding files to model file
1 parent 7cf94a2 commit 6af7435

File tree

2 files changed

+299
-93
lines changed

2 files changed

+299
-93
lines changed

include/ggml/ggml.h

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,22 +2258,30 @@ extern "C" {
22582258
//
22592259

22602260
enum gguf_type {
2261-
GGUF_TYPE_UINT8 = 0,
2262-
GGUF_TYPE_INT8 = 1,
2263-
GGUF_TYPE_UINT16 = 2,
2264-
GGUF_TYPE_INT16 = 3,
2265-
GGUF_TYPE_UINT32 = 4,
2266-
GGUF_TYPE_INT32 = 5,
2267-
GGUF_TYPE_FLOAT32 = 6,
2268-
GGUF_TYPE_BOOL = 7,
2269-
GGUF_TYPE_STRING = 8,
2270-
GGUF_TYPE_ARRAY = 9,
2271-
GGUF_TYPE_UINT64 = 10,
2272-
GGUF_TYPE_INT64 = 11,
2273-
GGUF_TYPE_FLOAT64 = 12,
2261+
GGUF_TYPE_UINT8 = 0,
2262+
GGUF_TYPE_INT8 = 1,
2263+
GGUF_TYPE_UINT16 = 2,
2264+
GGUF_TYPE_INT16 = 3,
2265+
GGUF_TYPE_UINT32 = 4,
2266+
GGUF_TYPE_INT32 = 5,
2267+
GGUF_TYPE_FLOAT32 = 6,
2268+
GGUF_TYPE_BOOL = 7,
2269+
GGUF_TYPE_STRING = 8,
2270+
GGUF_TYPE_ARRAY = 9,
2271+
GGUF_TYPE_UINT64 = 10,
2272+
GGUF_TYPE_INT64 = 11,
2273+
GGUF_TYPE_FLOAT64 = 12,
2274+
GGUF_TYPE_NAMEDOBJECT = 13,
22742275
GGUF_TYPE_COUNT, // marks the end of the enum
22752276
};
22762277

2278+
struct gguf_nobj {
2279+
uint64_t nname;
2280+
char * name;
2281+
uint64_t n;
2282+
char * data;
2283+
};
2284+
22772285
struct gguf_context;
22782286

22792287
struct gguf_init_params {
@@ -2303,23 +2311,27 @@ extern "C" {
23032311
GGML_API enum gguf_type gguf_get_kv_type (const struct gguf_context * ctx, int key_id);
23042312
GGML_API enum gguf_type gguf_get_arr_type(const struct gguf_context * ctx, int key_id);
23052313

2314+
GGML_API struct gguf_nobj gguf_find_name_nobj(const struct gguf_context * ctx, const char * name);
2315+
23062316
// will abort if the wrong type is used for the key
2307-
GGML_API uint8_t gguf_get_val_u8 (const struct gguf_context * ctx, int key_id);
2308-
GGML_API int8_t gguf_get_val_i8 (const struct gguf_context * ctx, int key_id);
2309-
GGML_API uint16_t gguf_get_val_u16 (const struct gguf_context * ctx, int key_id);
2310-
GGML_API int16_t gguf_get_val_i16 (const struct gguf_context * ctx, int key_id);
2311-
GGML_API uint32_t gguf_get_val_u32 (const struct gguf_context * ctx, int key_id);
2312-
GGML_API int32_t gguf_get_val_i32 (const struct gguf_context * ctx, int key_id);
2313-
GGML_API float gguf_get_val_f32 (const struct gguf_context * ctx, int key_id);
2314-
GGML_API uint64_t gguf_get_val_u64 (const struct gguf_context * ctx, int key_id);
2315-
GGML_API int64_t gguf_get_val_i64 (const struct gguf_context * ctx, int key_id);
2316-
GGML_API double gguf_get_val_f64 (const struct gguf_context * ctx, int key_id);
2317-
GGML_API bool gguf_get_val_bool(const struct gguf_context * ctx, int key_id);
2318-
GGML_API const char * gguf_get_val_str (const struct gguf_context * ctx, int key_id);
2319-
GGML_API const void * gguf_get_val_data(const struct gguf_context * ctx, int key_id);
2320-
GGML_API int gguf_get_arr_n (const struct gguf_context * ctx, int key_id);
2321-
GGML_API const void * gguf_get_arr_data(const struct gguf_context * ctx, int key_id);
2322-
GGML_API const char * gguf_get_arr_str (const struct gguf_context * ctx, int key_id, int i);
2317+
GGML_API uint8_t gguf_get_val_u8 (const struct gguf_context * ctx, int key_id);
2318+
GGML_API int8_t gguf_get_val_i8 (const struct gguf_context * ctx, int key_id);
2319+
GGML_API uint16_t gguf_get_val_u16 (const struct gguf_context * ctx, int key_id);
2320+
GGML_API int16_t gguf_get_val_i16 (const struct gguf_context * ctx, int key_id);
2321+
GGML_API uint32_t gguf_get_val_u32 (const struct gguf_context * ctx, int key_id);
2322+
GGML_API int32_t gguf_get_val_i32 (const struct gguf_context * ctx, int key_id);
2323+
GGML_API float gguf_get_val_f32 (const struct gguf_context * ctx, int key_id);
2324+
GGML_API uint64_t gguf_get_val_u64 (const struct gguf_context * ctx, int key_id);
2325+
GGML_API int64_t gguf_get_val_i64 (const struct gguf_context * ctx, int key_id);
2326+
GGML_API double gguf_get_val_f64 (const struct gguf_context * ctx, int key_id);
2327+
GGML_API bool gguf_get_val_bool(const struct gguf_context * ctx, int key_id);
2328+
GGML_API const char * gguf_get_val_str (const struct gguf_context * ctx, int key_id);
2329+
GGML_API struct gguf_nobj gguf_get_val_nobj(const struct gguf_context * ctx, int key_id);
2330+
GGML_API const void * gguf_get_val_data(const struct gguf_context * ctx, int key_id);
2331+
GGML_API int gguf_get_arr_n (const struct gguf_context * ctx, int key_id);
2332+
GGML_API const void * gguf_get_arr_data(const struct gguf_context * ctx, int key_id);
2333+
GGML_API const char * gguf_get_arr_str (const struct gguf_context * ctx, int key_id, int i);
2334+
GGML_API struct gguf_nobj gguf_get_arr_nobj(const struct gguf_context * ctx, int key_id, int i);
23232335

23242336
GGML_API int gguf_get_n_tensors (const struct gguf_context * ctx);
23252337
GGML_API int gguf_find_tensor (const struct gguf_context * ctx, const char * name);
@@ -2343,8 +2355,10 @@ extern "C" {
23432355
GGML_API void gguf_set_val_f64 (struct gguf_context * ctx, const char * key, double val);
23442356
GGML_API void gguf_set_val_bool(struct gguf_context * ctx, const char * key, bool val);
23452357
GGML_API void gguf_set_val_str (struct gguf_context * ctx, const char * key, const char * val);
2358+
GGML_API void gguf_set_val_nobj(struct gguf_context * ctx, const char * key, const char * name, const int len, const void * val);
23462359
GGML_API void gguf_set_arr_data(struct gguf_context * ctx, const char * key, enum gguf_type type, const void * data, int n);
23472360
GGML_API void gguf_set_arr_str (struct gguf_context * ctx, const char * key, const char ** data, int n);
2361+
GGML_API void gguf_set_arr_nobj(struct gguf_context * ctx, const char * key, const struct gguf_nobj * data, int n);
23482362

23492363
// set or add KV pairs from another context
23502364
GGML_API void gguf_set_kv(struct gguf_context * ctx, struct gguf_context * src);

0 commit comments

Comments
 (0)