Expand description
Descriptor field reads for the Hurray C ABI (ADR-039, ADR-040).
hurray_descriptor_decode validates every
layout and every optional section hurray-core supports, but the scalar
accessors beside it stop at the fixed header. A C caller handed a CSR
descriptor would learn layout_tag == 0x07 and nothing more — not nnz, not
which buffer is row_ptr — and one handed a per-block-quantized tensor would
learn nothing at all about the scheme. This module is what closes that gap.
§Five functions, not seventy
The layout payloads and the five optional sections hold about seventy fields
between them. Rather than one accessor each, a field is named by a
HurrayDescriptorField identifier and read through one of five typed
functions:
| Function | Reads |
|---|---|
hurray_descriptor_field_u64 | every unsigned or boolean scalar |
hurray_descriptor_field_i64 | signed scalars (zero_point) |
hurray_descriptor_field_f64 | real scalars (scale, the statistics) |
hurray_descriptor_field_u64_array | tile_shape, morton_bits, mode_order, parent_shape, shard_offset |
hurray_descriptor_field_i64_array | strides, outer_strides, inner_strides |
A new layout or section adds identifier constants, not symbols — which is how
the wire format itself evolves (ADR-019), applied to the ABI. The trade is
that a C compiler cannot check a field against the sub-object in hand; a
mismatch is HURRAY_ERR_FIELD_NOT_APPLICABLE at runtime instead.
§Reading one
Scalars are a single call. Arrays use the capacity/length in-out pattern
hurray_descriptor_shape
established: pass the capacity in *out_len, read the true length back out,
and retry after HURRAY_ERR_BUFFER_TOO_SMALL.
Constants§
- HURRAY_
COMPOSITE_ MEMBER_ FIELD_ ROLE - This tensor’s role within its enclosing composite: correction
0x00, base0x01. - HURRAY_
EXT_ TYPE_ FIELD_ BIT_ WIDTH - Width of one element in bits.
- HURRAY_
EXT_ TYPE_ FIELD_ EXPONENT_ BIAS - Exponent bias;
0for integer types. - HURRAY_
EXT_ TYPE_ FIELD_ EXPONENT_ BITS - Number of exponent bits;
0for integer types. - HURRAY_
EXT_ TYPE_ FIELD_ HAS_ INF - Whether the type encodes infinity.
0or1. - HURRAY_
EXT_ TYPE_ FIELD_ HAS_ NAN - Whether the type encodes NaN.
0or1. - HURRAY_
EXT_ TYPE_ FIELD_ IS_ FLOAT - Whether the type is floating-point.
0or1. - HURRAY_
EXT_ TYPE_ FIELD_ IS_ SIGNED - Whether the type is signed.
0or1. - HURRAY_
EXT_ TYPE_ FIELD_ MANTISSA_ BITS - Number of mantissa bits.
- HURRAY_
EXT_ TYPE_ FIELD_ PACKING_ FACTOR - Elements packed per storage byte;
1when unpacked. - HURRAY_
EXT_ TYPE_ FIELD_ SIGN_ BITS - Number of sign bits.
- HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ INDEX_ TYPE - Block-paged (
0x0A) block-table element width:u320x00,u640x01. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ KV_ ROLE - Block-paged (
0x0A) KV role wire byte: key0x00, value0x01, fused0x02. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ LAYER_ INDEX - Block-paged (
0x0A) transformer layer index. Optional. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ NUM_ PAGES - Block-paged (
0x0A) total pages in the shared pool. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ NUM_ SEQS - Block-paged (
0x0A) number of sequences sharing the pool. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ PAGED_ AXIS - Block-paged (
0x0A) index of the paged axis. - HURRAY_
LAYOUT_ FIELD_ BLOCK_ PAGED_ PAGE_ SIZE - Block-paged (
0x0A) elements per page along the paged axis. - HURRAY_
LAYOUT_ FIELD_ COMPOSITE_ COMBINE_ OP - Composite (
0x0B) combine-op wire byte;0x00unless the rule is overlay. - HURRAY_
LAYOUT_ FIELD_ COMPOSITE_ MEMBER_ COUNT - Composite (
0x0B) number of member descriptors following the head. - HURRAY_
LAYOUT_ FIELD_ COMPOSITE_ RULE - Composite (
0x0B) composition rule wire byte. - HURRAY_
LAYOUT_ FIELD_ COO_ IS_ SORTED - COO (
0x06) whether coordinates are in lexicographic order.0or1. - HURRAY_
LAYOUT_ FIELD_ COO_ NNZ - COO (
0x06) stored non-zero count. - HURRAY_
LAYOUT_ FIELD_ CSC_ NNZ - CSC (
0x08) stored non-zero count. - HURRAY_
LAYOUT_ FIELD_ CSF_ MODE_ ORDER - CSF (
0x09) mode storage order. Unsigned array. - HURRAY_
LAYOUT_ FIELD_ CSF_ NNZ - CSF (
0x09) stored non-zero count. - HURRAY_
LAYOUT_ FIELD_ CSR_ NNZ - CSR (
0x07) stored non-zero count. - HURRAY_
LAYOUT_ FIELD_ HILBERT_ ORDER - Hilbert (
0x40) curve order; every dimension equals2^order. - HURRAY_
LAYOUT_ FIELD_ HILBERT_ RANK - Hilbert (
0x40) curve rank. - HURRAY_
LAYOUT_ FIELD_ MORTON_ BITS - Morton (
0x05) per-dimension interleave bit counts. Unsigned array. - HURRAY_
LAYOUT_ FIELD_ STRIDED_ STRIDES - Strided (
0x03) per-dimension strides, in logical elements. Signed array. - HURRAY_
LAYOUT_ FIELD_ TILED_ DEPTH - Tiled (
0x04) number of nesting levels fromleveldownward. - HURRAY_
LAYOUT_ FIELD_ TILED_ INNER_ LAYOUT - Tiled (
0x04) layout tag governing the order of elements within a tile. - HURRAY_
LAYOUT_ FIELD_ TILED_ INNER_ STRIDES - Tiled (
0x04) explicit strides within a tile. Signed array, optional. - HURRAY_
LAYOUT_ FIELD_ TILED_ OUTER_ LAYOUT - Tiled (
0x04) layout tag governing the order of tiles. - HURRAY_
LAYOUT_ FIELD_ TILED_ OUTER_ STRIDES - Tiled (
0x04) explicit strides between tiles. Signed array, optional. - HURRAY_
LAYOUT_ FIELD_ TILED_ TILE_ SHAPE - Tiled (
0x04) tile extent per dimension. Unsigned array. - HURRAY_
QUANT_ FIELD_ MXFP_ AXIS - MXFP (
0x05) quantization axis. - HURRAY_
QUANT_ FIELD_ MXFP_ BLOCK_ SIZE - MXFP (
0x05) elements per quantization block. - HURRAY_
QUANT_ FIELD_ MXFP_ SCALE_ BUFFER - MXFP (
0x05) buffer index holding the shared-exponent vector. - HURRAY_
QUANT_ FIELD_ NF4_ AXIS - NF4 (
0x04) quantization axis. - HURRAY_
QUANT_ FIELD_ NF4_ BLOCK_ SIZE - NF4 (
0x04) elements per quantization block. - HURRAY_
QUANT_ FIELD_ NF4_ SCALE_ BUFFER - NF4 (
0x04) buffer index holding the scale vector. - HURRAY_
QUANT_ FIELD_ PER_ BLOCK_ AXIS - Per-block affine (
0x03) quantization axis. - HURRAY_
QUANT_ FIELD_ PER_ BLOCK_ BLOCK_ SIZE - Per-block affine (
0x03) elements per quantization block. - HURRAY_
QUANT_ FIELD_ PER_ BLOCK_ SCALE_ BUFFER - Per-block affine (
0x03) buffer index holding the scale vector. - HURRAY_
QUANT_ FIELD_ PER_ BLOCK_ SCALE_ TYPE - Per-block affine (
0x03) element type tag of the scale vector. - HURRAY_
QUANT_ FIELD_ PER_ BLOCK_ ZERO_ POINT_ BUFFER - Per-block affine (
0x03) buffer index holding the zero-point vector. Absent for a symmetric scheme. - HURRAY_
QUANT_ FIELD_ PER_ CHANNEL_ AXIS - Per-channel affine (
0x02) quantization axis. - HURRAY_
QUANT_ FIELD_ PER_ CHANNEL_ SCALE_ BUFFER - Per-channel affine (
0x02) buffer index holding the scale vector. - HURRAY_
QUANT_ FIELD_ PER_ CHANNEL_ SCALE_ TYPE - Per-channel affine (
0x02) element type tag of the scale vector. - HURRAY_
QUANT_ FIELD_ PER_ CHANNEL_ ZERO_ POINT_ BUFFER - Per-channel affine (
0x02) buffer index holding the zero-point vector. Absent for a symmetric scheme. - HURRAY_
QUANT_ FIELD_ PER_ TENSOR_ SCALE - Per-tensor affine (
0x01) scale. Real scalar,float32on the wire. - HURRAY_
QUANT_ FIELD_ PER_ TENSOR_ ZERO_ POINT - Per-tensor affine (
0x01) zero point. Signed scalar,int32on the wire. - HURRAY_
QUANT_ FIELD_ SCHEME_ TAG - Quantization scheme tag of the section this descriptor carries: per-tensor
affine
0x01, per-channel affine0x02, per-block affine0x03, NF40x04, MXFP0x05. - HURRAY_
SHARD_ FIELD_ PARENT_ SHAPE - Shape of the logical parent tensor. Unsigned array, length equal to the rank.
- HURRAY_
SHARD_ FIELD_ SHARD_ OFFSET - This shard’s starting index within the parent. Unsigned array, length equal to the rank.
- HURRAY_
STATS_ FIELD_ COMPUTED_ MASK - Raw
computed_maskbitfield. Always present when the section is. - HURRAY_
STATS_ FIELD_ HAS_ INF - Whether any element is infinite.
0or1, guarded byNAN_INF_VALID(bit 5). - HURRAY_
STATS_ FIELD_ HAS_ NAN - Whether any element is NaN.
0or1, guarded byNAN_INF_VALID(bit 5). - HURRAY_
STATS_ FIELD_ NM_ M Mof N:M structured sparsity. Guarded byNM_SPARSITY_VALID(bit 4).- HURRAY_
STATS_ FIELD_ NM_ N Nof N:M structured sparsity. Guarded byNM_SPARSITY_VALID(bit 4).- HURRAY_
STATS_ FIELD_ NNZ - Non-zero element count. Guarded by
NNZ_VALID(bit 0). - HURRAY_
STATS_ FIELD_ SPARSITY_ RATIO - Fraction of elements that are zero. Real scalar, guarded by
SPARSITY_VALID(bit 1). - HURRAY_
STATS_ FIELD_ VALUE_ ABS_ MAX - Largest absolute stored value. Real scalar, guarded by
VALUE_RANGE_VALID(bit 2). - HURRAY_
STATS_ FIELD_ VALUE_ MAX - Largest stored value. Real scalar, guarded by
VALUE_RANGE_VALID(bit 2). - HURRAY_
STATS_ FIELD_ VALUE_ MEAN - Arithmetic mean. Real scalar, guarded by
VALUE_STATS_VALID(bit 3). - HURRAY_
STATS_ FIELD_ VALUE_ MIN - Smallest stored value. Real scalar, guarded by
VALUE_RANGE_VALID(bit 2). - HURRAY_
STATS_ FIELD_ VALUE_ STDDEV - Standard deviation. Real scalar, guarded by
VALUE_STATS_VALID(bit 3).
Functions§
- hurray_
descriptor_ ⚠field_ f64 - Reads a real scalar field of the descriptor.
- hurray_
descriptor_ ⚠field_ i64 - Reads a signed scalar field of the descriptor.
- hurray_
descriptor_ ⚠field_ i64_ array - Reads a signed array field of the descriptor.
- hurray_
descriptor_ ⚠field_ u64 - Reads an unsigned or boolean scalar field of the descriptor.
- hurray_
descriptor_ ⚠field_ u64_ array - Reads an unsigned array field of the descriptor.
Type Aliases§
- Hurray
Descriptor Field - Identifies one field of a tensor descriptor’s layout payload or of one of its optional sections.