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

Renato Golin llvmlistbot at llvm.org
Tue Aug 18 03:42:58 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,
----------------
rengolin wrote:

I think we should relax these restrictions, and let them auto cast like elementwise. 

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


More information about the Mlir-commits mailing list