fn
contiguous
→Tensorcontiguous(input: Tensor)Return a tensor with C-contiguous (row-major) memory layout.
If input is already contiguous this is a no-op and returns the
same tensor; otherwise a fresh buffer is allocated and the data is
copied into row-major order.
Parameters
inputTensorPossibly non-contiguous source.
Returns
TensorContiguous tensor with identical shape, dtype, device and values.
Notes
Operations that rely on stride assumptions (e.g. view,
certain BLAS kernels) require contiguous input. Calling
contiguous after a sequence of stride-changing ops
(transpose, permute, expand) is the canonical
fix when downstream ops complain.
Examples
>>> import lucid
>>> x = lucid.zeros(3, 4).transpose(0, 1)
>>> x.is_contiguous()
False
>>> lucid.contiguous(x).is_contiguous()
True