dialects: (linalg) write tiles back into the tensors carried by tile loops - #6370
Draft
dipo101 wants to merge 2 commits into
Draft
dialects: (linalg) write tiles back into the tensors carried by tile loops#6370dipo101 wants to merge 2 commits into
dipo101 wants to merge 2 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6370 +/- ##
==========================================
- Coverage 86.94% 86.93% -0.02%
==========================================
Files 440 440
Lines 65973 65999 +26
Branches 7493 7493
==========================================
+ Hits 57360 57376 +16
- Misses 7036 7044 +8
- Partials 1577 1579 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dipo101
marked this pull request as ready for review
August 15, 2026 23:44
superlopuh
reviewed
Aug 16, 2026
superlopuh
reviewed
Aug 16, 2026
Building the slice of an operand computes where the tile sits within that operand and then materializes it, which are separate concerns: the geometry is the same whether the operand is a memref or a tensor, while the op that materializes the slice is not. Move that computation into `SliceParameters.compute`, and have `_build_tiled_slice` take the result along with the type it is slicing. This mirrors how upstream separates `computeSliceParameters` from `materializeTiledShape`, and makes the geometry testable on its own. Generated IR is unchanged.
…loops A tile of a memref is written through the subview that views it, but a tile of a tensor is a new value, so it has to be written back explicitly and carried out of the loops it was computed in. Pass the outputs of an op with tensor semantics as the loop nest iteration arguments, slice those outputs from the values the innermost loop carries rather than from the originals, and write each computed tile back with a `tensor.insert_slice`. The innermost loop yields the updated tensors and each enclosing loop yields the results of the loop nested inside it, so the outermost loop produces the fully updated tensors, which then replace the results of the original op. Slicing an output from the original tensor rather than from the carried value, or erasing the op rather than replacing its results, would both give IR that verifies but drops the work of the surrounding iterations. The offsets, sizes and strides of a tile are now computed once as `SliceParameters`, since a tile has to be written back exactly where it was extracted from. Tiling memrefs carries nothing, writes nothing back, and yields nothing, so its generated IR is unchanged. Tiling tensors is still rejected during analysis, so this is not yet reachable from the pass.
dipo101
force-pushed
the
linalg-tiling-tensor-writeback
branch
from
August 16, 2026 11:25
3c35293 to
0e88664
Compare
dipo101
marked this pull request as draft
August 16, 2026 11:37
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.
A tile of a memref is written through the subview that views it, but a tile of a tensor is a new value, so it has to be written back explicitly and carried out of the loops it was computed in.
This passes the outputs of an op with tensor semantics as the loop nest iteration arguments, slices those outputs from the values the innermost loop carries rather than from the originals, and writes each computed tile back with a
tensor.insert_slice. The innermost loop yields the updated tensors and each enclosing loop yields the results of the loop nested inside it, so the outermost loop produces the fully updated tensors, which then replace the results of the original op:Two things here are easy to get wrong, and both give IR that verifies while dropping the work of the surrounding iterations: slicing an output from the original tensor rather than from the carried value, and erasing the op rather than replacing its results.
A tile is written back exactly where it was extracted from, so both use the same
SliceParameters.Tiling memrefs carries nothing, writes nothing back and yields nothing, so its generated IR is unchanged and the existing filecheck expectations are untouched. Tiling tensors is still rejected during analysis, so this is not yet reachable from the pass; a later PR lifts that.