@@ -75,12 +75,13 @@ verifyGPUMatmulPipeline(Operation *op,
75
75
IREE::Codegen::LoweringConfigAttr loweringConfig,
76
76
IREE::Codegen::TranslationInfoAttr translationInfo,
77
77
ArrayRef<int64_t > workgroupSize) {
78
- // This verifier only applies to matmul.
79
78
CodeGenPipeline pipeline = translationInfo.getDispatchLoweringPassPipeline ();
79
+
80
80
if (pipeline != CodeGenPipeline::LLVMGPUMatmulTensorCore &&
81
81
pipeline != CodeGenPipeline::LLVMGPUMatmulTensorCoreMmaSync) {
82
82
return success ();
83
83
}
84
+
84
85
// Only verify batched and unbatched matmul.
85
86
if (!isa<linalg::MatmulOp, linalg::BatchMatmulOp>(op)) {
86
87
return success ();
@@ -234,4 +235,58 @@ verifyGPUMatmulPipeline(Operation *op,
234
235
return success ();
235
236
}
236
237
238
+ // / Verifies pipelines that use iree_gpu.lowering_config attributes.
239
+ LogicalResult
240
+ verifyGPUMatmulPipeline (Operation *op,
241
+ IREE::GPU::LoweringConfigAttr loweringConfig,
242
+ IREE::Codegen::TranslationInfoAttr translationInfo) {
243
+
244
+ CodeGenPipeline pipeline = translationInfo.getDispatchLoweringPassPipeline ();
245
+ // TODO: add verification for other pipelines
246
+ if (pipeline != CodeGenPipeline::LLVMGPUVectorDistribute) {
247
+ return success ();
248
+ }
249
+
250
+ // Only verify batched and unbatched matmul.
251
+ if (!isa<linalg::MatmulOp, linalg::BatchMatmulOp>(op)) {
252
+ return success ();
253
+ }
254
+
255
+ unsigned reduction = static_cast <uint32_t >(IREE::GPU::TilingLevel::Reduction);
256
+ uint numLoops = llvm::cast<linalg::LinalgOp>(op).getNumLoops ();
257
+ size_t size = 0 ;
258
+
259
+ SmallVector<int64_t > reductionTileSizes =
260
+ loweringConfig.getStaticTilingLevelSizes (reduction, op);
261
+
262
+ size = reductionTileSizes.size ();
263
+
264
+ if (size > numLoops) {
265
+ return op->emitOpError (" expected number of reduction tile size is equal "
266
+ " or less than number of loops" );
267
+ }
268
+ for (size_t i = 0 ; i < size; ++i) {
269
+ if (reductionTileSizes[i] > 0 &&
270
+ llvm::cast<linalg::LinalgOp>(op).getIteratorTypesArray ()[i] !=
271
+ utils::IteratorType::reduction) {
272
+ return op->emitOpError (
273
+ " expected to non-zero reduction tile has reduction iterator" );
274
+ }
275
+ }
276
+
277
+ SmallVector<int64_t > workgroupTileSizes =
278
+ loweringConfig.getWorkgroupTileSizes ();
279
+ size = workgroupTileSizes.size ();
280
+ for (size_t i = 0 ; i < size; ++i) {
281
+ if (workgroupTileSizes[i] > 0 &&
282
+ llvm::cast<linalg::LinalgOp>(op).getIteratorTypesArray ()[i] !=
283
+ utils::IteratorType::parallel) {
284
+ return op->emitOpError (
285
+ " expected to non-zero workgroup tile has parallel iterator" );
286
+ }
287
+ }
288
+
289
+ return success ();
290
+ }
291
+
237
292
} // namespace mlir::iree_compiler
0 commit comments