torch.FlipShape
export type FlipShape<S extends Shape, Dim extends number> = number extends Dim
? S
: number extends S['length']
? S
: LessThan<Dim, S['length']> extends true
? S // Valid
: flip_error_dim_out_of_range<Dim, S['length']>;Sextends ShapeDimextends numberCompute output shape of flip operation with bounds checking. flip preserves shape but requires all dims < rank. Note: Multi-dim validation is complex; we check single dim for simplicity.
Examples
type R1 = FlipShape<readonly [2, 3, 4], 1>; // readonly [2, 3, 4] ✓
type R2 = FlipShape<readonly [2, 3], 5>; // flip_error_dim_out_of_range<5, 2>