TensorSliceBuilder

DSL builder for creating tensor slices with fluent syntax.

This class provides a DSL for defining tensor slicing operations using a fluent interface. It supports various slicing patterns including:

  • Range selection: range(start, end)

  • Single index selection: at(index)

  • Full dimension selection: all()

  • Strided access: step(start, end, step)

The builder is designed to work with the segment { } block pattern where each call to segment defines slicing for one dimension.

Usage Example

tensor.sliceView {
segment { range(0, 10) } // First dimension: select indices 0-9
segment { at(5) } // Second dimension: select index 5
segment { all() } // Third dimension: select all indices
segment { step(0, 20, 2) } // Fourth dimension: select every 2nd index from 0-19
}

Parameters

T

the data type constraint extending DType

V

the actual value type

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun segment(block: SegmentBuilder<T, V>.() -> Slice<T, V>)

Defines slicing for the next dimension using the provided block.