Module Nx_io.Gguf
GGUF files.
A GGUF file holds a model's arrays and its metadata, key-values that describe the architecture, the tokenizer and the file itself, as GGML's specification defines them. Each array is stored as one GGUF type (Gguf.dtype). A scalar type stores each element whole, and a block format stores the elements of a row in blocks of a fixed number of elements and bytes. An array's logical shape is its shape in elements, in row-major order (Gguf.tensor_info).
An array of a scalar type loads at its logical shape. An array of a block format loads as its bytes, at uint8, at its logical shape with the last extent replaced by the size of a row in bytes. A Q8_0 block is 32 elements in 34 bytes, so a Q8_0 array of logical shape [|m; 64|] loads at shape [|m; 68|].
type value = The type for metadata values, one case per GGUF value type. An unsigned 64-bit value is held in int64 by its bits. An array's elements are of one type.
type dtype = The type for GGUF storage types. F32, F16, BF16, F64, I8, I16, I32 and I64 are the scalar types, which load as float32, float16, bfloat16, float64, int8, int16, int32 and int64. The others are block formats.
type tensor_info = {- #
dtype : dtype;(*The type the array is stored as.
*) - #
shape : int array;(*The array's logical shape, the reverse of the dimensions the file lists, whose first varies fastest.
*)
}The type for an array's description in the file.
type tThe type for the contents of a GGUF file.
val info : string -> t -> tensor_infoinfo name g is the description of g's array name.
Raises Failure if g has no array name.