[Mlir-commits] [mlir] [mlir][bufferization] Add `BufferizableOpInterface::hasTensorSemantics` (PR #75273)
Jacques Pienaar
llvmlistbot at llvm.org
Thu Jan 4 12:53:43 PST 2024
================
@@ -989,3 +995,22 @@ bufferization::detail::unknownGetAliasingValues(OpOperand &opOperand) {
r.addAlias({bbArg, BufferRelation::Unknown, /*isDefinite=*/false});
return r;
}
+
+static bool isaTensor(Type t) { return isa<TensorType>(t); }
+
+bool bufferization::detail::defaultHasTensorSemanticsForBufferization(
+ Operation *op) {
+ bool hasTensorBlockArgument = any_of(op->getRegions(), [](Region &r) {
+ return any_of(r.getBlocks(), [](Block &b) {
+ return any_of(b.getArguments(), [](BlockArgument bbArg) {
+ return isaTensor(bbArg.getType());
+ });
+ });
+ });
+ if (hasTensorBlockArgument)
+ return true;
+
+ bool hasTensorResult = any_of(op->getResultTypes(), isaTensor);
+ bool hasTensorOperand = any_of(op->getOperandTypes(), isaTensor);
----------------
jpienaar wrote:
I was wondering: is outputs only sufficient?
https://github.com/llvm/llvm-project/pull/75273
More information about the Mlir-commits
mailing list