This is an archive of the discontinued LLVM Phabricator instance.

[mlir][bufferize] Provide default BufferizableOpInterface impl for destination style ops
ClosedPublic

Authored by springerm on Oct 20 2022, 6:02 AM.

Details

Summary

tensor.insert and tensor.insert_slice (as destination style ops) do no longer need to implement the entire BufferizableOpInterface.

Depends On D136346

Diff Detail

Event Timeline

springerm created this revision.Oct 20 2022, 6:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2022, 6:02 AM
springerm requested review of this revision.Oct 20 2022, 6:02 AM
pifon2a added inline comments.Oct 24 2022, 3:41 AM
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

why is it included in the default implementation of bufferization interface? Shouldn't it be outside of default implementation for bufferization interface. Otherwise, continuing this logic, I could also check here if (auto pad = dyn_cast<PadOp>(..)) and then write code for PadOp bufferization here.

springerm added inline comments.Oct 24 2022, 3:53 AM
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

What do you mean by "outside"?

All DPS ops have this property. So by putting this logic into the default implementation, there is one less method to implement.

Most BufferizableOpInterface impls of DPS ops will become real simple. E.g., take a look at tensor.insert (InsertOpInterface in this revision). Only the bufferize method must be implemented.

pifon2a added inline comments.Oct 24 2022, 4:02 AM
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

I mean by "outside" not in the definition of BufferizableOpInterface. I would prefer if we had an external model for DPS Ops similar to what we had in Linalg/Transforms/BufferizableOpInterfaceImpl.cpp for all Linalg ops.

springerm added inline comments.Oct 24 2022, 4:10 AM
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

Unfortunately only ops can implement interfaces. Interfaces can currently not implement other interfaces.

pifon2a added inline comments.Oct 24 2022, 4:32 AM
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

We can template it w.r.t. operation type, can't we? Then the users would just register an external model for bufferizable interface for DPS ops. Yes, it will be 1 registration per op, but IMO it is cleaner than writing it in td.

springerm updated this revision to Diff 470126.Oct 24 2022, 6:01 AM
springerm marked an inline comment as done.

address comments

mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
215–219

We discussed offline. Instead of putting the default impl into the interface defaultImplementation, we provide a templatized external model struct with the default implementations.

pifon2a accepted this revision.Oct 25 2022, 1:11 AM
pifon2a added inline comments.
mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
712

nit: methods

This revision is now accepted and ready to land.Oct 25 2022, 1:11 AM
This revision was landed with ongoing or failed builds.Oct 27 2022, 1:53 AM
This revision was automatically updated to reflect the committed changes.