diff options
| author | Rik Huijzer <github@huijzer.xyz> | 2023-11-09 20:36:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-09 20:36:32 +0100 |
| commit | d0da3d8393939790bb1a6b3b5a36daeeef000c9b (patch) | |
| tree | 684bde034ac33a3c828ad006fd3f68c9a0cbd146 /llvm/lib/TextAPI/TextAPIError.cpp | |
| parent | bede0106d0df0ac77df7e5716e73cae96029e289 (diff) | |
[mlir][tensor] Fold when source is const (#71643)
Fixes https://github.com/llvm/llvm-project/issues/60656.
This patch implements a basic fold for various reshape/resize tensor
operations. Specifically, the folding removes tensor reshape/resize ops
when they are applied to a constant tensor. For example, the following
function:
```mlir
func.func @main(%dest : tensor<8x16x8x32xf32>) -> tensor<8x16x8x32xf32> {
%cst = arith.constant dense<1.000000e-01> : tensor<64x128xf32>
%0 = tensor.pack %cst outer_dims_perm = [1, 0] inner_dims_pos = [0, 1]
inner_tiles = [8, 32] into %dest : tensor<64x128xf32> -> tensor<8x16x8x32xf32>
return %0 : tensor<8x16x8x32xf32>
}
```
will be changed into the following with `mlir-opt -canonicalize`:
```mlir
func.func @main(%arg0: tensor<8x16x8x32xf32>) -> tensor<8x16x8x32xf32> {
%cst = arith.constant dense<1.000000e-01> : tensor<8x16x8x32xf32>
return %cst : tensor<8x16x8x32xf32>
}
```
As a side-note, this patch is essentially an extension of
https://github.com/llvm/llvm-project/commit/f79f430d4b268429f96be95622facd2775b25624.
Diffstat (limited to 'llvm/lib/TextAPI/TextAPIError.cpp')
0 files changed, 0 insertions, 0 deletions
