dialects: (linalg) thread loop-carried values through tile loops - #6368
Merged
Conversation
Tiling operands with value semantics needs the accumulated result threaded through the tile loop nest, since each tile produces a new value rather than writing through a view. Give `_build_tile_loops` an optional `iter_args` parameter. The outermost loop initialises the carried values from `iter_args`, and every nested loop initialises them from the enclosing loop block arguments, so the innermost body sees the values accumulated by the surrounding iterations. Initialising a nested loop from the original values instead would silently discard the work of the enclosing iterations. `scf.ForOp` derives its result types from its `iter_args`, so the loops gain results automatically. Tiling memrefs passes no `iter_args`, leaving the loops without block arguments or results, and its generated IR unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6368 +/- ##
=======================================
Coverage 86.94% 86.94%
=======================================
Files 440 440
Lines 65966 65969 +3
Branches 7491 7491
=======================================
+ Hits 57355 57358 +3
Misses 7035 7035
Partials 1576 1576 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dipo101
marked this pull request as ready for review
August 14, 2026 16:57
Contributor
Author
|
@superlopuh PR 2 of 5 is ready for review, ptal |
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.
Part of the tensor-based tiling checkbox on #6140, and the second of the smaller PRs split out of #6362. Follows on from #6366.
Tiling an operand with value semantics needs the accumulated result threaded through the tile loop nest, since each tile produces a new value rather than writing through a view.
This gives
_build_tile_loopsan optionaliter_argsparameter. The outermost loop initialises the carried values fromiter_args, and every nested loop initialises them from the enclosing loop's block arguments, so the innermost body sees the values accumulated by the surrounding iterations:Initialising a nested loop from the original values instead would silently discard the work of the enclosing iterations, giving IR that verifies but computes the wrong thing. The added test pins that down: removing the reassignment makes it fail on the inner loop's
iter_args.scf.ForOpderives its result types from itsiter_args, so the loops gain results automatically.Tiling memrefs passes no
iter_args, leaving the loops without block arguments or results, so its generated IR is unchanged. Nothing passesiter_argsyet; that arrives with the later PRs in the series, which is why this one is not reachable from the pass and_build_tile_loopsis tested directly.