[Mlir-commits] [mlir] [mlir][linalg] `BufferizeToAllocationOp`: fix side effects (PR #72986)
Matthias Springer
llvmlistbot at llvm.org
Tue Nov 21 05:07:49 PST 2023
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/72986
`bufferize_to_allocation` does not bufferize/replace ops if `bufferize_destination_only` is set.
Fixes #72931.
>From 4351d3c9b27d97d3c00ba5bc2d30d3e33320c66a Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Tue, 21 Nov 2023 14:05:19 +0100
Subject: [PATCH] [mlir][linalg] `BufferizeToAllocationOp`: fix side effects
`bufferize_to_allocation` does not bufferize/replace ops if `bufferize_destination_only` is set.
---
.../Dialect/Linalg/TransformOps/LinalgTransformOps.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index de4965f937162ea..ef5d88d46dd28a0 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -289,7 +289,13 @@ DiagnosedSilenceableFailure transform::BufferizeToAllocationOp::apply(
void transform::BufferizeToAllocationOp::getEffects(
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
- consumesHandle(getTarget(), effects);
+ if (getBufferizeDestinationOnly()) {
+ // The destination is replaced with a newly allocated buffer, but the op
+ // itself remains in place.
+ onlyReadsHandle(getTarget(), effects);
+ } else {
+ consumesHandle(getTarget(), effects);
+ }
producesHandle(getAllocatedBuffer(), effects);
producesHandle(getNewOps(), effects);
modifiesPayload(effects);
More information about the Mlir-commits
mailing list