Skip to content

Commit 70777d9

Browse files
[mlir][bufferize][NFC] Move FuncOp bufferization to BufferizableOpInterface impl
FuncOps are now less special. They must still be analyzed + bufferized in a certain order, but they are now bufferized same as other ops that have a region: Bufferize the op first (`bufferize` interface method), then bufferize the region body with other bufferization patterns. In the case of FuncOps, the function signature is bufferized together with ReturnOps. Similar to how, e.g., scf.for ops are bufferized together with scf.yield ops. This change is essentially a reimplementation of the FuncOp bufferization, but mostly NFC from a user's perspective (apart from error messages). This change is in preparation of moving the code to the bufferization dialect. Differential Revision: https://reviews.llvm.org/D123214
1 parent 85eb8b7 commit 70777d9

File tree

3 files changed

+176
-191
lines changed

3 files changed

+176
-191
lines changed

mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ static bool isaTensor(Type t) { return t.isa<TensorType>(); }
237237

238238
/// Return true if the given op has a tensor result or a tensor operand.
239239
static bool hasTensorSemantics(Operation *op) {
240+
if (auto funcOp = dyn_cast<FunctionOpInterface>(op)) {
241+
bool hasTensorArg = any_of(funcOp.getArgumentTypes(), isaTensor);
242+
bool hasTensorResult = any_of(funcOp.getResultTypes(), isaTensor);
243+
return hasTensorArg || hasTensorResult;
244+
}
245+
240246
bool hasTensorResult = any_of(op->getResultTypes(), isaTensor);
241247
bool hasTensorOperand = any_of(op->getOperandTypes(), isaTensor);
242248
return hasTensorResult || hasTensorOperand;

0 commit comments

Comments
 (0)