Skip to content

Commit 6367677

Browse files
[mlir][linalg] BufferizeToAllocationOp: fix side effects (#72986)
`bufferize_to_allocation` does not bufferize/replace targeted ops if `bufferize_destination_only` is set. Fixes #72931.
1 parent 147c5d6 commit 6367677

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,13 @@ DiagnosedSilenceableFailure transform::BufferizeToAllocationOp::apply(
289289

290290
void transform::BufferizeToAllocationOp::getEffects(
291291
SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
292-
consumesHandle(getTarget(), effects);
292+
if (getBufferizeDestinationOnly()) {
293+
// The destination is replaced with a newly allocated buffer, but the op
294+
// itself remains in place.
295+
onlyReadsHandle(getTarget(), effects);
296+
} else {
297+
consumesHandle(getTarget(), effects);
298+
}
293299
producesHandle(getAllocatedBuffer(), effects);
294300
producesHandle(getNewOps(), effects);
295301
modifiesPayload(effects);

0 commit comments

Comments
 (0)