Improve checks in concat_slice_elimination against optional attrs and unsqueeze_elimination against invalid model#27638
Merged
yuslepukhin merged 7 commits intomainfrom Mar 19, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves robustness and correctness of two optimizer passes (ConcatSliceElimination and UnsqueezeElimination) by adding safer handling of optional Slice inputs and stricter validation of Unsqueeze axes, and extends the optimizer unit test suite to cover these scenarios.
Changes:
- Materialize default
axes/stepsfor Slice inConcatSliceEliminationand tighten the supported fusion pattern tostarts.size() == 1. - Add out-of-range and duplicate-axis validation to
UnsqueezeElimination, returning explicit errors for invalid models. - Add targeted optimizer tests for Unsqueeze elimination and Slice optional-input defaulting behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| onnxruntime/test/optimizer/graph_transform_test.cc | Adds unit tests for Unsqueeze elimination behavior and for Concat+Slice fusion when Slice omits optional axes/steps. |
| onnxruntime/core/optimizer/unsqueeze_elimination.cc | Adds axis range/dup validation for Unsqueeze elimination and improves robustness against invalid models. |
| onnxruntime/core/optimizer/concat_slice_elimination.cc | Materializes Slice default axes/steps, adds <numeric>, and narrows fusion eligibility to single-dimension slicing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
edgchen1
reviewed
Mar 13, 2026
edgchen1
reviewed
Mar 16, 2026
edgchen1
previously approved these changes
Mar 16, 2026
edgchen1
approved these changes
Mar 16, 2026
Member
Author
|
/azp run Linux TensorRT CI |
|
No pipelines are associated with this pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improvements to the
concat_slice_eliminationandunsqueeze_eliminationoptimizer passes, focusing on correctness, robustness, and code clarity. The changes include enhanced handling of optional Slice operator attributes, stricter validation of axes and steps, and improved error handling for invalid model inputs.Improvements to
concat_slice_elimination:axesandstepsin the Slice operator, ensuring safe indexing and alignment with ONNX defaults. (onnxruntime/core/optimizer/concat_slice_elimination.cc)starts.size() == 1, clarifying the scope of the optimization and preventing incorrect fusions. (onnxruntime/core/optimizer/concat_slice_elimination.cc)<numeric>include to support new code usingstd::iota. (onnxruntime/core/optimizer/concat_slice_elimination.cc)Improvements to
unsqueeze_elimination:onnxruntime/core/optimizer/unsqueeze_elimination.cc)core/providers/common.hinclude for utility functions used in validation. (onnxruntime/core/optimizer/unsqueeze_elimination.cc)