Implementing kernel
C++ engine symbols that back this Python API.Reshape a tensor to shape.
The total number of elements must match
(). Exactly one entry may
be -1, inferred from the remaining sizes.
On the CPU a dense input is viewed, not copied: the result reads
the same buffer, so an in-place write to either reaches the other.
On metal the result is a copy.
Parameters
inputTensorSource tensor.
shapeint or sequence of int= ()Target shape. Exactly one entry may be
-1 (auto-inferred).Returns
TensorTensor of the requested shape — a view of input on the CPU,
a copy on metal.
Notes
view behaves the same way, and neither ever refuses a layout:
a CPU input that is not contiguous — a transpose, a column slice — is
copied, unless the new shape only adds or drops size-1 axes.
Examples
>>> import lucid
>>> x = lucid.arange(12)
>>> lucid.reshape(x, (3, 4)).shape
(3, 4)