TorchLean API

NN.Runtime.Autograd.Engine.Core.Linear

Linear-algebra operations for the eager engine.

The definitions here cover matrix products, batched products, affine layers, and the corresponding runtime graph nodes shared by CPU and CUDA-backed execution.

def Runtime.Autograd.Tape.linear {α : Type} [Add α] [Mul α] [Zero α] [DecidableEq Spec.Shape] {inDim outDim : } (t : Tape α) (wId bId xId : ) :

Fully-connected linear layer y = W x + b (matvec).

Type-level shapes enforce W : (outDim, inDim), x : (inDim,), b : (outDim,). PyTorch comparison: torch.nn.functional.linear.

Instances For
    def Runtime.Autograd.Tape.matmul {α : Type} [Context α] [DecidableRel fun (x1 x2 : α) => x1 > x2] [DecidableEq Spec.Shape] {m n p : } (t : Tape α) (aId bId : ) :

    2D matrix multiplication.

    PyTorch comparison: torch.matmul(a, b) for 2D tensors.

    Instances For
      def Runtime.Autograd.Tape.bmm {α : Type} [Add α] [Mul α] [Zero α] [DecidableEq Spec.Shape] {batch m n p : } (t : Tape α) (aId bId : ) :

      Batched matrix multiplication.

      PyTorch comparison: torch.bmm(a, b).

      Instances For
        def Runtime.Autograd.Tape.concatVectors {α : Type} [Context α] [DecidableRel fun (x1 x2 : α) => x1 > x2] [DecidableEq Spec.Shape] {n m : } (t : Tape α) (aId bId : ) :

        Concatenate two 1D vectors along dimension 0.

        PyTorch comparison: torch.cat([a, b], dim=0) for vectors.

        Instances For
          def Runtime.Autograd.Tape.concatDim0 {α : Type} [DecidableEq Spec.Shape] {n m : } {s : Spec.Shape} (t : Tape α) (aId bId : ) :

          Concatenate two tensors along dimension 0.

          PyTorch comparison: torch.cat([a, b], dim=0).

          Instances For
            def Runtime.Autograd.Tape.sliceRange0 {α : Type} [Zero α] [DecidableEq Spec.Shape] {n : } {s : Spec.Shape} (t : Tape α) (xId start len : ) (h : len + start n) :

            Slice along dimension 0: x[start : start+len].

            The proof argument h enforces bounds. PyTorch comparison: x[start:start+len] on tensors with a leading dimension.

            Instances For