This is an archive of the discontinued LLVM Phabricator instance.

[mlir][interfaces] Remove getDestinationOperands from TilingInterface
ClosedPublic

Authored by springerm on Oct 19 2022, 3:25 AM.

Details

Summary

getDestinationOperands was almost a duplicate of DestinationStyleOpInterface::getOutputOperands. Now that the interface has been moved to mlir/Interfaces, it is no longer needed.

Diff Detail

Event Timeline

springerm created this revision.Oct 19 2022, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 19 2022, 3:25 AM
springerm requested review of this revision.Oct 19 2022, 3:25 AM
springerm retitled this revision from [mlir][interfaces] Remove getDestinationOperands from TilingInterface to [mlir][interfaces][NFC] Remove getDestinationOperands from TilingInterface.Oct 19 2022, 3:26 AM
pifon2a accepted this revision.Oct 19 2022, 7:26 AM

Nice

This revision is now accepted and ready to land.Oct 19 2022, 7:26 AM
mravishankar requested changes to this revision.Oct 19 2022, 10:00 AM

Thanks for doing this Matthias. Have a comment on the API/requirements to use the API though.

mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
135

I see that this methods asserts if the defining op does not implement one of two interfaces.... Maybe we can make this return an Optional<Value> of FailureOr<Value> to avoid the assert.
At the very least please add the assert requirement in the comments here.

139

This one is a bit harder to avoid the assert. One options is

LogicalResult getOrCreateDestinations(OpBuilder &b, Location loc, Operation *op, SmallVectorImpl<Value> &destinationValues);

Makes the two APIs incosistent, but I am thinking loud here. Having an assert though is the least desirable solution.

This revision now requires changes to proceed.Oct 19 2022, 10:00 AM

Also please drop the NFC tag. It is a breaking change...

address comments

springerm marked 2 inline comments as done.Oct 20 2022, 12:55 AM
springerm retitled this revision from [mlir][interfaces][NFC] Remove getDestinationOperands from TilingInterface to [mlir][interfaces] Remove getDestinationOperands from TilingInterface.
mravishankar requested changes to this revision.Oct 20 2022, 9:44 AM

Have a few more comments. With that this should be good to go.

mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
141

Nit: Usually return by value is at the end of the arguments list.

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
389

Do you mind moving this to the start. Basically make this an early failure before any transformations are done. Without this it can get the pattern rewrite driver into an infinite loop (triggering the fails safe of returning failure after 10 iterations or so).

399

This doesnt need to be a failure I think. You can just replace lines 390 onwards to

if (auto destinationPassingOp = dyn_cast<DestinationStyleOpInterface>(...)) {
  SmallVector<Value> destination;
  if (succeeded(getOrCreateDestination(...)) {
    updateDestinationOperandsForTiledOp(...)
  }
}
581

Replace lines 578 onwards with the same schema as line 390 onwards above.

586–587

Replace lines 588 onwards with the same schema as line 390 onwards above.

This revision now requires changes to proceed.Oct 20 2022, 9:44 AM
springerm marked 4 inline comments as done.Oct 21 2022, 3:28 AM
springerm updated this revision to Diff 469531.Oct 21 2022, 3:28 AM

address comments

springerm marked an inline comment as done.Oct 21 2022, 3:28 AM
This revision is now accepted and ready to land.Oct 21 2022, 9:51 AM