Repository navigation
Conversation
Require a matrix RHS and non-contracting Slice axes before reordering. Read ranks from constant Tensors and skip unreadable or invalid axes. Add numerical and structural regressions for broadcasting, vector RHS, safe matrix RHS, dynamic indices and shared inputs.
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.
Superseded by #367, which contains the same patch with the required DCO sign-off.
Summary
adjust_slice_and_matmulcan change model outputs when the constant RHS has batch dimensions or is a vector. Checking only that Slice avoids the contracting axis does not preserve broadcasting or the meaning of its axes after MatMul.For example, reversing axis 0 of
X[1,3,4]before multiplying byB[2,4,5]leaves X unchanged. Moving that Slice after MatMul reverses the two broadcasted B batches instead. Both graphs pass the full ONNX checker and produce shape[2,3,5], but their values differ.Changes
A matrix RHS preserves the data's rank and non-contracting axis positions without introducing batch pairing changes. Dynamic starts/ends/steps and the existing rewrite remain supported. This conservative guard also skips some safe batched/vector RHS patterns, which may reduce constant-folding opportunities; broader support can be added separately.
This pass is explicitly enabled and is not in the default fuse/elimination pass list.
Testing
Locally on macOS, after rebuilding the native extension:
ONNX_BUILD_TESTS=ONand CTest: 2/2 passed.git diff --check: passed.CI results are pending.