Update find_concat_same_inputs to handle dimension > 1 - #5142
Open
pfultz2 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends simplify_algebra’s find_concat_same_input rewrite so it can simplify concat(x, x, ..., x) not only when the concatenation axis has length 1, but also when the axis length is > 1 (by rewriting to an unsqueeze + multibroadcast + reshape “tile” sequence). Corresponding unit tests are updated and expanded to cover additional axes and tiling cases.
Changes:
- Update
find_concat_same_inputto handlelens[axis] > 1usingunsqueeze→multibroadcast→reshape. - Update existing dot/concat simplification expectations to match the new rewrite.
- Add new test cases for tiling along axis 0 and axis 1 (including non-last-axis scenarios).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/simplify_algebra.cpp |
Generalizes concat(same input) simplification to support axis length > 1 via tiling sequence. |
test/simplify_algebra_test.cpp |
Updates prior expectations and adds coverage for the new tiling rewrite across multiple axes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1114
to
1118
| auto axis = ins->get_operator().to_value()["axis"].to<int64_t>(); | ||
| const auto& lens = x->get_shape().lens(); | ||
|
|
||
| if(axis < 0 or axis >= lens.size()) | ||
| return; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5142 +/- ##
========================================
Coverage 93.12% 93.12%
========================================
Files 625 625
Lines 33162 33168 +6
========================================
+ Hits 30879 30885 +6
Misses 2283 2283
🚀 New features to boost your workflow:
|
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.
Motivation
Technical Details
Changelog Category
Add a
CHANGELOG.mdentry for any option other thanNot ApplicableFollow the LLVM AI Tool Use Policy for contributions using AI.