slice

fun <T : DType, V> Tensor<T, V>.slice(slices: List<Slice<T, V>>): TensorView<T, V>(source)

Creates a tensor view using a direct list of slice descriptors.

This method provides a lower-level API for slicing when the slice descriptors are already available, bypassing the DSL builder. Useful for programmatic slice generation or integration with other systems.

Usage Example

val slices = listOf(
Slice.Range<MyDType, Float>(0, 10),
Slice.At<MyDType, Float>(5),
Slice.All<MyDType, Float>()
)
val view = tensor.slice(slices)

Return

a TensorView providing sliced access to this tensor's data

Parameters

slices

the list of slice descriptors, one for each tensor dimension

Throws

if slice list doesn't match tensor rank

if any slice is invalid for its dimension