This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Fix linalg on tensor fusion
ClosedPublic

Authored by nicolasvasilache on Mar 22 2021, 5:49 AM.

Details

Summary
  • Drop unnecessary occurrences of rewriter.eraseOp: dead linalg ops on tensors should be cleaned up by DCE.
  • reimplement the part of Linalg on fusion that constructs the body and block arguments: the previous implementation had too much magic. Instead this spells out all cases explicitly and asserts / introduces TODOs for incorrect cases.

As a consequence, we can use the default traversal order for this pattern.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Mar 22 2021, 5:49 AM
pifon2a accepted this revision.Mar 22 2021, 5:56 AM
pifon2a added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
151–152

merge these?

165

merge these two drop_fronts?

This revision is now accepted and ready to land.Mar 22 2021, 5:56 AM
ftynse accepted this revision.Mar 22 2021, 6:01 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
151–152

Nit: I don't think the first "take_front" is necessary (assuming consumerIdx < consumer.getNumInputs always holds)

154–155

this "4" without code looks fishy

174–176

Leftover code

Use the default traversal order.

nicolasvasilache edited the summary of this revision. (Show Details)Mar 22 2021, 6:08 AM
nicolasvasilache marked 5 inline comments as done.Mar 22 2021, 6:15 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
165

hmm this will convolute the logic which currently is: drop the IVs, then take the last K - consumerIdx inputs.

nicolasvasilache marked an inline comment as done.

Address review.

This revision was landed with ongoing or failed builds.Mar 22 2021, 6:30 AM
This revision was automatically updated to reflect the committed changes.