Repository navigation
[Codegen][CPU] Fix lowerGenericScalarToVectorContract for rank-N inner tiles. - #24488
Merged
Merged
Conversation
…r tiles. After #24455 attaches the per-operand swizzle to the encoder info, the `inner_tiled` op for the generic-scalar 1×1×1 MMA family receives operands whose non-unit dim (size = `intrinsics_{m,n,k}`) can sit at any position in the rank-N tile, not just at the start. The previous `dropTrailingUnitDims` reduction relied on non-unit dims being leading, so e.g. an LHS tile of shape `vector<1x1x4x1x1xf32>` (intrinsics_m=4 with N=K=1) collapsed to rank-3 `vector<1x1x4>` instead of the rank-2 `(M, K)` shape `vector.contract` needs — and the wrapper code then emitted a malformed `vector.broadcast` of `vector<4x1>` into `vector<1x1x4x1x1>` to glue the result back to the inner_tiled's output tile. Switch to a `vector.shape_cast` directly to the canonical `(M, K) / (N, K) / (M, N)` rank-2 shape: by construction (1×1×1 base intrinsic) every non-unit dim contributing to an operand tile came from an `intrinsics_*` cross-intrinsic factor, so the total element count of each operand is exactly `intrinsics_m * intrinsics_k` (etc.) and the shape_cast is element-preserving. `shape_cast` the contract result back to the inner_tiled op's original ACC tile shape so verification matches downstream. Progress towards #24323. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> Signed-off-by: Benoit Jacob <[email protected]>
hanhanW
approved these changes
May 14, 2026
RattataKing
pushed a commit
to RattataKing/iree
that referenced
this pull request
May 27, 2026
…r tiles. (iree-org#24488) After iree-org#24455 attaches the per-operand swizzle to the encoder info, the `inner_tiled` op for the generic-scalar 1×1×1 MMA family receives operands whose non-unit dim (size = `intrinsics_{m,n,k}`) can sit at any position in the rank-N tile, not just at the start. The previous `dropTrailingUnitDims` reduction relied on non-unit dims being leading, so e.g. an LHS tile of shape `vector<1x1x4x1x1xf32>` (intrinsics_m=4 with N=K=1) collapsed to rank-3 `vector<1x1x4>` instead of the rank-2 `(M, K)` shape `vector.contract` needs — and the wrapper code then emitted a malformed `vector.broadcast` of `vector<4x1>` into `vector<1x1x4x1x1>` to glue the result back to the inner_tiled's output tile. Switch to a `vector.shape_cast` directly to the canonical `(M, K) / (N, K) / (M, N)` rank-2 shape: by construction (1×1×1 base intrinsic) every non-unit dim contributing to an operand tile came from an `intrinsics_*` cross-intrinsic factor, so the total element count of each operand is exactly `intrinsics_m * intrinsics_k` (etc.) and the shape_cast is element-preserving. `shape_cast` the contract result back to the inner_tiled op's original ACC tile shape so verification matches downstream. Progress towards iree-org#24323. Signed-off-by: Benoit Jacob <[email protected]> Co-authored-by: Claude Opus 4.7 (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.
After #24455 attaches the per-operand swizzle to the encoder info, the
inner_tiledop for the generic-scalar 1×1×1 MMA family receives operands whose non-unit dim (size =intrinsics_{m,n,k}) can sit at any position in the rank-N tile, not just at the start. The previousdropTrailingUnitDimsreduction relied on non-unit dims being leading, so e.g. an LHS tile of shapevector<1x1x4x1x1xf32>(intrinsics_m=4 with N=K=1) collapsed to rank-3vector<1x1x4>instead of the rank-2(M, K)shapevector.contractneeds — and the wrapper code then emitted a malformedvector.broadcastofvector<4x1>intovector<1x1x4x1x1>to glue the result back to the inner_tiled's output tile.Switch to a
vector.shape_castdirectly to the canonical(M, K) / (N, K) / (M, N)rank-2 shape: by construction (1×1×1 base intrinsic) every non-unit dim contributing to an operand tile came from anintrinsics_*cross-intrinsic factor, so the total element count of each operand is exactlyintrinsics_m * intrinsics_k(etc.) and the shape_cast is element-preserving.shape_castthe contract result back to the inner_tiled op's original ACC tile shape so verification matches downstream.Progress towards #24323.