Reduction semantics #
Independent unordered and row-major ordered denotations for checked reductions, together with their aggregation and differential laws.
Independent reduction denotation: apply aggregate to the multiset of input
values in each certified input-to-output coordinate fiber.
Using a multiset makes permutation invariance part of the function's type and allows the output scalar type to differ from the input scalar type.
Instances For
Independent denotation for a reducer that is defined only on nonempty fibers.
The positive fiber-size premise is shape-level evidence that every aggregate application receives at least one value.
Instances For
Values in one reduction fiber, listed in physical row-major order.
The coordinate equivalence supplies the same fiber used by denoteReduce,
while List.ofFn fixes an order that remains meaningful for IEEE floating
point operations and other nonassociative scalar functions.
Instances For
The ordered fiber list has the checked reduction-fiber cardinality.
A positive checked fiber size makes every ordered fiber list nonempty.
Ordered reduction denotation with an explicit initial accumulator.
The list fold visits removed-axis coordinates in row-major order. The finalizer also receives the checked fiber cardinality, which supports operations such as mean without recounting the list.
Instances For
Ordered reduction denotation initialized from the first fiber value.
This form gives minimum and maximum a precise IEEE behavior without sentinel values. Positivity of the checked fiber size proves that the first value exists; the remaining row-major values are folded from left to right.
Instances For
Evaluate a sum reduction using any explicit reconstruction of the complete input coordinate from the retained output coordinate and removed-axis coordinates.
The premises state exactly that the reconstruction remains in the requested output fiber and recovers every supplied removed-axis tuple. This form is independent of rank and is convenient when relating einops reductions to established finite-sum operations.
Sum reduction preserves the total additive sum of all tensor entries.
The output fibers partition the finite input-coordinate space, including when that space is empty.
The adjoint of sum reduction under the finite tensor pairing is pullback along the retained-coordinate projection.
At the tensor level this pullback broadcasts each output cotangent across all input coordinates in its reduction fiber, which is the algebraic core of the sum-reduction VJP.
The VJP of a checked mean reduction broadcasts the output cotangent and scales it by the reciprocal of the reduction-fiber size.
The denominator is the product of the removed axis lengths certified by the
checked pattern. Positivity rules out an empty mean, while CharZero ensures
that this positive natural number remains nonzero in the scalar division
ring.