[Mlir-commits] [mlir] [mlir][bufferization] Buffer deallocation: Disallow unregistered ops (PR #75127)

Matthias Springer llvmlistbot at llvm.org
Mon Dec 11 22:27:29 PST 2023


matthias-springer wrote:

Another tricky case would be ops that sometimes allocate and sometimes don't. This is something that we do not support properly at the moment.
```mlir
// With a probability of 40%: %0 = %m
// With a probability of 60%: %0 is a new allocation
%0 = test.probabilistic_alloc {p = 0.4 : f32} %m : memref<?xf32>
```

Such an op would have to declare an `Allocate` side effect. I think side effects are a "maybe" property. False positives are allowed in `getEffects`. I guess this is somewhat of an edge case. But we could support such cases correctly by requiring that ops with an `Allocate` side effect to implement the `BufferDeallocationOpInterface`, which can then be queried to build the ownership indicator.

(In the example above, without further knowledge about the op, `BufferDeallocationOpInterface::materializeUniqueOwnershipForMemref` could compare the pointers of `%0` and `%m`. If they are the same, we take the ownership indicator of `%m`. Otherwise, `%true`.)

@maerhart Does this make sense?


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


More information about the Mlir-commits mailing list