[Mlir-commits] [mlir] [mlir][linalg] Canonicalize non-identity `linalg.generic` ops (PR #101430)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Aug 1 10:55:15 PDT 2024


================
@@ -1217,9 +1217,8 @@ 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. It follows that they are permutations.
+    if (!llvm::all_equal(linalgOp.getIndexingMapsArray()))
----------------
MaheshRavishankar wrote:

Rest of the logic should cover the "copy" semantics, but if the input and output have same indexing map, then it shouldnt really matter.

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


More information about the Mlir-commits mailing list