Shape-Erased Tensors #
SomeTensor stores a TorchLean.Tensor together with the shape that indexes its type. It is the
sole general shape-erasure boundary for tensors in TorchLean. Runtime collections use it when they
must contain tensors of different shapes, including autograd tapes, graph interpreters, and
certificate checkers.
Backend-specific resources are not alternative tensor wrappers. For example, the CUDA tape keeps an opaque device buffer together with runtime shape and allocation metadata; operation-polymorphic programs similarly package references owned by a monad rather than tensor values.
A tensor paired with the shape that indexes its type.
- shape : Shape
The runtime shape of the tensor.
- tensor : TorchLean.Tensor α self.shape
The tensor value, indexed by its stored shape.
Instances For
Package a statically shaped tensor for shape-erased storage.
Instances For
Packing a tensor records its static shape as the runtime shape.
Packing and unpacking a tensor returns it unchanged, since the recorded shape matches.
Cast the stored tensor after checking its runtime shape.
Instances For
Casting to the shape already recorded returns the stored tensor.
Repacking a tensor after a successful shape cast recovers the original value.
Erasing a tensor's shape after transport recovers the original shape-erased value.
Swap two adjacent axes at depth, retaining the resulting shape in the package.