Skip to main content

compress_dims

Function compress_dims 

Source
pub fn compress_dims(
    dims: &[usize],
    all_strides: &[Vec<isize>],
) -> (Vec<usize>, Vec<Vec<isize>>)
Expand description

Remove size-1 dimensions from fused dims and all corresponding strides.

After fuse_dims(), many dimensions may be 1 (either originally size-1 or merged into a neighbor). These contribute nothing to iteration but increase loop depth. This function strips them out.

If ALL dimensions are 1 (scalar-like), a single dimension of size 1 is preserved so the kernel has something to iterate over.