This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg][bufferize][NFC] Analyze OpOperands instead of OpResults
ClosedPublic

Authored by springerm on Dec 14 2021, 12:02 AM.

Details

Summary

With this change, the analysis takes a look at OpOperands instead of OpResults. OpOperands can bufferize out-of-place (even if they have no aliasing OpResults). The analysis does no longer care about OpResults.

Previously, only OpResults could bufferize out-of-place, so OpOperands that have no aliasing OpResults were never copied by Comprehensive Bufferize. This does not fit wwell with the new CallOp bufferization that is introduced in a subsequent change. In essence, called FuncOps can then be treated as "black boxes" that may read/write to any bbArg, even if they do not return anything.

Depends On D115840

Diff Detail

Event Timeline

springerm created this revision.Dec 14 2021, 12:02 AM
springerm requested review of this revision.Dec 14 2021, 12:02 AM
springerm planned changes to this revision.Dec 14 2021, 11:14 PM

We decided on a different implementation strategy for the moment. Keeping this revision around until we have a good solution for ModuleBufferization.

nicolasvasilache accepted this revision.Jan 7 2022, 5:43 AM
This revision is now accepted and ready to land.Jan 7 2022, 5:43 AM

Note: during the peer-review session we identified the fat that this current impl pushes bufferization further into "destination-passing style"-land and that we may want to generalize in the future (e.g. this cannot work with the torch-mlir as is).
We discussed that we could alternatively:

  1. pick any dominating tensor in the program (not just an op operand) as a candidate for "inplace"
  2. perform SSA use-def analysis on that tensor
  3. use it as the result

This would support something like %c = torch.mm(%a, %b) while avoiding to materialize a new %c for each op.

Supporting such use cases will require extensions and likely a DenseSet<OpOperand*> -> DenseSet<tuple<Value, bool>> change.

Future work.

Also cc @silvas

This revision was landed with ongoing or failed builds.Jan 7 2022, 8:03 AM
This revision was automatically updated to reflect the committed changes.