[Mlir-commits] [mlir] [mlir][tensor] Add consumer fusion for `tensor.pack` op. (PR #103715)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Aug 19 00:12:57 PDT 2024
Yun-Fly wrote:
Hi, @MaheshRavishankar @hanhanW. Let me try to rephrase the corner case we may encounter:
```
%1 = tensor.empty() : tensor<30xf32>
%pack = tensor.pack %1 outer_dims_perm = [0] padding_value(%pad : f32) inner_dims_pos = [0] inner_tiles = [16] into %output : tensor<30xf32> -> tensor<2x16xf32>
```
If we do not consider tiling, the `%1` will be packed into two rows:
1. [0,1,2,...,15] -> (0,0),(0,1),...(0,15)
2. [16,17,,...,29] -> (1,0),(1,1),...,(1,13), and padding (1,14), (1,15)
Then, if we take tiling into consideration, i.e. the `tileSize` from operand of `pack` is `15`, which is not exactly divided by `16`.
1. the first slice is extracted from (0) to (14) and inserted into (0,0)~(0,14) in first row.
2. the second slice is extracted from (15) to (29) and SHOULD BE respectively inserted into two rows with different length. i.e. first row: (0, 15) and second row (1,0)~(1,13) and padding (1,14), (1,15).
I am seeking your advice about how to deal with this? Based on current coordination(`outerDimOffset = floor(offset,innerTile), outerDimTileSize = ceil(tileSize, innerTile)`), both of first slice and second one will be inserted into first row(`outerDimOffset=0` and `outerDimTileSize =1`).
BTW, this issue exists even if without padding, e.g.
```
%1 = tensor.empty() : tensor<30xf32>
%pack = tensor.pack %1 outer_dims_perm = [0] inner_dims_pos = [0] inner_tiles = [6] into %output : tensor<30xf32> -> tensor<5x6xf32>
```
where the `tileSize` from operand of `pack` is `5`.
https://github.com/llvm/llvm-project/pull/103715
More information about the Mlir-commits
mailing list