IdentityEliminationPass¶

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

Pass for eliminating redundant Identity nodes.

This pass removes Identity nodes according to the following rules:

  1. For any node of the form y = Identity(x), where y is not an output of any graph, replace all uses of y with a use of x, and remove the node.

  2. If y is an output of a graph, and x is defined in that graph and is not a graph input, output, or initializer, we can eliminate the node and rename x to be y.

  3. Otherwise, if y is a graph output, retain the node to preserve the existing names of graph inputs, outputs, and initializers.

call(model)[source]¶

Main entry point for the identity elimination pass.

Parameters:

model (Model)

Return type:

PassResult