[all-commits] [llvm/llvm-project] 6a91df: [mlir][bufferization] Remove allow-return-allocs a...

Martin Erhart via All-commits all-commits at lists.llvm.org
Wed Sep 13 02:31:33 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a91dfedeb956dfa092a6a3f411e8b02f0d5d289
      https://github.com/llvm/llvm-project/commit/6a91dfedeb956dfa092a6a3f411e8b02f0d5d289
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M mlir/docs/Bufferization.md
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizationBase.td
    M mlir/include/mlir/Dialect/Bufferization/TransformOps/BufferizationTransformOps.td
    M mlir/include/mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
    M mlir/include/mlir/Dialect/SparseTensor/Pipelines/Passes.h
    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/TransformOps/BufferizationTransformOps.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/FuncBufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp
    M mlir/lib/Dialect/ControlFlow/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
    M mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
    M mlir/lib/Dialect/SparseTensor/Transforms/SparsificationAndBufferizationPass.cpp
    M mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp
    M mlir/python/mlir/dialects/_bufferization_transform_ops_ext.py
    M mlir/test/Dialect/Arith/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-allow-return-allocs.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis-empty-tensor-elimination.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-compat.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-pass-statistics.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-allow-return-allocs.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-analysis.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-out-params.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/tensor-copy-insertion-memory-space.mlir
    M mlir/test/Dialect/Bufferization/Transforms/tensor-copy-insertion.mlir
    M mlir/test/Dialect/Bufferization/Transforms/transform-ops.mlir
    M mlir/test/Dialect/Bufferization/invalid.mlir
    M mlir/test/Dialect/ControlFlow/one-shot-bufferize-analysis.mlir
    M mlir/test/Dialect/ControlFlow/one-shot-bufferize-invalid.mlir
    M mlir/test/Dialect/ControlFlow/one-shot-bufferize.mlir
    M mlir/test/Dialect/Linalg/one-shot-bufferize-analysis.mlir
    M mlir/test/Dialect/Linalg/one-shot-bufferize.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-allow-return-allocs-no-deallocs.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-analysis.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-invalid.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-tensor-copy-insertion.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize.mlir
    M mlir/test/Dialect/SparseTensor/one_shot_bufferize_tensor_copy_insertion.mlir
    M mlir/test/Dialect/SparseTensor/sparse_sddmm.mlir
    M mlir/test/Dialect/Tensor/one-shot-bufferize-tensor-copy-insertion.mlir
    M mlir/test/Dialect/Tensor/one-shot-bufferize.mlir
    M mlir/test/lib/Dialect/Bufferization/TestTensorCopyInsertion.cpp
    M mlir/test/python/dialects/transform_bufferization_ext.py

  Log Message:
  -----------
  [mlir][bufferization] Remove allow-return-allocs and create-deallocs pass options, remove bufferization.escape attribute

This is the first commit in a series with the goal to rework the
BufferDeallocation pass. Currently, this pass heavily relies on copies
to perform correct deallocations, which leads to very slow code and
potentially high memory usage. Additionally, there are unsupported cases
such as returning memrefs which this series of commits aims to add
support for as well.

This first commit removes the deallocation capabilities of
one-shot-bufferization.One-shot-bufferization should never deallocate any
memrefs as this should be entirely handled by the buffer-deallocation pass
going forward. This means the allow-return-allocs pass option will
default to true now, create-deallocs defaults to false and they, as well
as the escape attribute indicating whether a memref escapes the current region,
will be removed.

The documentation should w.r.t. these pass option changes should also be
updated in this commit.

Reviewed By: springerm

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


  Commit: 6f35401f867314d1b8c5e7e2c747d6b42b75d1d5
      https://github.com/llvm/llvm-project/commit/6f35401f867314d1b8c5e7e2c747d6b42b75d1d5
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M mlir/test/Integration/Dialect/Linalg/CPU/test-collapse-tensor.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-elementwise.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-expand-tensor.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-one-shot-bufferize.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-padtensor.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-subtensor-insert-multiple-uses.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-subtensor-insert.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-tensor-e2e.mlir
    M mlir/test/Integration/Dialect/Linalg/CPU/test-tensor-matmul.mlir

  Log Message:
  -----------
  [mlir][bufferization] Update linalg integration tests to lower ops created by bufferization-to-memref pass

This commit prepares the linalg integration tests to be run with the new
BufferDeallocation pass which requires the bufferization-to-memref pass
to be run afterwards.
The bufferization-to-memref pass may create ops of the SCF, Func, Arith,
and MemRef dialects. Currently, not all integration tests execute all the
conversion passes necessary to lower these dialects to LLVM.

Reviewed By: springerm

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


  Commit: 1bebb60a7565e5197d23120528f544b886b4d905
      https://github.com/llvm/llvm-project/commit/1bebb60a7565e5197d23120528f544b886b4d905
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M mlir/docs/Bufferization.md
    M mlir/include/mlir/Dialect/Bufferization/Transforms/BufferUtils.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-branchop-interface.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-callop-interface.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-existing-deallocs.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-function-boundaries.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-memoryeffect-interface.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-region-branchop-interface.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-subviews.mlir
    A mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/invalid-buffer-deallocation.mlir
    R mlir/test/Dialect/Bufferization/Transforms/buffer-deallocation.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir][bufferization] Improve buffer deallocation pass

Add a new Buffer Deallocation pass replacing the old one with the goal of
inserting fewer clone operations and supporting additional use-cases.
Please refer to the Buffer Deallocation section in the updated
Bufferization.md file for more information on how this new pass works.

