This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Add backward slice filtering in hoist padding.
ClosedPublic

Authored by gysit on Nov 23 2021, 1:32 AM.

Details

Summary

Adapt hoist padding to filter the backward slice before cloning the packing loop nest. The filtering removes all operations that are not used to index the hoisted pad tensor op and its extract slice op. The filtering is needed to support the more complex loop nests created after fusion. For example, fusing the producer of an output operand can added linalg ops and pad tensor ops to the backward slice. These operations have regions and currently prevent hoisting.

The following example demonstrates the effect of the newly introduced dropNonIndexDependencies method that filters the backward slice:

%source = linalg.fill(%cst, %arg0)
scf.for %i
  %unrelated = linalg.fill(%cst, %arg1)    // not used to index %source!
  scf.for %j (%arg2 = %unrelated)
    scf.for %k                             // not used to index %source!
      %ubi = affine.min #map(%i)
      %ubj = affine.min #map(%j)
      %slice = tensor.extract_slice %source [%i, %j] [%ubi, %ubj]
      %padded_slice = linalg.pad_tensor %slice

dropNonIndexDependencies(%padded_slice, %slice)
removes [scf.for %k, linalg.fill(%cst, %arg1)] from backwardSlice.

Depends On D114175

Diff Detail

Event Timeline

gysit created this revision.Nov 23 2021, 1:32 AM
gysit requested review of this revision.Nov 23 2021, 1:32 AM
nicolasvasilache accepted this revision.Nov 24 2021, 8:49 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
223

Can you add the comment that was dropped here plz?
this is related to internals of the backwardslice computation.

Thanks!

This revision is now accepted and ready to land.Nov 24 2021, 8:49 AM
gysit updated this revision to Diff 389553.Nov 24 2021, 10:52 AM

Address comment and reintroduced a check.

gysit marked an inline comment as done.Nov 24 2021, 10:55 AM
gysit added inline comments.
mlir/lib/Dialect/Linalg/Transforms/HoistPadding.cpp
223

Actually I dropped a bit too much. Added a missing check and a comment. The checks will then move to dropNonIndexDependencies in https://reviews.llvm.org/D114438.

This revision was automatically updated to reflect the committed changes.
gysit marked an inline comment as done.