Skip to content

Fix common-subexpression elimination across domains - #362

Merged
take-cheeze merged 1 commit into
onnx:mainfrom
sean0407:codex/onnx-optimizer-343-cse-domain
Nov 4, 2026
Merged

take-cheeze merged 1 commit into
onnx:mainfrom
sean0407:codex/onnx-optimizer-343-cse-domain

Conversation

@sean0407

Copy link
Copy Markdown
Contributor

Summary

Fixes #343 by including each node's ONNX domain in both the common-subexpression hash and equality comparison. This prevents a standard-domain operator from being merged with a local function that has the same op_type, inputs, and attributes but different semantics.

Reproduction

The regression test builds a valid model containing standard-domain Add(X, X) and a local local::Add(X, X) function whose body multiplies its inputs. Before this change, eliminate_common_subexpression merged the nodes and the optimized model produced a different output from the original.

Changed files

  • onnxoptimizer/passes/cse_util.h
  • onnxoptimizer/test/optimizer_test.py

Checks run

  • pytest -n 1 onnxoptimizer/test/optimizer_test.py -k "eliminate_common_subexression or respects_domain" — 4 passed in an isolated container.
  • git diff --check — passed.

@sean0407
sean0407 requested review from a team as code owners October 21, 2026 11:25
Signed-off-by: sean0407 <sean0407@gmail.com>
@sean0407
sean0407 force-pushed the codex/onnx-optimizer-343-cse-domain branch from f501341 to 905c262 Compare October 21, 2026 11:26
@take-cheeze
take-cheeze merged commit 5863b46 into onnx:main Nov 4, 2026
30 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.

eliminate_common_subexpression conflates nodes from different operator domains

2 participants