fn
atleast_1d
→Tensor | tuple[Tensor, ...]atleast_1d(tensors: Tensor = ())Promote each input to at least 1 dimension.
Scalars (0-D tensors) are reshaped to length-1 vectors; tensors that already have rank pass through unchanged. Commonly used as a defensive guard at the top of routines that vectorise over a leading axis.
Parameters
*tensorsTensorOne or more input tensors of arbitrary rank.
Returns
Tensor | tuple[Tensor, ...]A single tensor when called with one argument, otherwise a tuple of the promoted tensors in the same order as the inputs.
Notes
Promotion rule per input t with original rank r:
Mirrors NumPy's np.atleast_1d. Higher-rank atleast_2d and
atleast_3d variants follow the same pattern with extra leading /
trailing unit axes.
Examples
>>> import lucid
>>> s = lucid.tensor(3.0)
>>> v = lucid.tensor([1.0, 2.0])
>>> a, b = lucid.atleast_1d(s, v)
>>> a.shape, b.shape
((1,), (2,))