TorchLean API

NN.GraphSpec.DAG.Primitives.Shape

DAG Shape and Reduction Primitives #

Reductions, transposes, gathers, broadcasting, concatenation, slicing, and shape-preserving views.

Sum a statically nonempty tensor axis.

Instances For

    Average a statically nonempty tensor axis.

    Instances For

      Swap adjacent tensor axes at a statically chosen depth.

      Instances For
        @[simp]

        Pure evaluation of an adjacent-axis swap.

        def NN.GraphSpec.DAG.PrimOp.select (shape : Spec.Shape) (axis : ℕ) [Spec.Shape.AxisInBounds axis shape] (index : Fin (shape.axisSize axis)) :
        PrimOp [shape] (shape.eraseAxis axis)

        Select one bounded coordinate along an arbitrary tensor axis.

        Instances For
          def NN.GraphSpec.DAG.PrimOp.broadcast {source target : Spec.Shape} (proof : source.CanBroadcastTo target) :
          PrimOp [source] target

          Expand singleton or missing dimensions according to a checked broadcasting derivation.

          Instances For
            theorem NN.GraphSpec.DAG.PrimOp.applyAdjacentSwaps_range_eq_replaceAxis (shape : Spec.Shape) (axis extent : ℕ) (hAxis : axis < shape.rank) :
            (Spec.Shape.dim extent (shape.eraseAxis axis)).applyAdjacentSwaps (List.range axis) = shape.replaceAxis axis extent

            Moving a replacement extent from the front to axis realizes replaceAxis.

            @[simp]
            theorem NN.GraphSpec.DAG.PrimOp.replaceAxis_axisSize (shape : Spec.Shape) (axis : ℕ) [hAxis : Spec.Shape.AxisInBounds axis shape] :
            shape.replaceAxis axis (shape.axisSize axis) = shape

            Replacing an in-bounds axis by its existing extent leaves the shape unchanged.

            Move a chosen runtime axis to the front, retaining the unchanged axes in their order.

            Instances For

              Restore a front runtime axis to its original position.

              Instances For
                def NN.GraphSpec.DAG.PrimOp.concatAxisSpec {α : Type} [TorchLean.Storage α] (shape : Spec.Shape) (axis left right : ℕ) [Spec.Shape.AxisInBounds axis shape] (a : TorchLean.Tensor α (shape.replaceAxis axis left)) (b : TorchLean.Tensor α (shape.replaceAxis axis right)) :
                TorchLean.Tensor α (shape.replaceAxis axis (left + right))

                Concatenate tensors along an arbitrary statically valid axis.

                Instances For
                  def NN.GraphSpec.DAG.PrimOp.concatAxis (shape : Spec.Shape) (axis left right : ℕ) [Spec.Shape.AxisInBounds axis shape] :
                  PrimOp [shape.replaceAxis axis left, shape.replaceAxis axis right] (shape.replaceAxis axis (left + right))

                  Concatenate along axis; shape supplies every unchanged axis extent.

                  Instances For
                    @[simp]
                    theorem NN.GraphSpec.DAG.PrimOp.concatAxis_specFwd {shape : Spec.Shape} {axis left right : ℕ} [Spec.Shape.AxisInBounds axis shape] {α : Type} [TorchLean.Storage α] [Context α] (a : TorchLean.Tensor α (shape.replaceAxis axis left)) (b : TorchLean.Tensor α (shape.replaceAxis axis right)) :

                    The pure meaning of arbitrary-axis concatenation.

                    def NN.GraphSpec.DAG.PrimOp.sliceAxisRange (shape : Spec.Shape) (axis start length : ℕ) [Spec.Shape.AxisInBounds axis shape] (hRange : start + length ≤ shape.axisSize axis) :
                    PrimOp [shape] (shape.replaceAxis axis length)

                    Select a checked contiguous range along an arbitrary statically valid axis.

                    Instances For
                      @[simp]
                      theorem NN.GraphSpec.DAG.PrimOp.sliceAxisRange_specFwd {shape : Spec.Shape} {axis start length : ℕ} [Spec.Shape.AxisInBounds axis shape] (hRange : start + length ≤ shape.axisSize axis) {α : Type} [TorchLean.Storage α] [Context α] (input : TorchLean.Tensor α shape) :
                      (sliceAxisRange shape axis start length hRange).specFwd (TorchLean.TensorPack.cons input TorchLean.TensorPack.nil) = TorchLean.Tensor.sliceAxisRangeSpec axis input start length hRange

                      The pure meaning of a checked arbitrary-axis contiguous slice.

                      def NN.GraphSpec.DAG.PrimOp.reshape (source target : Spec.Shape) (hSize : source.size = target.size) :
                      PrimOp [source] target

                      Reshape a tensor while preserving its statically known number of entries.

                      Instances For
                        @[simp]
                        theorem NN.GraphSpec.DAG.PrimOp.reshape_specFwd {source target : Spec.Shape} (hSize : source.size = target.size) {α : Type} [TorchLean.Storage α] [Context α] (input : TorchLean.Tensor α source) :

                        Pure evaluation of a shape-preserving view.