Shape-changing tensor operations #
Flatten, unflatten, and reshape preserve the row-major scalar sequence. Since
TorchLean.Tensor owns a contiguous certified buffer, these operations are
zero-copy changes to the static shape proof.
The buffer and specification size functions agree on the flattened shape.
A reshape changes coordinates without changing their row-major index.
A one-axis coordinate linearizes to its sole finite index.
Reverse the coordinates of an arbitrary statically valid axis.
Instances For
Flatten a tensor into a one-dimensional row-major vector.
Execution reuses the original native buffer; only the certified static shape changes.
Instances For
Restore a row-major vector to a specified shape with the same element count.
Execution reuses the vector's native buffer.
Instances For
Flattening an outer dimension places each flattened slice in one contiguous row-major segment.
Unflattening a flattened tensor returns the original tensor.
Flattening an unflattened vector returns the original vector.
Reshape a tensor while preserving its row-major scalar sequence.
Instances For
Flattening a reshape returns the original flat data, transported by the size equality.
Reshaping to an equal-size shape and back preserves every tensor entry.
Collect optional tensor slices along a new leading axis.
Slices are evaluated once, in index order. A missing slice makes the whole result none; an empty
family gives an empty tensor. The intermediate vector retains each successful slice so that the
output can be assembled in one pass. Rebuilding the remaining tensor at every recursive step would
copy earlier results repeatedly, making large batches and mixture models unnecessarily expensive.