TorchLean API

NN.IR.Payload

IR Payloads #

Shared payload records for IR evaluators and verifier backends.

The graph stores operation tags and edges. Tensor-valued constants, weights, convolution kernels, and BatchNorm running statistics live in a separate payload keyed by node id, matching the way formats such as ONNX keep graph structure separate from initializers.

structure NN.IR.ConstFlat (α : Type) [Context α] :

Payload record for a const node.

Constants are stored in a flat representation so backends can use one vector container and let IR evaluation reshape the data to the node's declared output shape.

Instances For
    structure NN.IR.LinearWB (α : Type) [Context α] :

    Payload record for a linear node: weight matrix W and bias vector b.

    The node's input x comes from the graph edge; W,b live in the external Payload, similar to ONNX initializers or a PyTorch state_dict.

    Instances For
      structure NN.IR.Conv2DParams (α : Type) [Context α] :

      Payload record for a conv2d node.

      The spec-layer Conv2DSpec carries the typed kernel and bias. The cached dimensions let verifier passes reconstruct flat shapes without unpacking the spec package at every use site.

      • inC :

        Input channels.

      • outC :

        Output channels.

      • kH :

        Kernel height.

      • kW :

        Kernel width.

      • stride :

        Stride.

      • padding :

        Padding size.

      • inH :

        Input height.

      • inW :

        Input width.

      • hIn : self.inC 0

        Proof that the input channel count is nonzero, required by the spec convolution layer.

      • hKH : self.kH 0

        Proof that the kernel height is nonzero.

      • hKW : self.kW 0

        Proof that the kernel width is nonzero.

      • spec : Spec.Conv2DSpec self.inC self.outC self.kH self.kW self.stride self.padding α

        Spec-layer convolution package containing weights, bias, and convolution metadata.

      Instances For

        Payload record for eval-mode BatchNorm2d over N×C×H×W tensors.

        Instances For
          structure NN.IR.Payload (α : Type) [Context α] :

          External parameter payloads keyed by IR node id.

          This is focused on denotational IR evaluation. Runtime backends may store tensors differently, but their proof-facing semantics pass through this shape-indexed boundary.

          Instances For