OutputFixPass¶

class onnx_ir.passes.common.OutputFixPass[source]¶

Pass for adding Identity nodes to fix invalid output configurations.

This pass adds Identity nodes according to the following rules:

  • If a graph input is directly used as a graph output (without any intermediate nodes), insert an Identity node between them. The ONNX specification does not allow a graph input to be directly used as a graph output without any processing nodes in between.

  • If a value is used multiple times as graph outputs, insert Identity nodes for each duplicate usage (keeping the first usage unchanged). This ensures each output value is unique, as required by the ONNX specification.

This pass processes both the main graph and all subgraphs (e.g., in control flow operators).

Example transformations:
Direct input-to-output:

Before: input -> (direct connection) -> output After: input -> Identity -> output

Duplicate outputs:

Before: value -> [output1, output2] After: value -> output1, value -> Identity -> output2

Added in version 0.1.13.

call(model)[source]¶

Main entry point for the output fix pass.

Parameters:

model (Model)

Return type:

PassResult