TorchLean API

NN.Runtime.Autograd.Compiled.IRExec.Core

IRExec #

IR → executable SSA graph bridge.

This module lets us run an op-tagged NN.IR.Graph by compiling it into an executable Proofs.Autograd.Algebra.GraphData (the SSA/DAG representation used by the proof-compiled runtime).

Why this exists:

Important:

PyTorch intuition #

If you’re coming from PyTorch:

Reading map #

Main definitions #

Implementation notes #

References #

Tags #

ir, compiler, runtime, graphdata, forward-semantics

@[simp]
theorem Runtime.Autograd.Compiled.Except.ok_bind {ε α β : Type} (a : α) (f : αExcept ε β) :
Except.ok a >>= f = f a

simp rule for Except-do chains: binding an .ok value is just function application.

@[simp]
theorem Runtime.Autograd.Compiled.Except.error_bind {ε α β : Type} (e : ε) (f : αExcept ε β) :

simp rule for Except-do chains: binding an .error short-circuits.

Used heavily when discharging impossible branches in compilation correctness proofs.

@[simp]
theorem Runtime.Autograd.Compiled.Except.bind_ok {ε α β : Type} (a : α) (f : αExcept ε β) :
(Except.ok a).bind f = f a

Definitional simplification for Except.bind on .ok.

@[simp]
theorem Runtime.Autograd.Compiled.Except.bind_error {ε α β : Type} (e : ε) (f : αExcept ε β) :

Definitional simplification for Except.bind on .error.

A forward-executable SSA graph derived from an NN.IR.Graph.

The compiled graph stores:

  • one distinguished input shape (inShape),
  • one shape per compiled node (ss, corresponding to IR node ids 1..n-1),
  • and executable node closures (g) consumed by GraphData.eval.
Instances For

    Evaluate the compiled executable SSA graph on a concrete input tensor.

    The result is the full typed runtime context [inShape] ++ ss, i.e. input followed by every compiled node value in topological order.

    Instances For

      Denotation Table Helper #

      ExecGraphData.eval produces a typed runtime context TList α ([inShape] ++ ss).

      For debugging and for the forward-correctness development in NN.Runtime.Autograd.Compiled.IRExec.Correctness, we provide a helper that erases this context into an IR-style value table Array (NN.IR.DVal α) in node-id order.

      Convert a runtime AnyTensor (shape carried as a field) into an IR denotation value DVal.

      Instances For

        Convert a typed runtime context TList α ss into an IR-style value table.

        This is phrased in terms of Array (DVal α) because the IR denotation functions (denoteAll*) are array-based, while the compiled runtime evaluates into a typed context (TList).

        Instances For

          Convert the full evaluated context into an IR-style value table (one DVal per node id).

          This is the concrete bridge used in semantic equivalence statements that compare compiled evaluation against NN.IR.Graph.denoteAll*.

          Instances For