[all-commits] [llvm/llvm-project] 96c161: [mlir][linalg] fix OuterUnitDims linalg.pack decom...

Christopher McGirr via All-commits all-commits at lists.llvm.org
Fri Jun 27 00:24:54 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 96c1611163d3420c78e30b13c1f7211e3572e58b
      https://github.com/llvm/llvm-project/commit/96c1611163d3420c78e30b13c1f7211e3572e58b
  Author: Christopher McGirr <7071833+chrsmcgrr at users.noreply.github.com>
  Date:   2025-06-27 (Fri, 27 Jun 2025)

  Changed paths:
    M mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
    M mlir/test/Dialect/Linalg/decompose-pack.mlir
    M mlir/test/Dialect/Linalg/decompose-unpack.mlir

  Log Message:
  -----------
  [mlir][linalg] fix OuterUnitDims linalg.pack decomposition pattern (#141613)

Given the following example:
```
module {
  func.func @main(%arg0: tensor<1x1x1x4x1xf32>, %arg1: tensor<1x1x4xf32>) -> tensor<1x1x1x4x1xf32> {
    %pack = linalg.pack %arg1 outer_dims_perm = [1, 2, 0] inner_dims_pos = [2, 0] inner_tiles = [4, 1] into %arg0 : tensor<1x1x4xf32> -> tensor<1x1x1x4x1xf32>
    return %pack : tensor<1x1x1x4x1xf32>
  }
}
```

We would generate an invalid transpose operation because the calculated
permutation would be `[0, 2, 0]` which is semantically incorrect. As the
permutation must contain unique integers corresponding to the source
tensor dimensions.

The following change modifies how we calculate the permutation array and
ensures that the dimension indices given in the permutation array is
unique.

The above example would then translate to a transpose having a
permutation of `[1, 2, 0]`. Following the rule, that the `inner_dim_pos`
is appended to the permutation array and the preceding indices are
filled with the remaining dimensions.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list