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

Adam Siemieniuk llvmlistbot at llvm.org
Thu Jun 12 08:24:11 PDT 2025


================
@@ -117,6 +119,16 @@ def Linalg_PackOp : Linalg_RelayoutOp<"pack", [
         into %dest : tensor<128x256xf32> -> tensor<16x8 x 8x32 xf32>
     //                                             \  /   \  /
     //                                       outer dims  inner dims
+    // CHW to CHWhw
+    %0 = linalg.pack %source inner_dims_pos = [2, 1] inner_tiles = [4, 2]
+        into %dest : tensor<1x8x16xf32> -> tensor<1x2x4 x 4x2 xf32>
----------------
adam-smnk wrote:

I think the result is incorrect, it should be `1x4x4x4x2xf32`.
I'd suggest to make it more readable:
- avoid unit dims - I feel that these often read like they are irrelevant because of size `1`, I'd make untiled dims prime numbers
- pick dims and tile size such that each dimension has a different size before and after tiling - ideally also without common divisors to make it more obvious which number corresponds to which dims+tile

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


More information about the Mlir-commits mailing list