Slice
Represents a slice descriptor for tensor slicing operations.
Slice is a sealed class hierarchy that describes different ways to select elements along a single tensor dimension. It provides the building blocks for complex tensor slicing operations while maintaining type safety and enabling compile-time optimization opportunities.
Slice Types
The sealed class hierarchy includes:
Range: Contiguous range of indices [start, end)
At: Single specific index selection
All: Full dimension selection (equivalent to :)
Step: Strided access with start, end, and step size
Design Principles
Type Safety: Compile-time guarantees about slice validity
Composability: Slices can be combined and normalized
Performance: Enable optimization based on slice patterns
Expressiveness: Support common slicing use cases
Parameters
the data type constraint extending DType
the actual value type