Skip to main content

Module subgraph

Module subgraph 

Source
Expand description

Sub-graph execution helper.

Op::If branches and Op::While body/cond are sub-graphs nested inside a parent graph. To execute them, the backend recursively compiles and runs the inner graph with bound inputs.

Strategy: compile the sub-graph lazily on first encounter, cache the ExecutableGraph for repeated invocations (loops). A future optimization: hoist the compile to the parent’s compile-time once we have a stable IR for sub-graphs.

Structs§

SubgraphCache
Lazily-compiled sub-graph cache. Keyed by sub-graph name (caller must ensure names are unique within the parent graph). Backend-agnostic: stores boxed ExecutableGraphs.

Functions§

run_if
Helper: evaluate an Op::If by running one of two sub-graphs.
run_while
Helper: evaluate an Op::While by repeatedly running cond + body. loop_carried are the values flowing through iterations.