[mlir][bufferization] Add TensorCopyInsertion pass
authorMatthias Springer <springerm@google.com>
Thu, 9 Jun 2022 19:49:37 +0000 (21:49 +0200)
committerMatthias Springer <springerm@google.com>
Thu, 9 Jun 2022 19:55:52 +0000 (21:55 +0200)
commit3b2004e16b30e60ab1e3eaca3398e303270cb666
treea7c94b9d3321e385338f9100f7e6bcca59befdde
parent6d890a0fb8b1962cf7b58e9e16ff4545f1f2b84f
[mlir][bufferization] Add TensorCopyInsertion pass

This pass runs the One-Shot Analysis to find out which tensor OpOperands must bufferize out-of-place. It then rewrites those tensor OpOperands to explicit allocations with a copy in the form of `bufferization.alloc_tensor`. The resulting IR can then be bufferized without having to care about read-after-write conflicts.

This change makes it possible to connect One-Shot Analysis to other bufferizations such as the sparse compiler.

Differential Revision: https://reviews.llvm.org/D126573
mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
mlir/include/mlir/Dialect/Bufferization/Transforms/TensorCopyInsertion.h [new file with mode: 0644]
mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt
mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp [new file with mode: 0644]
mlir/test/Dialect/Bufferization/Transforms/tensor-copy-insertion.mlir [new file with mode: 0644]