File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import torch
2+ from gguf import GGUFReader
3+
4+ def print_tensors (r : GGUFReader ):
5+ print (f"Total number of tensors: { len (r .tensors )} \n " )
6+ for tensor in r .tensors :
7+ print (f"Name: { tensor .name } " )
8+ print (f" shape: { tensor .shape } , type: { tensor .tensor_type } , elements: { tensor .n_elements } " )
9+
10+ def print_tensor (r : GGUFReader , name : str ):
11+ tensor = next (t for t in r .tensors if t .name == name )
12+ print (f"Tensor: { tensor .name } " )
13+ print (f" shape: { tensor .shape } , type: { tensor .tensor_type } , elements: { tensor .n_elements } " )
14+ print (f" data:\n { tensor .data } " )
15+
16+ def print_field (r : GGUFReader , field_name : str ):
17+ field = r .get_field (field_name )
18+ print (f"Field: { field_name } " )
19+ print (f" contents: { field .contents ()} " )
20+ print (f" type: { type (field )} , value: { field } " )
21+
22+ def main ():
23+ gguf_path = "/home/danbev/work/ai/llama.cpp/models/granite-4.0-h-tiny-Q4_0.gguf"
24+ r = GGUFReader (gguf_path )
25+ #print_tensors(r)
26+ print_tensor (r , "blk.39.ssm_in.weight" )
27+
28+ print_field (r , "granitehybrid.expert_used_count" )
29+ if __name__ == "__main__" :
30+ main ()
You can’t perform that action at this time.
0 commit comments