[Mlir-commits] [mlir] db60491 - [mlir][bufferization] Check OpFilter before casting to BufferizableOpInterface (#85690)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Mar 19 02:31:28 PDT 2024
Author: Benjamin Kramer
Date: 2024-03-19T10:31:25+01:00
New Revision: db6049112790f6bee51883b6aa99d0660f17e3a5
URL: https://github.com/llvm/llvm-project/commit/db6049112790f6bee51883b6aa99d0660f17e3a5
DIFF: https://github.com/llvm/llvm-project/commit/db6049112790f6bee51883b6aa99d0660f17e3a5.diff
LOG: [mlir][bufferization] Check OpFilter before casting to BufferizableOpInterface (#85690)
This doesn't change functionality, but lets us avoid attaching all the
interfaces after 513cdb82223a106f183b49a40d9acb1f7efbbe7e turned casting
without loading into an error.
Added:
Modified:
mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
index 8f0f6d1fcc8490..55c9299c58effd 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
@@ -344,11 +344,11 @@ bool BufferizationOptions::isOpAllowed(Operation *op) const {
BufferizableOpInterface
BufferizationOptions::dynCastBufferizableOp(Operation *op) const {
+ if (!isOpAllowed(op))
+ return nullptr;
auto bufferizableOp = dyn_cast<BufferizableOpInterface>(op);
if (!bufferizableOp)
return nullptr;
- if (!isOpAllowed(op))
- return nullptr;
return bufferizableOp;
}
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index 6a0ad66549965a..8dbf701620121a 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -453,7 +453,7 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
// canonicalize away (or canonicalize to more precise layouts).
SmallVector<Operation *> worklist;
op->walk<WalkOrder::PostOrder>([&](Operation *op) {
- if (hasTensorSemantics(op))
+ if (options.isOpAllowed(op) && hasTensorSemantics(op))
worklist.push_back(op);
});
@@ -472,8 +472,6 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
auto bufferizableOp = options.dynCastBufferizableOp(nextOp);
if (!bufferizableOp)
continue;
- if (!options.isOpAllowed(nextOp))
- continue;
// Skip ops that no longer have tensor semantics.
if (!hasTensorSemantics(nextOp))
continue;
More information about the Mlir-commits
mailing list