Skip to content

[Codegen] NFC: Lift InnerTiledOp unroll pattern to Codegen. - #24357

Merged
bjacob merged 1 commit into
mainfrom
users/bjacob/nfc-lift-inner-tiled-unroll
May 4, 2026
Merged

bjacob merged 1 commit into
mainfrom
users/bjacob/nfc-lift-inner-tiled-unroll

Conversation

@bjacob

@bjacob bjacob commented May 4, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to the previous NFC, moving the third (and last) iree_codegen.inner_tiled rewrite pattern out of
Codegen/Dialect/GPU/Transforms/:

  • UnrollInnerTiledPattern (unrolls along iter dimensions until each intrinsic invocation has a unit iter shape)

The pattern itself is dialect-neutral; only the convenience no-args populate function applied a default config (matmul-like LHS-reuse traversal order, unit native shape) that happens to be a good fit for any architecture, including CPU.

Renames the populate functions:

  • IREE::GPU::populateIREEGPUVectorUnrollPatterns (with-options form) -> IREE::Codegen::populateUnrollInnerTiledPatterns
  • IREE::GPU::populateIREEGPUVectorUnrollPatterns (no-args form) -> IREE::Codegen::populateUnrollInnerTiledPatterns

Renames the GPU-specific helper gpuMatmulLikeUnrollOrder to matmulLikeUnrollOrder (its content is dialect-neutral). The kUnrollAccDistribute / kUnrollAccReassemble HoistableConversionOp tag constants move with the pattern.

Updates the in-tree callers in IREEGPUExtensions.cpp and UnrollToIntrinsics.cpp, and adjusts BUILD.bazel/CMakeLists.txt deps.

Strict NFC; no functional or behavioral change.

Progress towards #24323

Follow-up to the previous NFC, moving the third (and last)
`iree_codegen.inner_tiled` rewrite pattern out of
`Codegen/Dialect/GPU/Transforms/`:

  - `UnrollInnerTiledPattern` (unrolls along iter dimensions until each
    intrinsic invocation has a unit iter shape)

The pattern itself is dialect-neutral; only the convenience
no-args populate function applied a default config (matmul-like
LHS-reuse traversal order, unit native shape) that happens to be a
good fit for any architecture, including CPU.

Renames the populate functions:

  - `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (with-options form)
        -> `IREE::Codegen::populateUnrollInnerTiledPatterns`
  - `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (no-args form)
        -> `IREE::Codegen::populateUnrollInnerTiledPatterns`

Renames the GPU-specific helper `gpuMatmulLikeUnrollOrder` to
`matmulLikeUnrollOrder` (its content is dialect-neutral). The
`kUnrollAccDistribute` / `kUnrollAccReassemble` HoistableConversionOp
tag constants move with the pattern.

Updates the in-tree callers in `IREEGPUExtensions.cpp` and
`UnrollToIntrinsics.cpp`, and adjusts BUILD.bazel/CMakeLists.txt deps.

Strict NFC; no functional or behavioral change.

Signed-off-by: Benoit Jacob <[email protected]>

Progress towards #24323

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This transform op should be moved as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The next PR #24358 shows the equivalent call on CPU. Does that look good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That one (#24358) looks good to me. This comment is mainly for transform_dialect::ApplyUnrollMultiMmaOp; can be addressed in either this PR or a follow-up.

There are several test name and method name still using multi_mma, and the other option may be cleaning them up in a follow-up. E.g.,

I can kick started an AI session for doing this. However, it may conflict with your in-flight changes, so I haven't started yet. Let me know if you want to take it over or feel free to leave it to me. I can do it in my bubble time when your work are mostly landed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll leave it to you! I'll enable auto-merge here so this gets merged soon (I need to leave for today) and you'll be unblocked to implement your changes on top.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sgtm

