mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-27 03:44:35 +00:00
gguf : add gguf_get_kv_type
This commit is contained in:
parent
b2440f1943
commit
eb8ca6996f
4
ggml.c
4
ggml.c
@ -19031,6 +19031,10 @@ const char * gguf_get_key(struct gguf_context * ctx, int i) {
|
||||
return ctx->header.kv[i].key.data;
|
||||
}
|
||||
|
||||
const enum gguf_type gguf_get_kv_type(struct gguf_context * ctx, int i) {
|
||||
return ctx->header.kv[i].type;
|
||||
}
|
||||
|
||||
const char * gguf_get_arr_str(struct gguf_context * ctx, int key_id, int i) {
|
||||
struct gguf_kv * kv = &ctx->header.kv[key_id];
|
||||
struct gguf_str * str = &((struct gguf_str *) kv->value.arr.data)[i];
|
||||
|
9
ggml.h
9
ggml.h
@ -1744,10 +1744,11 @@ extern "C" {
|
||||
GGML_API size_t gguf_get_data_offset(struct gguf_context * ctx);
|
||||
GGML_API void * gguf_get_data (struct gguf_context * ctx);
|
||||
|
||||
GGML_API int gguf_get_n_kv(struct gguf_context * ctx);
|
||||
GGML_API int gguf_find_key(struct gguf_context * ctx, const char * key);
|
||||
GGML_API const char * gguf_get_key (struct gguf_context * ctx, int i);
|
||||
GGML_API void gguf_get_val (struct gguf_context * ctx, int i, void * val);
|
||||
GGML_API int gguf_get_n_kv(struct gguf_context * ctx);
|
||||
GGML_API int gguf_find_key(struct gguf_context * ctx, const char * key);
|
||||
GGML_API const char * gguf_get_key (struct gguf_context * ctx, int i);
|
||||
GGML_API const enum gguf_type gguf_get_kv_type (struct gguf_context * ctx, int i);
|
||||
GGML_API void gguf_get_val (struct gguf_context * ctx, int i, void * val);
|
||||
|
||||
GGML_API const char * gguf_get_arr_str(struct gguf_context * ctx, int key_id, int i);
|
||||
GGML_API float gguf_get_arr_f32(struct gguf_context * ctx, int key_id, int i);
|
||||
|
@ -652,6 +652,9 @@ struct gguf_file_saver {
|
||||
const char * key = gguf_get_key(any_file_loader->gguf_ctx, i);
|
||||
if (strcmp(key, "general.quantization_version") == 0) {
|
||||
file.write_val<uint32_t>("general.quantization_version", GGUF_TYPE_UINT32, new_ftype);
|
||||
} else {
|
||||
const gguf_type vtype = gguf_get_kv_type(any_file_loader->gguf_ctx, i);
|
||||
GGML_UNUSED(vtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user