Skip to content

Fix FuseInitializersTransformer consumer input lookup - #32426

Merged
Xavier Dupré (xadupre) merged 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/fuse-initializer-output-name
Sep 8, 2026
Merged

Xavier Dupré (xadupre) merged 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/fuse-initializer-output-name

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Description

Fixes #32405.

FuseInitializersTransformer locates the consumer input to replace by comparing the producer node name with consumer input value names. ONNX does not require node names and output value names to match.

When they differ, the lookup can reach the end of InputDefs() and the following access can go out of bounds.

The transformer now matches the consumer input against the Cast node's output value name and guards against an unexpected missing match.

Tests

Adds a regression test where the Cast node name differs from its output value name, matching the failure reported in #32405.

Copilot AI balanced review requested due to automatic review settings September 3, 2026 18:03
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix addresses the reported crash and includes adequate regression coverage.

Pull request overview

Fixes initializer fusion when Cast node and output names differ, preventing out-of-bounds access.

Changes:

  • Match consumer inputs using the Cast output value name.
  • Enforce that a matching consumer input exists.
  • Add regression coverage for independently named nodes and values.
File summaries
File Description
onnxruntime/core/optimizer/fuse_initializers_transformer.cc Corrects consumer input lookup and adds a bounds guard.
onnxruntime/test/optimizer/fuse_initializers_transformer_regression_test.cc Verifies successful fusion with differing Cast node/output names.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@xadupre
Xavier Dupré (xadupre) merged commit bb331b7 into microsoft:main Sep 8, 2026
90 checks passed
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.

FuseInitializersTransformer crashes on Gemma when ConstantFolding is disabled

3 participants