This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add hoisting transformation for transfer ops on tensor
ClosedPublic

Authored by ThomasRaoux on Jan 5 2021, 1:12 PM.

Details

Summary

Add same hoisting transformation existing for transfer ops on buffers for transfer_ops on tensor. The logic is significantly different so this is done as a separate transformation and it is expect that user would know which transformation to use based on the flow.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Jan 5 2021, 1:12 PM
ThomasRaoux requested review of this revision.Jan 5 2021, 1:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2021, 1:12 PM
nicolasvasilache accepted this revision.Jan 6 2021, 8:21 AM
nicolasvasilache added inline comments.
mlir/include/mlir/Dialect/Vector/VectorUtils.h
171

xxxIndices

mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
84

significantly

94

removed by the

100

forOp.getTerminator()

114

please hoist into a static helper function

126

Same, can we please isolate in a helper function and document each subcase?

132

// Skip the candidate use, only inspect the "other" uses.

135

// Consider all transitive uses through a vector.transfer_write.

139

// Consider all nested uses through an scf::ForOp.

148

This case looks like it could fold into the previous scf::ForOp by considering both the uses of the corresponding BBArg as well as the uses of the corresponding result?

mlir/lib/Dialect/Vector/VectorUtils.cpp
351

xxxIndices

This revision is now accepted and ready to land.Jan 6 2021, 8:21 AM
aartbik added inline comments.Jan 6 2021, 9:38 AM
mlir/include/mlir/Dialect/Linalg/Transforms/Hoisting.h
38

perhaps add the "on buffers" restriction explicitly in the doc of L36 method

mlir/include/mlir/Dialect/Vector/VectorUtils.h
171

typo: cies

Address review feedback.

ThomasRaoux marked 10 inline comments as done.Jan 6 2021, 11:28 AM
ThomasRaoux added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/Hoisting.h
38

Good point. I updated the comment above.

mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
100

Looks like ForOp doesn't have such a method but there is a simpler way indeed. Replaced it with forOp.getBody()->getTerminator()

114

Makes sense, moved the logic and the one below into two helper functions.

148

The problem is that it wouldn't work for the case where we have several nested ForOp where the tensor is just pass-through. Since I rely on separate canonicalization to remove those I need to handle this case if I want to support hoisting out of nested loops.

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