[Mlir-commits] [mlir] e35ff26 - [mlir][vector] NFC - Add debug information to vector unrolling patterns
Nicolas Vasilache
llvmlistbot at llvm.org
Thu Jun 8 01:11:25 PDT 2023
Author: Nicolas Vasilache
Date: 2023-06-08T08:06:47Z
New Revision: e35ff2605f695b9cf41d4f51260ccb866d4d34e0
URL: https://github.com/llvm/llvm-project/commit/e35ff2605f695b9cf41d4f51260ccb866d4d34e0
DIFF: https://github.com/llvm/llvm-project/commit/e35ff2605f695b9cf41d4f51260ccb866d4d34e0.diff
LOG: [mlir][vector] NFC - Add debug information to vector unrolling patterns
Added:
Modified:
mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
index 5eee318b51b33..1a8f78031ba4f 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
@@ -18,10 +18,13 @@
#include "mlir/Support/MathExtras.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Debug.h"
#include <numeric>
#include <optional>
-#define DEBUG_TYPE "vector-unrolling"
+#define DEBUG_TYPE "vector-unroll"
+#define DBGS() (llvm::dbgs() << "[" DEBUG_TYPE "]: ")
+#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
using namespace mlir;
using namespace mlir::vector;
@@ -138,24 +141,47 @@ static Operation *cloneOpWithOperandsAndTypes(OpBuilder &builder, Location loc,
/// std::nullopt if the op shouldn't be or cannot be unrolled.
static std::optional<SmallVector<int64_t>>
getTargetShape(const vector::UnrollVectorOptions &options, Operation *op) {
- if (options.filterConstraint && failed(options.filterConstraint(op)))
+ LDBG("");
+ LDBG("Get unroll shape for op " << op->getName().getStringRef());
+ if (options.filterConstraint && failed(options.filterConstraint(op))) {
+ LDBG("--no filter constraint -> BAIL");
return std::nullopt;
+ }
assert(options.nativeShape &&
"vector unrolling expects the native shape or native"
"shape call back function to be set");
auto unrollableVectorOp = dyn_cast<VectorUnrollOpInterface>(op);
- if (!unrollableVectorOp)
+ if (!unrollableVectorOp) {
+ LDBG("--not an unrollable op -> BAIL");
return std::nullopt;
+ }
auto maybeUnrollShape = unrollableVectorOp.getShapeForUnroll();
- if (!maybeUnrollShape)
+ if (!maybeUnrollShape) {
+ LDBG("--could not get shape of op " << *op << " -> BAIL");
return std::nullopt;
+ }
+ LLVM_DEBUG(
+ llvm::interleaveComma(*maybeUnrollShape, DBGS() << "--vector op shape: ");
+ llvm::dbgs() << "\n";);
+
std::optional<SmallVector<int64_t>> targetShape = options.nativeShape(op);
- if (!targetShape)
+ if (!targetShape) {
+ LDBG("--no unrolling target shape defined " << *op << "-> SKIP");
return std::nullopt;
+ }
+ LLVM_DEBUG(llvm::interleaveComma(*targetShape, DBGS() << "--target shape: ");
+ llvm::dbgs() << "\n";);
+
auto maybeShapeRatio = computeShapeRatio(*maybeUnrollShape, *targetShape);
- if (!maybeShapeRatio ||
- llvm::all_of(*maybeShapeRatio, [](int64_t v) { return v == 1; }))
+ if (!maybeShapeRatio) {
+ LDBG("--could not compute integral shape ratio -> BAIL");
+ return std::nullopt;
+ }
+ if (llvm::all_of(*maybeShapeRatio, [](int64_t v) { return v == 1; })) {
+ LDBG("--no unrolling needed -> SKIP");
return std::nullopt;
+ }
+ LDBG("--found an integral shape ratio to unroll to -> SUCCESS");
return targetShape;
}
More information about the Mlir-commits
mailing list