This is an archive of the discontinued LLVM Phabricator instance.

[mlir][TilingInterface] Add an option to tile and fuse to yield replacement for the fused producer.
ClosedPublic

Authored by mravishankar on Jan 4 2023, 8:37 PM.

Details

Summary

This patch adds an option to the method that fuses a producer with a
tiled consumer, to also yield from the tiled loops a value that can be
used to replace the original producer. This is only valid if it can be
assertained that the slice of the producer computed within each
iteration of the tiled loop nest does not compute slices of the
producer redundantly. The analysis to derive this is very involved. So
this is left to the caller to assertain. A test is added that mimics
the scf::tileConsumerAndFuseProducersGreedilyUsingSCFForOp, but also
yields the values of all fused producers. This can be used as a
reference for how a caller could use this functionality.

Depends on D141027

Diff Detail

Event Timeline

mravishankar created this revision.Jan 4 2023, 8:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 4 2023, 8:37 PM
mravishankar requested review of this revision.Jan 4 2023, 8:37 PM
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
510

Can this be done after the fact with a second call that will be properly documented as injecting user-specified information in the IR while bypassing a complex analysis ?

tileAndFuseProducerOfSlice is complex enough as it is and yieldFusedProducerReplacement is deceptively simple to trigger and break semantics.

A separate function that would apply after the transformation with a proper name and warning that this is an "assume-like" transform, seems highly desirable.

mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp
252

Skimming quickly through this, this seems entirely unnecessary.

Just use the transform dialect and avoid complex to maintain tests.

mravishankar edited the summary of this revision. (Show Details)

Address comments.

Added a new method to that has to be called explicitly when the fused
producer value has to be yielded.

mravishankar marked an inline comment as done.Jan 15 2023, 10:19 PM
mravishankar added inline comments.
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
510

Good point. That make things simpler in the caller as well. Changed to add a new method for yielding the producer.

mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp
252

Agreed. I wanted to land these before I go and change the tests to drop the filters and use transform dialect.

This revision is now accepted and ready to land.Jan 16 2023, 12:25 AM
This revision was landed with ongoing or failed builds.Jan 16 2023, 10:36 AM
This revision was automatically updated to reflect the committed changes.
mravishankar marked an inline comment as done.

This patch had a use-after-free issue. Fixed with https://reviews.llvm.org/D141869