[all-commits] [llvm/llvm-project] 96480b: [mlir][bufferization] Drop TensorLikeType::getBuff...

Andrei Golubev via All-commits all-commits at lists.llvm.org
Tue Jun 9 03:38:54 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 96480b2880838fe3fb3f3120347beb1ed1560d37
      https://github.com/llvm/llvm-project/commit/96480b2880838fe3fb3f3120347beb1ed1560d37
  Author: Andrei Golubev <andrey.golubev at intel.com>
  Date:   2026-06-09 (Tue, 09 Jun 2026)

  Changed paths:
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizationTypeInterfaces.td
    M mlir/lib/Dialect/Arith/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
    M mlir/lib/Dialect/Bufferization/IR/BufferizationDialect.cpp
    M mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
    M mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-non-module-bufferize.mlir
    A mlir/test/Dialect/Bufferization/Transforms/test-one-shot-module-bufferize.mlir
    M mlir/test/lib/Dialect/Bufferization/TestOneShotModuleBufferize.cpp
    M mlir/test/lib/Dialect/Bufferization/TestTensorCopyInsertion.cpp
    M mlir/test/lib/Dialect/Test/TestOpDefs.cpp
    M mlir/test/lib/Dialect/Test/TestTypeDefs.td
    M mlir/test/lib/Dialect/Test/TestTypes.cpp

  Log Message:
  -----------
  [mlir][bufferization] Drop TensorLikeType::getBufferType() (#201350)

Replace TensorLikeType::getBufferType() with
options.unknownTypeConverterFn() hook. Make the hook work with
tensor-like and buffer-like types (instead of builtins) to maintain the
same behaviour at the API boundary level and still allow user types to
be properly supported.

Historically, an attempt to support user types within the one-shot
bufferization framework was made. As part of it,
TensorLikeType::getBufferType() was introduced to allow user-provided
types to customize bufferization. However, the whole affair proved to be
overly complex: there is an interface with customization points for
user-provided tensors, and options-based (not sufficient) implementation
for builtin tensors. On top of this, there was always a
function-specific hook to customize function-level behaviour further. As
a result of this, users would need to implement two different mechanisms
on their end: interface implementation + option hooks.

It seems more reasonable at this stage to thus drop the interface part
and just allow unknown type conversion hook to be used directly. That
way, users would only need to supply that hook themselves (with the
caveat of having to perform a type dispatch inside of the hook).

As a drive by, multiple tests that exercise the usage of custom tensor
type (e.g. !test.test_tensor) are moved to work on top of a test pass.
Default memory space inference hook is also updated to work on top of
tensor-like type to align the signature to the unknown type conversion.

Note for LLVM integration:
* Implementation(s) of `TensorLikeType::getBufferType()` for
(user-provided) tensor types should now be moved into a user-specified
`BufferizationOptions::unknownTypeConverterFn()` hook
* In case upstream one-shot-bufferization pass was used to bufferize IR
with user types, such a setup would likely fail now, since a fallback to
type-based bufferization can now only be set through bufferization
options, and cannot be configured at the upstream pass level. One needs
to create a new pass that sets up the necessary bufferization hooks and
calls one-shot-bufferization infrastructure manually.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list