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)
:
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
iinto aForwardNodeclosure (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.