Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gguf.cpp : find key example
  • Loading branch information
klosax authored Jul 28, 2023
commit e9d2990c3dcb3afc0d70050c7f97263d72d0f678
14 changes: 14 additions & 0 deletions examples/gguf/gguf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,20 @@ bool gguf_ex_read_0(const std::string & fname) {
}
}

// find kv string
{
char findkey[32];
sprintf(findkey, "some.parameter.string");

int keyidx = gguf_find_key(ctx, findkey);
if (keyidx == -1) {
fprintf(stdout, "%s: find key: %s not found.\n", __func__, findkey);
} else {
const char * key_value = gguf_get_val_str(ctx, keyidx);
fprintf(stdout, "%s: find key: %s found, kv[%d] value = %s\n", __func__, findkey, keyidx, key_value);
}
}

// tensor info
{
const int n_tensors = gguf_get_n_tensors(ctx);
Expand Down