Page MenuHomePhabricator

[mlir][Linalg] Add callbacks to fusion of elementwise operations to control fusion.

Authored by mravishankar on Apr 2 2021, 3:24 PM.



Right now Elementwise operations fusion in Linalg fuses everything it
can. This can run up against resource limits of the target hardware
without some checks. This patch adds a callback function that clients
can use to implement a cost function. When two elementwise operations
are deemed structurally fusable, the callback can be used to control
if the fusion applies.

Depends On D99819

Diff Detail

Event Timeline

mravishankar created this revision.Apr 2 2021, 3:24 PM
mravishankar requested review of this revision.Apr 2 2021, 3:24 PM
hanchung accepted this revision.Apr 4 2021, 11:51 PM
hanchung added inline comments.

Adding a blank line right before the comment usually helps readability.


/*producer=*/ and /*consumer=*/


Do we really need a template here? I don't see a reason to make it template. How about making limit to be a function argument?


When I see a dyn_cast, I would expect you to check if it is null. Otherwise, it should be cast, and will hit an assertion in dbg mode if it is not a Linalg op (because this is really wrong).

This revision is now accepted and ready to land.Apr 4 2021, 11:51 PM
mravishankar marked 2 inline comments as done.

Addressing comments.

mravishankar marked 2 inline comments as done.Apr 5 2021, 3:35 PM
mravishankar added inline comments.

I dont think so. They are arguments here (they are just not used).


Then it cant be used as a callback directly below.


Yeah, good catch. Just dropping use of LinalgOp here.

mravishankar marked 2 inline comments as done.

Fixing builds

This revision was landed with ongoing or failed builds.Apr 5 2021, 4:09 PM
This revision was automatically updated to reflect the committed changes.