[Mlir-commits] [mlir] [mlir][scf] Extend consumer fuse to nested loop structure (PR #94190)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Jun 5 10:59:30 PDT 2024
MaheshRavishankar wrote:
> Seems to me like this should be done by multiple application of existing transformations and not by creating a new custom transformation that unrolls both in C++
I agree with Nicolas' comment here. This is the way tile and fuse is supposed to work. You start with
```
%0 = <producer>
%1 = <consumer>(...%0...)
```
First tile the consumer
```
%0 = <producer>
%1 = scf.for ... shared_outs/init(%arg0 =...) {
%2 = scf.for ... shared_outs/init(%arg1 = %arg0) {
%3 = <consumer>(...%0...)
%4 = ... insert_slice %3 into %arg1 ...
scf.yield %4
}
scf.yield %2
}
```
then you fuse `%0` within the `scf.for` nest that is created during tiling of consumer to get
```
%1 = scf.for ... shared_outs/init(%arg0 =...) {
%2 = scf.for ... shared_outs/init(%arg1 = %arg0) {
%0 = <producer>
%3 = <consumer>(...%0...)
%4 = ... insert_slice %3 into %arg1 ...
scf.yield %4
}
scf.yield %2
}
```
So you are fusing the operation into an "immediately created" tiled loop nest. The more general case you are looking for can be done through repeated application.
https://github.com/llvm/llvm-project/pull/94190
More information about the Mlir-commits
mailing list