Skip to content

Commit 68b02a0

Browse files
committed
Address banach-space's comments
Signed-off-by: hanhanW <[email protected]>
1 parent 9309168 commit 68b02a0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

mlir/include/mlir/Dialect/Linalg/IR/LinalgRelayoutOps.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,15 @@ def Linalg_PackOp : Linalg_RelayoutOp<"pack", [
150150

151151
`padding_value` specifies a padding value at the boundary on non-perfectly
152152
divisible dimensions. Padding is optional:
153-
- If absent, it assumes the tile perfectly divides the dimension.
153+
- If absent, it is assumed that for all inner tiles,
154+
`shape(source)[inner_dims_pos[i]] % inner_tiles[i] == 0`, i.e. all inner
155+
tiles divide perfectly the corresponding outer dimension in the result
156+
tensor.
154157
- If present, it will pad along high dimensions (high-padding) to make the
155158
tile complete. Note that it is not allowed to have artificial padding that
156159
is not strictly required by linalg.pack (i.e., padding past what is needed
157-
to complete the last tile along each packed dimension).. It is UB if extra
158-
padding is requested for dynamic cases. For static cases, they are caught
159-
by the verifier.
160+
to complete the last tile along each packed dimension). It is UB if extra
161+
padding is requested.
160162

161163
Example:
162164
```mlir

mlir/test/Dialect/Linalg/invalid.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,15 +1846,15 @@ func.func @pack_invalid_result_shape(%input: tensor<256x128xf32>, %output: tenso
18461846

18471847
// -----
18481848

1849-
func.func @pack_invalid(%input: tensor<256x128xf32>, %output: tensor<8x7x16x32xf32>) -> tensor<8x7x16x32xf32> {
1849+
func.func @pack_invalid_result_shape(%input: tensor<256x128xf32>, %output: tensor<8x7x16x32xf32>) -> tensor<8x7x16x32xf32> {
18501850
// expected-error@+1 {{expected 'tensor<8x8x16x32xf32>' for the unpacked domain value, got 'tensor<8x7x16x32xf32>'}}
18511851
%0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [16, 32] into %output : tensor<256x128xf32> -> tensor<8x7x16x32xf32>
18521852
return %0 : tensor<8x7x16x32xf32>
18531853
}
18541854

18551855
// -----
18561856

1857-
func.func @unpack_with_slicing_tiles(%input: tensor<3x8xf32>, %output: tensor<9xf32>) -> tensor<9xf32> {
1857+
func.func @unpack_with_dropping_tiles(%input: tensor<3x8xf32>, %output: tensor<9xf32>) -> tensor<9xf32> {
18581858
// expected-error@+1 {{expected 'tensor<2x8xf32>' for the unpacked domain value, got 'tensor<3x8xf32>'}}
18591859
%0 = linalg.unpack %input inner_dims_pos = [0] inner_tiles = [8] into %output
18601860
: tensor<3x8xf32> -> tensor<9xf32>
@@ -1863,7 +1863,7 @@ func.func @unpack_with_slicing_tiles(%input: tensor<3x8xf32>, %output: tensor<9x
18631863

18641864
// -----
18651865

1866-
func.func @unpack_invalid(%output: tensor<256x128xf32>, %input: tensor<8x8x4x32xf32>) -> tensor<256x128xf32> {
1866+
func.func @unpack_invalid_source_shape(%output: tensor<256x128xf32>, %input: tensor<8x8x4x32xf32>) -> tensor<256x128xf32> {
18671867
// expected-error@+1 {{expected 'tensor<8x32x4x32xf32>' for the unpacked domain value, got 'tensor<8x8x4x32xf32>'}}
18681868
%0 = linalg.unpack %input inner_dims_pos = [1, 0] inner_tiles = [4, 32] into %output : tensor<8x8x4x32xf32> -> tensor<256x128xf32>
18691869
return %0 : tensor<256x128xf32>

0 commit comments

Comments
 (0)