Skip to content

dialects: (linalg) thread loop-carried values through tile loops - #6368

Merged
superlopuh merged 1 commit into
xdslproject:mainfrom
dipo101:linalg-tiling-loop-carried
Aug 14, 2026
Merged

dialects: (linalg) thread loop-carried values through tile loops#6368
superlopuh merged 1 commit into
xdslproject:mainfrom
dipo101:linalg-tiling-loop-carried

Conversation

@dipo101

@dipo101 dipo101 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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_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's block arguments, so the innermost body sees the values accumulated by the surrounding iterations:

outer loop:   iter_args(%accI = %B)        <- the original value
  inner loop: iter_args(%accJ = %accI)     <- the enclosing loop's block argument

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.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, so its generated IR is unchanged. Nothing passes iter_args yet; that arrives with the later PRs in the series, which is why this one is not reachable from the pass and _build_tile_loops is tested directly.

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

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.94%. Comparing base (5484aad) to head (8dcbda1).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dipo101
dipo101 marked this pull request as ready for review August 14, 2026 16:57
@dipo101

dipo101 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@superlopuh PR 2 of 5 is ready for review, ptal

@superlopuh superlopuh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@superlopuh superlopuh added the dialects Changes on the dialects label Aug 14, 2026
@superlopuh
superlopuh merged commit ccc30e8 into xdslproject:main Aug 14, 2026
25 checks passed
@dipo101
dipo101 deleted the linalg-tiling-loop-carried branch August 15, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dialects Changes on the dialects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants