pub trait OptimizerPass: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn run(
&self,
graph: &mut Graph,
ctx: &PassContext,
) -> Result<(), OptimizerError>;
// Provided method
fn postconditions(&self, graph: &Graph) -> Result<(), OptimizerError> { ... }
}Expand description
A single graph→graph rewrite (see docs/ORT2.md §18.1).
Passes mutate the Graph in place and must preserve its structural
invariants; postconditions is checked
after each pass in debug builds by run_passes.
Required Methods§
Sourcefn run(
&self,
graph: &mut Graph,
ctx: &PassContext,
) -> Result<(), OptimizerError>
fn run( &self, graph: &mut Graph, ctx: &PassContext, ) -> Result<(), OptimizerError>
Apply the rewrite in place.
Provided Methods§
Sourcefn postconditions(&self, graph: &Graph) -> Result<(), OptimizerError>
fn postconditions(&self, graph: &Graph) -> Result<(), OptimizerError>
Invariants that must hold after this pass. The default requires the
graph to pass full structural validation (Graph::validate).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".