This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Generalize vector::transfer hoisting on tensors.
ClosedPublic

Authored by nicolasvasilache on Feb 15 2021, 1:34 PM.

Details

Summary

This revision adds support for hoisting "subtensor + vector.transfer_read" / "subtensor_insert + vector.transfer_write pairs" across scf.for.
The unit of hoisting becomes a HoistableRead / HoistableWrite struct which contains a pair of "vector.transfer_read + optional subtensor" / "vector.transfer_write + optional subtensor_insert".
scf::ForOp canonicalization patterns are applied greedily on the successful application of the transformation to cleanup the IR more eagerly and potentially expose more transformation opportunities.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Feb 15 2021, 1:34 PM
ftynse accepted this revision.Feb 16 2021, 1:11 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
120

Nit: do you want to also check that ranks are equal (i.e., there's an equal number of offsets, sizes and strides)? zip will only let you check the prefix otherwise

271

It may be defined in the loop and still be loop-invariant, but detecting that sounds like LICM's job. Consider running it before this pass if you aren't already.

291

Even a local constexpr size_t kFirstIndexingPosition = 2 would make it better (ideally, this should move to the op itself)

This revision is now accepted and ready to land.Feb 16 2021, 1:11 AM
nicolasvasilache marked 2 inline comments as done.Feb 16 2021, 1:21 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
271

Yes, LICM should be run before (see CodegenStrategy.cpp which is one way of driving all this).

291

I had actually already added that, fixed.

nicolasvasilache marked an inline comment as done.

Addres

This revision was landed with ongoing or failed builds.Feb 16 2021, 1:48 AM
This revision was automatically updated to reflect the committed changes.