Skip to content

Commit 2327538

Browse files
committed
feat(off-topic): print the number of elements in tensors with llama-gguf
Branch: Mamba2SSD Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
1 parent 42b3837 commit 2327538

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/gguf/gguf.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,12 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) {
184184
const char * name = gguf_get_tensor_name (ctx, i);
185185
const size_t size = gguf_get_tensor_size (ctx, i);
186186
const size_t offset = gguf_get_tensor_offset(ctx, i);
187-
const char * type = ggml_type_name(gguf_get_tensor_type(ctx, i));
187+
const auto type = gguf_get_tensor_type(ctx, i);
188+
const char * type_name = ggml_type_name(type);
189+
const size_t type_size = ggml_type_size(type);
190+
const size_t n_elements = size / type_size;
188191

189-
printf("%s: tensor[%d]: name = %s, size = %zu, offset = %zu, type = %s\n", __func__, i, name, size, offset, type);
192+
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);
190193
}
191194
}
192195

0 commit comments

Comments
 (0)