Elementary-axis coordinates #
AxisTuple length axes assigns a bounded coordinate to every axis occurrence
in a finite axis list. It is equivalent to Coord (axes.map length), but its
named indexing makes permutation, projection, and replication maps direct.
The equivalence is recursive in the axis list. Its first tuple entry is the
outermost tensor coordinate, matching Coord and its row-major linearization.
Grouping adjacent elementary axes does not change the number of tensor entries.
Coordinates of a grouped tensor shape are equivalent to one bounded coordinate for every elementary axis.
Both sides use row-major order, so grouping and ungrouping are represented by an equality of flat finite-index spaces rather than an arbitrary bijection.
Instances For
Convert coordinates from a shape certified to equal a grouped elementary-axis shape. This keeps dependent shape transport in one reusable definition.
Instances For
A shape equal to a grouped elementary-axis shape has the same number of entries as the corresponding ungrouped shape.
Join coordinates over two consecutive axis lists.
The left coordinates remain first, followed by the right coordinates. This is the computational operation used to combine retained and reduced axes without constructing an intermediate tensor.
Instances For
Looking up a left-axis position in an appended tuple returns the left coordinate.
Select and reorder a tuple along inclusion of one finite axis list in another. If an axis appears more than once in the target, its first occurrence is selected; checked einops plans rule out that ambiguity.
Instances For
Selecting the left axes from appended coordinates recovers the left tuple.
Selecting the right axes from appended coordinates recovers the right tuple when the two axis lists are disjoint.
Successive axis selections compose to direct selection from the largest tuple.
No duplicate-free hypothesis is needed: every selection consistently uses
the first occurrence returned by idxOf, and the intermediate lookup
recovers the same axis before the final lookup.
Selecting from target to source and then back to target recovers the
original tuple when target has no duplicate axes.
The source list need not be duplicate-free for this direction: idxOf
chooses one source occurrence, and the reverse selection identifies its axis
with the unique target occurrence.
Reordering between duplicate-free axis lists containing the same axes is an equivalence of bounded coordinate tuples.