Repository navigation
[Fix][Relax] Normalize squeeze axes before layout inference - #20773
Open
Edwardssss wants to merge 1 commit into
Open
Edwardssss wants to merge 1 commit into
Edwardssss wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
Fixes #20422.
InferLayoutSqueezeuses the squeeze axes to index a rank-sized axis mask. Previously, explicit negative axes were used without normalization. This can index outside the mask and cause undefined behavior duringConvertLayout, including the reported allocation failure. Structural inference normalizes its own local axes but does not rewrite the original operator attributes, so thatnormalization does not protect layout inference.
Normalize explicit axes with the existing
NormalizeAxeshelper using the logical input rank before constructing the layout mask. This preserves existing axis validation and leaves omitted-axis handling and blocked-layout fallback behavior unchanged. The fix applies to Relax directly as well as ONNX-imported graphs, rather than special-casing the importer.Test
Extend the existing squeeze layout tests with negative and mixed-sign axes, including blocked-layout fallback. Add coverage for a squeeze without layout changes, omitted and empty axes, and a channel squeeze remapped from NCHW to NHWC. The channel test explicitly checks the resulting axis is 3.