[Mlir-commits] [mlir] [MLIR][NFC] Add allow Insert/extract slice option to pack/unpack op (PR #117340)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Nov 25 07:13:26 PST 2024
Max191 wrote:
> Why not add tests for that? I don't really know how fusion is tested, but this summary implies that we should be writing tests showing how these things compose? And demonstrating the impact of this new flag.
I'm not really sure where a test like this belongs. If you have a suggestion for where we could put it that would be very helpful!
Here is an example case where this helps:
```mlir
%producer = tensor.pack %src into %dest ...
%consumer_loop = scf.for ... {
%slice = tensor.extract_slice %producer ...
%consumer = "some_op" %slice ...
...
}
```
After decomposition this becomes one of 2 options:
```
// With the slice lowering:
%pad = tensor.pad %src ...
%producer = tensor.insert_slice %pad into %dest ...
%consumer_loop = scf.for ... {
%slice = tensor.extract_slice %producer ...
%consumer = "some_op" %slice ...
...
}
// With the non-slice (expand_shape/transpose) lowering\
%pad = tensor.pad %src
%expand = tensor.expand_shape %pad ...
%producer = linalg.transpose ins(%expand ...
%consumer_loop = scf.for ... {
%slice = tensor.extract_slice %producer ...
%consumer = "some_op" %slice ...
...
}
```
If we then want to run fusion of `%producer` into the `%consumer_loop`, then this would be blocked by the insert_slice in the first (slice) case, but not in the second (non-slice) case.
So if we want to test this specific case, then we would be testing the composition of these 2 transform ops, and I'm not sure where the correct test directory for this is. Alternatively, we can add a test for the fusion case above (which would be expected to fail fusion), but I'm not sure if that's a very useful test.
https://github.com/llvm/llvm-project/pull/117340
More information about the Mlir-commits
mailing list