gguf-dump: add --data-offset
This commit is contained in:
parent
9a590c8226
commit
b664c3cad7
2 changed files with 6 additions and 1 deletions
|
@ -69,6 +69,7 @@ class GGUFReader:
|
||||||
# I - same as host, S - swapped
|
# I - same as host, S - swapped
|
||||||
byte_order: Literal['I'] | Literal['S'] = 'I'
|
byte_order: Literal['I'] | Literal['S'] = 'I'
|
||||||
alignment: int = GGUF_DEFAULT_ALIGNMENT
|
alignment: int = GGUF_DEFAULT_ALIGNMENT
|
||||||
|
start_data_offset: int
|
||||||
|
|
||||||
# Note: Internal helper, API may change.
|
# Note: Internal helper, API may change.
|
||||||
gguf_scalar_to_np: dict[GGUFValueType, type[np.generic]] = {
|
gguf_scalar_to_np: dict[GGUFValueType, type[np.generic]] = {
|
||||||
|
@ -117,6 +118,7 @@ class GGUFReader:
|
||||||
padding = offs % self.alignment
|
padding = offs % self.alignment
|
||||||
if padding != 0:
|
if padding != 0:
|
||||||
offs += self.alignment - padding
|
offs += self.alignment - padding
|
||||||
|
self.start_data_offset = offs
|
||||||
self._build_tensors(offs, tensors_fields)
|
self._build_tensors(offs, tensors_fields)
|
||||||
|
|
||||||
_DT = TypeVar('_DT', bound = npt.DTypeLike)
|
_DT = TypeVar('_DT', bound = npt.DTypeLike)
|
||||||
|
|
|
@ -364,6 +364,7 @@ def main() -> None:
|
||||||
parser.add_argument("--no-tensors", action="store_true", help="Don't dump tensor metadata")
|
parser.add_argument("--no-tensors", action="store_true", help="Don't dump tensor metadata")
|
||||||
parser.add_argument("--json", action="store_true", help="Produce JSON output")
|
parser.add_argument("--json", action="store_true", help="Produce JSON output")
|
||||||
parser.add_argument("--json-array", action="store_true", help="Include full array values in JSON output (long)")
|
parser.add_argument("--json-array", action="store_true", help="Include full array values in JSON output (long)")
|
||||||
|
parser.add_argument("--data-offset", action="store_true", help="Start of data offset")
|
||||||
parser.add_argument("--markdown", action="store_true", help="Produce markdown output")
|
parser.add_argument("--markdown", action="store_true", help="Produce markdown output")
|
||||||
parser.add_argument("--verbose", action="store_true", help="increase output verbosity")
|
parser.add_argument("--verbose", action="store_true", help="increase output verbosity")
|
||||||
|
|
||||||
|
@ -371,7 +372,7 @@ def main() -> None:
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
|
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)
|
||||||
|
|
||||||
if not args.json and not args.markdown:
|
if not args.json and not args.markdown and not args.data_offset:
|
||||||
logger.info(f'* Loading: {args.model}')
|
logger.info(f'* Loading: {args.model}')
|
||||||
|
|
||||||
reader = GGUFReader(args.model, 'r')
|
reader = GGUFReader(args.model, 'r')
|
||||||
|
@ -380,6 +381,8 @@ def main() -> None:
|
||||||
dump_metadata_json(reader, args)
|
dump_metadata_json(reader, args)
|
||||||
elif args.markdown:
|
elif args.markdown:
|
||||||
dump_markdown_metadata(reader, args)
|
dump_markdown_metadata(reader, args)
|
||||||
|
elif args.data_offset:
|
||||||
|
print(reader.start_data_offset)
|
||||||
else:
|
else:
|
||||||
dump_metadata(reader, args)
|
dump_metadata(reader, args)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue