sliceRanges

fun <T : DType, V> Tensor<T, V>.sliceRanges(vararg ranges: Pair<Int, Int>): TensorView<T, V>(source)

Convenience method for creating simple range slices across all dimensions.

This method provides a quick way to slice all dimensions with ranges, which is a common operation in neural network processing.

Usage Example

// Slice a 4D NCHW tensor: batch[0:2], channels[1:5], height[10:20], width[5:15]
val view = tensor.sliceRanges(
0 to 2, // batch dimension
1 to 5, // channel dimension
10 to 20, // height dimension
5 to 15 // width dimension
)

Return

a TensorView with range slices applied to all dimensions

Parameters

ranges

pairs of (start, end) for each dimension

Throws

if range count doesn't match tensor rank