Repository navigation
[Codegen] NFC: Lift InnerTiledOp lower & drop-unit-dim patterns to Codegen. - #24351
Merged
Merged
Conversation
…degen.
Moves the two `iree_codegen.inner_tiled` rewrite patterns and their
populate functions out of `Codegen/Dialect/GPU/Transforms/` into
`Codegen/Dialect/Codegen/Transforms/LowerInnerTiled.cpp`:
- `LowerInnerTiledPattern` (replaces an iter-bound-empty `inner_tiled`
with the per-intrinsic ops emitted by its kind's
`buildUnderlyingOperations`)
- `DropInnerTiledUnitDimsPattern` (folds unit iteration bounds and
pulls the corresponding extract/broadcast pairs out of the loop)
Both patterns operate on `IREE::Codegen::InnerTiledOp` and dispatch
through the kind's interface, so there is nothing GPU-specific about
them. Lifting them lets CPU pass authors share the same lowering logic
without a `Codegen/Dialect/GPU/...` include.
Renames the populate functions accordingly:
- `IREE::GPU::populateIREEGPULowerInnerTiledPatterns`
-> `IREE::Codegen::populateLowerInnerTiledPatterns`
- `IREE::GPU::populateIREEGPUDropUnitDimsPatterns`
-> `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns`
The `kShapeCastToIntrinsic` / `kShapeCastFromIntrinsic` and
`kDropUnitDims` / `kAddUnitDims` HoistableConversionOp tag constants
move with the patterns. The remaining tag pair on the GPU side
(`kUnrollAccDistribute` / `kUnrollAccReassemble`) stays in
`Codegen/Dialect/GPU/Transforms/Transforms.cpp` since it's still only
used by the GPU unroll path.
Updates the existing in-tree callers in `LowerIREEGPUOps.cpp`,
`IREEGPUExtensions.cpp`, and `UnrollToIntrinsics.cpp`, and adjusts
BUILD.bazel/CMakeLists.txt deps so GPU's transform libraries depend on
`IREECodegenTransforms`.
Strict NFC; no functional or behavioral change.
Signed-off-by: Benoit Jacob <[email protected]>
Progress towards #24323
25 of 28 tasks
bjacob
marked this pull request as ready for review
May 4, 2026 16:12
bjacob
requested review from
Groverkss,
MaheshRavishankar,
Max191,
krzysz00,
nirvedhmeshram and
qedawkins
as code owners
May 4, 2026 16:12
Groverkss
approved these changes
May 4, 2026
bjacob
enabled auto-merge (squash)
May 4, 2026 16:20
bjacob
added a commit
that referenced
this pull request
May 4, 2026
…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
added a commit
that referenced
this pull request
May 4, 2026
…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
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
…degen. (#24351) Moves the two `iree_codegen.inner_tiled` rewrite patterns and their populate functions out of `Codegen/Dialect/GPU/Transforms/` into `Codegen/Dialect/Codegen/Transforms/LowerInnerTiled.cpp`: - `LowerInnerTiledPattern` (replaces an iter-bound-empty `inner_tiled` with the per-intrinsic ops emitted by its kind's `buildUnderlyingOperations`) - `DropInnerTiledUnitDimsPattern` (folds unit iteration bounds and pulls the corresponding extract/broadcast pairs out of the loop) Both patterns operate on `IREE::Codegen::InnerTiledOp` and dispatch through the kind's interface, so there is nothing GPU-specific about them. Lifting them lets CPU pass authors share the same lowering logic without a `Codegen/Dialect/GPU/...` include. Renames the populate functions accordingly: - `IREE::GPU::populateIREEGPULowerInnerTiledPatterns` -> `IREE::Codegen::populateLowerInnerTiledPatterns` - `IREE::GPU::populateIREEGPUDropUnitDimsPatterns` -> `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns` The `kShapeCastToIntrinsic` / `kShapeCastFromIntrinsic` and `kDropUnitDims` / `kAddUnitDims` HoistableConversionOp tag constants move with the patterns. The remaining tag pair on the GPU side (`kUnrollAccDistribute` / `kUnrollAccReassemble`) stays in `Codegen/Dialect/GPU/Transforms/Transforms.cpp` since it's still only used by the GPU unroll path. Updates the existing in-tree callers in `LowerIREEGPUOps.cpp`, `IREEGPUExtensions.cpp`, and `UnrollToIntrinsics.cpp`, and adjusts BUILD.bazel/CMakeLists.txt deps so GPU's transform libraries depend on `IREECodegenTransforms`. 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
…degen. (iree-org#24351) Moves the two `iree_codegen.inner_tiled` rewrite patterns and their populate functions out of `Codegen/Dialect/GPU/Transforms/` into `Codegen/Dialect/Codegen/Transforms/LowerInnerTiled.cpp`: - `LowerInnerTiledPattern` (replaces an iter-bound-empty `inner_tiled` with the per-intrinsic ops emitted by its kind's `buildUnderlyingOperations`) - `DropInnerTiledUnitDimsPattern` (folds unit iteration bounds and pulls the corresponding extract/broadcast pairs out of the loop) Both patterns operate on `IREE::Codegen::InnerTiledOp` and dispatch through the kind's interface, so there is nothing GPU-specific about them. Lifting them lets CPU pass authors share the same lowering logic without a `Codegen/Dialect/GPU/...` include. Renames the populate functions accordingly: - `IREE::GPU::populateIREEGPULowerInnerTiledPatterns` -> `IREE::Codegen::populateLowerInnerTiledPatterns` - `IREE::GPU::populateIREEGPUDropUnitDimsPatterns` -> `IREE::Codegen::populateDropInnerTiledUnitDimsPatterns` The `kShapeCastToIntrinsic` / `kShapeCastFromIntrinsic` and `kDropUnitDims` / `kAddUnitDims` HoistableConversionOp tag constants move with the patterns. The remaining tag pair on the GPU side (`kUnrollAccDistribute` / `kUnrollAccReassemble`) stays in `Codegen/Dialect/GPU/Transforms/Transforms.cpp` since it's still only used by the GPU unroll path. Updates the existing in-tree callers in `LowerIREEGPUOps.cpp`, `IREEGPUExtensions.cpp`, and `UnrollToIntrinsics.cpp`, and adjusts BUILD.bazel/CMakeLists.txt deps so GPU's transform libraries depend on `IREECodegenTransforms`. 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]>
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.
Moves the two
iree_codegen.inner_tiledrewrite patterns and their populate functions out ofCodegen/Dialect/GPU/Transforms/intoCodegen/Dialect/Codegen/Transforms/LowerInnerTiled.cpp:LowerInnerTiledPattern(replaces an iter-bound-emptyinner_tiledwith the per-intrinsic ops emitted by its kind'sbuildUnderlyingOperations)DropInnerTiledUnitDimsPattern(folds unit iteration bounds and pulls the corresponding extract/broadcast pairs out of the loop)Both patterns operate on
IREE::Codegen::InnerTiledOpand dispatch through the kind's interface, so there is nothing GPU-specific about them. Lifting them lets CPU pass authors share the same lowering logic without aCodegen/Dialect/GPU/...include.Renames the populate functions accordingly:
IREE::GPU::populateIREEGPULowerInnerTiledPatterns->IREE::Codegen::populateLowerInnerTiledPatternsIREE::GPU::populateIREEGPUDropUnitDimsPatterns->IREE::Codegen::populateDropInnerTiledUnitDimsPatternsThe
kShapeCastToIntrinsic/kShapeCastFromIntrinsicandkDropUnitDims/kAddUnitDimsHoistableConversionOp tag constants move with the patterns. The remaining tag pair on the GPU side (kUnrollAccDistribute/kUnrollAccReassemble) stays inCodegen/Dialect/GPU/Transforms/Transforms.cppsince it's still only used by the GPU unroll path.Updates the existing in-tree callers in
LowerIREEGPUOps.cpp,IREEGPUExtensions.cpp, andUnrollToIntrinsics.cpp, and adjusts BUILD.bazel/CMakeLists.txt deps so GPU's transform libraries depend onIREECodegenTransforms.Strict NFC; no functional or behavioral change.
Progress towards #24323