11#include  " ggml.h" 
2+ #include  " gguf.h" 
23
34#include  < cstdio> 
4- #include  < cinttypes> 
55#include  < string> 
66#include  < sstream> 
7- #include  < fstream> 
87#include  < vector> 
98
109#undef  MIN
@@ -135,9 +134,10 @@ static bool gguf_ex_read_0(const std::string & fname) {
135134
136135        for  (int  i = 0 ; i < n_tensors; ++i) {
137136            const  char  * name   = gguf_get_tensor_name   (ctx, i);
137+             const  size_t  size   = gguf_get_tensor_size   (ctx, i);
138138            const  size_t  offset = gguf_get_tensor_offset (ctx, i);
139139
140-             printf (" %s: tensor[%d]: name = %s, offset = %zu\n " 
140+             printf (" %s: tensor[%d]: name = %s, size = %zu,  offset = %zu\n " , size , offset);
141141        }
142142    }
143143
@@ -182,9 +182,10 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) {
182182
183183        for  (int  i = 0 ; i < n_tensors; ++i) {
184184            const  char  * name   = gguf_get_tensor_name   (ctx, i);
185+             const  size_t  size   = gguf_get_tensor_size   (ctx, i);
185186            const  size_t  offset = gguf_get_tensor_offset (ctx, i);
186187
187-             printf (" %s: tensor[%d]: name = %s, offset = %zu\n " 
188+             printf (" %s: tensor[%d]: name = %s, size = %zu,  offset = %zu\n " , size , offset);
188189        }
189190    }
190191
@@ -199,7 +200,8 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) {
199200
200201            struct  ggml_tensor  * cur = ggml_get_tensor (ctx_data, name);
201202
202-             printf (" %s: tensor[%d]: n_dims = %d, name = %s, data = %p\n " ggml_n_dims (cur), cur->name , cur->data );
203+             printf (" %s: tensor[%d]: n_dims = %d, ne = (%d, %d, %d, %d), name = %s, data = %p\n " 
204+                 __func__, i, ggml_n_dims (cur), int (cur->ne [0 ]), int (cur->ne [1 ]), int (cur->ne [2 ]), int (cur->ne [3 ]), cur->name , cur->data );
203205
204206            //  print first 10 elements
205207            const  float  * data = (const  float  *) cur->data ;
@@ -215,7 +217,7 @@ static bool gguf_ex_read_1(const std::string & fname, bool check_data) {
215217                const  float  * data = (const  float  *) cur->data ;
216218                for  (int  j = 0 ; j < ggml_nelements (cur); ++j) {
217219                    if  (data[j] != 100  + i) {
218-                         fprintf (stderr, " %s: tensor[%d]:  data[%d] =  %f\n " 
220+                         fprintf (stderr, " %s: tensor[%d],  data[%d]: found  %f, expected %f \n " ,  float ( 100  + i) );
219221                        gguf_free (ctx);
220222                        return  false ;
221223                    }
@@ -245,6 +247,8 @@ int main(int argc, char ** argv) {
245247        check_data = false ;
246248    }
247249
250+     srand (123456 );
251+ 
248252    const  std::string fname (argv[1 ]);
249253    const  std::string mode  (argv[2 ]);
250254
0 commit comments