gguf-py readme example fixes for keys: general.architecture and general.alignment
This commit is contained in:
parent
bd90eca237
commit
eda5614f41
2 changed files with 7 additions and 2 deletions
|
@ -15,7 +15,6 @@ def writer_example() -> None:
|
||||||
# Example usage with a file
|
# Example usage with a file
|
||||||
gguf_writer = GGUFWriter("example.gguf", "llama")
|
gguf_writer = GGUFWriter("example.gguf", "llama")
|
||||||
|
|
||||||
gguf_writer.add_architecture()
|
|
||||||
gguf_writer.add_block_count(12)
|
gguf_writer.add_block_count(12)
|
||||||
gguf_writer.add_uint32("answer", 42) # Write a 32-bit integer
|
gguf_writer.add_uint32("answer", 42) # Write a 32-bit integer
|
||||||
gguf_writer.add_float32("answer_in_float", 42.0) # Write a 32-bit float
|
gguf_writer.add_float32("answer_in_float", 42.0) # Write a 32-bit float
|
||||||
|
|
|
@ -107,7 +107,13 @@ class GGUFReader:
|
||||||
offs, tensors_fields = self._build_tensors_fields(offs, tensor_count)
|
offs, tensors_fields = self._build_tensors_fields(offs, tensor_count)
|
||||||
new_align = self.fields.get('general.alignment')
|
new_align = self.fields.get('general.alignment')
|
||||||
if new_align is not None:
|
if new_align is not None:
|
||||||
if new_align.types != [GGUFValueType.UINT64]:
|
if (
|
||||||
|
(
|
||||||
|
new_align.types != [GGUFValueType.UINT64]
|
||||||
|
) and (
|
||||||
|
new_align.types != [GGUFValueType.UINT32]
|
||||||
|
)
|
||||||
|
):
|
||||||
raise ValueError('Bad type for general.alignment field')
|
raise ValueError('Bad type for general.alignment field')
|
||||||
self.alignment = new_align.parts[-1][0]
|
self.alignment = new_align.parts[-1][0]
|
||||||
padding = offs % self.alignment
|
padding = offs % self.alignment
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue