From 5886f4f545591dafbbd9d6117a46d7399ce13bfa Mon Sep 17 00:00:00 2001 From: Gabe Goodhart Date: Wed, 5 Nov 2025 10:58:16 -0700 Subject: [PATCH] examples(gguf): GGUF example outputs (#17025) * feat(llama-gguf): Print out the tensor type in llama-gguf r Branch: Mamba2Perf Signed-off-by: Gabe Goodhart * feat(off-topic): print the number of elements in tensors with llama-gguf Branch: Mamba2SSD Signed-off-by: Gabe Goodhart * style: valign Branch: GGUFToolOutputs Signed-off-by: Gabe Goodhart * Update examples/gguf/gguf.cpp --------- Signed-off-by: Gabe Goodhart Co-authored-by: Georgi Gerganov --- examples/gguf/gguf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index f31989c8c5..499cfacc92 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -184,8 +184,13 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) { const char * name = gguf_get_tensor_name (ctx, i); const size_t size = gguf_get_tensor_size (ctx, i); const size_t offset = gguf_get_tensor_offset(ctx, i); + const auto type = gguf_get_tensor_type (ctx, i); - printf("%s: tensor[%d]: name = %s, size = %zu, offset = %zu\n", __func__, i, name, size, offset); + const char * type_name = ggml_type_name(type); + const size_t type_size = ggml_type_size(type); + const size_t n_elements = size / type_size; + + printf("%s: tensor[%d]: name = %s, size = %zu, offset = %zu, type = %s, n_elts = %zu\n", __func__, i, name, size, offset, type_name, n_elements); } }