MLIR 24.0.0git
WmmaOpsToNvvm.cpp
Go to the documentation of this file.
1//===------ WmmaOpsToNVVM.cpp - WMMA LD/ST/Compute to NVVM lowering -------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains definitions of patterns to lower GPU Subgroup MMA ops to
10// NVVM Dialect.
11//
12//===----------------------------------------------------------------------===//
13
24#include "mlir/IR/Types.h"
25
26using namespace mlir;
27
28namespace {
29
30/// Checks if all the operands of the op being lowered are of LLVM Types. The
31/// types are expected to be converted by the `LLVMTypeConverter` before the op
32/// is actually lowered. If the type of an operands is not already converted it
33/// hints a missing typeConversion and failure is returned in that case.
34static LogicalResult areAllLLVMTypes(Operation *op, ValueRange operands,
35 ConversionPatternRewriter &rewriter) {
36 if (!llvm::all_of(operands, [](Value value) {
37 return LLVM::isCompatibleType(value.getType());
38 })) {
39 return rewriter.notifyMatchFailure(
40 op, "cannot convert if operands aren't of LLVM type.");
41 }
42
43 return success();
44}
45
46/// Error string to emit when an unimplemented WMMA variant is encountered.
47static constexpr StringRef kInvalidCaseStr = "Unsupported WMMA variant.";
48
49static NVVM::MMAFrag convertOperand(StringRef operandName) {
50 if (operandName == "AOp")
51 return NVVM::MMAFrag::a;
52 if (operandName == "BOp")
53 return NVVM::MMAFrag::b;
54 if (operandName == "COp")
55 return NVVM::MMAFrag::c;
56 llvm_unreachable("Unknown operand name");
57}
58
59static NVVM::MMATypes getElementType(gpu::MMAMatrixType type) {
60 if (type.getElementType().isF16())
61 return NVVM::MMATypes::f16;
62 if (type.getElementType().isF32())
63 return type.getOperand() == "COp" ? NVVM::MMATypes::f32
64 : NVVM::MMATypes::tf32;
65 if (type.getElementType().isF64())
66 return NVVM::MMATypes::f64;
67 if (type.getElementType().isSignedInteger(8))
68 return NVVM::MMATypes::s8;
70 return NVVM::MMATypes::u8;
71 // Accumulator type is signless and implies signed.
72 if (type.getElementType().isInteger(32))
73 return NVVM::MMATypes::s32;
74 llvm_unreachable("Unsupported type");
75}
76
77/// This class implements the conversion of GPU MMA loadOp to wmma.load op
78/// in the NVVM dialect. The conversion not only emits the NVVM op but also
79/// emits code that is necessary to store the data in the destination memref
80/// after it has been loaded.
81struct WmmaLoadOpToNVVMLowering
82 : public ConvertOpToLLVMPattern<gpu::SubgroupMmaLoadMatrixOp> {
83 using ConvertOpToLLVMPattern<
84 gpu::SubgroupMmaLoadMatrixOp>::ConvertOpToLLVMPattern;
85
86 LogicalResult
87 matchAndRewrite(gpu::SubgroupMmaLoadMatrixOp subgroupMmaLoadMatrixOp,
88 OpAdaptor adaptor,
89 ConversionPatternRewriter &rewriter) const override {
90 Operation *op = subgroupMmaLoadMatrixOp.getOperation();
91 if (failed(areAllLLVMTypes(op, adaptor.getOperands(), rewriter)))
92 return failure();
93
94 // Get the shape of the MMAMatrix type being returned. The shape will
95 // choose which intrinsic this op will be lowered to.
96 NVVM::MMALayout layout = subgroupMmaLoadMatrixOp.getTranspose()
97 ? NVVM::MMALayout::col
98 : NVVM::MMALayout::row;
99 gpu::MMAMatrixType retType =
100 cast<gpu::MMAMatrixType>(subgroupMmaLoadMatrixOp.getRes().getType());
101 ArrayRef<int64_t> retTypeShape = retType.getShape();
102 int64_t m = 0;
103 int64_t n = 0;
104 int64_t k = 0;
105 NVVM::MMATypes eltype = getElementType(retType);
106 // NVVM intrinsics require to give mxnxk dimensions, infer the missing
107 // dimension based on the valid intrinsics available.
108 if (retType.getOperand() == "AOp") {
109 m = retTypeShape[0];
110 k = retTypeShape[1];
111 n = NVVM::WMMALoadOp::inferNDimension(m, k, eltype);
112 } else if (retType.getOperand() == "BOp") {
113 k = retTypeShape[0];
114 n = retTypeShape[1];
115 m = NVVM::WMMALoadOp::inferMDimension(k, n, eltype);
116 } else if (retType.getOperand() == "COp") {
117 m = retTypeShape[0];
118 n = retTypeShape[1];
119 k = NVVM::WMMALoadOp::inferKDimension(m, n, eltype);
120 }
121 NVVM::MMAFrag frag = convertOperand(retType.getOperand());
122 // Check that there is an exisiting instruction for the combination we need.
123 if (NVVM::WMMALoadOp::getIntrinsicID(m, n, k, layout, eltype, frag) == 0)
124 return rewriter.notifyMatchFailure(op, kInvalidCaseStr);
125
126 Type resType = convertMMAToLLVMType(retType);
127 Location loc = op->getLoc();
128
129 // Create nvvm.mma_load op according to the operand types.
130 Value dataPtr = getStridedElementPtr(
131 rewriter, loc,
132 cast<MemRefType>(subgroupMmaLoadMatrixOp.getSrcMemref().getType()),
133 adaptor.getSrcMemref(), adaptor.getIndices());
134
135 // The NVVM op takes the leading dimension as an `i32`. Reject a value that
136 // does not fit rather than silently truncating it.
137 int64_t leadDimension =
138 subgroupMmaLoadMatrixOp.getLeadDimension().getSExtValue();
139 if (!llvm::isInt<32>(leadDimension))
140 return rewriter.notifyMatchFailure(
141 op, "leading dimension does not fit into an i32");
142 Value leadingDim = LLVM::ConstantOp::create(
143 rewriter, loc, rewriter.getI32Type(),
144 rewriter.getI32IntegerAttr(static_cast<int32_t>(leadDimension)));
145 rewriter.replaceOpWithNewOp<NVVM::WMMALoadOp>(
146 op, resType, dataPtr, leadingDim, m, n, k, layout, eltype, frag);
147 return success();
148 }
149};
150
151/// This class implements the conversion of GPU MMA storeOp to wmma.store op
152/// in the NVVM dialect. The conversion not only emits the NVVM op but also
153/// emits code that is necessary to unpack the data in the source and
154/// convert the data in the format that is needed by the NVVM op.
155struct WmmaStoreOpToNVVMLowering
156 : public ConvertOpToLLVMPattern<gpu::SubgroupMmaStoreMatrixOp> {
157 using ConvertOpToLLVMPattern<
158 gpu::SubgroupMmaStoreMatrixOp>::ConvertOpToLLVMPattern;
159
160 LogicalResult
161 matchAndRewrite(gpu::SubgroupMmaStoreMatrixOp subgroupMmaStoreMatrixOp,
162 OpAdaptor adaptor,
163 ConversionPatternRewriter &rewriter) const override {
164 Operation *op = subgroupMmaStoreMatrixOp.getOperation();
165 if (failed(areAllLLVMTypes(op, adaptor.getOperands(), rewriter)))
166 return failure();
167
168 Location loc = op->getLoc();
169
170 SmallVector<Value, 4> storeOpOperands;
171 // Get the shape of the MMAMatrix type being stored. The shape will
172 // choose which intrinsic this op will be lowered to.
173 gpu::MMAMatrixType srcType =
174 cast<gpu::MMAMatrixType>(subgroupMmaStoreMatrixOp.getSrc().getType());
175 ArrayRef<int64_t> srcTypeShape = srcType.getShape();
176 NVVM::MMALayout layout = subgroupMmaStoreMatrixOp.getTranspose()
177 ? NVVM::MMALayout::col
178 : NVVM::MMALayout::row;
179 NVVM::MMATypes eltype = getElementType(srcType);
180 int64_t m = srcTypeShape[0];
181 int64_t n = srcTypeShape[1];
182 int64_t k = NVVM::WMMAStoreOp::inferKDimension(m, n, eltype);
183 if (NVVM::WMMAStoreOp::getIntrinsicID(m, n, k, layout, eltype) == 0)
184 return rewriter.notifyMatchFailure(op, kInvalidCaseStr);
185
186 auto matrixType = cast<LLVM::LLVMStructType>(adaptor.getSrc().getType());
187 for (unsigned i = 0, e = matrixType.getBody().size(); i < e; ++i) {
188 Value toUse =
189 LLVM::ExtractValueOp::create(rewriter, loc, adaptor.getSrc(), i);
190 storeOpOperands.push_back(toUse);
191 }
192
193 Value dataPtr = getStridedElementPtr(
194 rewriter, loc,
195 cast<MemRefType>(subgroupMmaStoreMatrixOp.getDstMemref().getType()),
196 adaptor.getDstMemref(), adaptor.getIndices());
197 // The NVVM op takes the leading dimension as an `i32`. Reject a value that
198 // does not fit rather than silently truncating it.
199 int64_t leadDimension =
200 subgroupMmaStoreMatrixOp.getLeadDimension().getSExtValue();
201 if (!llvm::isInt<32>(leadDimension))
202 return rewriter.notifyMatchFailure(
203 op, "leading dimension does not fit into an i32");
204 Value leadingDim = LLVM::ConstantOp::create(
205 rewriter, loc, rewriter.getI32Type(),
206 rewriter.getI32IntegerAttr(static_cast<int32_t>(leadDimension)));
207 rewriter.replaceOpWithNewOp<NVVM::WMMAStoreOp>(
208 op, dataPtr, m, n, k, layout, eltype, storeOpOperands, leadingDim);
209 return success();
210 }
211};
212
213/// This class implements the conversion of GPU MMA computeOp to wmma.mma op
214/// in the NVVM dialect.
215struct WmmaMmaOpToNVVMLowering
216 : public ConvertOpToLLVMPattern<gpu::SubgroupMmaComputeOp> {
217 using ConvertOpToLLVMPattern<
218 gpu::SubgroupMmaComputeOp>::ConvertOpToLLVMPattern;
219
220 LogicalResult
221 matchAndRewrite(gpu::SubgroupMmaComputeOp subgroupMmaComputeOp,
222 OpAdaptor adaptor,
223 ConversionPatternRewriter &rewriter) const override {
224 Operation *op = subgroupMmaComputeOp.getOperation();
225 if (failed(areAllLLVMTypes(op, adaptor.getOperands(), rewriter)))
226 return failure();
227
228 Location loc = op->getLoc();
229
230 // The wmma.mma intrinsic in llvm requires the operands as individual
231 // values. So individual elements from the memrefs need to be extracted and
232 // then passed on to the intrinsic call. Emit llvm ops to extract individual
233 // values form lowered memrefs.
234 SmallVector<Value> unpackedOps;
235 auto unpackOp = [&](Value operand) {
236 // f64 a and b fragments are not structs but scalars.
237 if (!isa<LLVM::LLVMStructType>(operand.getType())) {
238 unpackedOps.push_back(operand);
239 return;
240 }
241 // every other type is lowered to an LLVM struct, extract the values.
242 auto structType = cast<LLVM::LLVMStructType>(operand.getType());
243 for (size_t i = 0, e = structType.getBody().size(); i < e; ++i) {
244 Value toUse = LLVM::ExtractValueOp::create(rewriter, loc, operand, i);
245 unpackedOps.push_back(toUse);
246 }
247 };
248
249 // Get the shapes of the MMAMatrix type being used. The shapes will
250 // choose which intrinsic this op will be lowered to.
251 gpu::MMAMatrixType aType =
252 cast<gpu::MMAMatrixType>(subgroupMmaComputeOp.getOpA().getType());
253 ArrayRef<int64_t> aTypeShape = aType.getShape();
254 gpu::MMAMatrixType cType =
255 cast<gpu::MMAMatrixType>(subgroupMmaComputeOp.getOpC().getType());
256 ArrayRef<int64_t> cTypeShape = cType.getShape();
257 int64_t m = cTypeShape[0];
258 int64_t n = cTypeShape[1];
259 int64_t k = aTypeShape[1];
260 NVVM::MMALayout aLayout = subgroupMmaComputeOp.getATranspose()
261 ? NVVM::MMALayout::col
262 : NVVM::MMALayout::row;
263 NVVM::MMALayout bLayout = subgroupMmaComputeOp.getBTranspose()
264 ? NVVM::MMALayout::col
265 : NVVM::MMALayout::row;
266 NVVM::MMATypes sourceType = getElementType(aType);
267 NVVM::MMATypes destType = getElementType(cType);
268 if (NVVM::WMMAMmaOp::getIntrinsicID(m, n, k, aLayout, bLayout, sourceType,
269 destType) == 0)
270 return rewriter.notifyMatchFailure(op, kInvalidCaseStr);
271
272 NVVM::MMATypes bElementType = getElementType(
273 cast<gpu::MMAMatrixType>(subgroupMmaComputeOp.getOpB().getType()));
274 if (bElementType != sourceType)
275 return rewriter.notifyMatchFailure(
276 op, "WMMA compute op input matrix element types must match.");
277
278 unpackOp(adaptor.getOpA());
279 unpackOp(adaptor.getOpB());
280 unpackOp(adaptor.getOpC());
281
282 rewriter.replaceOpWithNewOp<NVVM::WMMAMmaOp>(
283 op, adaptor.getOpC().getType(), m, n, k, aLayout, bLayout, sourceType,
284 destType, unpackedOps);
285 return success();
286 }
287};
288
289/// Convert GPU MMA ConstantMatrixOp to a chain of InsertValueOp.
290struct WmmaConstantOpToNVVMLowering
291 : public ConvertOpToLLVMPattern<gpu::SubgroupMmaConstantMatrixOp> {
292 using ConvertOpToLLVMPattern<
293 gpu::SubgroupMmaConstantMatrixOp>::ConvertOpToLLVMPattern;
294
295 LogicalResult
296 matchAndRewrite(gpu::SubgroupMmaConstantMatrixOp subgroupMmaConstantOp,
297 OpAdaptor adaptor,
298 ConversionPatternRewriter &rewriter) const override {
299 if (failed(areAllLLVMTypes(subgroupMmaConstantOp.getOperation(),
300 adaptor.getOperands(), rewriter)))
301 return failure();
302 Location loc = subgroupMmaConstantOp.getLoc();
303 Value cst = adaptor.getOperands()[0];
304 Type type = convertMMAToLLVMType(
305 cast<gpu::MMAMatrixType>(subgroupMmaConstantOp.getType()));
306 // If the element is not a struct, it means it's a scalar f64.
307 auto structType = dyn_cast<LLVM::LLVMStructType>(type);
308 if (!structType) {
309 rewriter.replaceOp(subgroupMmaConstantOp, cst);
310 return success();
311 }
312 // If the element type is a vector create a vector from the operand.
313 if (auto vecType = dyn_cast<VectorType>(structType.getBody()[0])) {
314 Value vecCst = LLVM::PoisonOp::create(rewriter, loc, vecType);
315 for (int64_t vecEl = 0; vecEl < vecType.getNumElements(); vecEl++) {
316 Value idx = LLVM::ConstantOp::create(rewriter, loc,
317 rewriter.getI32Type(), vecEl);
318 vecCst = LLVM::InsertElementOp::create(rewriter, loc, vecType, vecCst,
319 cst, idx);
320 }
321 cst = vecCst;
322 }
323 Value matrixStruct = LLVM::PoisonOp::create(rewriter, loc, structType);
324 for (size_t i : llvm::seq(size_t(0), structType.getBody().size())) {
325 matrixStruct =
326 LLVM::InsertValueOp::create(rewriter, loc, matrixStruct, cst, i);
327 }
328 rewriter.replaceOp(subgroupMmaConstantOp, matrixStruct);
329 return success();
330 }
331};
332
333static Value createMinMaxF(OpBuilder &builder, Location loc, Value lhs,
334 Value rhs, bool isMin) {
335 auto floatType = cast<FloatType>(getElementTypeOrSelf(lhs.getType()));
336 Type i1Type = builder.getI1Type();
337 if (auto vecType = dyn_cast<VectorType>(lhs.getType()))
338 i1Type = VectorType::get(vecType.getShape(), i1Type);
339 Value cmp = LLVM::FCmpOp::create(
340 builder, loc, i1Type,
341 isMin ? LLVM::FCmpPredicate::olt : LLVM::FCmpPredicate::ogt, lhs, rhs);
342 Value sel = LLVM::SelectOp::create(builder, loc, cmp, lhs, rhs);
343 Value isNan = LLVM::FCmpOp::create(builder, loc, i1Type,
344 LLVM::FCmpPredicate::uno, lhs, rhs);
345 Value nan = LLVM::ConstantOp::create(
346 builder, loc, lhs.getType(),
347 builder.getFloatAttr(floatType,
348 APFloat::getQNaN(floatType.getFloatSemantics())));
349 return LLVM::SelectOp::create(builder, loc, isNan, nan, sel);
350}
351
352static Value createScalarOp(OpBuilder &builder, Location loc,
353 gpu::MMAElementwiseOp op,
354 ArrayRef<Value> operands) {
355 switch (op) {
356 case gpu::MMAElementwiseOp::ADDF:
357 return LLVM::FAddOp::create(builder, loc, operands[0].getType(), operands);
358 case gpu::MMAElementwiseOp::MULF:
359 return LLVM::FMulOp::create(builder, loc, operands[0].getType(), operands);
360 case gpu::MMAElementwiseOp::DIVF:
361 return LLVM::FDivOp::create(builder, loc, operands[0].getType(), operands);
362 case gpu::MMAElementwiseOp::MAXF:
363 return createMinMaxF(builder, loc, operands[0], operands[1],
364 /*isMin=*/false);
365 case gpu::MMAElementwiseOp::MINF:
366 return createMinMaxF(builder, loc, operands[0], operands[1],
367 /*isMin=*/true);
368 default:
369 llvm_unreachable("unknown op");
370 }
371}
372
373/// Convert GPU MMA elementwise ops to extract + op + insert.
374struct WmmaElementwiseOpToNVVMLowering
375 : public ConvertOpToLLVMPattern<gpu::SubgroupMmaElementwiseOp> {
376 using ConvertOpToLLVMPattern<
377 gpu::SubgroupMmaElementwiseOp>::ConvertOpToLLVMPattern;
378
379 LogicalResult
380 matchAndRewrite(gpu::SubgroupMmaElementwiseOp subgroupMmaElementwiseOp,
381 OpAdaptor adaptor,
382 ConversionPatternRewriter &rewriter) const override {
383 if (failed(areAllLLVMTypes(subgroupMmaElementwiseOp.getOperation(),
384 adaptor.getOperands(), rewriter)))
385 return failure();
386 Location loc = subgroupMmaElementwiseOp.getLoc();
387 size_t numOperands = adaptor.getOperands().size();
388 Type destType = convertMMAToLLVMType(
389 cast<gpu::MMAMatrixType>(subgroupMmaElementwiseOp.getType()));
390
391 // If the element is not a struct, it means it's a scalar f64.
392 LLVM::LLVMStructType structDestTy =
393 dyn_cast<LLVM::LLVMStructType>(destType);
394 if (!structDestTy) {
395 SmallVector<Value> operands;
396 for (auto operand : adaptor.getOperands()) {
397 operands.push_back(operand);
398 }
399 Value element = createScalarOp(
400 rewriter, loc, subgroupMmaElementwiseOp.getOpType(), operands);
401 rewriter.replaceOp(subgroupMmaElementwiseOp, element);
402 return success();
403 }
404 Value matrixStruct = LLVM::PoisonOp::create(rewriter, loc, structDestTy);
405 for (size_t i = 0, e = structDestTy.getBody().size(); i < e; ++i) {
406 SmallVector<Value> extractedOperands;
407 for (size_t opIdx = 0; opIdx < numOperands; opIdx++) {
408 extractedOperands.push_back(LLVM::ExtractValueOp::create(
409 rewriter, loc, adaptor.getOperands()[opIdx], i));
410 }
411 Value element =
412 createScalarOp(rewriter, loc, subgroupMmaElementwiseOp.getOpType(),
413 extractedOperands);
414 matrixStruct =
415 LLVM::InsertValueOp::create(rewriter, loc, matrixStruct, element, i);
416 }
417 rewriter.replaceOp(subgroupMmaElementwiseOp, matrixStruct);
418 return success();
419 }
420};
421
422} // namespace
423
424/// Return the LLVMStructureType corresponding to the MMAMatrixType `type`.
426 NVVM::MMAFrag frag = convertOperand(type.getOperand());
427 NVVM::MMATypes eltType = getElementType(type);
428 auto nRow = type.getShape()[0];
429 auto nCol = type.getShape()[1];
430 std::pair<Type, unsigned> typeInfo =
431 NVVM::inferMMAType(eltType, frag, nRow, nCol, type.getContext());
432 // Special handling for f64 a and b fragments
433 Type f64Ty = Float64Type::get(type.getContext());
434 if (typeInfo.first == f64Ty && typeInfo.second == 1) {
435 return f64Ty;
436 }
437 return LLVM::LLVMStructType::getLiteral(
438 type.getContext(), SmallVector<Type, 8>(typeInfo.second, typeInfo.first));
439}
440
442 const LLVMTypeConverter &converter, RewritePatternSet &patterns,
443 PatternBenefit benefit) {
444 patterns.add<WmmaLoadOpToNVVMLowering, WmmaMmaOpToNVVMLowering,
445 WmmaStoreOpToNVVMLowering, WmmaConstantOpToNVVMLowering,
446 WmmaElementwiseOpToNVVMLowering>(converter, benefit);
447}
return success()
static LogicalResult areAllLLVMTypes(Operation *op, ValueRange operands, ConversionPatternRewriter &rewriter)
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
Definition SPIRVOps.cpp:230
FloatAttr getFloatAttr(Type type, double value)
Definition Builders.cpp:263
IntegerType getI1Type()
Definition Builders.cpp:61
Utility class for operation conversions targeting the LLVM dialect that match exactly one source oper...
Definition Pattern.h:233
Conversion from types to the LLVM IR dialect.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
This class helps build Operations.
Definition Builders.h:210
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Location getLoc()
The source location the operation was defined or derived from.
Definition Operation.h:240
This class represents the benefit of a pattern match in a unitless scheme that ranges from 0 (very li...
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
bool isF64() const
Definition Types.cpp:41
bool isSignedInteger() const
Return true if this is a signed integer type (with the specified width).
Definition Types.cpp:78
bool isF32() const
Definition Types.cpp:40
bool isUnsignedInteger() const
Return true if this is an unsigned integer type (with the specified width).
Definition Types.cpp:90
bool isInteger() const
Return true if this is an integer type (with the specified width).
Definition Types.cpp:58
bool isF16() const
Definition Types.cpp:38
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:392
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Type getType() const
Return the type of this value.
Definition Value.h:105
MMAMatrix represents a matrix held by a subgroup for matrix-matrix multiply accumulate operations.
Definition GPUBase.h:132
ArrayRef< int64_t > getShape() const
Get shape of the matrix.
Definition GPUBase.cpp:129
Type getElementType() const
Get elementType of a single element.
Definition GPUBase.cpp:133
StringRef getOperand() const
The general form of operation this type supports is given by the equation C += A*B.
Definition GPUBase.cpp:135
Value getStridedElementPtr(OpBuilder &builder, Location loc, const LLVMTypeConverter &converter, MemRefType type, Value memRefDesc, ValueRange indices, LLVM::GEPNoWrapFlags noWrapFlags=LLVM::GEPNoWrapFlags::none)
Performs the index computation to get to the element at indices of the memory pointed to by memRefDes...
Definition Pattern.cpp:628
bool isCompatibleType(Type type)
Returns true if the given type is compatible with the LLVM dialect.
std::pair< mlir::Type, unsigned > inferMMAType(mlir::NVVM::MMATypes type, mlir::NVVM::MMAFrag frag, int nRow, int nCol, mlir::MLIRContext *context)
Return the element type and number of elements associated with a wmma matrix of given chracteristics.
detail::InFlightRemark failed(Location loc, RemarkOpts opts)
Report an optimization remark that failed.
Definition Remarks.h:886
Include the generated interface declarations.
Type getType(OpFoldResult ofr)
Returns the int type of the integer in ofr.
Definition Utils.cpp:311
Type convertMMAToLLVMType(gpu::MMAMatrixType type)
Return the LLVMStructureType corresponding to the MMAMatrixType type.
Type getElementTypeOrSelf(Type type)
Return the element type or return the type itself.
void populateGpuWMMAToNVVMConversionPatterns(const LLVMTypeConverter &converter, RewritePatternSet &patterns, PatternBenefit benefit=1)
Collect a set of patterns to convert WMMA ops from GPU dialect to NVVM.