From 56ce65e2b649c665c5257131c691bf959959b912 Mon Sep 17 00:00:00 2001 From: Nicolas Vasilache Date: Fri, 5 Jun 2020 13:02:13 -0400 Subject: [PATCH] [mlir][Linalg] NFC - Cleanup debug, address post-commit review. --- .../mlir/Dialect/Linalg/Transforms/Transforms.h | 3 +-- mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp | 30 +++++++++------------- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h index 2437ac5..101a1a5 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -400,8 +400,7 @@ enum class LinalgLoweringType { AffineLoops = 2, ParallelLoops = 3 }; -template -struct LinalgLoweringPattern : public RewritePattern { +template struct LinalgLoweringPattern : public RewritePattern { LinalgLoweringPattern(MLIRContext *context, LinalgLoweringType loweringType, LinalgMarker marker = LinalgMarker(), PatternBenefit benefit = 1) diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index 1aefb8f..f46d08f 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -35,10 +35,7 @@ using namespace mlir::edsc; using namespace mlir::edsc::intrinsics; using namespace mlir::linalg; -using llvm::dbgs; - -#define DEBUG_TYPE "linalg-transforms" - +#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE << "]: ") //===----------------------------------------------------------------------===// // Transformations exposed as rewrite patterns. //===----------------------------------------------------------------------===// @@ -120,6 +117,7 @@ LogicalResult mlir::linalg::LinalgBaseTilingPattern::matchAndRewrite( return failure(); if (failed(marker.checkAndNotify(rewriter, linalgOp))) return failure(); + Optional res = tileLinalgOp(rewriter, linalgOp, options); if (!res) @@ -213,30 +211,26 @@ LogicalResult mlir::linalg::applyStagedPatterns( function_ref stage3Lambda) { unsigned iteration = 0; (void)iteration; - StringRef dbgPref = "\n[" DEBUG_TYPE "]: "; - (void)dbgPref; for (const auto &patterns : stage1Patterns) { + LLVM_DEBUG(DBGS() << "Before 1st stage, iter: " << ++iteration << "\n" + << *op); if (!applyPatternsAndFoldGreedily(op, patterns)) { - dbgs() << "Underlying first stage rewrite did not converge"; + LLVM_DEBUG(DBGS() << "Underlying first stage rewrite did not converge"); return failure(); } - LLVM_DEBUG(dbgs() - << dbgPref << "After 1st stage, iter: " << ++iteration << "\n" - << *op); + LLVM_DEBUG(DBGS() << "After 1st stage, iter: " << ++iteration << "\n" + << *op); if (!applyPatternsAndFoldGreedily(op, stage2Patterns)) { - LLVM_DEBUG(dbgs() - << dbgPref << "Underlying 2nd stage rewrite did not converge"); + LLVM_DEBUG(DBGS() << "Underlying 2nd stage rewrite did not converge"); return failure(); } - LLVM_DEBUG(dbgs() - << dbgPref << "After 2nd stage, iter : " << iteration << "\n" - << *op); + LLVM_DEBUG(DBGS() << "After 2nd stage, iter : " << iteration << "\n" + << *op); if (stage3Lambda) { if (failed(stage3Lambda(op))) return failure(); - LLVM_DEBUG(dbgs() - << dbgPref << "After 3rd stage, iter : " << iteration << "\n" - << *op); + LLVM_DEBUG(DBGS() << "After 3rd stage, iter : " << iteration << "\n" + << *op); } } return success(); -- 2.7.4