This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Modify LinalgStructuredInterface to allow the computation block to have arguments only for a subset of operands.
ClosedPublic

Authored by olegshyshkov on Sep 22 2022, 8:39 AM.

Details

Summary

Currently there is an expectations that there is a corresponsing block argument
for each operand. For some operation, it leads to unused arguments. For example,
in map, only input operands are used for the computation.

Diff Detail

Event Timeline

olegshyshkov created this revision.Sep 22 2022, 8:39 AM
olegshyshkov requested review of this revision.Sep 22 2022, 8:39 AM
pifon2a accepted this revision.Sep 22 2022, 9:20 AM

Thanks!

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
581

What about calling it getTiedOpOperands? Because it returns the list of getTiedOpOperand(i) for every block arg.

This revision is now accepted and ready to land.Sep 22 2022, 9:20 AM
mravishankar requested changes to this revision.Sep 22 2022, 10:21 AM

I think this is a big change. Having unused arguments is not a big deal. It removes some consistency that would be very involved to work around.

This revision now requires changes to proceed.Sep 22 2022, 10:21 AM

I think this is a big change. Having unused arguments is not a big deal. It removes some consistency that would be very involved to work around.

I've actually been annoyed by the trailing unused bbarg hanging around for some time ..
In the linalg.generic case I agree that consistency trumps the rest.
It is innocuous to me to relax the interface so we can create ops with nicer ergonomics.

If anything, I think this even increases consistency because the bbArgs region verifier directly relates to the matching block operands without an implicit level of indirection.

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
581

The "tied" terminology would be a misnomer here I think as it relates to DPS

See e.g. https://stackoverflow.com/questions/57551135/how-does-llvm-translate-three-address-llvm-ir-add-into-x86-two-address-add ()

"Tied" means two operands are mapped to the same register. When we write Constraints = "$src1 = $dst" in tablegen, generated code would set $src1 and $dst as "tied" (GlobalISel/Utils.cpp):

I introduced it improperly a while back but would appreciate the cleanup.
e.g. getTiedOpOperand(bbArg) -> getMatchingOpOperand(bbArg) and other places (getTiedIndexingMap -> getMatchingIndexingMap etc)

Then this one could be called getOpOperandsMatchingBBargs ?

Renamed the method to getOpOperandsMatchingBBargs.

olegshyshkov marked 2 inline comments as done.Sep 22 2022, 11:07 AM
olegshyshkov added inline comments.
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
581

getOpOperandsMatchingBBargs sounds good. I was hesitant to add such a verbose name at first.

olegshyshkov marked an inline comment as done.Sep 22 2022, 11:07 AM
mravishankar resigned from this revision.Sep 22 2022, 11:41 AM

removing my blocker based on @nicolasvasilache comments.

This revision is now accepted and ready to land.Sep 22 2022, 11:41 AM
olegshyshkov added inline comments.Sep 22 2022, 11:51 AM
mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
581

I'll prepare a separate patch to cleanup getTiedOpOperand(bbArg) -> getMatchingOpOperand(bbArg) tomorrow.

removing my blocker based on @nicolasvasilache comments.

Thanks for your flexibility @mravishankar!

I'll prepare a separate patch to cleanup getTiedOpOperand(bbArg) -> getMatchingOpOperand(bbArg) tomorrow.

Great, thank you!