[mlir][linalg] Add output tensor args folding for linalg.tiled_loop.
authorAlexander Belyaev <pifon@google.com>
Thu, 25 Mar 2021 17:08:30 +0000 (18:08 +0100)
committerAlexander Belyaev <pifon@google.com>
Thu, 25 Mar 2021 17:11:05 +0000 (18:11 +0100)
commit7f2236cf581e6d666e4c3eb512a76f1608fe0bf7
tree4904a45769d98b7c967e8afd83e46467ea49def2
parent4c7ebf79e923072e8d298134e6ca04618fe4eba9
[mlir][linalg] Add output tensor args folding for linalg.tiled_loop.

Folds away TiledLoopOp output tensors when the following conditions are met:
* result of `linalg.tiled_loop` has no uses
* output tensor is the argument of `linalg.yield`

Example:

```
%0 = linalg.tiled_loop ...  outs (%out, %out_buf:tensor<...>, memref<...>) {
  ...
  linalg.yield %out : tensor ...
}
```

Becomes

```
linalg.tiled_loop ...  outs (%out_buf:memref<...>) {
  ...
  linalg.yield
}
```

Differential Revision: https://reviews.llvm.org/D99333
mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/canonicalize.mlir