TensorEncoding
Physical storage encoding — how tensor data is laid out in memory.
A TensorEncoding describes the byte-level format of a buffer, independent of the logical numeric type (LogicalDType). For example, a FLOAT32 tensor may be stored as Dense (4 bytes per element) or as Q4_K (packed 4-bit blocks with per-block scales).
Encodings are sealed so that pattern-matching in loaders and backends is exhaustive and compiler-checked.
Inheritors
Types
Dense element-per-slot layout. One element occupies a fixed number of bytes.
Opaque / unknown encoding. Used as a fallback for formats the runtime cannot yet interpret but still wants to carry through without error.
GGML Q4_K block quantization: 256 elements per 144-byte block.
GGML Q8_0 block quantization: 32 elements per 34-byte block.
Ternary encoding: 2 bits per element, packed 4 elements per byte.
TurboQuant PolarOnly encoding: rotation + scalar quantization + bit-packing.
TurboQuant PolarPlusQjl encoding: rotation + scalar quantization + QJL residual + bit-packing.
Properties
Functions
Physical bytes required to store elementCount logical elements in this encoding, or null if the encoding is opaque/variable.