Coordinate semantics for pack and unpack #
A checked packing pattern identifies one star region in every input shape. Its dimensions may differ between components, but all leading and trailing dimensions agree. The star region is flattened in row-major order and the flattened segments are placed consecutively on one packed axis.
The central object in this module is CheckedPack.packedCoordinateEquiv.
It first reshapes each component's star region to its checked segment, then
uses the general segment-concatenation equivalence. denotePack reads through
the inverse equivalence, while denoteUnpack reads through the forward
equivalence. Both round-trip laws therefore hold for every scalar type,
including scalar components, zero-size shapes, and zero-length segments.
No tensor lowering is executed here. The later lowering theorem compares reshape and concatenation primitives with this coordinate denotation.
The dependent family of input tensors accepted by a checked pack plan.
Instances For
The packed tensor type determined by a checked pack plan.
Instances For
Reshape every component coordinate into the corresponding segment coordinate.
The equivalence is dependent because components may have different ranks and
star shapes. Row-major reshape preserves all scalar positions, while
componentSegmentEquiv keeps component and metadata order synchronized.
Instances For
The coordinate equivalence defining both pack and unpack.
On the input side, a coordinate records which component is selected and a coordinate inside that component. On the output side, the component's row-major star coordinate is placed in its consecutive segment of the packed axis; leading and trailing coordinates are unchanged.
Instances For
Pack a checked family by reading the unique component coordinate represented by each packed output coordinate.
Instances For
Unpack a tensor by embedding each requested component coordinate into its checked segment of the packed axis.
Instances For
Pack reads the component and coordinate selected by the packed coordinate.
Unpack reads the packed coordinate assigned to the requested component entry.
Unpacking a packed component family recovers every component tensor.
Packing a complete checked unpack recovers the original packed tensor.
Packing both component families preserves their direct-sum finite pairing.
The coordinate equivalence partitions every packed coordinate into exactly one component coordinate. Multiplication order is unchanged, so the theorem holds over a potentially noncommutative semiring.