Skip to content

[FIX][ONNX] Avoid duplicate parameters for ONNX initializer inputs - #21137

Open
shpetimhaxhiu wants to merge 1 commit into
apache:mainfrom
shpetimhaxhiu:fix/onnx-initializer-input-dedup
Open

shpetimhaxhiu wants to merge 1 commit into
apache:mainfrom
shpetimhaxhiu:fix/onnx-initializer-input-dedup

Conversation

@shpetimhaxhiu

Copy link
Copy Markdown

Fixes #21133. Thanks to @tangyixuan01 for isolating the duplicate variable and the LLVM compilation failure.

The ONNX importer registers initializers before parsing graph inputs. When an initializer also appears in graph.input, the importer currently appends the same Relax variable once as a model input and again as a parameter. The LLVM build fails with a variable-used-before-definition error.

This change registers only newly created model inputs in the input list. With keep_params_in_input=True, initialized values still appear exactly once in the trailing parameter list and retain their initializer values after detach_params. The regression uses two initializers interleaved with a required input and checks both parameter modes. On native Windows x64 LLVM, the compiled model matched ONNX Runtime with the default weights and with an explicitly supplied replacement weight.

All 17 targeted tests passed. The full Windows frontend comparison had 84 failures shared with the unpatched baseline. The new initializer regression was the only test whose result changed.

OpenAI Codex assisted with the implementation and validation.

Register required graph inputs separately from initializer-backed parameters.

Reported-by: tangyixuan01 (apache#21133)

Generated-by: OpenAI Codex (GPT-6)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Relax][ONNX] Duplicate function parameter when an initializer is also a graph input

1 participant