fn
view
→Tensorview(input: Tensor, shape: int | Sequence[int] = ())Return a view of input with a different shape.
The total number of elements must be preserved. Unlike
reshape, view requires the input to be contiguous
over the affected dims and never copies — if a view is not possible
a runtime error is raised.
Parameters
inputTensorSource tensor. Must be contiguous w.r.t. the requested layout.
shapeint or sequence of int= ()Target shape. Exactly one entry may be
-1 (auto-inferred).Returns
TensorTensor sharing storage with input.
Notes
Use view when zero-copy is part of the contract; use
reshape when correctness should take precedence over
layout assumptions.
Examples
>>> import lucid
>>> x = lucid.arange(12)
>>> lucid.view(x, (3, 4)).shape
(3, 4)