gguf-py : numpy 2 newbyteorder fix (#9772)

This commit is contained in:
Jett Janiak 2024-12-13 15:48:44 +01:00 committed by GitHub
parent 9f35e44592
commit 4601a8bb67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -145,11 +145,10 @@ class GGUFReader:
count = int(count)
itemsize = int(np.empty([], dtype = dtype).itemsize)
end_offs = offset + itemsize * count
return (
self.data[offset:end_offs]
.view(dtype = dtype)[:count]
.newbyteorder(override_order or self.byte_order)
)
arr = self.data[offset:end_offs].view(dtype=dtype)[:count]
if override_order is None:
return arr
return arr.view(arr.dtype.newbyteorder(override_order))
def _push_field(self, field: ReaderField, skip_sum: bool = False) -> int:
if field.name in self.fields: