onnx_ir.passes¶

Use built-in passes¶

Common, reusable passes are implemented in onnx_ir.passes.common. You can use onnx_ir.passes.Sequential to chain passes or use onnx_ir.passes.PassManager which supports early stopping if no changes are made.

Pass infrastructure¶

Inherent onnx_ir.passes.InPlacePass or onnx_ir.passes.FunctionalPass to define a pass. You will need to implement the call method which returns a onnx_ir.passes.PassResult.

Alternatively, inherent the base class onnx_ir.passes.PassBase <onnx_ir.passes.PassBase> and override the two properties changes_input and in_place to set properties of the pass.

onnx_ir.passes.PassBase

Base class for all passes.

onnx_ir.passes.InPlacePass

A pass that modifies the input model in place and returns it.

onnx_ir.passes.FunctionalPass

A pass that returns a new model but does not modify the input model.

onnx_ir.passes.Sequential

Run a sequence of passes in order.

onnx_ir.passes.PassResult

Result of a pass.

onnx_ir.passes.PassManager

Pass manager for the IR.

Errors¶

exception onnx_ir.passes.InvariantError¶

Raised when an invariant is violated.

exception onnx_ir.passes.PreconditionError¶

Raised when a precondition is violated.

exception onnx_ir.passes.PostconditionError¶

Raised when a postcondition is violated.

exception onnx_ir.passes.PassError¶

Raised when an error occurs during a pass.