diff --git a/include/triton-shared/Conversion/TritonArithToLinalg/ConversionPatterns.hpp b/include/triton-shared/Conversion/TritonArithToLinalg/ConversionPatterns.hpp index 8e8ece4..4f8dbb9 100644 --- a/include/triton-shared/Conversion/TritonArithToLinalg/ConversionPatterns.hpp +++ b/include/triton-shared/Conversion/TritonArithToLinalg/ConversionPatterns.hpp @@ -1098,10 +1098,23 @@ struct MatmulConverter : public OpConversionPattern { auto zeroes = linalg::FillOp::create(rewriter, loc, ValueRange{zero}, ValueRange{init}) .result(); - - auto res = linalg::MatmulOp::create(rewriter, loc, ValueRange{opa, opb}, - ValueRange{zeroes}) - .getResult(0); + Value res; + auto rank = dstType.getRank(); + + if (rank == 2) { + // Standard matmul + res = linalg::MatmulOp::create(rewriter, loc, ValueRange{opa, opb}, + ValueRange{zeroes}) + .getResult(0); + } else if (rank == 3) { + // Batched matmul + res = linalg::BatchMatmulOp::create(rewriter, loc, ValueRange{opa, opb}, + ValueRange{zeroes}) + .getResult(0); + } else { + return rewriter.notifyMatchFailure( + op, "Only 2D or 3D inputs supported for tt.dot lowering"); + } if (!skipC) { if (integers) {