This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg][bufferize] Add BufferizableOpInterface
ClosedPublic

Authored by springerm on Nov 1 2021, 5:40 PM.

Details

Summary

This commit adds a new op interface: BufferizableOpInterface. In the future, ops that implement this interface can be bufferized using Comprehensive Bufferize.

Note: The interface methods of this interface correspond to the "op interface" in ComprehensiveBufferize.cpp.

Diff Detail

Event Timeline

springerm created this revision.Nov 1 2021, 5:40 PM
springerm requested review of this revision.Nov 1 2021, 5:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 1 2021, 5:40 PM
springerm added a comment.EditedNov 2 2021, 1:41 AM

Just fyi, we talked about removing methods from the interface. That is done in D112902. This commit just translates the existing "op interface" from ComprehensiveBufferize.cpp into a .td file. The interface is exactly the one that's described in ComprehensiveBufferize.cpp (NFC).

nicolasvasilache accepted this revision.Nov 2 2021, 1:55 AM
nicolasvasilache added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td
40

This would crash.
The doc says it's optional, should you remove it ?

61

Same here.

79

Is this the one we discussed as "property derived from other interface methods"?

From https://mlir.llvm.org/docs/Interfaces/, there is a variant you are interested in:

StaticInterfaceMethod<[{
  This method corresponds to a static interface method that has an explicit
  implementation of the method body. Given that the method body has been
  explicitly implemented, this method should not be defined by the operation
  implementing this method.
This revision is now accepted and ready to land.Nov 2 2021, 1:55 AM
mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td
79

This is fine as a followup at the place where you propose removing it.

springerm marked 4 inline comments as done.Nov 2 2021, 2:07 AM
springerm added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td
40

Yes, I want it it to crash.

If an op does not have tensor OpOperands, this method should not be called in the first place. If it is called, there's a problem with our code.

It will also crash if a programmer forgot to implement this interface method.

79

Nice, will make it static in D112902 with a default impl that does the right thing.

This revision was automatically updated to reflect the committed changes.
springerm marked 2 inline comments as done.