Native shaped tensor storage #
Rep α shape owns one contiguous row-major buffer selected by
Storage α. Its proof field certifies that the buffer length is exactly
Shape.size shape, while its coordinate-function view supplies the
mathematical observation semantics.
A contiguous row-major tensor whose storage length is certified by its shape.
The proof is erased by code generation. At runtime a tensor is therefore its selected native buffer, rather than a coordinate closure or a second semantic representation.
- buffer : Storage.Buffer α
Contiguous row-major scalar storage.
The storage has exactly one entry for every coordinate of the shape.
Instances For
Read one row-major entry using a platform-native array index.
The explicit bound is the same safety certificate carried by Fin in
getFlat. This form is used by generated kernels whose index arithmetic has
already been proved to fit USize, avoiding boxed natural-number indexing in
the scalar loop.
Instances For
Platform-native and finite flat reads agree at the same row-major position.
Generic arrays satisfy this definitionally. Specialized storage proves it through the common ordinary-array observation.
Changing a native flat index along an equality does not change the observed tensor entry. The two bounds proofs may differ because their types mention the index; proof irrelevance removes that distinction after the indices agree.
Replace one row-major entry while preserving the tensor's static shape.
Packed storage performs a native copy-on-write update. Other storage types use
the universal array-backed update capability supplied by Storage.Update.
Instances For
Replace the entry at a statically valid multidimensional coordinate.
Instances For
Transform the entry at one statically valid coordinate.
Instances For
Render a tensor as shape-aware nested lists, with rank-zero tensors rendered as their scalar value.
The recursion follows the coordinate type itself, so it works uniformly at every rank and renders a zero-length axis as an empty list.
Instances For
Print a finite dependent tensor family in component order.
This includes the result type returned by unpack; each component retains
its own statically checked shape and uses the ordinary tensor representation.
Build a tensor with a platform-native flat-index loop when its static size
fits USize, and retain the universal finite-index construction otherwise.
The native and semantic callbacks are connected by an erased certificate. Ordinary executable tensor shapes therefore use unboxed loop counters and native storage reads, while the representation remains total for arbitrary mathematical shapes.
Instances For
Rebuilding a tensor from a buffer equal to Array.ofFn values gives the
canonical flat-function tensor.
This theorem lets verified native builders replace their certified output buffer without exposing proof-field equality to generated code.
Native flat construction has the ordinary finite-index tensor semantics.
Executable tensors have decidable elementwise equality whenever their scalar type does.
The comparison uses the storage's certified ordinary-array observation. Equality of those observations determines equality of the native buffers, while the size certificates are proof-irrelevant.
Native tensor traversal agrees with folding the proof-facing observation.
The proof-facing ordinary array observation has the statically known tensor
size. Evaluating data may convert specialized storage, so native kernels use
buffer, getFlat, and getFlatUSize instead.
Reading a flat entry immediately after replacing it returns the new value.