@@ -47,6 +47,8 @@ constexpr const GGUFVersion kGGUFVersionV1 = 1;
4747constexpr  const  GGUFVersion kGGUFVersionV2  = 2 ;
4848constexpr  const  GGUFVersion kGGUFVersionV3  = 3 ;
4949
50+ constexpr  std::size_t  kMaxElementsToShow  = 50 ;
51+ 
5052enum  GGUFMetadataValueType : uint32_t  {
5153  GGUFMetadataValueTypeUint8 = 0 ,
5254  GGUFMetadataValueTypeInt8,
@@ -127,10 +129,21 @@ inline std::string to_string(GGUFMetadataValueType vt, const std::any& v) {
127129  return  " array" 
128130}
129131inline  std::string to_string (const  GGUFMetadataKVArrayValue& arr_v) {
130-   std::string res;
131-   auto  num = std::min (size_t (5 ), arr_v.arr .size ());
132-   for  (size_t  i = 0 ; i < num; i++) {
133-     res += to_string (arr_v.type , arr_v.arr [i]) + "  " 
132+   std::string res = " [" 
133+   size_t  array_size = arr_v.arr .size ();
134+   size_t  elementsToShow = std::min (kMaxElementsToShow , array_size);
135+   for  (size_t  i = 0 ; i < elementsToShow; i++) {
136+     res += to_string (arr_v.type , arr_v.arr [i]) + " , " 
137+   }
138+   if (array_size > 0 ) {
139+     res.pop_back ();
140+     res.pop_back ();
141+   }
142+   res += " ]" 
143+   if (array_size > elementsToShow) {
144+     res += " ... (" 
145+     res += std::to_string (array_size - elementsToShow);
146+     res += "  more elements)" 
134147  }
135148  return  res;
136149}
@@ -191,6 +204,9 @@ struct GGUFTensorInfo {
191204  // 
192205  //  The offset is the start of the file.
193206  int64_t  start_offset;
207+ 
208+   GGUFTensorInfo ()
209+   : name(" " 0 ), dimensions(), type(GGMLType{}), offset(0 ), start_offset(0 ) {}
194210};
195211
196212struct  GGUFHelper  {
@@ -419,6 +435,10 @@ struct GGUFHeader {
419435  //  MetadataKV are the key-value pairs in the metadata,
420436  std::vector<GGUFMetadataKV> metadata_kv;
421437
438+   //  Constructor to initialize member variables.
439+   GGUFHeader ()
440+     : magic{0 }, version{0 }, tensor_count(0 ), metadata_kv_count(0 ), metadata_kv() {}
441+ 
422442  std::pair<GGUFMetadataKV, bool > Get (const  std::string& name) {
423443    for  (auto  const & kv : metadata_kv) {
424444      if  (kv.key  == name) {
@@ -478,6 +498,20 @@ struct GGUFFile {
478498  //  which describes how many bits are used to store a weight,
479499  //  higher is better.
480500  double  model_bits_per_weight;
501+ 
502+   GGUFFile ()
503+     : header(),
504+       tensor_infos (),
505+       padding(0 ),
506+       split_paddings(),
507+       tensor_data_start_offset(-1 ),
508+       split_tensor_data_start_offsets(),
509+       size(0 ),
510+       split_sizes(),
511+       model_size(0 ),
512+       split_model_sizes(),
513+       model_parameters(0 ),
514+       model_bits_per_weight(0.0 ) {}
481515};
482516
483517inline  std::optional<GGUFFile> ParseGgufFile (const  std::string& path) {
0 commit comments