[Mlir-commits] [mlir] [MLIR][XeGPU][XeVM] XeGPU to XeVM: Add lowering for xegpu.dpas_mx (PR #196981)
Artem Kroviakov
llvmlistbot at llvm.org
Wed May 13 02:31:16 PDT 2026
================
@@ -1066,6 +1076,78 @@ class AtomicRMWToXeVMPattern : public OpConversionPattern<xegpu::AtomicRMWOp> {
}
};
+class DpasMxToXeVMPattern : public OpConversionPattern<xegpu::DpasMxOp> {
+ using OpConversionPattern::OpConversionPattern;
+ LogicalResult
+ matchAndRewrite(xegpu::DpasMxOp op, xegpu::DpasMxOp::Adaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+ auto loc = op.getLoc();
+ auto ctxt = rewriter.getContext();
+ auto aTy = op.getA().getType();
+ auto bTy = op.getB().getType();
+ auto resultType = cast<VectorType>(op.getType());
+
+ auto chipStr = xegpu::getChipStr(op);
+ if (!chipStr)
+ return rewriter.notifyMatchFailure(op, "cannot determine target chip");
+
+ const auto *uArch = xegpu::uArch::getUArch(*chipStr);
+ if (!uArch)
+ return rewriter.notifyMatchFailure(op, "unsupported target uArch");
+
+ // TODO: Add supported shape check
+
+ xevm::ElemType precATy = encodePrecision(aTy.getElementType());
+ xevm::ElemType precBTy = encodePrecision(bTy.getElementType());
+ Value c = op.getAcc();
+ if (!c) {
+ auto elementTy = resultType.getElementType();
+ Attribute initValueAttr;
+ if (isa<FloatType>(elementTy))
+ initValueAttr = FloatAttr::get(elementTy, 0.0);
+ else
+ initValueAttr = IntegerAttr::get(elementTy, 0);
+ c = arith::ConstantOp::create(
----------------
akroviakov wrote:
Can't we call a type conversion on the result type to get a 1d vector type at creation of `c` in this branch?
If we also retrieve c through the adaptor
```
Value c = adaptor.getAcc();
```
then we should not need the `c` shape cast below (either way we have a 1d vector).
https://github.com/llvm/llvm-project/pull/196981
More information about the Mlir-commits
mailing list