Skip to main content

Module injectivity

Module injectivity 

Source
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 larger block above the pairwise budget cannot be settled without enumeration, so it spills to the exact (allocating) check. All three 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.