[Mlir-commits] [mlir] 91beb51 - [mlir] NFC - Add debug information for Linalg transformations.
Nicolas Vasilache
llvmlistbot at llvm.org
Fri May 29 15:37:31 PDT 2020
Author: Nicolas Vasilache
Date: 2020-05-29T18:35:22-04:00
New Revision: 91beb5176b4d5a7cc09c419b9d75cb19f67d0bf9
URL: https://github.com/llvm/llvm-project/commit/91beb5176b4d5a7cc09c419b9d75cb19f67d0bf9
DIFF: https://github.com/llvm/llvm-project/commit/91beb5176b4d5a7cc09c419b9d75cb19f67d0bf9.diff
LOG: [mlir] NFC - Add debug information for Linalg transformations.
Address post-commit review of https://reviews.llvm.org/D79518
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/IR/PatternMatch.h
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 2e0673795f30..2e6a85926079 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -521,7 +521,7 @@ struct LinalgCopyVTWForwardingPattern
LogicalResult applyStagedPatterns(
Operation *op, ArrayRef<OwningRewritePatternList> stage1Patterns,
const OwningRewritePatternList &stage2Patterns,
- llvm::function_ref<LogicalResult(Operation *)> stage3Lambda = nullptr);
+ function_ref<LogicalResult(Operation *)> stage3Lambda = nullptr);
} // namespace linalg
} // namespace mlir
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 6b124e0ecdfa..8178f71ec43d 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -394,7 +394,7 @@ class OwningRewritePatternList {
/// type `T`.
template <typename T>
OwningRewritePatternList(T &&t) {
- patterns.emplace_back(std::make_unique<T>(t));
+ patterns.emplace_back(std::make_unique<T>(std::forward<T>(t)));
}
PatternListT::iterator begin() { return patterns.begin(); }
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index 527d162298bf..76e118e482f0 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -37,6 +37,8 @@ using namespace mlir::linalg;
using llvm::dbgs;
+#define DEBUG_TYPE "linalg-transforms"
+
//===----------------------------------------------------------------------===//
// Transformations exposed as rewrite patterns.
//===----------------------------------------------------------------------===//
@@ -45,13 +47,13 @@ const StringLiteral mlir::linalg::LinalgTransforms::kLinalgTransformMarker =
"__internal_linalg_transform__";
mlir::linalg::LinalgMarker::LinalgMarker(ArrayRef<StringRef> matchDisjunction,
- llvm::Optional<StringRef> replacement)
+ Optional<StringRef> replacement)
: matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
replacement(replacement) {}
mlir::linalg::LinalgMarker::LinalgMarker(ArrayRef<StringRef> matchDisjunction,
StringRef replacement)
- : LinalgMarker(matchDisjunction, llvm::Optional<StringRef>{replacement}) {}
+ : LinalgMarker(matchDisjunction, Optional<StringRef>{replacement}) {}
LogicalResult
mlir::linalg::LinalgMarker::checkAndNotify(PatternRewriter &rewriter,
@@ -72,7 +74,7 @@ mlir::linalg::LinalgMarker::checkAndNotify(PatternRewriter &rewriter,
// 3. Has no marker but was expecting a marker.
return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) {
diag << " does not have any marker from list: ";
- llvm::interleaveComma(matchDisjunction, diag);
+ interleaveComma(matchDisjunction, diag);
});
}
@@ -84,7 +86,7 @@ mlir::linalg::LinalgMarker::checkAndNotify(PatternRewriter &rewriter,
// 5. Fail to match.
return rewriter.notifyMatchFailure(op, [&](Diagnostic &diag) {
diag << " does not have any marker from list: ";
- llvm::interleaveComma(matchDisjunction, diag);
+ interleaveComma(matchDisjunction, diag);
});
}
@@ -105,7 +107,7 @@ mlir::linalg::LinalgTilingOptions::setTileSizes(ArrayRef<int64_t> ts) {
OpBuilder::InsertionGuard guard(b);
b.setInsertionPointToStart(
&op->getParentOfType<FuncOp>().getBody().front());
- return llvm::to_vector<4>(llvm::map_range(tileSizes, [&](int64_t s) {
+ return llvm::to_vector<4>(map_range(tileSizes, [&](int64_t s) {
Value v = b.create<ConstantIndexOp>(op->getLoc(), s);
return v;
}));
@@ -217,19 +219,33 @@ LogicalResult mlir::linalg::LinalgBaseVectorizationPattern::matchAndRewrite(
LogicalResult mlir::linalg::applyStagedPatterns(
Operation *op, ArrayRef<OwningRewritePatternList> stage1Patterns,
const OwningRewritePatternList &stage2Patterns,
- llvm::function_ref<LogicalResult(Operation *)> stage3Lambda) {
+ function_ref<LogicalResult(Operation *)> stage3Lambda) {
+ unsigned iteration = 0;
+ (void)iteration;
+ StringRef dbgPref = "\n[" DEBUG_TYPE "]: ";
+ (void)dbgPref;
for (const auto &patterns : stage1Patterns) {
if (!applyPatternsAndFoldGreedily(op, patterns)) {
- llvm::dbgs() << "Underlying first stage rewrite did not converge";
+ dbgs() << "Underlying first stage rewrite did not converge";
return failure();
}
+ LLVM_DEBUG(dbgs()
+ << dbgPref << "After 1st stage, iter: " << ++iteration << "\n"
+ << *op);
if (!applyPatternsAndFoldGreedily(op, stage2Patterns)) {
- llvm::dbgs() << "Underlying second stage rewrite did not converge";
+ LLVM_DEBUG(dbgs()
+ << dbgPref << "Underlying 2nd stage rewrite did not converge");
return failure();
}
+ LLVM_DEBUG(dbgs()
+ << dbgPref << "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);
}
}
return success();
More information about the Mlir-commits
mailing list