Repository navigation
Conversation
I just replaced the factory function search in the driver registry with the find_if in the algorithms library. It's advisable to utilize STL iterating ops than custom ones. This makes it more readable and encourages consistency. Sorry for the bad formatting, I'm presently on my phone.
Modified my last commit
Collaborator
|
Sorry, but purely stylistic changes like this are difficult to integrate. |
antiagainst
reviewed
May 28, 2021
bjacob
referenced
this pull request
in bjacob/iree
Jan 14, 2022
This fixes the codegen for the 2d vector transfers that we need to do in matmul kernels targeting 2D (matrix) simd operations, for instance allowing PR iree-org#7778 to achieve nice codegen such as: ``` 11a14: ad 05 00 f1 subs x13, x13, #1 11a18: f8 66 c1 ac ldp q24, q25, [x23], iree-org#32 11a1c: 7a 6f c1 ac ldp q26, q27, [x27], iree-org#32 11a20: 41 e3 98 4f sdot v1.4s, v26.16b, v24.4b[0] 11a24: 60 e3 98 4f sdot v0.4s, v27.16b, v24.4b[0] 11a28: 43 e3 b8 4f sdot v3.4s, v26.16b, v24.4b[1] 11a2c: 62 e3 b8 4f sdot v2.4s, v27.16b, v24.4b[1] 11a30: 46 eb 98 4f sdot v6.4s, v26.16b, v24.4b[2] 11a34: 64 eb 98 4f sdot v4.4s, v27.16b, v24.4b[2] 11a38: 53 eb b8 4f sdot v19.4s, v26.16b, v24.4b[3] 11a3c: 70 eb b8 4f sdot v16.4s, v27.16b, v24.4b[3] 11a40: 54 e3 99 4f sdot v20.4s, v26.16b, v25.4b[0] 11a44: 71 e3 99 4f sdot v17.4s, v27.16b, v25.4b[0] 11a48: 57 e3 b9 4f sdot v23.4s, v26.16b, v25.4b[1] 11a4c: 76 e3 b9 4f sdot v22.4s, v27.16b, v25.4b[1] 11a50: 55 eb 99 4f sdot v21.4s, v26.16b, v25.4b[2] 11a54: 72 eb 99 4f sdot v18.4s, v27.16b, v25.4b[2] 11a58: 47 eb b9 4f sdot v7.4s, v26.16b, v25.4b[3] 11a5c: 65 eb b9 4f sdot v5.4s, v27.16b, v25.4b[3] 11a60: a1 fd ff 54 b.ne 0x11a14 <.text+0x11a8> ```
bjacob
referenced
this pull request
in bjacob/iree
Jan 21, 2022
This fixes the codegen for the 2d vector transfers that we need to do in matmul kernels targeting 2D (matrix) simd operations, for instance allowing PR iree-org#7778 to achieve nice codegen such as: ``` 11a14: ad 05 00 f1 subs x13, x13, #1 11a18: f8 66 c1 ac ldp q24, q25, [x23], iree-org#32 11a1c: 7a 6f c1 ac ldp q26, q27, [x27], iree-org#32 11a20: 41 e3 98 4f sdot v1.4s, v26.16b, v24.4b[0] 11a24: 60 e3 98 4f sdot v0.4s, v27.16b, v24.4b[0] 11a28: 43 e3 b8 4f sdot v3.4s, v26.16b, v24.4b[1] 11a2c: 62 e3 b8 4f sdot v2.4s, v27.16b, v24.4b[1] 11a30: 46 eb 98 4f sdot v6.4s, v26.16b, v24.4b[2] 11a34: 64 eb 98 4f sdot v4.4s, v27.16b, v24.4b[2] 11a38: 53 eb b8 4f sdot v19.4s, v26.16b, v24.4b[3] 11a3c: 70 eb b8 4f sdot v16.4s, v27.16b, v24.4b[3] 11a40: 54 e3 99 4f sdot v20.4s, v26.16b, v25.4b[0] 11a44: 71 e3 99 4f sdot v17.4s, v27.16b, v25.4b[0] 11a48: 57 e3 b9 4f sdot v23.4s, v26.16b, v25.4b[1] 11a4c: 76 e3 b9 4f sdot v22.4s, v27.16b, v25.4b[1] 11a50: 55 eb 99 4f sdot v21.4s, v26.16b, v25.4b[2] 11a54: 72 eb 99 4f sdot v18.4s, v27.16b, v25.4b[2] 11a58: 47 eb b9 4f sdot v7.4s, v26.16b, v25.4b[3] 11a5c: 65 eb b9 4f sdot v5.4s, v27.16b, v25.4b[3] 11a60: a1 fd ff 54 b.ne 0x11a14 <.text+0x11a8> ```
bjacob
added a commit
that referenced
this pull request
Jan 21, 2022
This fixes the codegen for the 2d vector transfers that we need to do in matmul kernels targeting 2D (matrix) simd operations, for instance allowing PR #7778 to achieve nice codegen such as: ``` 11a14: ad 05 00 f1 subs x13, x13, #1 11a18: f8 66 c1 ac ldp q24, q25, [x23], #32 11a1c: 7a 6f c1 ac ldp q26, q27, [x27], #32 11a20: 41 e3 98 4f sdot v1.4s, v26.16b, v24.4b[0] 11a24: 60 e3 98 4f sdot v0.4s, v27.16b, v24.4b[0] 11a28: 43 e3 b8 4f sdot v3.4s, v26.16b, v24.4b[1] 11a2c: 62 e3 b8 4f sdot v2.4s, v27.16b, v24.4b[1] 11a30: 46 eb 98 4f sdot v6.4s, v26.16b, v24.4b[2] 11a34: 64 eb 98 4f sdot v4.4s, v27.16b, v24.4b[2] 11a38: 53 eb b8 4f sdot v19.4s, v26.16b, v24.4b[3] 11a3c: 70 eb b8 4f sdot v16.4s, v27.16b, v24.4b[3] 11a40: 54 e3 99 4f sdot v20.4s, v26.16b, v25.4b[0] 11a44: 71 e3 99 4f sdot v17.4s, v27.16b, v25.4b[0] 11a48: 57 e3 b9 4f sdot v23.4s, v26.16b, v25.4b[1] 11a4c: 76 e3 b9 4f sdot v22.4s, v27.16b, v25.4b[1] 11a50: 55 eb 99 4f sdot v21.4s, v26.16b, v25.4b[2] 11a54: 72 eb 99 4f sdot v18.4s, v27.16b, v25.4b[2] 11a58: 47 eb b9 4f sdot v7.4s, v26.16b, v25.4b[3] 11a5c: 65 eb b9 4f sdot v5.4s, v27.16b, v25.4b[3] 11a60: a1 fd ff 54 b.ne 0x11a14 <.text+0x11a8> ```
qedawkins
pushed a commit
to qedawkins/iree
that referenced
this pull request
Feb 10, 2023
Eliasj42
pushed a commit
that referenced
this pull request
Oct 31, 2024
…18894) Main motivation of this patch is to resolve issue where we have the same constOp being used by multiple operations. But with a twist where first time the constOp needs a layout is on a op that topologically comes after other ops that use constOp. This will generate a copy of constOp in the location right before the latter op, which is problematic because this constOp will be used by other ops before it. Previously for the test added we get this error: ``` within split at contraction_layout.mlir:1 offset :24:10: note: see current operation: %9 = "arith.addf"(%8, %6) <{fastmath = #arith.fastmath<none>}> : (vector<96x64xf16>, vector<96x64xf16>) -> vector<96x64xf16> within split at contraction_layout.mlir:1 offset :22:19: error: operand #1 does not dominate this use %scaled_rhs = arith.mulf %read_1, %cst_1 : vector<96x64xf16> ``` While minor, this is also problematic because this error seem to stopped layout analysis (but not fatally) S.T it fails to vector distribute in some cases, making it hard to debug. Signed-off-by: Stanley Winata <[email protected]> Signed-off-by: Elias Joseph <[email protected]>
This was referenced Apr 1, 2025
This was referenced Apr 9, 2025
jtuyls
added a commit
that referenced
this pull request
May 20, 2025
In fusion of consumer `tensor.collapse_shape` operations into `scf.forall`, there is a potential dominance issue if the `tensor.parallel_insert_slice` operation depends on both a BlockArgument and an affine expression on the same BlockArgument (in this order). This lead to the following error for the added test: ``` ... error: operand #1 does not dominate this use %2 = affine.apply #map(%arg4) ... ``` Signed-off-by: Jorn Tuyls <[email protected]>
amd-justchen
pushed a commit
that referenced
this pull request
May 21, 2025
Trying `-DIREE_LINK_COMPILER_SHARED_LIBRARY=OFF` per #20763 (comment)
ziereis
referenced
this pull request
in ziereis/iree
May 22, 2025
In fusion of consumer `tensor.collapse_shape` operations into `scf.forall`, there is a potential dominance issue if the `tensor.parallel_insert_slice` operation depends on both a BlockArgument and an affine expression on the same BlockArgument (in this order). This lead to the following error for the added test: ``` ... error: operand #1 does not dominate this use %2 = affine.apply #map(%arg4) ... ``` Signed-off-by: Jorn Tuyls <[email protected]> Signed-off-by: Thomas Ziereis <[email protected]>
amd-justchen
added a commit
that referenced
this pull request
May 22, 2025
Trying `-DIREE_LINK_COMPILER_SHARED_LIBRARY=OFF` per #20763 (comment) Signed-off-by: Justin Chen <[email protected]>
4 tasks
yzhang93
added a commit
that referenced
this pull request
Jul 24, 2025
This PR adds a pattern to swap the `collapse_shape` with the `extract_slice` op to enable more loop fusion opportunity. Note this pattern is adapted from the upstream[ `BubbleUpCollapseShapeThroughExtractSlice`](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L322) by allowing some special cases we've seen through the IGEMM path. The special case is processed under `CASE #1` session with the corresponding tests mainly focusing on the changes. Note that some strict conditions are added to match the special case for convolutions which maybe not general and robust enough to add to upstream. In addition, we break the [upstream single pattern](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L767) into two separate ones to be able to apply them separately in different passes. --------- Signed-off-by: yzhang93 <[email protected]>
AWoloszyn
pushed a commit
that referenced
this pull request
Dec 1, 2025
In fusion of consumer `tensor.collapse_shape` operations into `scf.forall`, there is a potential dominance issue if the `tensor.parallel_insert_slice` operation depends on both a BlockArgument and an affine expression on the same BlockArgument (in this order). This lead to the following error for the added test: ``` ... error: operand #1 does not dominate this use %2 = affine.apply #map(%arg4) ... ``` Signed-off-by: Jorn Tuyls <[email protected]>
AWoloszyn
pushed a commit
that referenced
this pull request
Dec 1, 2025
This PR adds a pattern to swap the `collapse_shape` with the `extract_slice` op to enable more loop fusion opportunity. Note this pattern is adapted from the upstream[ `BubbleUpCollapseShapeThroughExtractSlice`](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L322) by allowing some special cases we've seen through the IGEMM path. The special case is processed under `CASE #1` session with the corresponding tests mainly focusing on the changes. Note that some strict conditions are added to match the special case for convolutions which maybe not general and robust enough to add to upstream. In addition, we break the [upstream single pattern](https://github.com/llvm/llvm-project/blob/ffb453989b0e95d85b6cfa543b65fec23b65649d/mlir/lib/Dialect/Tensor/Transforms/ReshapePatterns.cpp#L767) into two separate ones to be able to apply them separately in different passes. --------- Signed-off-by: yzhang93 <[email protected]>
robtaylor
added a commit
to ChipFlow/iree
that referenced
this pull request
Feb 23, 2026
…sPass
This fixes a bug that caused ElideTimepointsPass to fail on IR containing
loops (scf.for, scf.while, etc.) with two distinct issues:
1. SSA dominance violations ("operand iree-org#1 does not dominate this use"):
- Added dominance check before absorbing an await timepoint into a
timeline op's await list
- Changed pendingReplacements to use replaceUsesWithIf with dominance
check instead of replaceAllUsesWith
2. Infinite iteration in fixed-point pipeline:
- The pass was creating join ops and then re-adding the same timepoints
because Value identity checks don't detect coverage by join ops
- Added explicit check for whether a timepoint is already covered by
a join in the timeline op's await list
- Fixed didChange tracking to only signal changes when actual
modifications occur
Fixes iree-org#21982
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
glatosinski
pushed a commit
to antmicro/iree
that referenced
this pull request
Apr 13, 2026
lialan
added a commit
that referenced
this pull request
May 8, 2026
GPUPushDownDMABoundsToConsumers fired on every DMA whose innermost dim is statically dynamic, including the common "shape-dynamic but runtime-DWORD-aligned" cases. For 4000x4000xf16 with N_tile=128 the RHS DMA's tensor<32x?xf16> source got both an unnecessary iree_gpu.buffer_resource_cast validBytes wrap and an unnecessary consumer-side extract_slice + tensor.pad chain after the outer forall, even though N=4000 is naturally DWORD-aligned and the LDS tile is fully filled for interior workgroups. The pad chain in particular lowers via vectorizeAsTensorPadOp to a per-thread masked write into a tensor.empty, which bufferization commits to a private alloca round-trip per K-iteration (~8 KB scratch traffic per thread), making the e2e ~450-850x slower than main on 4000/6789/12345 square F16 matmuls on MI355X. Two skip predicates added: - padSourceBufferDescriptorToDWORD: also skip when the *root* tensor's innermost row is statically DWORD-aligned (root_innermost * elemBytes divisible by 4). The wrap exists only to guard the partial-DWORD straddle at the buffer end, which cannot occur when the buffer end is naturally DWORD-aligned. Catches the 4000-class case and preserves the wrap for 64x43, 131x131 (odd inner row, partial DWORD at end is real). - rewriteOneDMA: also skip the post-forall extract_slice + tensor.pad chain when the source's innermost extent has a static upper bound equal to innerTileSize. The UB is read from a static dim, an arith.constant size, or the constant operand of an affine.min on the defining tensor.extract_slice. Safety relies on AMDGPULowerCoalescedDMAToGatherLDS::applyOOBClamping forcing OOB lanes past the root buffer's end and writing 0 to the original (possibly swizzled) LDS destination through the same swizzle the matmul reads through; the matmul then sees zeros in OOB columns identical to what the consumer pad would have written. K-reduction contributions are zero (no pollution); N-OOB outputs are discarded by the downstream output extract_slice. The pad is therefore pure perf-dressing, and removing it avoids the vectorizeAsTensorPadOp / tensor.empty alloca round-trip. Helper getInnermostStaticUpperBound walks tensor.extract_slice -> arith.constant / affine.min to extract a constant UB. Adds three lit test cases: - skip_validbytes_when_root_innermost_aligned (Skip #1 standalone) - skip_consumer_pad_when_inner_ub_matches_tile (both skips fire) - consumer_pad_skipped_even_when_root_misaligned (Skip #2 alone, wrap remains for buffer-end correctness) Also registers gpu_pushdown_dma_bounds_to_consumers.mlir in BUILD.bazel and CMakeLists.txt (it was orphaned on this branch). Verification: - Existing pushdown lit (Tests 1-6): pass. - New pushdown lit (Tests 7-9): pass. - pipeline_dma_unaligned ctest: pass (matmul_64x43x64 still gets validBytes wrap because root 43 is odd). - All swizzle ctests (5/5): pass. - 131x131x131 e2e canary: pass; correct 131.0 in every cell. Boundary workgroup garbage is zeroed by applyOOBClamping; matmul output is correct on both K-boundary (LHS) and N-boundary (RHS). - coalesced_dma|swizzle|pushdown ctest set: 22/22 ran pass. - iree/tests/e2e/matmul label: 12/12 ran pass. Boo perf vs main baseline (mean us, 100 dispatches, gfx950): size main branch (correctness only) branch + Part A vs main 4000 172.82 147403.43 173.22 1.00x 6789 1999.27 909933.93 1101.76 0.55x 12345 10344.51 4843764.74 6965.16 0.67x The 4000 perf regression is fully closed; 6789 and 12345 land ~1.5-1.8x faster than main since the alloca round-trip is now gone on a path main was also taking suboptimally. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
lialan
added a commit
that referenced
this pull request
May 9, 2026
GPUPushDownDMABoundsToConsumers fired on every DMA whose innermost dim is statically dynamic, including the common "shape-dynamic but runtime-DWORD-aligned" cases. For 4000x4000xf16 with N_tile=128 the RHS DMA's tensor<32x?xf16> source got both an unnecessary iree_gpu.buffer_resource_cast validBytes wrap and an unnecessary consumer-side extract_slice + tensor.pad chain after the outer forall, even though N=4000 is naturally DWORD-aligned and the LDS tile is fully filled for interior workgroups. The pad chain in particular lowers via vectorizeAsTensorPadOp to a per-thread masked write into a tensor.empty, which bufferization commits to a private alloca round-trip per K-iteration (~8 KB scratch traffic per thread), making the e2e ~450-850x slower than main on 4000/6789/12345 square F16 matmuls on MI355X. Two skip predicates added: - padSourceBufferDescriptorToDWORD: also skip when the *root* tensor's innermost row is statically DWORD-aligned (root_innermost * elemBytes divisible by 4). The wrap exists only to guard the partial-DWORD straddle at the buffer end, which cannot occur when the buffer end is naturally DWORD-aligned. Catches the 4000-class case and preserves the wrap for 64x43, 131x131 (odd inner row, partial DWORD at end is real). - rewriteOneDMA: also skip the post-forall extract_slice + tensor.pad chain when the source's innermost extent has a static upper bound equal to innerTileSize. The UB is read from a static dim, an arith.constant size, or the constant operand of an affine.min on the defining tensor.extract_slice. Safety relies on AMDGPULowerCoalescedDMAToGatherLDS::applyOOBClamping forcing OOB lanes past the root buffer's end and writing 0 to the original (possibly swizzled) LDS destination through the same swizzle the matmul reads through; the matmul then sees zeros in OOB columns identical to what the consumer pad would have written. K-reduction contributions are zero (no pollution); N-OOB outputs are discarded by the downstream output extract_slice. The pad is therefore pure perf-dressing, and removing it avoids the vectorizeAsTensorPadOp / tensor.empty alloca round-trip. Helper getInnermostStaticUpperBound walks tensor.extract_slice -> arith.constant / affine.min to extract a constant UB. Adds three lit test cases: - skip_validbytes_when_root_innermost_aligned (Skip #1 standalone) - skip_consumer_pad_when_inner_ub_matches_tile (both skips fire) - consumer_pad_skipped_even_when_root_misaligned (Skip #2 alone, wrap remains for buffer-end correctness) Also registers gpu_pushdown_dma_bounds_to_consumers.mlir in BUILD.bazel and CMakeLists.txt (it was orphaned on this branch). Verification: - Existing pushdown lit (Tests 1-6): pass. - New pushdown lit (Tests 7-9): pass. - pipeline_dma_unaligned ctest: pass (matmul_64x43x64 still gets validBytes wrap because root 43 is odd). - All swizzle ctests (5/5): pass. - 131x131x131 e2e canary: pass; correct 131.0 in every cell. Boundary workgroup garbage is zeroed by applyOOBClamping; matmul output is correct on both K-boundary (LHS) and N-boundary (RHS). - coalesced_dma|swizzle|pushdown ctest set: 22/22 ran pass. - iree/tests/e2e/matmul label: 12/12 ran pass. Boo perf vs main baseline (mean us, 100 dispatches, gfx950): size main branch (correctness only) branch + Part A vs main 4000 172.82 147403.43 173.22 1.00x 6789 1999.27 909933.93 1101.76 0.55x 12345 10344.51 4843764.74 6965.16 0.67x The 4000 perf regression is fully closed; 6789 and 12345 land ~1.5-1.8x faster than main since the alloca round-trip is now gone on a path main was also taking suboptimally. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
lialan
added a commit
that referenced
this pull request
May 9, 2026
* tests/e2e/rocm_specific/matmul_unaligned_innermost_dma.mlir: replace the informational stub with two check.expect_almost_eq_const cases: matmul_f16_padded_64x43x64 (K=43, 86 B/row, validBytes wrap + consumer pad both fire) and matmul_f16_dynamic_80x80x80 (all dims 80, 160 B/row DWORD-aligned, non-tile-divisible -> Part A skips fire). * tests/e2e/rocm_specific/CMakeLists.txt: register the new e2e under gfx94|gfx95 with --iree-llvmgpu-use-direct-load. * compiler/src/iree/compiler/Codegen/LLVMGPU/test/ROCDL/ pipeline_dma_unaligned.mlir: add a matmul_80x80x80 block asserting no validBytes operand on fat_raw_buffer_cast and gather_to_lds reaching both bindings (skip #1 + skip #2 verified). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
lialan
added a commit
that referenced
this pull request
May 9, 2026
…ion. GPUPushDownDMABoundsToConsumers's Skip #2 predicate elides the consumer extract_slice + tensor.pad chain when the DMA source's innermost extent has a static upper bound equal to the LDS inner tile size. The original helper hand-walked the SSA chain one level: it required the immediate defining op to be a tensor.extract_slice and read the size operand directly from arith.constant or affine.min. That fired on the canonical shape `tensor.extract_slice ... [..., affine.min(..., tile)]` but gave up on any other producer chain (tensor.cast, multi-level slicing, affine.apply, scf.if, etc.). Switch the body to ValueBoundsConstraintSet::computeConstantBound on the source's innermost dim with closedUB=true. This delegates traversal to ValueBoundsOpInterface implementations registered for tensor, affine, arith, scf, etc., reaching constant upper bounds across full producer chains rather than just the immediate defining op. iree_gpu.buffer_resource_cast does not implement ValueBoundsOpInterface (it is a Pure, AllTypesMatch op that preserves shape). Peel any chain of these casts before delegating, otherwise Skip #2 would silently fail to fire whenever Skip #1's wrap had already been inserted on the source above the DMA. Adds Test 10 (`inner_ub_through_tensor_cast`): tensor.cast between an extract_slice with static inner size and the DMA source. The old helper bailed out on tensor.cast as the immediate defining op; the new helper traces the bound through it and Skip #2 still elides the pad. Root is intentionally DWORD-misaligned so Skip #1 is out of the picture and the test exclusively exercises the generalized UB extraction. All existing pushdown / coalesced-DMA / swizzle ctests pass (10/10). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
lialan
added a commit
that referenced
this pull request
May 12, 2026
GPUPushDownDMABoundsToConsumers fired on every DMA whose innermost dim is statically dynamic, including the common "shape-dynamic but runtime-DWORD-aligned" cases. For 4000x4000xf16 with N_tile=128 the RHS DMA's tensor<32x?xf16> source got both an unnecessary iree_gpu.buffer_resource_cast validBytes wrap and an unnecessary consumer-side extract_slice + tensor.pad chain after the outer forall, even though N=4000 is naturally DWORD-aligned and the LDS tile is fully filled for interior workgroups. The pad chain in particular lowers via vectorizeAsTensorPadOp to a per-thread masked write into a tensor.empty, which bufferization commits to a private alloca round-trip per K-iteration (~8 KB scratch traffic per thread), making the e2e ~450-850x slower than main on 4000/6789/12345 square F16 matmuls on MI355X. Two skip predicates added: - padSourceBufferDescriptorToDWORD: also skip when the *root* tensor's innermost row is statically DWORD-aligned (root_innermost * elemBytes divisible by 4). The wrap exists only to guard the partial-DWORD straddle at the buffer end, which cannot occur when the buffer end is naturally DWORD-aligned. Catches the 4000-class case and preserves the wrap for 64x43, 131x131 (odd inner row, partial DWORD at end is real). - rewriteOneDMA: also skip the post-forall extract_slice + tensor.pad chain when the source's innermost extent has a static upper bound equal to innerTileSize. The UB is read from a static dim, an arith.constant size, or the constant operand of an affine.min on the defining tensor.extract_slice. Safety relies on AMDGPULowerCoalescedDMAToGatherLDS::applyOOBClamping forcing OOB lanes past the root buffer's end and writing 0 to the original (possibly swizzled) LDS destination through the same swizzle the matmul reads through; the matmul then sees zeros in OOB columns identical to what the consumer pad would have written. K-reduction contributions are zero (no pollution); N-OOB outputs are discarded by the downstream output extract_slice. The pad is therefore pure perf-dressing, and removing it avoids the vectorizeAsTensorPadOp / tensor.empty alloca round-trip. Helper getInnermostStaticUpperBound walks tensor.extract_slice -> arith.constant / affine.min to extract a constant UB. Adds three lit test cases: - skip_validbytes_when_root_innermost_aligned (Skip #1 standalone) - skip_consumer_pad_when_inner_ub_matches_tile (both skips fire) - consumer_pad_skipped_even_when_root_misaligned (Skip #2 alone, wrap remains for buffer-end correctness) Also registers gpu_pushdown_dma_bounds_to_consumers.mlir in BUILD.bazel and CMakeLists.txt (it was orphaned on this branch). Verification: - Existing pushdown lit (Tests 1-6): pass. - New pushdown lit (Tests 7-9): pass. - pipeline_dma_unaligned ctest: pass (matmul_64x43x64 still gets validBytes wrap because root 43 is odd). - All swizzle ctests (5/5): pass. - 131x131x131 e2e canary: pass; correct 131.0 in every cell. Boundary workgroup garbage is zeroed by applyOOBClamping; matmul output is correct on both K-boundary (LHS) and N-boundary (RHS). - coalesced_dma|swizzle|pushdown ctest set: 22/22 ran pass. - iree/tests/e2e/matmul label: 12/12 ran pass. Boo perf vs main baseline (mean us, 100 dispatches, gfx950): size main branch (correctness only) branch + Part A vs main 4000 172.82 147403.43 173.22 1.00x 6789 1999.27 909933.93 1101.76 0.55x 12345 10344.51 4843764.74 6965.16 0.67x The 4000 perf regression is fully closed; 6789 and 12345 land ~1.5-1.8x faster than main since the alloca round-trip is now gone on a path main was also taking suboptimally. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
AGindinson
pushed a commit
that referenced
this pull request
Jul 6, 2026
See issue #24673. Details are repeated here. `iree-reduce` crashes in `reduceLinalgOnTensorsDelta` when it tries to replace a `linalg` op that produces a **complex**-typed tensor. The strategy builds a zero constant via `Builder::getZeroAttr(elementType)`, which returns a **null** attribute for `complex` (it only supports int/index/float). Creating an `arith.constant` from the null attribute aborts the process. The proposed fix simply does an early-out if the type is not int, float, or index instead of crashing. Repro: `interesting.sh` ```bash #!/bin/bash # Interestingness oracle for iree-reduce. # # A reduced candidate is "interesting" (exit 0) only while it still contains the # complex-typed linalg.generic (identified by the complex.create in its body). # This keeps the reducer from deleting the op via an earlier strategy, so it # reaches reduceLinalgOnTensorsDelta with the complex op still present. grep -q "complex.create" "$1" ``` `complex_repro.mlir` ``` // Minimal reproducer for the iree-reduce crash in reduceLinalgOnTensorsDelta. // // The linalg.generic writes a complex<f32> tensor. When the reducer decides to // replace this op with a linalg.fill of a zero constant, it calls // Builder::getZeroAttr(complex<f32>), which returns a null attribute. Building // an arith.constant from that null attribute crashes ("Failed to infer result // type(s)"). // // The op survives the earlier reduction strategies because the interestingness // check (interesting.sh) requires "complex.create" to remain present, so the // reducer reaches reduceLinalgOnTensorsDelta with the complex op still in place. func.func @main(%arg0: tensor<4xf32>) -> tensor<4xcomplex<f32>> { %empty = tensor.empty() : tensor<4xcomplex<f32>> %0 = linalg.generic { indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"] } ins(%arg0 : tensor<4xf32>) outs(%empty : tensor<4xcomplex<f32>>) { ^bb0(%in: f32, %out: complex<f32>): %c = complex.create %in, %in : complex<f32> linalg.yield %c : complex<f32> } -> tensor<4xcomplex<f32>> return %0 : tensor<4xcomplex<f32>> } ``` Run using: ```bash chmod +x interesting.sh iree-reduce ./interesting.sh ./complex_repro.mlir -o reduced.mlir ``` Crashes with: ``` LLVM ERROR: Failed to infer result type(s): "arith.constant"(...) {} : () -> ( ??? ) Please report issues to https://github.com/iree-org/iree/issues and include the crash backtrace. Stack dump: 0. Program arguments: ../../fix-undef-global-hoist/iree-compiler/tools/iree-reduce ./interesting.sh ./complex_repro.mlir -o reduced.mlir #0 0x00007aa82ee7cf5b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:881:13 #1 0x00007aa82ee7ab83 llvm::sys::RunSignalHandlers() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:109:18 #2 0x00007aa82ee7de71 SignalHandler(int, siginfo_t*, void*) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:448:38 #3 0x00007aa828e45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330) #4 0x00007aa828e9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x00007aa828e9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10 #6 0x00007aa828e9eb2c pthread_kill ./nptl/pthread_kill.c:89:10 #7 0x00007aa828e4527e raise ./signal/../sysdeps/posix/raise.c:27:6 #8 0x00007aa828e288ff abort ./stdlib/abort.c:81:7 #9 0x00007aa82ee0850b llvm::report_fatal_error(llvm::Twine const&, bool) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/ErrorHandling.cpp:137:5 #10 0x00007aa82ee0858e (fix-undef-global-hoist/iree-compiler/lib/libIREECompiler.so+0x580858e) #11 0x00007aa837dabc21 (fix-undef-global-hoist/iree-compiler/lib/libIREECompiler.so+0xe7abc21) #12 0x00007aa834c50cc1 llvm::SmallVectorTemplateCommon<mlir::Type, void>::begin() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:276:45 #13 0x00007aa834c50cc1 llvm::SmallVectorTemplateCommon<mlir::Type, void>::end() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:278:27 #14 0x00007aa834c50cc1 llvm::SmallVector<mlir::Type, 2u>::~SmallVector() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1242:46 #15 0x00007aa834c50cc1 mlir::arith::ConstantOp::build(mlir::OpBuilder&, mlir::OperationState&, mlir::TypedAttr) fix-undef-global-hoist/iree-compiler/llvm-project/tools/mlir/include/mlir/Dialect/Arith/IR/ArithOps.cpp.inc:4379:1 #16 0x00007aa834c131be mlir::arith::ConstantOp::create(mlir::OpBuilder&, mlir::Location, mlir::TypedAttr) fix-undef-global-hoist/iree-compiler/llvm-project/tools/mlir/include/mlir/Dialect/Arith/IR/ArithOps.cpp.inc:4384:55 #17 0x00007aa8337db6af mlir::Operation::getInlineOpResult(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:1035:61 #18 0x00007aa8337db6af mlir::Operation::getOpResultImpl(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:1045:14 #19 0x00007aa8337db6af mlir::Operation::getResult(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:432:54 #20 0x00007aa8337db6af mlir::OpTrait::OneTypedResult<mlir::Type>::Impl<mlir::arith::ConstantOp>::getResult() fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:708:33 #21 0x00007aa8337db6af mlir::OpTrait::OneTypedResult<mlir::Type>::Impl<mlir::arith::ConstantOp>::operator mlir::Value() fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:713:54 #22 0x00007aa8337db6af mlir::iree_compiler::Reducer::reduceLinalgOnTensorsDelta(mlir::iree_compiler::Reducer::ChunkManager&, mlir::iree_compiler::Reducer::WorkItem&) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Strategies/ReduceLinalgOnTensorsDelta.cpp:114:18 #23 0x00007aa834d464dd mlir::iree_compiler::Reducer::Delta::checkChunk(mlir::iree_compiler::Reducer::Chunk, llvm::function_ref<void (mlir::iree_compiler::Reducer::ChunkManager&, mlir::iree_compiler::Reducer::WorkItem&)>, llvm::ArrayRef<mlir::iree_compiler::Reducer::Chunk>, llvm::DenseSet<mlir::iree_compiler::Reducer::Chunk, llvm::DenseMapInfo<mlir::iree_compiler::Reducer::Chunk, void>>&) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Framework/Delta.cpp:39:8 #24 0x00007aa834d46aa7 llvm::LogicalResult::failed() const fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43 #25 0x00007aa834d46aa7 llvm::failed(llvm::LogicalResult) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58 #26 0x00007aa834d46aa7 mlir::iree_compiler::Reducer::Delta::runDeltaPass(llvm::function_ref<void (mlir::iree_compiler::Reducer::ChunkManager&, mlir::iree_compiler::Reducer::WorkItem&)>, llvm::StringRef) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Framework/Delta.cpp:105:11 #27 0x00007aa82f5d68ea mlir::iree_compiler::Reducer::ireeRunReducingStrategies(mlir::OwningOpRef<mlir::Operation*>, mlir::iree_compiler::Reducer::ReducerConfig&) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/iree_reduce_lib.cc:39:9 #28 0x00007aa82edba149 ireeReduceMainFromCL(int, char**, mlir::MLIRContext&) fix-undef-global-hoist/iree/compiler/src/iree/compiler/API/Internal/IREEReduceToolEntryPoint.cpp:102:26 #29 0x00007aa82edba149 ireeReduceRunMain fix-undef-global-hoist/iree/compiler/src/iree/compiler/API/Internal/IREEReduceToolEntryPoint.cpp:134:7 #30 0x00007aa828e2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #31 0x00007aa828e2a28b call_init ./csu/../csu/libc-start.c:128:20 #32 0x00007aa828e2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5 #33 0x00005a84cb2e26e5 _start (../../fix-undef-global-hoist/iree-compiler/tools/iree-reduce+0x16e5) ``` Signed-off-by: Paul Stark <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[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.
I just replaced the factory function search in the driver registry with the find_if in the algorithms library.
It's advisable to utilize STL iterating ops than custom ones. This makes it more readable and encourages consistency.
Sorry for the bad formatting, I'm presently on my phone.