[Mlir-commits] [mlir] [MLIR][Linalg] Fix empty tensor assumptions for linalg.pack decomposition (PR #160246)

Andrzej WarzyƄski llvmlistbot at llvm.org
Mon Oct 6 02:38:19 PDT 2025


================
@@ -274,3 +274,22 @@ func.func @pack_with_adjacent_trailing_dimensions_inner_dims_pos_and_unit_outer(
 // CHECK:         %[[INSERT:.+]] = tensor.insert_slice %[[TRANSP]] into %[[DEST]]
 // CHECK-SAME:      [0, 0, 0, 0, 0] [1, 1, 1, 4, 1] [1, 1, 1, 1, 1] : tensor<1x4x1xf32> into tensor<1x1x1x4x1xf32>
 // CHECK:         return %[[INSERT]]
+
+// -----
+
+func.func @pack_with_zero_pos_tile_size(%arg0: tensor<8x1x1x1xf32>, %arg1:tensor<1x1x1x1x8x1xf32>) -> tensor<1x1x1x1x8x1xf32> {
+  %pack = linalg.pack %arg0 outer_dims_perm = [0, 1, 2, 3] inner_dims_pos = [0, 3] inner_tiles = [8, 1] into %arg1: tensor<8x1x1x1xf32> -> tensor<1x1x1x1x8x1xf32>
+  return %pack : tensor<1x1x1x1x8x1xf32>
+}
----------------
banach-space wrote:

I was trying to understand what makes this case unique so that we can document it. Note that there are other examples where one of the inner dims pos is zero, e.g. `@pack_with_non_adjacent_inner_dims_pos_and_unit_outer`.

In this example, I see two unique features:
* non-adjacent inner dims pos
* non-permuted inner dims. 

Could you update the function name accordingly? How about `@pack_with_non_adjacent_and_not_permuated_inner_dims`. I would also add a comment to highlight this even more - it's quite non-obvious.

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


More information about the Mlir-commits mailing list