Repository navigation
[Codegen][CPU] Lower data-tiled inner_tiled in VirtualVectorLoweringPass. - #24358
Merged
Merged
Conversation
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
hanhanW
reviewed
May 4, 2026
Contributor
There was a problem hiding this comment.
Can we add the test to virtual_vector_lowering.mlir directly? I don't see a reason for having a separate file atm.
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]>
hanhanW
approved these changes
May 4, 2026
bjacob
requested review from
Groverkss,
MaheshRavishankar,
Max191,
krzysz00,
nirvedhmeshram and
qedawkins
as code owners
May 4, 2026 20:58
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]>
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.
iree_codegen.inner_tiledis a high-level vector op (a multi-dimcontraction 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
LLVMCPUVirtualVectorLoweringPassalready does forvector.contract,vector.multi_reduction,vector.transfer_*, andthe IREE VectorExt ops. So land the CPU
inner_tiledlowering inthat pass rather than in a separate pass.
Three pattern populates from
IREE::Codegen(introduced in PR #24351 and #24357) join the target-independentblock of
LLVMCPUVirtualVectorLoweringPass:IREE::Codegen::populateUnrollInnerTiledPatternsunrolls anynon-unit iter dim (typically a residual reduction tile) to unit.
IREE::Codegen::populateDropInnerTiledUnitDimsPatternsdrops the(now-unit) iter domain so the lowered op has empty iter bounds,
which is the precondition of...
IREE::Codegen::populateLowerInnerTiledPatternsreplaces theiter-free vector-semantics
inner_tiledwith the per-intrinsicops emitted by its kind's
buildUnderlyingOperations— forIREE::CPU::DataTiledMMAAttrthose arellvm.call_intrinsicops.These patterns only match
iree_codegen.inner_tiled, so they areorthogonal to the existing patterns in this pass; the
DropVectorUnitDimsPassthat runs immediately before this one onlytouches
vector.*ops and similarly does not interact.After the greedy pattern application, run
IREE::Util::eliminateHoistableConversionsto cancel the inverse-pairutil.hoistable_conversionops the inner_tiled lowering wraps aroundthe per-intrinsic ACC distribute/reassemble. GPU's
LowerIREEGPUOpspass calls this for the same reason; the introducing pattern set is
the right place to clean up after itself.
LLVMCPUVirtualVectorLoweringPassruns post-bufferization. That isfine for
iree_codegen.inner_tiled: by then the op is already invector semantics (lifted by
GenericVectorizationPassvia theInnerTiledOpVectorizationModelVectorizableOpInterfaceexternalmodel), and bufferization does not touch vectors.
Adds a focused
compiler/src/iree/compiler/Codegen/LLVMCPU/test/virtual_vector_lowering_inner_tiled.mlirlit test that runs through
iree-llvmcpu-virtual-vector-loweringandasserts a single
llvm.fma.v16f32call with no survivingutil.hoistable_conversionon the AVX-512 1x16x1 f32 single-tile case.Updates a stale forward reference in
KernelDispatch.cppleft overfrom #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 fireinside
LLVMCPUVirtualVectorLoweringPass.Progress towards #24323