torch.IndexSpec
export type IndexSpec = number | RangeSpec | null | '...' | MaskSpec | IndicesSpec;Values
numberRangeSpecnull'...'MaskSpecIndicesSpec
Index specification for a single dimension in .at() calls.
number: Select single index (removes dimension, like Python'sx[i])[start, end]: Slice range (like Python'sx[start:end])[start, end, step]: Strided slice (like Python'sx[start:end:step])null: Keep entire dimension (like Python'sx[:])'...': Ellipsis - expands to fill remaining dimensions (like Python'sx[...])Tensor(boolean): Masked selection - returns 1D tensor (like Python'sx[mask])Tensor(integer): Index selection along dimension (like Python'sx[indices])
Examples
// Python equivalents:
// x[0] → 0
// x[1:5] → [1, 5]
// x[::2] → [0, null, 2] (every other element)
// x[1:10:2] → [1, 10, 2]
// x[:] → null
// x[..., 0] → '...', 0
// x[mask] → mask (boolean Tensor)
// x[indices] → indices (integer Tensor)