Flatten (TorchLean.Tensor → FloatArray) #
Row-major order with outermost axis first and innermost axis last.
def
Runtime.Autograd.LibTorch.Convert.flattenFloat
{s : Spec.Shape}
(t : TorchLean.Tensor Float s)
:
Flatten a TorchLean.Tensor Float s into a row-major FloatArray (CUDA-compatible).
Instances For
def
Runtime.Autograd.LibTorch.Convert.flattenBoolMask
{s : Spec.Shape}
(mask : TorchLean.Tensor Bool s)
:
Flatten a TorchLean.Tensor Bool s mask to FloatArray as 0.0/1.0 values in row-major
order.
Instances For
Unflatten (FloatArray → TorchLean.Tensor) #
These functions assume row-major order. The public operations check the expected length and return
none on mismatch. Runtime code that already owns the buffer-size invariant calls the internal
workers directly.
def
Runtime.Autograd.LibTorch.Convert.Internal.unflattenFloat
{s : Spec.Shape}
(a : FloatArray)
(offset : ℕ)
:
Read a tensor out of a starting at offset, trusting the caller for the bounds. The checked
entry point is unflattenFloat?; this one exists so a batched download can slice one array.
Instances For
Unflatten a row-major FloatArray into a TorchLean.Tensor Float s when a.size matches.