diff options
author | Nicolas Vasilache <nicolas.vasilache@gmail.com> | 2021-03-04 21:52:05 +0000 |
---|---|---|
committer | Nicolas Vasilache <nicolas.vasilache@gmail.com> | 2021-03-05 09:42:19 +0000 |
commit | 35908406dc69415de392600bfb93f15865135584 (patch) | |
tree | b57ff119b02d884215c763b46b8b11ca9cd97aa2 /clang/unittests/Frontend/CompilerInvocationTest.cpp | |
parent | 43e421417378bab378eccdf88a66a0a46304fa13 (diff) | |
download | llvm-35908406dc69415de392600bfb93f15865135584.zip llvm-35908406dc69415de392600bfb93f15865135584.tar.gz llvm-35908406dc69415de392600bfb93f15865135584.tar.bz2 |
[mlir][scf] Canonicalize scf.for last tensor iteration result.
Canonicalize the iter_args of an scf::ForOp that involve a tensor_load and
for which only the last loop iteration is actually visible outside of the
loop. The canonicalization looks for a pattern such as:
```
%t0 = ... : tensor_type
%0 = scf.for ... iter_args(%bb0 : %t0) -> (tensor_type) {
...
// %m is either tensor_to_memref(%bb00) or defined above the loop
%m... : memref_type
... // uses of %m with potential inplace updates
%new_tensor = tensor_load %m : memref_type
...
scf.yield %new_tensor : tensor_type
}
```
`%bb0` may have either 0 or 1 use. If it has 1 use it must be exactly a
`%m = tensor_to_memref %bb0` op that feeds into the yielded `tensor_load`
op.
If no aliasing write of `%new_tensor` occurs between tensor_load and yield
then the value %0 visible outside of the loop is the last `tensor_load`
produced in the loop.
For now, we approximate the absence of aliasing by only supporting the case
when the tensor_load is the operation immediately preceding the yield.
The canonicalization rewrites the pattern as:
```
// %m is either a tensor_to_memref or defined above
%m... : memref_type
scf.for ... { // no iter_args
... // uses of %m with potential inplace updates
}
%0 = tensor_load %m : memref_type
```
Differential revision: https://reviews.llvm.org/D97953
Diffstat (limited to 'clang/unittests/Frontend/CompilerInvocationTest.cpp')
0 files changed, 0 insertions, 0 deletions