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

Han-Chung Wang llvmlistbot at llvm.org
Thu Aug 1 10:19:45 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()))
----------------
hanhanW wrote:

Do we also check if they are permutation? I'm a bit worried about something like `#map = affine_map<(d0, d1, d2) -> (d0, d1 + d2)>` or something with symbols (e.g., `s0`). 


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


More information about the Mlir-commits mailing list