ONNX102: duplicate-graph-output

Code: ONNX102

Name: duplicate-graph-output

Severity: error

Category: ir

Target: graph

Fixable: 🔧 Yes

Message

Duplicate Value object in graph outputs.

Suggestion

Remove the duplicate Value references from graph outputs, or apply --fix to insert Identity nodes with OutputFixPass.

Details

Each Value object in a graph’s outputs must appear only once. In onnx_ir, this checks object identity (not just name equality).

Example

# Remove duplicate outputs by identity
seen = set()
unique_outputs = []
for output in graph.outputs:
    if id(output) not in seen:
        seen.add(id(output))
        unique_outputs.append(output)
graph.outputs[:] = unique_outputs