diff options
author | gysit <gysit@google.com> | 2022-04-11 14:23:53 +0000 |
---|---|---|
committer | gysit <gysit@google.com> | 2022-04-11 14:28:59 +0000 |
commit | 973dbe20f681ca885edd0f5e63cde62dbdb6c186 (patch) | |
tree | 0e43ea15cc9abc8a722aac80a1ba153795d7ef2e /llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp | |
parent | 40ad6670138ab8130a426432b0e94544b5e03642 (diff) | |
download | llvm-973dbe20f681ca885edd0f5e63cde62dbdb6c186.zip llvm-973dbe20f681ca885edd0f5e63cde62dbdb6c186.tar.gz llvm-973dbe20f681ca885edd0f5e63cde62dbdb6c186.tar.bz2 |
[mlir][tensor] Add pattern to fold ExtractSliceOp, PadOp chains.
The pattern folds chains of tensor::ExtractSliceOp, tensor::PadOp pairs if they pad different dimensions. Repeated tiling and padding of the tiled dimensions may introduce such chains. This canonicalization pattern folds these chains to a single tensor::ExtractSliceOp, tensor::PadOp pair that pads all dimensions at once, which simplifies vectorization and bufferization.
Example:
```mlir
%0 = tensor.extract_slice %input[16, 0] [%sz0, 64] [1, 1]
: tensor<64x64xf32> to tensor<?x64xf32>
%1 = tensor.pad %0 low[0, 0] high[%pw0, 0] { ...
} : tensor<?x64xf32> to tensor<8x64xf32>
%2 = tensor.extract_slice %1[0, 4] [8, %sz1] [1, 1]
: tensor<8x64xf32> to tensor<8x?xf32>
%res = tensor.pad %2 nofold low[0, 0] high[0, %pw1] { ...
} : tensor<8x?xf32> to tensor<8x4xf32>
```
folds into:
```mlir
%0 = tensor.extract_slice %input[16, 4] [%sz0, %sz1] [1, 1]
: tensor<64x64xf32> to tensor<?x?xf32>
%res = tensor.pad %0 nofold low[0, 0] high[%pw0, %pw1] { ...
} : tensor<?x?xf32> to tensor<8x4xf32>
```
Reviewed By: nicolasvasilache, hanchung
Differential Revision: https://reviews.llvm.org/D122722
Diffstat (limited to 'llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp')
0 files changed, 0 insertions, 0 deletions