Flat-index lowering for fused shape transformations #
A sequence of rearrangements, repeats, and arbitrary coordinate pullbacks can be represented by one output-to-source coordinate map. The compiler also carries a proof that a flat-index map denotes the same coordinate program. This module executes that certified flat map directly over native tensor storage, avoiding multidimensional coordinate construction in the output loop.
The kernel is independent of transform kind, tensor rank, scalar type, and chain length. Its correctness theorem reconnects the executable flat-index program to the ordinary coordinate pullback semantics.
Certificates that relate flat and coordinate maps compose at every pair of intermediate shapes.
Transporting an intermediate shape equality preserves a certified flat map.
The coordinate and flat transports are both identity operations after substituting the shape equality, so this theorem keeps dependent shape alignment out of generated scalar loops.
Recover a coordinate projection from an arbitrary row-major flat-index map.
This is the semantic view of a native flat pullback. It lets later consumers compose directly with an already compiled source-index program without reconstructing the checked transformation that produced it.
Instances For
Linearizing coordinateMapOfFlatMap recovers the original flat map.
Primitive rearrangement is a flat-index pullback along any certified representation of its output-to-input coordinate map.
This theorem lets elaboration replace the generic checked-plan interpreter with a partially evaluated index program without relying on definitional equality between the two implementations.
Primitive rearrangement is exactly one certified flat-index pullback.
This form is used by downstream fusion passes that consume a rearranged tensor without allocating its intermediate output buffer.
Primitive repeat is a flat-index pullback along any certified representation of its output-to-input coordinate map.
Primitive repeat is exactly one certified flat-index pullback.
The statement is independent of rank, scalar type, and the number of repeated axes, so consumer fusion needs no repeat-specific execution path.
An equality with a flat pullback certifies direct reads from the source tensor.
Consumer fusion passes use this pointwise orientation because their generated loops already hold the source tensor and the logical input index.
Execute a fused shape-only transformation through one certified flat-index map and one final output allocation.
inputMap records the independent coordinate semantics. inputFlatMap is
the executable representation of that map, and hInputMap is the certificate
linking the two.
Instances For
The native flat-index kernel equals the corresponding composed coordinate pullback.
This theorem is the compiler correctness boundary for every fused rearrange or repeat chain.
Fused flat-index execution of a rearrangement equals the ordinary checked rearrangement applied after the preceding pullback.
Fused flat-index execution of a repeat equals the ordinary checked repeat applied after the preceding pullback.