TorchLean API

NN.Tensor.ShapeErasure

Tensor Shape-Erasure Boundary #

Conversions between statically shape-indexed TensorPack values and arrays of existentially packaged Spec.SomeTensor values. Runtime tapes and heterogeneous external data use the erased representation; typed computation should recover a TensorPack immediately after crossing that boundary.

Erase the individual tensor shapes in a typed pack into a runtime array.

Instances For

    Tag each shape-erased tensor with its runtime index, beginning at start.

    Instances For

      Push the shape-erased tensors of a pack onto acc, from the head of the pack onward.

      Instances For

        Pushing onto acc appends the ordinary shape erasure to it.

        toShapeErasedArray in one pass of pushes, which replaces it in compiled code.

        Instances For

          Push the indexed shape-erased tensors of a pack onto acc, numbering from index.

          Instances For
            theorem TorchLean.TensorPack.toIndexedShapeErasedArrayAux_eq {α : Type} [Storage α] {ss : List Spec.Shape} (tensors : TensorPack α ss) (index : ℕ) (acc : Array (ℕ × Spec.SomeTensor α)) :
            tensors.toIndexedShapeErasedArrayAux index acc = acc ++ tensors.toIndexedShapeErasedArray index

            Pushing onto acc appends the ordinary indexed shape erasure to it.

            toIndexedShapeErasedArray in one pass of pushes, which replaces it in compiled code.

            Instances For
              def TorchLean.TensorPack.ofShapeErasedArray {α : Type} [Storage α] (values : Array (Spec.SomeTensor α)) (start : ℕ := 0) {shapes : List Spec.Shape} :

              Recover a statically shape-indexed pack from a prefix of a shape-erased runtime array.

              start selects the first array entry to consume. The conversion checks every stored shape and fails if the array is too short or an entry has the wrong shape. Entries after the requested pack are intentionally ignored, which supports recovering a typed prefix of a larger runtime context.

              Instances For