code format
This commit is contained in:
parent
ad6fd8de25
commit
6a13722ca5
1 changed files with 2 additions and 3 deletions
|
@ -6,7 +6,6 @@ from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import mmap
|
|
||||||
import struct
|
import struct
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from typing import Any, Literal, NamedTuple, TypeVar, Union
|
from typing import Any, Literal, NamedTuple, TypeVar, Union
|
||||||
|
@ -133,7 +132,7 @@ class GGUFReader:
|
||||||
offs += self.alignment - padding
|
offs += self.alignment - padding
|
||||||
self.data_offset = offs
|
self.data_offset = offs
|
||||||
self._build_tensors(offs, tensors_fields)
|
self._build_tensors(offs, tensors_fields)
|
||||||
|
|
||||||
def __del__(self) -> None:
|
def __del__(self) -> None:
|
||||||
self.data.close()
|
self.data.close()
|
||||||
|
|
||||||
|
@ -174,7 +173,7 @@ class GGUFReader:
|
||||||
def _get_str(self, offset: int, return_size=False) -> tuple[npt.NDArray[np.uint64], npt.NDArray[np.uint8]]:
|
def _get_str(self, offset: int, return_size=False) -> tuple[npt.NDArray[np.uint64], npt.NDArray[np.uint8]]:
|
||||||
self.data.seek(offset)
|
self.data.seek(offset)
|
||||||
slen = struct.unpack('<Q', self.data.read(8))
|
slen = struct.unpack('<Q', self.data.read(8))
|
||||||
sdata = struct.unpack('<'+'B'*slen[0], self.data.read(1*slen[0]))
|
sdata = struct.unpack('<' + 'B' * slen[0], self.data.read(slen[0]))
|
||||||
output = (slen, sdata)
|
output = (slen, sdata)
|
||||||
if return_size:
|
if return_size:
|
||||||
output += (8 + slen[0],)
|
output += (8 + slen[0],)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue