Side effects of an op are described by the MemoryEffectsOpInterface
.
We currently have the following memory side effects: MemoryEffect::Allocate
, MemoryEffect::Free
, MemoryEffect::Read
, MemoryEffect::Write
.
Side effects are also used in Transform dialect to described handle access/consumption.
I’d like to get your opinion about ops that may have a side effect. An example is bufferization.dealloc
:
// Deallocate %m if %c.
bufferization.dealloc (%m : memref<?xf32>) if (%c : i1)
This op does currently not implement the MemoryEffectsOpInterface
. I think the op should implement that interface and declare a MemoryEffect::Free
side effect. However, that change breaks existing (old) code in the bufferization
dialect, which assumes that if an op has the MemoryEffect::Free
side effect, it will definitely free the memory.
As another example, consider a probabilistic allocation:
// 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>
I think this op should declare a MemoryEffect::Allocate
side effect.
The general questions are:
- If an op declares a side effect, is that a “definite” or a “maybe” property?
- Should it depend on the kind of side effect?
- Should we extend the
MemoryEffectsOpInterface
such that effects can be declared with a degree of “certainty”? E.g., “MUST BE” or “MAY BE”.