[Mlir-commits] [mlir] [mlir] [linalg] Add canonicalize pattern to swap transpose with broadcast (PR #97063)

Diego Caballero llvmlistbot at llvm.org
Fri Jul 5 12:26:57 PDT 2024


================
@@ -243,6 +243,14 @@ SmallVector<int64_t>
 computePermutationVector(int64_t permSize, ArrayRef<int64_t> positions,
                          ArrayRef<int64_t> desiredPositions);
 
+/// Returns a permutation vector that remove the result position in
+/// removePositions from inputPerm.
+///
+/// For example, inputPerm = {2, 4, 0, 1, 3} and removePositions = {1, 2} would
+/// result in a {2, 0, 1} permutation vector.
----------------
dcaballe wrote:

Thanks! I think we should already have this functionality implemented on `AffineMap`. Would you mind taking a look at the utilities in AffineMap.h? There are some `drop...` methods might get you what you need. You can get an AffineMap from a permutation with: https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/AffineMap.h#L103

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


More information about the Mlir-commits mailing list