This revision adds a BufferizationAliasInfo which maintains and updates information about which tensors will alias once bufferized, which bufferized tensors are equivalent to others and how to handle clobbers.
Bufferization greedily tries to bufferize inplace by:
- first trying to bufferize SubTensorInsertOp inplace, in reverse order (these are deemed the most expensives).
- then trying to bufferize all non SubTensorOp / SubTensorInsertOp, in reverse order.
- lastly trying to bufferize all SubTensorOp in reverse order.
Reverse order is a heuristic that seems to work nicely because structured tensor codegen very often proceeds by:
- take a subset of a tensor
- compute on that subset
- insert the result subset into the full tensor and yield a new tensor.
BufferizationAliasInfo + equivalence sets + clobber analysis allows bufferizing nested
subtensor/compute/subtensor_insert sequences inplace to a certain extent.
To fully realize inplace bufferization, additional container-containee analysis will be necessary and is left for a subsequent commit.
Does the printer for BlockArgument add a newline? I don't think it should if it does.