This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Break unnecessary dependency through unused `outs` tensor.
ClosedPublic

Authored by mravishankar on May 15 2021, 2:21 PM.

Details

Summary

LinalgOps that are all parallel do not use the value of outs
tensor. The semantics is that the outs tensor is fully
overwritten. Using anything other than init_tensor can add false
dependencies between operations, when the use is just for the shape of
the tensor. Adding a canonicalization to always use init_tensor in
such cases, breaks this dependence.

Diff Detail

Event Timeline

mravishankar created this revision.May 15 2021, 2:21 PM
mravishankar requested review of this revision.May 15 2021, 2:21 PM

I don't think this should be a blanket canonicalization as it will interact badly with the current work on bufferization post-linalg transforms.
Can you please make this an opt-in rewrite pattern that we may or may not want to apply depending on the case?

Moving pattern to elementwise fusion pass.

I don't think this should be a blanket canonicalization as it will interact badly with the current work on bufferization post-linalg transforms.
Can you please make this an opt-in rewrite pattern that we may or may not want to apply depending on the case?

Discussed this offline. This pattern might be worth having as a canonicalization, but bufferization might not be able to account for this now. Instead, this is moved to elementwise op fusion. Once the interaction with bufferization is evaluated, this can be made a canonicalization (on all LinalgOps)

hanchung accepted this revision.May 18 2021, 10:55 AM
hanchung added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
1338–1343

I think we only need index here. You can check if it is dynamic with operandType.isDynamicDim(idx).

This revision is now accepted and ready to land.May 18 2021, 10:55 AM
mravishankar added inline comments.May 18 2021, 10:03 PM
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
1338–1343

Maybe. I think the difference is not too much. Will leave it as is for now.