[all-commits] [llvm/llvm-project] 950f09: [mlir][bufferization] Factor out bufferization.dea...

Martin Erhart via All-commits all-commits at lists.llvm.org
Thu Aug 31 00:10:57 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 950f0944c95a5416415786487a1263de2dfcec13
      https://github.com/llvm/llvm-project/commit/950f0944c95a5416415786487a1263de2dfcec13
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-08-31 (Thu, 31 Aug 2023)

  Changed paths:
    M mlir/include/mlir/Conversion/Passes.td
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
    M mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp
    M mlir/lib/Conversion/BufferizationToMemRef/CMakeLists.txt
    M mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt
    A mlir/lib/Dialect/Bufferization/Transforms/LowerDeallocations.cpp
    R mlir/test/Conversion/BufferizationToMemRef/bufferization-to-memref-func.mlir
    M mlir/test/Conversion/BufferizationToMemRef/bufferization-to-memref.mlir
    A mlir/test/Dialect/Bufferization/Transforms/lower-deallocations-func.mlir
    A mlir/test/Dialect/Bufferization/Transforms/lower-deallocations.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir][bufferization] Factor out bufferization.dealloc lowering into separate pass

Moves the lowering of `bufferization.dealloc` to memref into a separate pass,
but still registers the pattern in the conversion pass.  This is helpful when
some tensor values (and thus `to_memref` or `to_tensor` operations) still
remain, e.g., when the function boundaries are not converted, or when constant
tensors are converted to memref.get_global at a later point.

However, it is still recommended to perform all bufferization before
deallocation to avoid memory leaks as all memref allocations inserted after the
deallocation pass was applied, have to be handled manually.

Note: The buffer deallocation pass assumes that memref values defined by
`bufferization.to_memref` don't return ownership and don't have to be
deallocated. `bufferization.to_tensor` operations are handled similarly to
`bufferization.clone` operations with the exception that the result value is
not handled because it's a tensor (not a memref).

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D159180




More information about the All-commits mailing list