From 8083ae347a1c2aef99435716f9106ad31ea78fa5 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Mon, 7 Aug 2023 19:02:18 +0300 Subject: [PATCH] gguf : minor stuff --- examples/gguf/gguf.cpp | 11 +++++------ ggml.c | 4 ---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index 671f8748f..a1b8edc71 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -256,10 +256,9 @@ bool gguf_ex_read_0(const std::string & fname) { // find kv string { - char findkey[32]; - sprintf(findkey, "some.parameter.string"); + const char * findkey = "some.parameter.string"; - int keyidx = gguf_find_key(ctx, findkey); + const int keyidx = gguf_find_key(ctx, findkey); if (keyidx == -1) { fprintf(stdout, "%s: find key: %s not found.\n", __func__, findkey); } else { @@ -297,7 +296,7 @@ bool gguf_ex_read_1(const std::string & fname) { }; struct gguf_context * ctx = gguf_init_from_file(fname.c_str(), params); - + fprintf(stdout, "%s: version: %d\n", __func__, gguf_get_version(ctx)); fprintf(stdout, "%s: alignment: %zu\n", __func__, gguf_get_alignment(ctx)); fprintf(stdout, "%s: data offset: %zu\n", __func__, gguf_get_data_offset(ctx)); @@ -388,7 +387,7 @@ bool gguf_ex_read_2(const std::string & fname) { // print first 10 elements const float * data = (const float *) cur->data; - + printf("%s data[:10] : ", name); for (int j = 0; j < 10; ++j) { @@ -402,7 +401,7 @@ fprintf(stdout, "%s: ctx_data size: %zu\n", __func__, ggml_get_mem_size(ctx_data ggml_free(ctx_data); gguf_free(ctx); - + return true; } diff --git a/ggml.c b/ggml.c index d3d745333..df8dce7e8 100644 --- a/ggml.c +++ b/ggml.c @@ -19031,10 +19031,6 @@ const char * gguf_get_key(struct gguf_context * ctx, int i) { return ctx->header.kv[i].key.data; } -enum gguf_type gguf_get_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];