[all-commits] [llvm/llvm-project] e62681: [mlir][bufferize] Eliminate tensor.empty ops inste...
Matthias Springer via All-commits
all-commits at lists.llvm.org
Fri Nov 11 02:42:57 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e62681e70a4e0cef34d7310d42de7d425784264b
https://github.com/llvm/llvm-project/commit/e62681e70a4e0cef34d7310d42de7d425784264b
Author: Matthias Springer <springerm at google.com>
Date: 2022-11-11 (Fri, 11 Nov 2022)
Changed paths:
R mlir/include/mlir/Dialect/Bufferization/Transforms/AllocTensorElimination.h
A mlir/include/mlir/Dialect/Bufferization/Transforms/EmptyTensorElimination.h
M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.h
M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
R mlir/lib/Dialect/Bufferization/Transforms/AllocTensorElimination.cpp
M mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt
A mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp
R mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-alloc-tensor-elimination.mlir
A mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis-empty-tensor-elimination.mlir
A mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-empty-tensor-elimination.mlir
R mlir/test/Dialect/Linalg/one-shot-bufferize-analysis-init-tensor-elimination.mlir
Log Message:
-----------
[mlir][bufferize] Eliminate tensor.empty ops instead of bufferization.alloc_tensor ops
tensor.empty op elimination is an optimization that brings IR in a more bufferization-friendly form. E.g.:
```
%0 = tensor.empty()
%1 = linalg.fill(%cst, %0) {inplace = [true]}
%2 = tensor.insert_slice %1 into %t[10][20][1]
```
Is rewritten to:
```
%0 = tensor.extract_slice %t[10][20][1]
%1 = linalg.fill(%cst, %0) {inplace = [true]}
%2 = tensor.insert_slice %1 into %t[10][20][1]
```
This optimization used to operate on bufferization.alloc_tensor ops. This is not correct because the documentation of bufferization.alloc_tensor says that it always bufferizes to an allocation. Instead, this optimization should operate on tensor.empty ops, which can then be lowered to bufferization.alloc_tensor ops (if they don't get eliminated).
Differential Revision: https://reviews.llvm.org/D137162
More information about the All-commits
mailing list