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} [TorchLean.Storage α] [Add α] [Mul α] [Zero α] {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} [TorchLean.Storage α] [Context α] [DecidableRel fun (x1 x2 : α) => x1 > x2] {m n p : } (t : Tape α) (aId bId : ) (batchA batchB batch : Spec.Shape := Spec.Shape.scalar) [broadcastA : batchA.BroadcastTo batch] [broadcastB : batchB.BroadcastTo batch] :

    Matrix-rank multiplication with explicit batch-prefix broadcasting.

    a has shape batchA ++ [m, n], b has shape batchB ++ [n, p], and the result has shape batch ++ [m, p]. The empty-prefix defaults preserve ordinary 2D matrix multiplication. PyTorch comparison: torch.matmul(a, b) for operands of rank at least two.

    Instances For
      def Runtime.Autograd.Tape.concatLeadingAxis {α : Type} [TorchLean.Storage α] {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.sliceLeadingAxisRange {α : Type} [TorchLean.Storage α] [Zero α] {n : } {s : Spec.Shape} (t : Tape α) (xId start len : ) (h : start + len 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