From 42b38373e78dd3dc54d4960d2777cb94c2b2b7aa Mon Sep 17 00:00:00 2001 From: Gabe Goodhart Date: Fri, 26 Sep 2025 16:43:39 -0600 Subject: [PATCH 1/4] feat(llama-gguf): Print out the tensor type in llama-gguf r Branch: Mamba2Perf Signed-off-by: Gabe Goodhart --- examples/gguf/gguf.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index f31989c8c55c6..1bf8e705e359c 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -184,8 +184,9 @@ 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 char * type = ggml_type_name(gguf_get_tensor_type(ctx, i)); - printf("%s: tensor[%d]: name = %s, size = %zu, offset = %zu\n", __func__, i, name, size, offset); + printf("%s: tensor[%d]: name = %s, size = %zu, offset = %zu, type = %s\n", __func__, i, name, size, offset, type); } } From 2327538284f9a402440f6f4228ae15d59a983e56 Mon Sep 17 00:00:00 2001 From: Gabe Goodhart Date: Tue, 4 Nov 2025 14:12:13 -0700 Subject: [PATCH 2/4] feat(off-topic): print the number of elements in tensors with llama-gguf Branch: Mamba2SSD Signed-off-by: Gabe Goodhart --- examples/gguf/gguf.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index 1bf8e705e359c..d28ede1c12927 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -184,9 +184,12 @@ 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 char * type = ggml_type_name(gguf_get_tensor_type(ctx, i)); + const auto type = gguf_get_tensor_type(ctx, i); + 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", __func__, i, name, size, offset, type); + 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); } } From 752869f367cd29056e40cd97e546739b0d91db45 Mon Sep 17 00:00:00 2001 From: Gabe Goodhart Date: Wed, 5 Nov 2025 10:50:36 -0700 Subject: [PATCH 3/4] style: valign Branch: GGUFToolOutputs Signed-off-by: Gabe Goodhart --- examples/gguf/gguf.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index d28ede1c12927..d247faefcdc27 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -181,12 +181,12 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) { printf("%s: n_tensors: %d\n", __func__, n_tensors); for (int i = 0; i < n_tensors; ++i) { - 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); - const char * type_name = ggml_type_name(type); - const size_t type_size = ggml_type_size(type); + 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); + 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); From 6b7eca96cd95b1ce10634420fe84445a082bd92c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Wed, 5 Nov 2025 19:58:03 +0200 Subject: [PATCH 4/4] Update examples/gguf/gguf.cpp --- examples/gguf/gguf.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/gguf/gguf.cpp b/examples/gguf/gguf.cpp index d247faefcdc27..499cfacc92aa9 100644 --- a/examples/gguf/gguf.cpp +++ b/examples/gguf/gguf.cpp @@ -181,10 +181,11 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) { printf("%s: n_tensors: %d\n", __func__, n_tensors); for (int i = 0; i < n_tensors; ++i) { - 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); + 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); + 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;