Repository navigation
[Codegen][CPU] Fix RHS indexing map in materialize-encoding inner_tiled lowering. - #24325
Merged
Merged
Conversation
…ed lowering.
The CPU encoding-materialization path (`lowerContractionOpToInnerTiled`)
emits an `iree_codegen.inner_tiled` op with the standard matmul indexing
maps `[(d0, d2), (d2, d1), (d0, d1)]`, but the RHS pack it lowers to
uses `outer_dims_perm = [1, 0]` so the packed RHS comes out with outer
dims in `(N_iter, K_iter)` order — i.e. mmt4d-style, not standard-matmul
style. The two interpretations of the same operand shape disagree, and
the inner_tiled verifier rejects the op with:
error: 'iree_codegen.inner_tiled' op shape does not match
iteration bounds
Switching the RHS map to `(d0, d1, d2) -> (d1, d2)` matches what the
pack actually produces and lets the verifier project a consistent
iteration domain across all three operands. The semantics are still a
valid contraction (one parallel + one reduction on each input, two
parallels on the output), just with the RHS walked in mmt4d order.
Without this fix, data-tiled `linalg.matmul` -> `inner_tiled` lowering
on CPU fails the verifier on the very first dispatch and never gets
near codegen; with it, end-to-end compile gets past verification all
the way to bufferization (where a separate, pre-existing pipeline gap
takes over: there is no CPU pass yet that vectorizes/lowers
`inner_tiled` before bufferize).
Signed-off-by: Benoit Jacob <[email protected]>
Progress towards #24323
25 of 28 tasks
bjacob
marked this pull request as ready for review
April 30, 2026 19:37
bjacob
requested review from
MaheshRavishankar,
Max191,
hanhanW,
jtuyls and
qedawkins
as code owners
April 30, 2026 19:37
hanhanW
approved these changes
Apr 30, 2026
jerryyin
pushed a commit
that referenced
this pull request
May 7, 2026
…ed lowering. (#24325) The CPU encoding-materialization path (`lowerContractionOpToInnerTiled`) emits an `iree_codegen.inner_tiled` op with the standard matmul indexing maps `[(d0, d2), (d2, d1), (d0, d1)]`, but the RHS pack it lowers to uses `outer_dims_perm = [1, 0]` so the packed RHS comes out with outer dims in `(N_iter, K_iter)` order — i.e. mmt4d-style, not standard-matmul style. The two interpretations of the same operand shape disagree, and the inner_tiled verifier rejects the op with: error: 'iree_codegen.inner_tiled' op shape does not match iteration bounds Switching the RHS map to `(d0, d1, d2) -> (d1, d2)` matches what the pack actually produces and lets the verifier project a consistent iteration domain across all three operands. The semantics are still a valid contraction (one parallel + one reduction on each input, two parallels on the output), just with the RHS walked in mmt4d order. Without this fix, data-tiled `linalg.matmul` -> `inner_tiled` lowering on CPU fails the verifier on the very first dispatch and never gets near codegen; with it, end-to-end compile gets past verification all the way to bufferization (where a separate, pre-existing pipeline gap takes over: there is no CPU pass yet that vectorizes/lowers `inner_tiled` before bufferize). Progress towards #24323
RattataKing
pushed a commit
to RattataKing/iree
that referenced
this pull request
May 27, 2026
…ed lowering. (iree-org#24325) The CPU encoding-materialization path (`lowerContractionOpToInnerTiled`) emits an `iree_codegen.inner_tiled` op with the standard matmul indexing maps `[(d0, d2), (d2, d1), (d0, d1)]`, but the RHS pack it lowers to uses `outer_dims_perm = [1, 0]` so the packed RHS comes out with outer dims in `(N_iter, K_iter)` order — i.e. mmt4d-style, not standard-matmul style. The two interpretations of the same operand shape disagree, and the inner_tiled verifier rejects the op with: error: 'iree_codegen.inner_tiled' op shape does not match iteration bounds Switching the RHS map to `(d0, d1, d2) -> (d1, d2)` matches what the pack actually produces and lets the verifier project a consistent iteration domain across all three operands. The semantics are still a valid contraction (one parallel + one reduction on each input, two parallels on the output), just with the RHS walked in mmt4d order. Without this fix, data-tiled `linalg.matmul` -> `inner_tiled` lowering on CPU fails the verifier on the very first dispatch and never gets near codegen; with it, end-to-end compile gets past verification all the way to bufferization (where a separate, pre-existing pipeline gap takes over: there is no CPU pass yet that vectorizes/lowers `inner_tiled` before bufferize). Progress towards iree-org#24323
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.
The CPU encoding-materialization path (
lowerContractionOpToInnerTiled) emits aniree_codegen.inner_tiledop with the standard matmul indexing maps[(d0, d2), (d2, d1), (d0, d1)], but the RHS pack it lowers to usesouter_dims_perm = [1, 0]so the packed RHS comes out with outer dims in(N_iter, K_iter)order — i.e. mmt4d-style, not standard-matmul style. The two interpretations of the same operand shape disagree, and the inner_tiled verifier rejects the op with:Switching the RHS map to
(d0, d1, d2) -> (d1, d2)matches what the pack actually produces and lets the verifier project a consistent iteration domain across all three operands. The semantics are still a valid contraction (one parallel + one reduction on each input, two parallels on the output), just with the RHS walked in mmt4d order.Without this fix, data-tiled
linalg.matmul->inner_tiledlowering on CPU fails the verifier on the very first dispatch and never gets near codegen; with it, end-to-end compile gets past verification all the way to bufferization (where a separate, pre-existing pipeline gap takes over: there is no CPU pass yet that vectorizes/lowersinner_tiledbefore bufferize).Progress towards #24323