Repository navigation
[Codegen][CPU] Attach swizzle to inner_tiled encoder info. - #24455
Merged
Merged
Conversation
Follow-up to #24437. That commit made `getUndistributedTileTypes` honor the swizzle's permutation, but the encoder side (`getInnerTiledEncodingInfo`) was still producing a rank-2 row-major inner tile that ignored the swizzle's `expand_shape` and permutation. For existing intrinsics the two sides happen to be compatible under `matchTileTypes`' unit-dim filter, but the encoder's rank-2 shape disagrees with the rank-N permutation-aware tile type as soon as any swizzle has a non-identity permutation (e.g. pre-transposed intrinsics, added in a follow-up). Set `info.swizzle = IREE::CPU::getSwizzle(mma, operandIdx)` so the pack pipeline's existing `getSwizzledShape` bridge applies the swizzle's `expand_shape` + `transpose` to the packed inner tile, matching the tile type `getUndistributedTileTypes` returns. Mirrors GPU's `getEncodingInfoImpl`. Drop the stale "Only used on GPU" comment on the `swizzle` field. Test fallout: `materialize_encoding_x86_64.mlir`'s four `_inner_tiled_avx512` CHECK groups now expect the `tensor.expand_shape` after each pack and the `tensor.collapse_shape` before the unpack, with the rank-N inner tile that the swizzle materializes. Progress towards #24323. Signed-off-by: Benoit Jacob <[email protected]>
25 of 28 tasks
bjacob
marked this pull request as ready for review
May 12, 2026 19:37
bjacob
requested review from
MaheshRavishankar,
Max191,
hanhanW,
jtuyls and
qedawkins
as code owners
May 12, 2026 19:38
hanhanW
approved these changes
May 12, 2026
bjacob
added a commit
that referenced
this pull request
May 14, 2026
…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]>
bjacob
added a commit
that referenced
this pull request
May 14, 2026
…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]>
bjacob
added a commit
that referenced
this pull request
May 14, 2026
…r tiles. (#24488) 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. Signed-off-by: Benoit Jacob <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
RattataKing
pushed a commit
to RattataKing/iree
that referenced
this pull request
May 27, 2026
…24455) Follow-up to iree-org#24437. That commit made `getUndistributedTileTypes` honor the swizzle's permutation, but the encoder side (`getInnerTiledEncodingInfo`) was still producing a rank-2 row-major inner tile that ignored the swizzle's `expand_shape` and permutation. For existing intrinsics the two sides happen to be compatible under `matchTileTypes`' unit-dim filter, but the encoder's rank-2 shape disagrees with the rank-N permutation-aware tile type as soon as any swizzle has a non-identity permutation (e.g. pre-transposed intrinsics, added in a follow-up). Set `info.swizzle = IREE::CPU::getSwizzle(mma, operandIdx)` so the pack pipeline's existing `getSwizzledShape` bridge applies the swizzle's `expand_shape` + `transpose` to the packed inner tile, matching the tile type `getUndistributedTileTypes` returns. Mirrors GPU's `getEncodingInfoImpl`. Drop the stale "Only used on GPU" comment on the `swizzle` field. Test fallout: `materialize_encoding_x86_64.mlir`'s four `_inner_tiled_avx512` CHECK groups now expect the `tensor.expand_shape` after each pack and the `tensor.collapse_shape` before the unpack, with the rank-N inner tile that the swizzle materializes. Progress towards iree-org#24323. Signed-off-by: Benoit Jacob <[email protected]>
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.
Follow-up to #24437. That commit made
getUndistributedTileTypeshonor the swizzle's permutation, but the encoder side (getInnerTiledEncodingInfo) was still producing a rank-2 row-major inner tile that ignored the swizzle'sexpand_shapeand permutation. For existing intrinsics the two sides happen to be compatible undermatchTileTypes' unit-dim filter, but the encoder's rank-2 shape disagrees with the rank-N permutation-aware tile type as soon as any swizzle has a non-identity permutation (e.g. pre-transposed intrinsics, added in a follow-up).Set
info.swizzle = IREE::CPU::getSwizzle(mma, operandIdx)so the pack pipeline's existinggetSwizzledShapebridge applies the swizzle'sexpand_shape+transposeto the packed inner tile, matching the tile typegetUndistributedTileTypesreturns. Mirrors GPU'sgetEncodingInfoImpl. Drop the stale "Only used on GPU" comment on theswizzlefield.Test fallout:
materialize_encoding_x86_64.mlir's four_inner_tiled_avx512CHECK groups now expect thetensor.expand_shapeafter each pack and thetensor.collapse_shapebefore the unpack, with the rank-N inner tile that the swizzle materializes.Progress towards #24323.