[Mlir-commits] [mlir] [mlir][linalg] Update pack and unpack documentation (PR #143903)

Han-Chung Wang llvmlistbot at llvm.org
Thu Jun 26 11:16:04 PDT 2025


================
@@ -93,17 +93,20 @@ def Linalg_PackOp : Linalg_RelayoutOp<"pack", [
     tensor of rank `n + k` with a tiled and packed layout (maybe with padding)
     and optionally transposes the tiled source tensor dimensions.
 
-    `inner_dims_pos` (mandatory) specifies `k` source tensor dimensions that are
-    being tiled, where `0 < k <= n`. The order of the dimensions matters:
-     - The tiled dimensions (of size `inner_tiles`) are added to the end of the result
-    tensor in the order in which they appear in `inner_dims_pos`.
-     - `inner_dims_pos[i]` specifies the source tensor dimension tiled by
-    `inner_tiles[i]`.
-
     `inner_tiles` (mandatory) specifies `k` tile sizes. These tile sizes
     correspond to the least significant ("inner") result tensor dimension sizes,
     in the same order. Tile sizes can be static or dynamic.
 
+    `inner_dims_pos` (mandatory) specifies `k` source tensor dimensions that are
+    being tiled, where `0 <= k <= n`.
----------------
hanhanW wrote:

>     The "pack" operation converts a source tensor of rank `n` into a result
>    tensor of rank `n + k` with a tiled and packed layout (maybe with padding)
>    and optionally transposes the tiled source tensor dimensions.

If we read from the start, I think `k` indicates the number of dimensions to pack, which is also the number of elements in `inner_dims_pos`. So it is `0 <= k <= n`.

You are right that the indices should go from `0` to `n-1`, and we may say that in the following statement like

```
  `inner_tiles[i]` where `0 <= i < k`. All the values in `inner_dims_pos` are within [0, n).
```

https://github.com/llvm/llvm-project/pull/143903


More information about the Mlir-commits mailing list