[Mlir-commits] [mlir] [MLIR][XeGPU] Support vector.contract transpose_a/transpose_b via 'vector-to-gpu' patterns (PR #182885)
Dmitry Chigarev
llvmlistbot at llvm.org
Sun Mar 1 13:33:44 PST 2026
================
@@ -844,6 +845,11 @@ struct ContractionLowering : public OpRewritePattern<vector::ContractionOp> {
struct ConvertVectorToXeGPUPass
: public impl::ConvertVectorToXeGPUBase<ConvertVectorToXeGPUPass> {
void runOnOperation() override {
+ RewritePatternSet prep(&getContext());
+ populatePrepareVectorToMMAPatterns(prep);
----------------
dchigarev wrote:
> If I understand correctly, CanonicalizeContractMatmulToMMT is what you need
`CanonicalizeContractMatmulToMMT` seems to do the opposite thing. It sees [`A * B.T` as a canonical form](https://github.com/llvm/llvm-project/blob/d9ca61b6e7b9aa94d244b831a3cb6274d3839d1c/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp#L1764-L1767) so [it doesn't do anything](https://github.com/llvm/llvm-project/blob/d9ca61b6e7b9aa94d244b831a3cb6274d3839d1c/mlir/test/Dialect/Vector/vector-contract-matmul-transforms.mlir#L144-L155) to convert it to the form we want (`A * B.T -> B' = B.T; A * B'`). The pattern from `PrepareVectorToMMAPatterns` do exactly the thing we want - splitting vector.contract_transpose_b into a separate transpose op and a separate contract op.
Unfortunately the `populatePrepareVectorToMMAPatterns` function also [adds another pattern that we don't really need (`CombineTransferReadOpTranspose`)](https://github.com/llvm/llvm-project/blob/d9ca61b6e7b9aa94d244b831a3cb6274d3839d1c/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp#L1260). We can avoid this "extra" pattern by either adding a separate `populateContractToGPUMMA` function or by adding a parameter to the existing populate-method. Both of these would require modifying the common code in `vector-to-gpu` pass, do we want to proceed with this approach?
> why need a separate applyPatternsGreedily here?
Agree, removed separate `applyPatternsGreedily` call
https://github.com/llvm/llvm-project/pull/182885
More information about the Mlir-commits
mailing list