[Mlir-commits] [mlir] [mlir] [bufferize] Inplace the operands that must be inplaced. (PR #106220)

Matthias Springer llvmlistbot at llvm.org
Tue Mar 18 00:41:31 PDT 2025


================
@@ -600,8 +600,12 @@ bool AnalysisState::canOmitTensorCopy(OpOperand &opOperand) const {
 }
 
 bool AnalysisState::isInPlace(OpOperand &opOperand) const {
-  // ToMemrefOps are always in-place.
-  if (isa<ToMemrefOp>(opOperand.getOwner()))
+  // We should always inplace operands that must be inplaced.
+  auto bufferizableOp =
+      getOptions().dynCastBufferizableOp(opOperand.getOwner());
+  if ((bufferizableOp &&
+       bufferizableOp.mustBufferizeInPlace(opOperand, *this)) ||
----------------
matthias-springer wrote:

This is problematic because `AnalysisState` won't be able to detect cases where multiple ops, that are all marked as `mustBufferizeInPlace`, cause a RaW conflict.

When running with `OneShotBufferizationState`, we are able to detect such cases:
```
not bufferizable under the given constraints: cannot avoid RaW conflict
```

What is your use case? There are no atomic operations that operate on tensors as far as I know.


https://github.com/llvm/llvm-project/pull/106220


More information about the Mlir-commits mailing list