@bjacob
bjacob enabled auto-merge (squash) May 4, 2026 20:50
@bjacob
bjacob merged commit 18a49cb into main May 4, 2026
64 of 65 checks passed
@bjacob
bjacob deleted the users/bjacob/nfc-lift-inner-tiled-unroll branch May 4, 2026 20:58
bjacob added a commit that referenced this pull request May 5, 2026
…ass. (#24358)

`iree_codegen.inner_tiled` is a high-level vector op (a multi-dim
contraction whose shape is described by its kind), and lowering it to
per-intrinsic ops is "high-level vector -> lower-level dialect", which
is exactly what `LLVMCPUVirtualVectorLoweringPass` already does for
`vector.contract`, `vector.multi_reduction`, `vector.transfer_*`, and
the IREE VectorExt ops. So land the CPU `inner_tiled` lowering in
that pass rather than in a separate pass.

Three pattern populates from `IREE::Codegen` (introduced in PR
#24351 and #24357) join the
target-independent
block of `LLVMCPUVirtualVectorLoweringPass`:

  - `IREE::Codegen::populateUnrollInnerTiledPatterns` unrolls any
    non-unit iter dim (typically a residual reduction tile) to unit.
  - `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns` drops the
    (now-unit) iter domain so the lowered op has empty iter bounds,
    which is the precondition of...
  - `IREE::Codegen::populateLowerInnerTiledPatterns` replaces the
    iter-free vector-semantics `inner_tiled` with the per-intrinsic
    ops emitted by its kind's `buildUnderlyingOperations` — for
    `IREE::CPU::DataTiledMMAAttr` those are `llvm.call_intrinsic` ops.

These patterns only match `iree_codegen.inner_tiled`, so they are
orthogonal to the existing patterns in this pass; the
`DropVectorUnitDimsPass` that runs immediately before this one only
touches `vector.*` ops and similarly does not interact.

After the greedy pattern application, run
`IREE::Util::eliminateHoistableConversions` to cancel the inverse-pair
`util.hoistable_conversion` ops the inner_tiled lowering wraps around
the per-intrinsic ACC distribute/reassemble. GPU's `LowerIREEGPUOps`
pass calls this for the same reason; the introducing pattern set is
the right place to clean up after itself.

`LLVMCPUVirtualVectorLoweringPass` runs post-bufferization. That is
fine for `iree_codegen.inner_tiled`: by then the op is already in
vector semantics (lifted by `GenericVectorizationPass` via the
`InnerTiledOpVectorizationModel` `VectorizableOpInterface` external
model), and bufferization does not touch vectors.

Updates a stale forward reference in `KernelDispatch.cpp` left over
from #24328 — the comment described
the unit-iter-dim drop and per-
intrinsic lower patterns as firing inside a pass named
`LLVMCPULowerInnerTiledPass`, which never landed; they now fire
inside `LLVMCPUVirtualVectorLoweringPass`.

Progress towards #24323

---------

Signed-off-by: Benoit Jacob <[email protected]>
jerryyin pushed a commit that referenced this pull request May 7, 2026
Follow-up to the previous NFC, moving the third (and last)
`iree_codegen.inner_tiled` rewrite pattern out of
`Codegen/Dialect/GPU/Transforms/`:

- `UnrollInnerTiledPattern` (unrolls along iter dimensions until each
intrinsic invocation has a unit iter shape)

The pattern itself is dialect-neutral; only the convenience no-args
populate function applied a default config (matmul-like LHS-reuse
traversal order, unit native shape) that happens to be a good fit for
any architecture, including CPU.

Renames the populate functions:

- `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (with-options form)
-> `IREE::Codegen::populateUnrollInnerTiledPatterns`
- `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (no-args form) ->
`IREE::Codegen::populateUnrollInnerTiledPatterns`

Renames the GPU-specific helper `gpuMatmulLikeUnrollOrder` to
`matmulLikeUnrollOrder` (its content is dialect-neutral). The
`kUnrollAccDistribute` / `kUnrollAccReassemble` HoistableConversionOp
tag constants move with the pattern.

Updates the in-tree callers in `IREEGPUExtensions.cpp` and
`UnrollToIntrinsics.cpp`, and adjusts BUILD.bazel/CMakeLists.txt deps.

Strict NFC; no functional or behavioral change.

Progress towards #24323
jerryyin pushed a commit that referenced this pull request May 7, 2026
…ass. (#24358)

`iree_codegen.inner_tiled` is a high-level vector op (a multi-dim
contraction whose shape is described by its kind), and lowering it to
per-intrinsic ops is "high-level vector -> lower-level dialect", which
is exactly what `LLVMCPUVirtualVectorLoweringPass` already does for
`vector.contract`, `vector.multi_reduction`, `vector.transfer_*`, and
the IREE VectorExt ops. So land the CPU `inner_tiled` lowering in
that pass rather than in a separate pass.

Three pattern populates from `IREE::Codegen` (introduced in PR
#24351 and #24357) join the
target-independent
block of `LLVMCPUVirtualVectorLoweringPass`:

  - `IREE::Codegen::populateUnrollInnerTiledPatterns` unrolls any
    non-unit iter dim (typically a residual reduction tile) to unit.
  - `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns` drops the
    (now-unit) iter domain so the lowered op has empty iter bounds,
    which is the precondition of...
  - `IREE::Codegen::populateLowerInnerTiledPatterns` replaces the
    iter-free vector-semantics `inner_tiled` with the per-intrinsic
    ops emitted by its kind's `buildUnderlyingOperations` — for
    `IREE::CPU::DataTiledMMAAttr` those are `llvm.call_intrinsic` ops.

These patterns only match `iree_codegen.inner_tiled`, so they are
orthogonal to the existing patterns in this pass; the
`DropVectorUnitDimsPass` that runs immediately before this one only
touches `vector.*` ops and similarly does not interact.

After the greedy pattern application, run
`IREE::Util::eliminateHoistableConversions` to cancel the inverse-pair
`util.hoistable_conversion` ops the inner_tiled lowering wraps around
the per-intrinsic ACC distribute/reassemble. GPU's `LowerIREEGPUOps`
pass calls this for the same reason; the introducing pattern set is
the right place to clean up after itself.

`LLVMCPUVirtualVectorLoweringPass` runs post-bufferization. That is
fine for `iree_codegen.inner_tiled`: by then the op is already in
vector semantics (lifted by `GenericVectorizationPass` via the
`InnerTiledOpVectorizationModel` `VectorizableOpInterface` external
model), and bufferization does not touch vectors.

Updates a stale forward reference in `KernelDispatch.cpp` left over
from #24328 — the comment described
the unit-iter-dim drop and per-
intrinsic lower patterns as firing inside a pass named
`LLVMCPULowerInnerTiledPass`, which never landed; they now fire
inside `LLVMCPUVirtualVectorLoweringPass`.

Progress towards #24323

---------

Signed-off-by: Benoit Jacob <[email protected]>
RattataKing pushed a commit to RattataKing/iree that referenced this pull request May 27, 2026
…#24357)

Follow-up to the previous NFC, moving the third (and last)
`iree_codegen.inner_tiled` rewrite pattern out of
`Codegen/Dialect/GPU/Transforms/`:

- `UnrollInnerTiledPattern` (unrolls along iter dimensions until each
intrinsic invocation has a unit iter shape)

The pattern itself is dialect-neutral; only the convenience no-args
populate function applied a default config (matmul-like LHS-reuse
traversal order, unit native shape) that happens to be a good fit for
any architecture, including CPU.

Renames the populate functions:

- `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (with-options form)
-> `IREE::Codegen::populateUnrollInnerTiledPatterns`
- `IREE::GPU::populateIREEGPUVectorUnrollPatterns` (no-args form) ->
`IREE::Codegen::populateUnrollInnerTiledPatterns`

Renames the GPU-specific helper `gpuMatmulLikeUnrollOrder` to
`matmulLikeUnrollOrder` (its content is dialect-neutral). The
`kUnrollAccDistribute` / `kUnrollAccReassemble` HoistableConversionOp
tag constants move with the pattern.

Updates the in-tree callers in `IREEGPUExtensions.cpp` and
`UnrollToIntrinsics.cpp`, and adjusts BUILD.bazel/CMakeLists.txt deps.

Strict NFC; no functional or behavioral change.

Progress towards iree-org#24323
RattataKing pushed a commit to RattataKing/iree that referenced this pull request May 27, 2026
…ass. (iree-org#24358)

`iree_codegen.inner_tiled` is a high-level vector op (a multi-dim
contraction whose shape is described by its kind), and lowering it to
per-intrinsic ops is "high-level vector -> lower-level dialect", which
is exactly what `LLVMCPUVirtualVectorLoweringPass` already does for
`vector.contract`, `vector.multi_reduction`, `vector.transfer_*`, and
the IREE VectorExt ops. So land the CPU `inner_tiled` lowering in
that pass rather than in a separate pass.

Three pattern populates from `IREE::Codegen` (introduced in PR
iree-org#24351 and iree-org#24357) join the
target-independent
block of `LLVMCPUVirtualVectorLoweringPass`:

  - `IREE::Codegen::populateUnrollInnerTiledPatterns` unrolls any
    non-unit iter dim (typically a residual reduction tile) to unit.
  - `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns` drops the
    (now-unit) iter domain so the lowered op has empty iter bounds,
    which is the precondition of...
  - `IREE::Codegen::populateLowerInnerTiledPatterns` replaces the
    iter-free vector-semantics `inner_tiled` with the per-intrinsic
    ops emitted by its kind's `buildUnderlyingOperations` — for
    `IREE::CPU::DataTiledMMAAttr` those are `llvm.call_intrinsic` ops.

These patterns only match `iree_codegen.inner_tiled`, so they are
orthogonal to the existing patterns in this pass; the
`DropVectorUnitDimsPass` that runs immediately before this one only
touches `vector.*` ops and similarly does not interact.

After the greedy pattern application, run
`IREE::Util::eliminateHoistableConversions` to cancel the inverse-pair
`util.hoistable_conversion` ops the inner_tiled lowering wraps around
the per-intrinsic ACC distribute/reassemble. GPU's `LowerIREEGPUOps`
pass calls this for the same reason; the introducing pattern set is
the right place to clean up after itself.

`LLVMCPUVirtualVectorLoweringPass` runs post-bufferization. That is
fine for `iree_codegen.inner_tiled`: by then the op is already in
vector semantics (lifted by `GenericVectorizationPass` via the
`InnerTiledOpVectorizationModel` `VectorizableOpInterface` external
model), and bufferization does not touch vectors.

Updates a stale forward reference in `KernelDispatch.cpp` left over
from iree-org#24328 — the comment described
the unit-iter-dim drop and per-
intrinsic lower patterns as firing inside a pass named
`LLVMCPULowerInnerTiledPass`, which never landed; they now fire
inside `LLVMCPUVirtualVectorLoweringPass`.

Progress towards iree-org#24323

---------

Signed-off-by: Benoit Jacob <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants