Skip to content

[Codegen][CPU] Lower data-tiled inner_tiled in VirtualVectorLoweringPass. - #24358

Merged
bjacob merged 3 commits into
mainfrom
users/bjacob/cpu-lower-inner-tiled
May 5, 2026
Merged

bjacob merged 3 commits into
mainfrom
users/bjacob/cpu-lower-inner-tiled

Conversation

@bjacob

@bjacob bjacob commented May 4, 2026

Copy link
Copy Markdown
Collaborator

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.

Adds a focused
compiler/src/iree/compiler/Codegen/LLVMCPU/test/virtual_vector_lowering_inner_tiled.mlir
lit test that runs through iree-llvmcpu-virtual-vector-lowering and
asserts a single llvm.fma.v16f32 call with no surviving
util.hoistable_conversion on the AVX-512 1x16x1 f32 single-tile case.

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

bjacob added 2 commits May 4, 2026 16:11
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
…ass.

`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 the previous NFC commit on this stack) 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.

Adds a focused
`compiler/src/iree/compiler/Codegen/LLVMCPU/test/virtual_vector_lowering_inner_tiled.mlir`
lit test that runs through `iree-llvmcpu-virtual-vector-lowering` and
asserts a single `llvm.fma.v16f32` call with no surviving
`util.hoistable_conversion` on the AVX-512 1x16x1 f32 single-tile case.

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`.

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

Progress towards #24323
@bjacob bjacob mentioned this pull request May 4, 2026
25 of 28 tasks
@bjacob
bjacob marked this pull request as ready for review May 4, 2026 20:30
@bjacob
bjacob requested a review from hanhanW as a code owner May 4, 2026 20:30

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.

Can we add the test to virtual_vector_lowering.mlir directly? I don't see a reason for having a separate file atm.

@bjacob bjacob May 4, 2026 •

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.

Good point. Pushed a840052.

Move the `iree_codegen.inner_tiled` lowering test out of its own file
and append it as another `// -----`-separated section in
`virtual_vector_lowering.mlir`. The two files had identical RUN lines
(`iree-llvmcpu-virtual-vector-lowering` with `--split-input-file`), so
there's no reason to keep them separate.

Signed-off-by: Benoit Jacob <[email protected]>
Base automatically changed from users/bjacob/nfc-lift-inner-tiled-unroll to main May 4, 2026 20:58
@bjacob
bjacob merged commit 020f6be into main May 5, 2026
61 of 63 checks passed
@bjacob
bjacob deleted the users/bjacob/cpu-lower-inner-tiled branch May 5, 2026 13:59
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
…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