[Mlir-commits] [mlir] [mlir][linalg] Canonicalize non-identity `linalg.generic` ops (PR #101430)
Ian Wood
llvmlistbot at llvm.org
Thu Aug 1 09:13:32 PDT 2024
================
@@ -1217,9 +1217,12 @@ struct EraseIdentityLinalgOp : public OpRewritePattern<OpTy> {
LogicalResult matchAndRewrite(OpTy linalgOp,
PatternRewriter &rewriter) const override {
- // Check all indexing maps are identity.
- if (llvm::any_of(linalgOp.getIndexingMapsArray(),
- [](AffineMap map) { return !map.isIdentity(); }))
+ // All indexing maps must be equal permutations
+ auto indexingMaps = linalgOp.getIndexingMapsArray();
+ if (!llvm::all_equal(indexingMaps))
+ return failure();
+
+ if (!indexingMaps.empty() && !indexingMaps.front().isPermutation())
----------------
IanWood1 wrote:
Good point, I didn't realize that if they are projections then a loop would be undefined. Removed this as it doesn't seem worth keeping.
https://github.com/llvm/llvm-project/pull/101430
More information about the Mlir-commits
mailing list