Reviewed By: springerm

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


  Commit: 29d86175e6a5fe956147734229dca88822415b21
      https://github.com/llvm/llvm-project/commit/29d86175e6a5fe956147734229dca88822415b21
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    A mlir/include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h
    A mlir/include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.td
    M mlir/include/mlir/Dialect/Bufferization/IR/CMakeLists.txt
    M mlir/include/mlir/Dialect/Bufferization/Transforms/BufferUtils.h
    A mlir/include/mlir/Dialect/ControlFlow/Transforms/BufferDeallocationOpInterfaceImpl.h
    M mlir/include/mlir/InitAllDialects.h
    A mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp
    M mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt
    A mlir/lib/Dialect/ControlFlow/Transforms/BufferDeallocationOpInterfaceImpl.cpp
    M mlir/lib/Dialect/ControlFlow/Transforms/CMakeLists.txt
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-region-branchop-interface.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir][bufferization][NFC] Introduce BufferDeallocationOpInterface

This new interface allows operations to implement custom handling of ownership
values and insertion of dealloc operations which is useful when an op cannot
implement the interfaces supported by default by the buffer deallocation pass
(e.g., because they are not exactly compatible or because there are some
additional semantics to it that would render the default implementations in
buffer deallocation invalid, or because no interfaces exist for this kind of
behavior and it's not worth introducing one plus a default implementation in
buffer deallocation). Additionally, it can also be used to provide more
efficient handling for a specific op than the interface based default
implementations can.

Reviewed By: springerm

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


  Commit: 89117f1807e5ac8db46295e977f02899e8ee8a56
      https://github.com/llvm/llvm-project/commit/89117f1807e5ac8db46295e977f02899e8ee8a56
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    A mlir/include/mlir/Dialect/Arith/Transforms/BufferDeallocationOpInterfaceImpl.h
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.h
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferDeallocationOpInterface.td
    M mlir/include/mlir/InitAllDialects.h
    A mlir/lib/Dialect/Arith/Transforms/BufferDeallocationOpInterfaceImpl.cpp
    M mlir/lib/Dialect/Arith/Transforms/CMakeLists.txt
    M mlir/lib/Dialect/Bufferization/IR/BufferDeallocationOpInterface.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-callop-interface.mlir

  Log Message:
  -----------
  [mlir][bufferization] BufferDeallocationOpInterface: support custom ownership update logic

Add a method to the BufferDeallocationOpInterface that allows operations to
implement the interface and provide custom logic to compute the ownership
indicators of values it defines. As a demonstrating example, this new method is
implemented by the `arith.select` operation.

Reviewed By: springerm

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


  Commit: 1356e853d47723c1be6eee2368d95c514a1816d1
      https://github.com/llvm/llvm-project/commit/1356e853d47723c1be6eee2368d95c514a1816d1
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    A mlir/include/mlir/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.h
    M mlir/include/mlir/InitAllDialects.h
    A mlir/lib/Dialect/SCF/Transforms/BufferDeallocationOpInterfaceImpl.cpp
    M mlir/lib/Dialect/SCF/Transforms/CMakeLists.txt
    A mlir/test/Dialect/SCF/buffer-deallocation.mlir

  Log Message:
  -----------
  [mlir][bufferization] Implement BufferDeallocationopInterface for scf.forall.in_parallel

The scf.forall.in_parallel terminator operation has a nested graph region with
the NoTerminator trait. Such regions are not supported by the default
implementations. Therefore, this commit adds a specialized implementation for
this operation which only covers the case where the nested region is empty.
This is because after bufferization, ops like tensor.parallel_insert_slice were
already converted to memref operations residing int the scf.forall only and the
nested region of scf.forall.in_parallel ends up empty.

Reviewed By: springerm

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


  Commit: f0c46639429768e46e1882036be7c2ddb712a985
      https://github.com/llvm/llvm-project/commit/f0c46639429768e46e1882036be7c2ddb712a985
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    A mlir/include/mlir/Dialect/Bufferization/Pipelines/Passes.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
    M mlir/include/mlir/InitAllPasses.h
    M mlir/lib/Dialect/Bufferization/CMakeLists.txt
    A mlir/lib/Dialect/Bufferization/Pipelines/BufferizationPipelines.cpp
    A mlir/lib/Dialect/Bufferization/Pipelines/CMakeLists.txt
    M mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-branchop-interface.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-callop-interface.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-existing-deallocs.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-function-boundaries.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-memoryeffect-interface.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-region-branchop-interface.mlir
    M mlir/test/Dialect/Bufferization/Transforms/BufferDeallocation/dealloc-subviews.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  [mlir][bufferization] Define a pipeline for buffer deallocation

Since buffer deallocation requires a few passes to be run in a somewhat fixed
sequence, it makes sense to have a pipeline for convenience (and to reduce the
number of transform ops to represent default deallocation).

Reviewed By: springerm

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


  Commit: cb5fe6ce7560fa05fbb7a1d94567e8c3be971930
      https://github.com/llvm/llvm-project/commit/cb5fe6ce7560fa05fbb7a1d94567e8c3be971930
  Author: Martin Erhart <merhart at google.com>
  Date:   2023-09-13 (Wed, 13 Sep 2023)

  Changed paths:
    M mlir/lib/Dialect/Arith/Transforms/BufferDeallocationOpInterfaceImpl.cpp

  Log Message:
  -----------
  [mlir][bufferization] Remove unused function


Compare: https://github.com/llvm/llvm-project/compare/8ebe1d1cc1e4...cb5fe6ce7560


More information about the All-commits mailing list