diff options
author | gysit <gysit@google.com> | 2022-04-11 10:19:40 +0000 |
---|---|---|
committer | gysit <gysit@google.com> | 2022-04-11 10:28:53 +0000 |
commit | 39b933647444234afb3f3d14563d02e4b8ee1b38 (patch) | |
tree | 7ba3b71371d46d9b645acd5c10bed4336e99908e /llvm/lib/CodeGen/CodeGen.cpp | |
parent | bb6f8d9a93ef0172f227b04c92e7bbb703641a79 (diff) | |
download | llvm-39b933647444234afb3f3d14563d02e4b8ee1b38.zip llvm-39b933647444234afb3f3d14563d02e4b8ee1b38.tar.gz llvm-39b933647444234afb3f3d14563d02e4b8ee1b38.tar.bz2 |
[mlir][vector] Swap ExtractSliceOp(TransferWriteOp).
Rewrite tensor::ExtractSliceOp(vector::TransferWriteOp) to vector::TransferWriteOp(tensor::ExtractSliceOp) if the full slice is overwritten and inserted into another tensor. After this rewrite, the operations bufferize in-place since all of them work on the same %iter_arg slice.
For example:
```mlir
%0 = vector.transfer_write %vec, %init_tensor[%c0, %c0]
: vector<8x16xf32>, tensor<8x16xf32>
%1 = tensor.extract_slice %0[0, 0] [%sz0, %sz1] [1, 1]
: tensor<8x16xf32> to tensor<?x?xf32>
%r = tensor.insert_slice %1 into %iter_arg[%iv0, %iv1] [%sz0, %sz1] [1, 1]
: tensor<?x?xf32> into tensor<27x37xf32>
```
folds to
```mlir
%0 = tensor.extract_slice %iter_arg[%iv0, %iv1] [%sz0, %sz1] [1, 1]
: tensor<27x37xf32> to tensor<?x?xf32>
%1 = vector.transfer_write %vec, %0[%c0, %c0]
: vector<8x16xf32>, tensor<?x?xf32>
%r = tensor.insert_slice %1 into %iter_arg[%iv0, %iv1] [%sz0, %sz1] [1, 1]
: tensor<?x?xf32> into tensor<27x37xf32>
Reviewed By: nicolasvasilache, hanchung
Differential Revision: https://reviews.llvm.org/D123190
Diffstat (limited to 'llvm/lib/CodeGen/CodeGen.cpp')
0 files changed, 0 insertions, 0 deletions