Skip to main content

Module csf

Module csf 

Source
Expand description

CSF (Compressed Sparse Fiber) element lookup and storage-invariant validation.

Implements the per-level binary-search descent from docs/spec/layouts/csf.md § Element Lookup and the invariant checks from docs/spec/layouts/csf.md § Storage Invariants.

All arithmetic uses checked_* to avoid silent overflow — this code can run on arbitrarily large tensors.

Functions§

element_offset
Looks up the storage offset (values buffer index) for a logical index in a CSF tensor, or returns None if the element is structurally absent (implicit zero).
validate_index_buffers
Validates the storage invariants for all CSF index buffers.