Skip to main content

validate_no_control_flow

Function validate_no_control_flow 

Source
pub fn validate_no_control_flow(graph: &Graph) -> Result<(), LoaderError>
Expand description

Reject subgraph-bearing (control-flow) ops the runtime cannot execute.

The CPU executor implements the three standard subgraph-bearing control-flow ops — If, Loop, and Scan (default ai.onnx domain) — by recursively executing their nested onnx_runtime_ir::Attribute::Graph/Graphs bodies. Any other op that smuggles a subgraph attribute (a control-flow construct this runtime does not implement, or a custom op hiding a nested graph) is still rejected fast: the executor has no path to run it, so a silent skip or a late panic would be worse than a clear load-time error.

The check descends into every nested subgraph as well, so an unimplemented control-flow op buried inside an If/Loop/Scan body is caught at load rather than surfacing only when that branch/iteration executes.