[Mlir-commits] [mlir] [mlir][linalg] Migrate elementwise named ops from OpDSL to tablegen multiclass (PR #216976)
Javed Absar
llvmlistbot at llvm.org
Wed Aug 19 06:16:15 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:
This would change the previous semantics of linalg.add etc. I think its better is we keep named ops as before, and instead use the now linalg.elementwise to fold indexing maps, boadcasts, casts. The flow named ops-> morph to linalg.elementwise -> do any folding optimizations -> linalg.generic makes things simpler easier.
https://github.com/llvm/llvm-project/pull/216976
More information about the Mlir-commits
mailing list