[Mlir-commits] [mlir] [MLIR][Linalg] Generic to category specialization for unary elementwise ops (PR #187217)

Julian Oppermann llvmlistbot at llvm.org
Wed Mar 18 03:16:17 PDT 2026


================
@@ -264,19 +267,21 @@ static bool isaElemwiseSingleUnaryOrBinaryOpInterface(linalg::GenericOp op,
            yieldOp->getOperand(0).getDefiningOp() != oper);
 }
 
-bool linalg::isaElemwiseSingleUnaryOpInterface(linalg::GenericOp op) {
+bool linalg::isaElemwiseSingleUnaryOpInterface(linalg::GenericOp op,
+                                               bool allowNonIdentityMaps) {
   // All basic elemwise checks.
-  if (!isaElemwiseSingleUnaryOrBinaryOpInterface(op, 1))
+  if (!isaElemwiseSingleUnaryOrBinaryOpInterface(op, 1, allowNonIdentityMaps))
     return false;
 
-  // Check input is actully used.
+  // Check input is actually used.
   if (!op.payloadUsesValueFromOperand(op.getDpsInputOperand(0)))
     return false;
   return true;
 }
 
 bool linalg::isaElemwiseSingleBinaryOpInterface(linalg::GenericOp op) {
-  if (!isaElemwiseSingleUnaryOrBinaryOpInterface(op, 2))
+  if (!isaElemwiseSingleUnaryOrBinaryOpInterface(
----------------
jopperm wrote:

The generic-to-category path isn't implemented yet for binary elementwise ops. Should be simple/mechanical, but there a lot more variants to test, so my plan was to handle that in a follow-up PR.

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


More information about the Mlir-commits mailing list