TorchLean API

NN.Runtime.Autograd.IRExec.Lowering

IR Node Lowering #

The canonical checked lowering loop and exhaustive operation-family dispatch from IR nodes to executable SSA nodes.

@[irreducible]
def Runtime.Autograd.IRExec.Internal.buildFrom {α : Type} [TorchLean.Storage α] [Context α] (g : NN.IR.Graph) (payload : NN.IR.Payload α) (inShape : Spec.Shape) (i : ) (st : State α inShape) :
Except String (State α inShape)

Lower the IR graph starting at node index i, extending the current SSA State.

This is the main lowering loop:

  • it checks i < g.nodes.size,
  • lowers node i into a ForwardNode closure (rejecting unsupported ops/shapes), and
  • appends the resulting node to the accumulating ForwardData.

The public entrypoint lowerToForwardGraph handles node 0 and calls buildFrom starting at i = 1.

Operationally, buildFrom is a checked lowering pass:

  • success means every visited node had well-typed parents and a supported lowering case,
  • failure returns a concrete error explaining the first unsupported/malformed node.
Instances For