@@ -134,12 +134,12 @@ def __init__(self, path: os.PathLike[str] | str, mode: Literal['r', 'r+', 'c'] =
134134 offs = 0
135135
136136 # Check for GGUF magic
137- if self ._get (offs , np .uint32 , override_order = '<' )[0 ] != GGUF_MAGIC :
137+ if self ._get (offs , np .dtype ( np . uint32 ) , override_order = '<' )[0 ] != GGUF_MAGIC :
138138 raise ValueError ('GGUF magic invalid' )
139139 offs += 4
140140
141141 # Check GGUF version
142- temp_version = self ._get (offs , np .uint32 )
142+ temp_version = self ._get (offs , np .dtype ( np . uint32 ) )
143143 if temp_version [0 ] & 65535 == 0 :
144144 # If we get 0 here that means it's (probably) a GGUF file created for
145145 # the opposite byte order of the machine this script is running on.
@@ -162,7 +162,7 @@ def __init__(self, path: os.PathLike[str] | str, mode: Literal['r', 'r+', 'c'] =
162162 offs += self ._push_field (ReaderField (offs , 'GGUF.version' , [temp_version ], [0 ], [GGUFValueType .UINT32 ]))
163163
164164 # Check tensor count and kv count
165- temp_counts = self ._get (offs , np .uint64 , 2 )
165+ temp_counts = self ._get (offs , np .dtype ( np . uint64 ) , 2 )
166166 offs += self ._push_field (ReaderField (offs , 'GGUF.tensor_count' , [temp_counts [:1 ]], [0 ], [GGUFValueType .UINT64 ]))
167167 offs += self ._push_field (ReaderField (offs , 'GGUF.kv_count' , [temp_counts [1 :]], [0 ], [GGUFValueType .UINT64 ]))
168168 tensor_count , kv_count = temp_counts
@@ -212,8 +212,8 @@ def _push_field(self, field: ReaderField, skip_sum: bool = False) -> int:
212212 return 0 if skip_sum else sum (int (part .nbytes ) for part in field .parts )
213213
214214 def _get_str (self , offset : int ) -> tuple [npt .NDArray [np .uint64 ], npt .NDArray [np .uint8 ]]:
215- slen = self ._get (offset , np .uint64 )
216- return slen , self ._get (offset + 8 , np .uint8 , slen [0 ].item ())
215+ slen = self ._get (offset , np .dtype ( np . uint64 ) )
216+ return slen , self ._get (offset + 8 , np .dtype ( np . uint8 ) , slen [0 ].item ())
217217
218218 def _get_field_parts (
219219 self , orig_offs : int , raw_type : int ,
@@ -234,9 +234,9 @@ def _get_field_parts(
234234 return int (val .nbytes ), [val ], [0 ], types
235235 # Handle arrays.
236236 if gtype == GGUFValueType .ARRAY :
237- raw_itype = self ._get (offs , np .uint32 )
237+ raw_itype = self ._get (offs , np .dtype ( np . uint32 ) )
238238 offs += int (raw_itype .nbytes )
239- alen = self ._get (offs , np .uint64 )
239+ alen = self ._get (offs , np .dtype ( np . uint64 ) )
240240 offs += int (alen .nbytes )
241241 aparts : list [npt .NDArray [Any ]] = [raw_itype , alen ]
242242 data_idxs : list [int ] = []
@@ -261,19 +261,19 @@ def _get_tensor_info_field(self, orig_offs: int) -> ReaderField:
261261 offs += int (name_len .nbytes + name_data .nbytes )
262262
263263 # Get Tensor Dimensions Count
264- n_dims = self ._get (offs , np .uint32 )
264+ n_dims = self ._get (offs , np .dtype ( np . uint32 ) )
265265 offs += int (n_dims .nbytes )
266266
267267 # Get Tensor Dimension Array
268- dims = self ._get (offs , np .uint64 , n_dims [0 ].item ())
268+ dims = self ._get (offs , np .dtype ( np . uint64 ) , n_dims [0 ].item ())
269269 offs += int (dims .nbytes )
270270
271271 # Get Tensor Encoding Scheme Type
272- raw_dtype = self ._get (offs , np .uint32 )
272+ raw_dtype = self ._get (offs , np .dtype ( np . uint32 ) )
273273 offs += int (raw_dtype .nbytes )
274274
275275 # Get Tensor Offset
276- offset_tensor = self ._get (offs , np .uint64 )
276+ offset_tensor = self ._get (offs , np .dtype ( np . uint64 ) )
277277 offs += int (offset_tensor .nbytes )
278278
279279 return ReaderField (
@@ -288,7 +288,7 @@ def _build_fields(self, offs: int, count: int) -> int:
288288 orig_offs = offs
289289 kv_klen , kv_kdata = self ._get_str (offs )
290290 offs += int (kv_klen .nbytes + kv_kdata .nbytes )
291- raw_kv_type = self ._get (offs , np .uint32 )
291+ raw_kv_type = self ._get (offs , np .dtype ( np . uint32 ) )
292292 offs += int (raw_kv_type .nbytes )
293293 parts : list [npt .NDArray [Any ]] = [kv_klen , kv_kdata , raw_kv_type ]
294294 idxs_offs = len (parts )
@@ -352,7 +352,7 @@ def _build_tensors(self, start_offs: int, fields: list[ReaderField]) -> None:
352352 item_type = np .dtype (np .int64 )
353353 else :
354354 item_count = n_bytes
355- item_type = np .uint8
355+ item_type = np .dtype ( np . uint8 )
356356 np_dims = quant_shape_to_byte_shape (np_dims , ggml_type )
357357 tensors .append (ReaderTensor (
358358 name = tensor_name ,
0 commit comments