Equivalent of readMetadataValue(), skips unused values rather than storing
| 80 | |
| 81 | // Equivalent of readMetadataValue(), skips unused values rather than storing |
| 82 | static bool gguf_skip_value(gguf_buf_reader & r, int32_t vtype) { |
| 83 | if (vtype == GGUF_TYPE_STRING) { |
| 84 | std::string tmp; |
| 85 | return r.read_str(tmp); |
| 86 | } |
| 87 | if (vtype == GGUF_TYPE_ARRAY) { |
| 88 | int32_t elem_type; |
| 89 | uint64_t count; |
| 90 | if (!r.read_val(elem_type)) { |
| 91 | return false; |
| 92 | } |
| 93 | if (!r.read_val(count)) { |
| 94 | return false; |
| 95 | } |
| 96 | if (elem_type == GGUF_TYPE_STRING) { |
| 97 | for (uint64_t i = 0; i < count; i++) { |
| 98 | std::string tmp; |
| 99 | if (!r.read_str(tmp)) { |
| 100 | return false; |
| 101 | } |
| 102 | } |
| 103 | return true; |
| 104 | } |
| 105 | if (elem_type == GGUF_TYPE_ARRAY) { |
| 106 | // nested arrays - recurse |
| 107 | for (uint64_t i = 0; i < count; i++) { |
| 108 | if (!gguf_skip_value(r, GGUF_TYPE_ARRAY)) { |
| 109 | return false; |
| 110 | } |
| 111 | } |
| 112 | return true; |
| 113 | } |
| 114 | size_t elem_sz = gguf_val_type_size(elem_type); |
| 115 | if (elem_sz == 0) { |
| 116 | return false; |
| 117 | } |
| 118 | return r.skip((size_t)count * elem_sz); |
| 119 | } |
| 120 | size_t sz = gguf_val_type_size(vtype); |
| 121 | if (sz == 0) { |
| 122 | return false; |
| 123 | } |
| 124 | return r.skip(sz); |
| 125 | } |
| 126 | |
| 127 | static bool gguf_read_uint32_val(gguf_buf_reader & r, int32_t vtype, uint32_t & out) { |
| 128 | // Handle array-valued fields (e.g. per-layer head counts in hybrid models) |
no test coverage detected