[Mlir-commits] [mlir] [mlir][bufferize] Add hoist-dynamic-allocs-option to buffer-results-to-out-params (PR #160985)
Matthias Springer
llvmlistbot at llvm.org
Sat Sep 27 02:18:07 PDT 2025
================
@@ -43,6 +43,53 @@ static bool hasStaticIdentityLayout(MemRefType type) {
return type.getLayout().isIdentity();
}
+/// Return the dynamic shapes of the `memref` based on the define op. If the
+/// complete dynamic shape fails to be captured, return an empty value.
+/// Currently, only function parameters are supported for capturing.
+static SmallVector<Value> getDynamicSize(Value memref, func::FuncOp funcOp) {
+ auto *defOp = memref.getDefiningOp();
+ if (!defOp)
+ return {};
+ auto operands = defOp->getOperands();
+ SmallVector<Value> dynamicSizes;
+ for (Value size : operands) {
+ BlockArgument sizeSrc = mlir::dyn_cast<BlockArgument>(size);
+ if (!sizeSrc)
+ return {};
+
+ bool finded = false;
+ for (BlockArgument argument : funcOp.getArguments()) {
----------------
matthias-springer wrote:
You should be able to use `llvm::find` instead of hand-writing the loop.
https://github.com/llvm/llvm-project/pull/160985
More information about the Mlir-commits
mailing list