fn
narrow
→Tensornarrow(input: Tensor, dim: int, start: int, length: int)Return a contiguous slice of input along dim.
Equivalent to input[..., start:start+length, ...] with the slice
applied at position dim. Returns a view — no data copy.
Parameters
inputTensorSource tensor.
dimintDimension to slice.
startintFirst index (inclusive).
lengthintNumber of elements to take. Must satisfy
start + length <= input.size(dim).Returns
TensorView into input of size length along dim.
Notes
Unlike NumPy slicing, narrow accepts only step 1; for general
strided slicing use indexing syntax.
Examples
>>> import lucid
>>> x = lucid.arange(10)
>>> lucid.narrow(x, dim=0, start=3, length=4)
Tensor([3, 4, 5, 6])