[Mlir-commits] [mlir] [MLIR][Linalg] Change the syntax of elementwise kind attribute (PR #222569)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Sep 10 02:48:49 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Renato Golin (rengolin)

<details>
<summary>Changes</summary>

Remove the need to add a "kind=" lead for the elementwise operation name, as well as the fully specified namespace for the attribute, shortening the syntax from:

```
linalg.elementwise kind=#linalg.elementwise_kind<add>
```

to
```
linalg.elementwise <add>
```

Closes #<!-- -->221194

Assisted by: Claude Opus

---

Patch is 225.37 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/222569.diff


45 Files Affected:

- (modified) mlir/docs/Tutorials/transform/Ch1.md (+9-9) 
- (modified) mlir/docs/Tutorials/transform/Ch4.md (+2-2) 
- (modified) mlir/docs/Tutorials/transform/ChH.md (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td (+2-4) 
- (modified) mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp (+8-19) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp (+2-2) 
- (modified) mlir/test/Dialect/Arith/sharding-propagation.mlir (+4-4) 
- (modified) mlir/test/Dialect/Bufferization/canonicalize.mlir (+2-2) 
- (modified) mlir/test/Dialect/Linalg/block-pack-matmul.mlir (+2-2) 
- (modified) mlir/test/Dialect/Linalg/decompose-generic-by-unfolding-projected-permutation.mlir (+3-3) 
- (modified) mlir/test/Dialect/Linalg/elementwise/fold.mlir (+20-20) 
- (modified) mlir/test/Dialect/Linalg/elementwise/generalize-named-ops.mlir (+7-7) 
- (modified) mlir/test/Dialect/Linalg/elementwise/invalid.mlir (+8-9) 
- (modified) mlir/test/Dialect/Linalg/elementwise/roundtrip.mlir (+9-9) 
- (modified) mlir/test/Dialect/Linalg/fold-add-into-dest.mlir (+16-16) 
- (modified) mlir/test/Dialect/Linalg/linalg-morph-elementwise-to-named.mlir (+32-32) 
- (modified) mlir/test/Dialect/Linalg/match-ops-interpreter.mlir (+3-3) 
- (modified) mlir/test/Dialect/Linalg/reshape_fusion.mlir (+2-2) 
- (modified) mlir/test/Dialect/Linalg/roundtrip-morphism-linalg-category-ops.mlir (+98-98) 
- (modified) mlir/test/Dialect/Linalg/scalable-unpack-producer-fusion.mlir (+12-12) 
- (modified) mlir/test/Dialect/Linalg/specialize-generic-ops.mlir (+43-43) 
- (modified) mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir (+20-20) 
- (modified) mlir/test/Dialect/Linalg/transform-op-fuse.mlir (+73-73) 
- (modified) mlir/test/Dialect/Linalg/transform-op-generalize.mlir (+2-2) 
- (modified) mlir/test/Dialect/Linalg/transform-op-rewrite-in-destination-passing-style.mlir (+2-2) 
- (modified) mlir/test/Dialect/Linalg/transform-op-specialize-elemwise-binary.mlir (+17-17) 
- (modified) mlir/test/Dialect/SCF/canonicalize.mlir (+4-4) 
- (modified) mlir/test/Dialect/SCF/parallel-loop-unroll.mlir (+6-6) 
- (modified) mlir/test/Dialect/SparseTensor/encoding_with_symbols.mlir (+2-2) 
- (modified) mlir/test/Dialect/SparseTensor/external_after_codegen.mlir (+1-1) 
- (modified) mlir/test/Dialect/Transform/test-promote-tensors.mlir (+3-3) 
- (modified) mlir/test/Examples/transform/Ch1/invalidation-1.mlir (+4-4) 
- (modified) mlir/test/Examples/transform/Ch1/invalidation-2.mlir (+2-2) 
- (modified) mlir/test/Examples/transform/Ch1/sequence.mlir (+4-4) 
- (modified) mlir/test/Examples/transform/Ch2/sequence.mlir (+3-3) 
- (modified) mlir/test/Examples/transform/Ch3/sequence.mlir (+3-3) 
- (modified) mlir/test/Examples/transform/Ch4/multiple.mlir (+4-4) 
- (modified) mlir/test/Examples/transform/Ch4/sequence.mlir (+2-2) 
- (modified) mlir/test/Interfaces/TilingInterface/query-fusability.mlir (+3-3) 
- (modified) mlir/test/Interfaces/TilingInterface/tile-and-fuse-consumer-using-slices.mlir (+18-18) 
- (modified) mlir/test/Interfaces/TilingInterface/tile-and-fuse-consumer.mlir (+17-17) 
- (modified) mlir/test/Interfaces/TilingInterface/tile-elementwise.mlir (+14-14) 
- (modified) mlir/test/Interfaces/TilingInterface/tile-fuse-and-yield-using-interface.mlir (+1-1) 
- (modified) mlir/test/python/dialects/linalg/ops.py (+13-9) 


``````````diff
diff --git a/mlir/docs/Tutorials/transform/Ch1.md b/mlir/docs/Tutorials/transform/Ch1.md
index c9cb7d330c1e6..14bccfbdb0c2b 100644
--- a/mlir/docs/Tutorials/transform/Ch1.md
+++ b/mlir/docs/Tutorials/transform/Ch1.md
@@ -19,13 +19,13 @@ func.func @fc_relu(%lhs: tensor<512x512xf32>, %rhs: tensor<512x512xf32>,
                           outs(%output: tensor<512x512xf32>) -> tensor<512x512xf32>
 
   // Elementwise addition.
-  %biased = linalg.elementwise kind=#linalg.elementwise_kind<add>
+  %biased = linalg.elementwise <add>
     ins(%matmul, %bias : tensor<512x512xf32>, tensor<512x512xf32>)
     outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
 
   // Elementwise max with 0 (ReLU).
   %c0f = arith.constant 0.0 : f32
-  %relued = linalg.elementwise kind=#linalg.elementwise_kind<max_signed>
+  %relued = linalg.elementwise <max_signed>
     indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> ()>, affine_map<(d0, d1) -> (d0, d1)>]
     ins(%biased, %c0f : tensor<512x512xf32>, f32)
     outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
@@ -101,13 +101,13 @@ sequence.mlir:5:13: remark: matmul
             ^
 sequence.mlir:5:13: note: see current operation: %0 = linalg.matmul ins(%arg0, %arg1 : tensor<512x512xf32>, tensor<512x512xf32>) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
 sequence.mlir:9:13: remark: elemwise_binaries
-  %biased = linalg.elementwise kind=#linalg.elementwise_kind<add>
+  %biased = linalg.elementwise <add>
             ^
-sequence.mlir:9:13: note: see current operation: %1 = linalg.elementwise kind=#linalg.elementwise_kind<add> ins(%0, %arg2 : tensor<512x512xf32>, tensor<512x512xf32>) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
+sequence.mlir:9:13: note: see current operation: %1 = linalg.elementwise <add> ins(%0, %arg2 : tensor<512x512xf32>, tensor<512x512xf32>) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
 sequence.mlir:15:13: remark: elemwise_binaries
-  %relued = linalg.elementwise kind=#linalg.elementwise_kind<max_signed>
+  %relued = linalg.elementwise <max_signed>
             ^
-sequence.mlir:15:13: note: see current operation: %2 = linalg.elementwise kind=#linalg.elementwise_kind<max_signed> indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> ()>, affine_map<(d0, d1) -> (d0, d1)>] ins(%1, %cst : tensor<512x512xf32>, f32) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
+sequence.mlir:15:13: note: see current operation: %2 = linalg.elementwise <max_signed> indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> ()>, affine_map<(d0, d1) -> (d0, d1)>] ins(%1, %cst : tensor<512x512xf32>, f32) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
 ```
 
 Note that `%arg2` is associated with both elementwise payload operations. Any handle is associated with a list of entities. Individual transformations may or may not care about the order of elements in that list.
@@ -168,11 +168,11 @@ func.func @fc_relu(%arg0: tensor<512x512xf32>,
            : tensor<4x32xf32> into tensor<512x512xf32>
     }
   }
-  %1 = linalg.elementwise kind=#linalg.elementwise_kind<add>
+  %1 = linalg.elementwise <add>
      ins(%0, %arg2 : tensor<512x512xf32>, tensor<512x512xf32>)
      outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
   %cst = arith.constant 0.000000e+00 : f32
-  %2 = linalg.elementwise kind=#linalg.elementwise_kind<max_signed>
+  %2 = linalg.elementwise <max_signed>
     indexing_maps = [#map2, #map3, #map2]
     ins(%1, %cst : tensor<512x512xf32>, f32)
     outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
@@ -391,7 +391,7 @@ test/Examples/transform/Ch1/invalidation-2.mlir:106:18: note: invalidated by thi
   %func, %call = transform.loop.outline %outline_target {func_name = "outlined"}
                  ^
 test/Examples/transform/Ch1/invalidation-2.mlir:24:13: note: ancestor payload op
-  %biased = linalg.elementwise kind=#linalg.elementwise_kind<add>
+  %biased = linalg.elementwise <add>
             ^
 test/Examples/transform/Ch1/invalidation-2.mlir:24:13: note: nested payload op
   %matmul = linalg.matmul ins(%lhs, %rhs: tensor<512x512xf32>, tensor<512x512xf32>)
diff --git a/mlir/docs/Tutorials/transform/Ch4.md b/mlir/docs/Tutorials/transform/Ch4.md
index f9a0dff5c90e3..438493e25123f 100644
--- a/mlir/docs/Tutorials/transform/Ch4.md
+++ b/mlir/docs/Tutorials/transform/Ch4.md
@@ -42,13 +42,13 @@ func.func @fc_relu(%lhs: tensor<512x512xf32>, %rhs: tensor<512x512xf32>,
             outs(%output: tensor<512x512xf32>) -> tensor<512x512xf32>
 
   // Elementwise addition.
-  %biased = linalg.elementwise kind=#linalg.elementwise_kind<add>
+  %biased = linalg.elementwise <add>
     ins(%matmul, %bias : tensor<512x512xf32>, tensor<512x512xf32>)
     outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
 
   // Elementwise max with 0 (ReLU).
   %c0f = arith.constant 0.0 : f32
-  %relued = linalg.elementwise kind=#linalg.elementwise_kind<max_signed>
+  %relued = linalg.elementwise <max_signed>
     ins(%biased, %c0f : tensor<512x512xf32>, f32)
     outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
   func.return %relued : tensor<512x512xf32>
diff --git a/mlir/docs/Tutorials/transform/ChH.md b/mlir/docs/Tutorials/transform/ChH.md
index ce24c5add631c..d2036dc8e97d6 100644
--- a/mlir/docs/Tutorials/transform/ChH.md
+++ b/mlir/docs/Tutorials/transform/ChH.md
@@ -290,7 +290,7 @@ scf.forall (%co) in (2) {
   scf.forall (%n, %y, %xo) in (5, 80, 20) {
     tensor.extract_slice
     // Implicit dimensions [ni=0:1, y=0:1, xi=0:5, ci=0:64]
-    %relued = linalg.elementwise kind=#linalg.elementwise_kind<max_signed> // ...
+    %relued = linalg.elementwise <max_signed> // ...
     scf.forall.in_parallel {
       tensor.parallel_insert_slice // ...
     }
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
index 682d016849e88..28039eb8230fb 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.h
@@ -148,7 +148,7 @@ isaTransposeOpInterface(GenericOp genericOp);
 
 /// Checks whether a given `genericOp` is semantically equivalent to a single
 /// linalg elementwise unary op, e.g.
-/// `linalg.elementwise kind=#linalg.elementwise_kind<exp>`.
+/// `linalg.elementwise <exp>`.
 /// If `allowNonIdentityMaps` is true, operations with custom indexing maps are
 /// included in the check. Note that these operations can only be represented by
 /// the category op.
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
index d5100483f3a00..2b6fc04ac0991 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
@@ -573,16 +573,14 @@ def ElementwiseOp : LinalgStructuredBase_Op<"elementwise", [
 
     Defining a unary linalg.elementwise with default indexing-map:
     ```mlir
-    %exp = linalg.elementwise
-        kind=#linalg.elementwise_kind<exp>
+    %exp = linalg.elementwise <exp>
         ins(%x : tensor<4x16x8xf32>)
         outs(%y: tensor<4x16x8xf32>) -> tensor<4x16x8xf32>
     ```
 
     Defining a binary linalg.elementwise with user-defined indexing-map:
     ```mlir
-    %add = linalg.elementwise
-        kind=#linalg.elementwise_kind<add>
+    %add = linalg.elementwise <add>
         indexing_maps = [#transpose, #broadcast, #identity]
         ins(%exp, %arg1 : tensor<4x16x8xf32>, tensor<4x16xf32>)
         outs(%arg2: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 09d0ba4d2a31c..657e183513e30 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -5139,24 +5139,13 @@ ElementwiseOp::getDefaultIndexingMaps(unsigned numMaps, unsigned numDims,
 }
 
 ParseResult ElementwiseOp::parse(OpAsmParser &parser, OperationState &result) {
-  // Expect e.g. `kind = #linalg.elemwise_kind<add>`
-  Attribute attr;
+  // Expect e.g. `<add>` (also accepts the full `#linalg.elementwise_kind<add>`).
+  ElementwiseKindAttr kindAttr;
   mlir::linalg::ElementwiseKind elemwiseKindVal;
-  if (parser.parseKeyword("kind") || parser.parseEqual())
+  if (parser.parseCustomAttributeWithFallback(kindAttr))
     return failure();
-
-  if (succeeded(parser.parseAttribute(attr))) {
-    auto elemwiseKindAttr = dyn_cast<ElementwiseKindAttr>(attr);
-    if (!elemwiseKindAttr)
-      return parser.emitError(parser.getCurrentLocation(),
-                              "expected ElementwiseKind attribute");
-    elemwiseKindVal = elemwiseKindAttr.getValue();
-  } else {
-    return parser.emitError(parser.getCurrentLocation(),
-                            "expected operation 'kind' attribute");
-  }
-  result.addAttribute(
-      "kind", ElementwiseKindAttr::get(parser.getContext(), elemwiseKindVal));
+  elemwiseKindVal = kindAttr.getValue();
+  result.addAttribute("kind", kindAttr);
 
   // Parse optional `indexing_maps`
   SmallVector<Attribute, 3> indexingMapsAttr;
@@ -5212,8 +5201,8 @@ ParseResult ElementwiseOp::parse(OpAsmParser &parser, OperationState &result) {
 }
 
 void ElementwiseOp::print(OpAsmPrinter &p) {
-  p << " kind=";
-  p.printAttribute(getKindAttr());
+  p << " ";
+  p.printStrippedAttrOrType(getKindAttr());
   SmallVector<StringRef, 3> elidedAttrs = {"operandSegmentSizes", "kind",
                                            "indexing_maps"};
   unsigned arity =
@@ -5239,7 +5228,7 @@ void ElementwiseOp::regionBuilder(
     function_ref<InFlightDiagnostic()> emitError) {
   std::optional<ElementwiseKind> elemwiseKind;
   for (auto attr : attrs) {
-    if (attr.getName() == b.getStringAttr("kind")) {
+    if (attr.getName() == "kind") {
       auto kindAttr = dyn_cast<ElementwiseKindAttr>(attr.getValue());
       if (!kindAttr) {
         if (emitError)
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
index 587aecc7adaf1..a73c466484c0d 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
@@ -74,7 +74,7 @@ static bool areBinOpsSwapped(GenericOp genericOp) {
 //     linalg.yield %0: f32
 //   } -> tensor<?xf32>
 // Here, the returned index is 1, and the generic op can be represented as
-//   %0 = linalg.elementwise kind=#linalg.elementwise_kind<mul>
+//   %0 = linalg.elementwise <mul>
 //          indexing_maps = [#mapA, affine_map<(d0) -> ()>, #mapRes]
 //          ins(%A, %cst : tensor<?xf32>, f32) outs(...) -> tensor<?xf32>
 static bool findIndexOfScalarOperand(GenericOp genericOp, int &index) {
@@ -105,7 +105,7 @@ static bool findIndexOfScalarOperand(GenericOp genericOp, int &index) {
 //     } -> tensor<?x?xf32>
 //
 // is specialized to
-//   linalg.elementwise kind=#linalg.elementwise_kind<exp> ...
+//   linalg.elementwise <exp> ...
 //
 // A named op is emitted instead for binary/ternary ops that still have a
 // linalg.* named equivalent (e.g. linalg.add).
diff --git a/mlir/test/Dialect/Arith/sharding-propagation.mlir b/mlir/test/Dialect/Arith/sharding-propagation.mlir
index 509c443ff9732..dab7a86b84827 100644
--- a/mlir/test/Dialect/Arith/sharding-propagation.mlir
+++ b/mlir/test/Dialect/Arith/sharding-propagation.mlir
@@ -17,7 +17,7 @@ shard.grid @grid4x4(shape = 4x4)
 // CHECK-NEXT: [[vsharded_4:%.*]] = shard.shard [[vsharded]] to [[vsharding_3]] annotate_for_users : tensor<1024x1024xf32>
 // CHECK-NEXT: [[vsharding_5:%.*]] = shard.sharding @grid4x4 split_axes = {{\[\[}}0]] : !shard.sharding
 // CHECK-NEXT: [[vsharded_6:%.*]] = shard.shard [[vsharded_2]] to [[vsharding_5]] annotate_for_users : tensor<1024x1024xf32>
-// CHECK-NEXT: [[v1:%.*]] = linalg.elementwise kind=#linalg.elementwise_kind<add> indexing_maps = {{.*}} ins([[vsharded_4]], [[vcst_0]] : tensor<1024x1024xf32>, f32) outs([[vsharded_6]] : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
+// CHECK-NEXT: [[v1:%.*]] = linalg.elementwise <add> indexing_maps = {{.*}} ins([[vsharded_4]], [[vcst_0]] : tensor<1024x1024xf32>, f32) outs([[vsharded_6]] : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
 // CHECK-NEXT: [[vsharding_7:%.*]] = shard.sharding @grid4x4 split_axes = {{\[\[}}0]] : !shard.sharding
 // CHECK-NEXT: [[vsharded_8:%.*]] = shard.shard [[v1]] to [[vsharding_7]] : tensor<1024x1024xf32>
 // CHECK-NEXT: return [[vsharded_8]] : tensor<1024x1024xf32>
@@ -27,7 +27,7 @@ func.func @test_shard_constant() -> (tensor<1024x1024xf32>) attributes {llvm.emi
     %sharded_1 = shard.shard %cst_1 to %sharding_1 : tensor<1024x1024xf32>
     %ci = arith.constant 43.4e+00 : f32
     %o1 = tensor.empty() : tensor<1024x1024xf32>
-    %res = linalg.elementwise kind=#linalg.elementwise_kind<add> indexing_maps = [#id, #sc, #id] ins(%sharded_1, %ci : tensor<1024x1024xf32>, f32) outs(%o1 : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
+    %res = linalg.elementwise <add> indexing_maps = [#id, #sc, #id] ins(%sharded_1, %ci : tensor<1024x1024xf32>, f32) outs(%o1 : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
     return %res : tensor<1024x1024xf32>
 }
 
@@ -43,14 +43,14 @@ func.func @test_shard_constant() -> (tensor<1024x1024xf32>) attributes {llvm.emi
 // CHECK-NEXT: [[vsharded_4:%.*]] = shard.shard [[vsharded]] to [[vsharding_3]] annotate_for_users : tensor<1024x1024xf32>
 // CHECK-NEXT: [[vsharding_5:%.*]] = shard.sharding @grid4x4 split_axes = {{\[\[}}0]] : !shard.sharding
 // CHECK-NEXT: [[vsharded_6:%.*]] = shard.shard [[vsharded_2]] to [[vsharding_5]] annotate_for_users : tensor<1024x1024xf32>
-// CHECK-NEXT: [[v1:%.*]] = linalg.elementwise kind=#linalg.elementwise_kind<add> indexing_maps = {{.*}} ins([[vsharded_4]], [[vcst_0]] : tensor<1024x1024xf32>, f32) outs([[vsharded_6]] : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
+// CHECK-NEXT: [[v1:%.*]] = linalg.elementwise <add> indexing_maps = {{.*}} ins([[vsharded_4]], [[vcst_0]] : tensor<1024x1024xf32>, f32) outs([[vsharded_6]] : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
 // CHECK-NEXT: [[vsharding_7:%.*]] = shard.sharding @grid4x4 split_axes = {{\[\[}}0]] : !shard.sharding
 // CHECK-NEXT: [[vsharded_8:%.*]] = shard.shard [[v1]] to [[vsharding_7]] : tensor<1024x1024xf32>
 func.func @test_shard_constant_back() -> (tensor<1024x1024xf32>) attributes {llvm.emit_c_interface} {
     %cst_1 = arith.constant dense<0.000000e+00> : tensor<1024x1024xf32>
     %ci = arith.constant 43.4e+00 : f32
     %o1 = tensor.empty() : tensor<1024x1024xf32>
-    %res = linalg.elementwise kind=#linalg.elementwise_kind<add> indexing_maps = [#id, #sc, #id] ins(%cst_1, %ci : tensor<1024x1024xf32>, f32) outs(%o1 : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
+    %res = linalg.elementwise <add> indexing_maps = [#id, #sc, #id] ins(%cst_1, %ci : tensor<1024x1024xf32>, f32) outs(%o1 : tensor<1024x1024xf32>) -> tensor<1024x1024xf32>
     %sharding_1 = shard.sharding @grid4x4 split_axes = [[0]] : !shard.sharding
     %sharded_1 = shard.shard %res to %sharding_1 : tensor<1024x1024xf32>
     return %sharded_1 : tensor<1024x1024xf32>
diff --git a/mlir/test/Dialect/Bufferization/canonicalize.mlir b/mlir/test/Dialect/Bufferization/canonicalize.mlir
index 887011e5be375..d235e673c2336 100644
--- a/mlir/test/Dialect/Bufferization/canonicalize.mlir
+++ b/mlir/test/Dialect/Bufferization/canonicalize.mlir
@@ -317,14 +317,14 @@ func.func @tensor_cast_to_buffer_layout_and_memspace(%arg0 : tensor<4x6x16x32xi8
 func.func @load_after_write_from_buffer_cast(%arg0: index, %arg1: index,
                             %arg2: tensor<?x?xf32>) -> f32 {
   %0 = bufferization.to_buffer %arg2 : tensor<?x?xf32> to memref<?x?xf32>
-  linalg.elementwise kind=#linalg.elementwise_kind<ceil> ins(%0 : memref<?x?xf32>) outs(%0 : memref<?x?xf32>)
+  linalg.elementwise <ceil> ins(%0 : memref<?x?xf32>) outs(%0 : memref<?x?xf32>)
   %1 = memref.load %0[%arg0, %arg1] : memref<?x?xf32>
   return %1 : f32
 }
 // CHECK-SAME: %[[IDX0:[0-9a-z]+]]: index, %[[IDX1:[0-9a-z]+]]: index
 // CHECK-SAME: %[[TENSOR:[0-9a-z]+]]: tensor<?x?xf32>
 //      CHECK: %[[M:.+]] = bufferization.to_buffer %[[TENSOR]] : tensor<?x?xf32> to memref<?x?xf32>
-//      CHECK: linalg.elementwise kind=#linalg.elementwise_kind<ceil> ins(%[[M]] : memref<?x?xf32>) outs(%[[M]] : memref<?x?xf32>)
+//      CHECK: linalg.elementwise <ceil> ins(%[[M]] : memref<?x?xf32>) outs(%[[M]] : memref<?x?xf32>)
 //      CHECK: %[[RES:.*]] = memref.load %[[M]][%[[IDX0]], %[[IDX1]]] : memref<?x?xf32>
 //      CHECK: return %[[RES]] : f32
 
diff --git a/mlir/test/Dialect/Linalg/block-pack-matmul.mlir b/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
index 1017bc047c67b..6ac4c12ff5379 100644
--- a/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
+++ b/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
@@ -142,7 +142,7 @@ func.func @block_matmul_with_consumer(
   %0 = tensor.empty() : tensor<128x128xf32>
   %1 = linalg.matmul ins(%A, %B : tensor<128x128xf32>, tensor<128x128xf32>)
                      outs(%C : tensor<128x128xf32>) -> tensor<128x128xf32>
-  %2 = linalg.elementwise kind=#linalg.elementwise_kind<add> ins(%1, %D : tensor<128x128xf32>, tensor<128x128xf32>)
+  %2 = linalg.elementwise <add> ins(%1, %D : tensor<128x128xf32>, tensor<128x128xf32>)
                   outs(%0 : tensor<128x128xf32>) -> tensor<128x128xf32>
   return %2 : tensor<128x128xf32>
 }
@@ -155,7 +155,7 @@ func.func @block_matmul_with_consumer(
 // CHECK: %[[RES_UNPACKED:.+]] = linalg.unpack %[[GEMM_RES_PACKED]]
 // CHECK-SAME:  inner_dims_pos = [0, 1] inner_tiles = [32, 16]
 // CHECK-SAME:  into %[[C]] : tensor<4x8x32x16xf32> -> tensor<128x128xf32>
-// CHECK: %[[ADD_RES:.+]] = linalg.elementwise kind=#linalg.elementwise_kind<add>
+// CHECK: %[[ADD_RES:.+]] = linalg.elementwise <add>
 // CHECK-SAME:  ins(%[[RES_UNPACKED]], %[[D]] : tensor<128x128xf32>, tensor<128x128xf32>) outs(%[[RES_DST]] : tensor<128x128xf32>)
 // CHECK: return %[[ADD_RES]] : tensor<128x128xf32>
 
diff --git a/mlir/test/Dialect/Linalg/decompose-generic-by-unfolding-projected-permutation.mlir b/mlir/test/Dialect/Linalg/decompose-generic-by-unfolding-projected-permutation.mlir
index 3cc39c5ac8333..991434b81c699 100644
--- a/mlir/test/Dialect/Linalg/decompose-generic-by-unfolding-projected-permutation.mlir
+++ b/mlir/test/Dialect/Linalg/decompose-generic-by-unfolding-projected-permutation.mlir
@@ -20,7 +20,7 @@ func.func @transpose_and_broadcast(%x : tensor<7x8x9xf32>, %y:  tensor<5x9x7x8x1
 // CHECK: %[[X_trans:.+]] = linalg.transpose ins(%[[X]] : tensor<7x8x9xf32>) outs(%[[E0]] : tensor<9x7x8xf32>) permutation = [2, 0, 1]
 // CHECK: %[[E1:.+]] = tensor.empty() : tensor<5x9x7x8x10xf32>
 // CHECK: %[[X_trans_bc:.+]] = linalg.broadcast ins(%[[X_trans]] : tensor<9x7x8xf32>) outs(%[[E1]] : tensor<5x9x7x8x10xf32>) dimensions = [0, 4]
-// CHECK: {{.*}} = linalg.elementwise kind=#linalg.elementwise_kind<div> ins(%[[X_trans_bc]], %[[Y]] : tensor<5x9x7x8x10xf32>, tensor<5x9x7x8x10xf32>) outs(%[[Z]] : tensor<5x9x7x8x10xf32>) -> tensor<5x9x7x8x10xf32>
+// CHECK: {{.*}} = linalg.elementwise <div> ins(%[[X_trans_bc]], %[[Y]] : tensor<5x9x7x8x10xf32>, tensor<5x9x7x8x10xf32>) outs(%[[Z]] : tensor<5x9x7x8x10xf32>) -> tensor<5x9x7x8x10xf32>
 // CHECK-NOT: linalg.generic
 
 // -----
@@ -44,7 +44,7 @@ func.func @transpose_only(%x : tensor<32x2x16xf32>, %y:  tensor<2x16x32xf32>, %z
 // CHECK-SAME: %[[X:.+]]: tensor<32x2x16xf32>, %[[Y:.+]]: tensor<2x16x32xf32>, %[[Z:.+]]: tensor<2x16x32xf32>) -> tensor<2x16x32xf32> {
 // CHECK: %[[E0:.+]] = tensor.empty() : tensor<2x16x32xf32>
 // CHECK: %[[X_trans:.+]] = linalg.transpose ins(%[[X]] : tensor<32x2x16xf32>) outs(%[[E0]] : tensor<2x16x32xf32>) permutation = [1, 2, 0]
-// CHECK: {{.*}} = linalg.elementwise kind=#linalg.elementwise_kind<div> ins(%[[X_trans]], %[[Y]] : tensor<2x16x32xf32>, tensor<2x16x32xf32>) outs(%[[Z]] : tensor<2x16x32xf32>) -> tensor<2x16x32xf32>
+// CHECK: {{.*}} = linalg.elementwise <div> ins(%[[X_trans]], %[[Y]] : tensor<2x16x32xf32>, tensor<2x16x32xf32>) outs(%[[Z]] : tensor<2x16x32xf32>) -> tensor<2x16x32xf32>
 // CHECK-NOT: linalg.generic
 
 // -----
@@ -67,5 +67,5 @@ func.func @broadcast_only(%x : tensor<2x16x32xf32>, %y:  tensor<2x32xf32>, %z :
 // CHECK-SAME: %[[X:.+]]: tensor<2x16x32xf32>, %[[Y:.+]]: tensor<2x32xf32>, %[[Z:.+]]: tensor<2x16x32xf32>) -> tensor<2x16x32xf32> {
 // CHECK: %[[E0:.+]] = tensor.empty...
[truncated]

``````````

</details>


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


More information about the Mlir-commits mailing list