[Mlir-commits] [mlir] [mlir][linalg] Migrate elementwise named ops from OpDSL to tablegen multiclass (PR #216976)

Javed Absar llvmlistbot at llvm.org
Sun Aug 23 08:29:44 PDT 2026


================
@@ -1216,6 +1217,182 @@ def BatchReduceMatmulOp : LinalgStructuredBase_Op<"batch_reduce_matmul", [
     }];
 }
 
+//===----------------------------------------------------------------------===//
+// Elementwise specializations
+//
+// These are registered ops that are specializations of `linalg.elementwise`,
+// also known as linalg (elementwise) named ops.
+// They always use identity indexing maps and fix the operation kind.
+// Their C++ implementations reuse the same helpers
+// (buildStructuredOp, RegionBuilderHelper) as ElementwiseOp.
+//===----------------------------------------------------------------------===//
+
+multiclass ElementwiseNamedOp<string mnemonic, string kind, int numRegionArgs,
+                              string opSummary> {
+  def Op : LinalgStructuredBase_Op<mnemonic, [AttrSizedOperandSegments,
+              DeclareOpInterfaceMethods<ElementwiseOpInterface>]> {
+    let summary = opSummary;
+    let description = [{
+      }] # opSummary # [{
+
+
+      The shapes and element types must be identical. The appropriate casts,
----------------
javedabsar1 wrote:

Extending the semantics of linalg elementwise named to include arbitrary indexing map i think is good if there is consensus. But upcat/downcast we couldnt even get consensus for linalg.elementwise. Without linalg.elementwise op having that support it is meaningless to add it to linalg.add [see https://github.com/llvm/llvm-project/pull/190566]

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


More information about the Mlir-commits mailing list