[Mlir-commits] [mlir] [mlir][bufferization] Add tensor-like and memref-like interfaces (PR #134220)

Andrei Golubev llvmlistbot at llvm.org
Thu Apr 3 02:49:52 PDT 2025


andrey-golubev wrote:

> > these new type interfaces are attached to the respective builtin types so that the switch is seamless.
> 
> Where is it done? I'm not sure how you get around the fact that these are in the bufferization folder which I don't think the core IR can depend on.

This is done in [`BufferizationDialect::initialize()`](https://github.com/llvm/llvm-project/pull/134220/files#diff-93e08b1e03259ffa2ff33aec1bd8f907f066e1d86cf83cf140fb031fb31c6f3aR81). So the flow is: users load the dialect and the new type interfaces get attached to the builtin types.

Indeed, as we cannot depend on bufferization in builtins, this is done via [external model](https://mlir.llvm.org/docs/Interfaces/#external-models-for-attribute-operation-and-type-interfaces). So, `TypeInterface x = rankedTensor` is not going to work *ever* without an explicit `llvm::cast`, but `mlir::isa<>` works. You can find `isa<>` check in the tests.

https://github.com/llvm/llvm-project/pull/134220


More information about the Mlir-commits mailing list