[Mlir-commits] [mlir] [mlir][bufferization] Add `BufferizableOpInterface::hasTensorSemantics` (PR #75273)

Matthias Springer llvmlistbot at llvm.org
Wed Jan 10 03:15:54 PST 2024


matthias-springer wrote:

This PR now depends on #77574, which aligns `DestinationStyleOpInterface::hasTensorSemantics` with the default implementation of `BufferizableOpInterface::hasTensorSemantics`.

For all ops that implement both `DestinationStyleOpInterface` and `BufferizableOpInterface` directly on the op without an external model (currently, the only such op is `MaterializeInDestinationOp`), those two implementations now "agree".

See comment in `BufferizationOps.td`:
```c++
    // Both `DestinationStyleOpInterface` and `BufferizableOpInterface` define
    // `hasTensorSemantics`. Both return the same result, but we have to choose
    // one to disambiguate the method lookup.
    using DestinationStyleOpInterface::Trait<MaterializeInDestinationOp>
        ::hasTensorSemantics;
```

It is possible to have different implementations as long as at least one of the two interfaces is implemented as an external model. In such a case, the functions of the external model can only be accessed by explicitly casting to the interface, and at that point it is clear which implementation is meant. In practice, I don't think that we will see cases where an op implements the two interfaces but has different implementations of `hasTensorSemantics`.


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


More information about the Mlir-commits mailing list