isContiguousSlice

fun <T : DType, V> isContiguousSlice(slices: List<Slice<T, V>>): Boolean(source)

Determines if a list of slices results in a contiguous memory access pattern.

This function analyzes slice patterns to optimize memory access and enable vectorized operations. It's particularly optimized for NCHW tensor layout commonly used in deep learning.

Contiguous Patterns (in order of efficiency):

  1. Batch slicing: tensor[0:k, :, :, :] - Most efficient

  2. Channel slicing: tensor[:, 0:k, :, :] - Highly efficient

  3. Spatial region slicing: tensor[:, :, h1:h2, w1:w2] - Good efficiency

  4. Width-only slicing: tensor[:, :, :, w1:w2] - Moderate efficiency

Return

true if the slicing pattern results in contiguous memory access

Parameters

slices

the list of slice descriptors to analyze