Skip to content

Commit 3f06cef

Browse files
author
katsu560
committed
delete gguf_find_key_array()
1 parent e18593c commit 3f06cef

File tree

3 files changed

+2
-43
lines changed

3 files changed

+2
-43
lines changed

examples/yolo/yolov3-tiny.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ static bool load_labels(const char * filename, std::vector<std::string> & labels
159159

160160
static bool load_labels_gguf(const struct gguf_context * ctx, const char * filename, std::vector<std::string> & labels)
161161
{
162-
int key_id = gguf_find_key_array(ctx, "embedded_files", filename);
163-
if (key_id == -1) {
164-
return false;
165-
}
166162
int tensor = gguf_find_tensor(ctx, filename);
167163
if (tensor == -1) {
168164
return false;
@@ -206,11 +202,6 @@ static bool load_alphabet_gguf(const struct gguf_context * ctx, std::vector<yolo
206202
for (int i = 32; i < 127; i++) {
207203
char fname[256];
208204
sprintf(fname, "data/labels/%d_%d.png", i, j);
209-
int key_id = gguf_find_key_array(ctx, "embedded_files", fname);
210-
if (key_id == -1) {
211-
fprintf(stderr, "Cannot find '%s' in embedded_files\n", fname);
212-
return false;
213-
}
214205
int tensor = gguf_find_tensor(ctx, fname);
215206
if (tensor == -1) {
216207
fprintf(stderr, "Cannot find '%s' in tensor\n", fname);
@@ -602,15 +593,15 @@ int main(int argc, char *argv[])
602593
}
603594
std::vector<std::string> labels;
604595
if (!load_labels_gguf(model.ctx_gguf, "data/coco.names", labels)) {
605-
fprintf(stderr, "%s: failed to load labels from 'data/coco.names' in model\n", __func__);
596+
fprintf(stderr, "%s: skipped loading labels from 'data/coco.names' in model\n", __func__);
606597
if (!load_labels("data/coco.names", labels)) {
607598
fprintf(stderr, "%s: failed to load labels from 'data/coco.names'\n", __func__);
608599
return 1;
609600
}
610601
}
611602
std::vector<yolo_image> alphabet;
612603
if (!load_alphabet_gguf(model.ctx_gguf, alphabet)) {
613-
fprintf(stderr, "%s: failed to load alphabet from model\n", __func__);
604+
fprintf(stderr, "%s: skipped loading alphabet from model\n", __func__);
614605
if (!load_alphabet(alphabet)) {
615606
fprintf(stderr, "%s: failed to load alphabet\n", __func__);
616607
return 1;

include/ggml/ggml.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,6 @@ extern "C" {
23052305

23062306
GGML_API int gguf_get_n_kv(const struct gguf_context * ctx);
23072307
GGML_API int gguf_find_key(const struct gguf_context * ctx, const char * key);
2308-
GGML_API int gguf_find_key_array(const struct gguf_context * ctx, const char * key, const char * val);
23092308
GGML_API const char * gguf_get_key (const struct gguf_context * ctx, int key_id);
23102309

23112310
GGML_API enum gguf_type gguf_get_kv_type (const struct gguf_context * ctx, int key_id);

src/ggml.c

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21791,37 +21791,6 @@ int gguf_find_key(const struct gguf_context * ctx, const char * key) {
2179121791
return keyfound;
2179221792
}
2179321793

21794-
int gguf_find_key_array(const struct gguf_context * ctx, const char * key, const char * val) {
21795-
// return -1 if key not found
21796-
int keyfound = -1;
21797-
int key_id = -1;
21798-
21799-
const int n_kv = gguf_get_n_kv(ctx);
21800-
21801-
for (int i = 0; i < n_kv; ++i) {
21802-
if (strcmp(key, gguf_get_key(ctx, i)) == 0) {
21803-
key_id = i;
21804-
break;
21805-
}
21806-
}
21807-
21808-
if (key_id != -1) {
21809-
if (ctx->kv[key_id].type == GGUF_TYPE_ARRAY) {
21810-
const int n = gguf_get_arr_n(ctx, key_id);
21811-
struct gguf_kv * kv = &ctx->kv[key_id];
21812-
21813-
for (int i = 0; i < n; ++i) {
21814-
struct gguf_str * str = &((struct gguf_str *) kv->value.arr.data)[i];
21815-
if (strcmp(val, str->data) == 0) {
21816-
keyfound = i;
21817-
}
21818-
}
21819-
}
21820-
}
21821-
21822-
return keyfound;
21823-
}
21824-
2182521794
const char * gguf_get_key(const struct gguf_context * ctx, int key_id) {
2182621795
GGML_ASSERT(key_id >= 0 && key_id < gguf_get_n_kv(ctx));
2182721796
return ctx->kv[key_id].key.data;

0 commit comments

Comments
 (0)