Expand description
§onnx-runtime-optimizer
Device-independent graph→graph optimization passes for the ORT 2.0 runtime
(see docs/ORT2.md §18 “Optimization Passes”). This is the first Phase-2
crate: pure, safe Rust graph rewriting over onnx_runtime_ir — no
CUDA, no ORT C library, no FFI.
§What lives here
| Concept | Type |
|---|---|
| Pass contract | OptimizationPass, PassContext, run_passes |
| Dead-code removal | DeadNodeElimination |
| Bounded constant folding | ConstantFolding |
| Operator fusion | OpFusion, FusionPattern, PatternMatch |
| Errors | OptimizerError, Result |
§Pipeline
default_passes returns only the device-independent passes implemented
here, in pipeline order: ConstantFolding → DeadNodeElimination → OpFusion.
§Deferred (Phase 2b / Phase 3)
The full pipeline in docs/ORT2.md §18.1 also lists passes that depend on
crates or analyses not yet built. They are intentionally not implemented
here and are listed in default_passes’s source in their eventual
pipeline position: ShapeInference (the loader owns inference for now),
AttentionFusionPass, LayoutPropagation, PlacementOptimizer,
TransferInsertion, InPlaceDetection, MemoryPlanning,
CudaGraphRegionDetection, and OverlapScheduling.
Structs§
- Constant
Folding - Folds constant-input nodes into initializers (bounded, integer/shape only).
- Dead
Node Elimination - Removes nodes that do not contribute to any graph output.
- Fusion
Pattern - A fusion rule: an op-type sequence rewritten to a single replacement op.
- OpFusion
- The op-fusion pass: applies each
FusionPatternto fixpoint. - Pass
Context - Shared, read-only context threaded through every pass.
- Pattern
Match - A matched occurrence of a
FusionPatternin a graph.#[derive(Clone, Debug)]
Enums§
- Optimizer
Error - Crate-level error for the optimization pipeline.
Constants§
- CONTRIB_
DOMAIN - The private contrib domain under which the optimizer emits every fused op.
Traits§
- Initializer
Resolver - Resolves graph initializer descriptors to their backing bytes.
- Optimization
Pass - A single graph→graph rewrite (see
docs/ORT2.md§18.1).
Functions§
- default_
fusion_ patterns - The default device-independent fusion patterns.
- default_
passes - The device-independent Phase-1 pass pipeline, in run order.
- run_
passes - Run
passesovergraphin order.
Type Aliases§
- Result
- A convenience
Resultalias for optimizer operations.