Expand description
Output-layout injectivity validation.
Kernel families that write through a strided destination must prove that
distinct logical positions map to distinct memory offsets. This is the one
owner of that analysis: strided-basic re-exports it for its kernel
families and strided-perm calls it before its unsafe permutation loops.
The common case is validated without allocating: axes are reduced in
ascending |stride| order and only the interleaved block of small-stride
axes is compared pairwise. A two-axis block is settled exactly by a gcd
argument regardless of size. A block of three or more axes is settled
exactly by searching for a colliding difference vector over all but its two
largest axes, which is cheap whenever the other axes are short, regardless
of the block’s element count. A block whose difference search exceeds its
budget falls back to pairwise comparison, then to the exact (allocating)
enumeration. All paths conservatively reject metadata whose spans do not
fit the analysis, which keeps the entry points panic-free.
Functions§
- is_
injective_ layout - Decide whether distinct logical positions map to distinct offsets.