@@ -19,13 +19,13 @@ func.func @fc_relu(%lhs: tensor<512x512xf32>, %rhs: tensor<512x512xf32>,
19
19
outs(%output: tensor<512x512xf32>) -> tensor<512x512xf32>
20
20
21
21
// Elementwise addition.
22
- %biased = linalg.elemwise_binary { fun = #linalg.binary_fn <add> }
22
+ %biased = linalg.elementwise kind= #linalg.elementwise_kind <add>
23
23
ins(%matmul, %bias : tensor<512x512xf32>, tensor<512x512xf32>)
24
24
outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
25
25
26
26
// Elementwise max with 0 (ReLU).
27
27
%c0f = arith.constant 0.0 : f32
28
- %relued = linalg.elemwise_binary { fun = #linalg.binary_fn <max_signed> }
28
+ %relued = linalg.elementwise kind= #linalg.elementwise_kind <max_signed>
29
29
ins(%biased, %c0f : tensor<512x512xf32>, f32)
30
30
outs(%output : tensor<512x512xf32>) -> tensor<512x512xf32>
31
31
func.return %relued : tensor<512x512xf32>
@@ -41,7 +41,7 @@ module attributes {transform.with_named_sequence} {
41
41
transform.named_sequence @__transform_main(
42
42
%arg0: !transform.any_op,
43
43
%arg1: !transform.op<"linalg.matmul">,
44
- %arg2: !transform.op<"linalg.elemwise_binary ">):
44
+ %arg2: !transform.op<"linalg.elementwise ">):
45
45
transform.yield
46
46
}
47
47
}
@@ -72,11 +72,11 @@ To check or debug a transform sequence, it is possible to print various entities
72
72
transform.sequence failures(propagate) {
73
73
^bb0(%arg0: !transform.any_op,
74
74
%arg1: !transform.op<"linalg.matmul">,
75
- %arg2: !transform.op<"linalg.elemwise_binary ">):
75
+ %arg2: !transform.op<"linalg.elementwise ">):
76
76
transform.debug.emit_remark_at %arg1, "matmul"
77
77
: !transform.op<"linalg.matmul">
78
78
transform.debug.emit_remark_at %arg2, "elemwise_binaries"
79
- : !transform.op<"linalg.elemwise_binary ">
79
+ : !transform.op<"linalg.elementwise ">
80
80
transform.yield
81
81
}
82
82
```
@@ -89,24 +89,24 @@ Since we don’t want to recompile the compiler every time we change a transform
89
89
``` sh
90
90
$ mlir-opt sequence.mlir --pass-pipeline="
91
91
builtin.module(transform-interpreter{
92
- debug-bind-trailing-args=linalg.matmul,linalg.elemwise_binary })"
92
+ debug-bind-trailing-args=linalg.matmul,linalg.elementwise })"
93
93
```
94
94
95
- The ` sequence.mlir ` file contains _ both_ the payload IR function _ and_ the transform IR sequence nested in the same module. The transform interpreter pass will apply the ` @__transform_main ` named sequence to the anchor operation of the pass. In our case, we also asked the interpreter pass to associate the two extra arguments of the top-level sequence with all ` linalg.matmul ` and ` linalg.elemwise_binary ` payload operations through the respective pass options. Running this pass results in the expected remarks:
95
+ The ` sequence.mlir ` file contains _ both_ the payload IR function _ and_ the transform IR sequence nested in the same module. The transform interpreter pass will apply the ` @__transform_main ` named sequence to the anchor operation of the pass. In our case, we also asked the interpreter pass to associate the two extra arguments of the top-level sequence with all ` linalg.matmul ` and ` linalg.elementwise ` payload operations through the respective pass options. Running this pass results in the expected remarks:
96
96
97
97
``` sh
98
98
sequence.mlir:7:13: remark: matmul
99
99
%matmul = linalg.matmul ins(%lhs, %rhs: tensor< 512x512xf32> , tensor< 512x512xf32> )
100
100
^
101
101
sequence.mlir:7:13: note: see current operation: %0 = linalg.matmul ins(%arg0, %arg1 : tensor< 512x512xf32> , tensor< 512x512xf32> ) outs(%arg3 : tensor< 512x512xf32> ) -> tensor< 512x512xf32>
102
102
sequence.mlir:10:13: remark: elemwise_binaries
103
- %biased = linalg.elemwise_binary { fun = # linalg.binary_fn <add> }
103
+ %biased = linalg.elementwise kind= # linalg.elementwise_kind <add>
104
104
^
105
- sequence.mlir:10:13: note: see current operation: %1 = linalg.elemwise_binary {fun = # linalg.binary_fn <add>} ins(%0, %arg2 : tensor<512x512xf32>, tensor<512x512xf32>) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
105
+ sequence.mlir:10: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>
106
106
sequence.mlir:14:13: remark: elemwise_binaries
107
- %relued = linalg.elemwise_binary { fun = # linalg.binary_fn <max_signed> }
107
+ %relued = linalg.elementwise kind= # linalg.elementwise_kind <max_signed>
108
108
^
109
- sequence.mlir:14:13: note: see current operation: %2 = linalg.elemwise_binary {fun = # linalg.binary_fn <max_signed>} ins(%1, %cst : tensor<512x512xf32>, f32) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
109
+ sequence.mlir:14:13: note: see current operation: %2 = linalg.elementwise kind= # linalg.elementwise_kind <max_signed>> ins(%1, %cst : tensor<512x512xf32>, f32) outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
110
110
```
111
111
112
112
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.
@@ -121,7 +121,7 @@ module attributes {transform.with_named_sequence} {
121
121
transform.named_sequence @__transform_main(
122
122
%arg0: !transform.any_op,
123
123
%arg1: !transform.op<"linalg.matmul">,
124
- %arg2: ! transform.op< " linalg.elemwise_binary " > ) {
124
+ %arg2: !transform.op<"linalg.elementwise ">) {
125
125
// The actual tiling transformation takes tile sizes as attributes.
126
126
%loop, %tiled = transform.structured.tile_using_forall %arg1
127
127
tile_sizes [4, 32]
@@ -163,10 +163,10 @@ func.func @fc_relu(%arg0: tensor<512x512xf32>,
163
163
: tensor<4x32xf32> into tensor<512x512xf32>
164
164
}
165
165
}
166
- %1 = linalg.elemwise_binary {fun = # linalg.binary_fn <add>}
166
+ %1 = linalg.elementwise kind= #linalg.elementwise_kind <add>>
167
167
ins(%0, %arg2 : tensor<512x512xf32>, tensor<512x512xf32>)
168
168
outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
169
- %2 = linalg.elemwise_binary {fun = # linalg.binary_fn <max_signed>}
169
+ %2 = linalg.elementwise kind= #linalg.elementwise_kind <max_signed>>
170
170
ins(%1, %cst : tensor<512x512xf32>, f32)
171
171
outs(%arg3 : tensor<512x512xf32>) -> tensor<512x512xf32>
172
172
return %2 : tensor<512x512xf32>
@@ -185,7 +185,7 @@ module attributes {transform.with_named_sequence} {
185
185
transform.named_sequence @__transform_main(
186
186
%arg0: !transform.any_op,
187
187
%arg1: !transform.op<"linalg.matmul">,
188
- %arg2: ! transform.op< " linalg.elemwise_binary " > ) {
188
+ %arg2: !transform.op<"linalg.elementwise ">) {
189
189
// The actual tiling transformation takes tile sizes as attributes.
190
190
%loop, %tiled = transform.structured.tile_using_forall %arg1 tile_sizes [4, 32]
191
191
: (!transform.op<"linalg.matmul">) -> (!transform.any_op, !transform.any_op)
@@ -219,7 +219,7 @@ module attributes {transform.with_named_sequence} {
219
219
transform.named_sequence @__transform_main
220
220
%arg0: !transform.any_op,
221
221
%arg1: !transform.op<"linalg.matmul">,
222
- %arg2: ! transform.op< " linalg.elemwise_binary " > ) {
222
+ %arg2: !transform.op<"linalg.elementwise ">) {
223
223
// We can cast one type to another as long as operations are compatible
224
224
// with both types. This creates "aliasing" handles.
225
225
%casted = transform.cast %arg1 : !transform.op<"linalg.matmul">
@@ -248,7 +248,7 @@ sequence.mlir:28:3: error: op uses a handle invalidated by a previously executed
248
248
transform.debug.emit_remark_at %matmul, " elemwise_binaries" : ! transform.op< " linalg.matmul" >
249
249
^
250
250
sequence.mlir:21:29: note: handle to invalidated ops
251
- ^bb0(%root: ! transform.any_op, %matmul: ! transform.op< " linalg.matmul" > , %elemwise: ! transform.op< " linalg.elemwise_binary " > ):
251
+ ^bb0(%root: ! transform.any_op, %matmul: ! transform.op< " linalg.matmul" > , %elemwise: ! transform.op< " linalg.elementwise " > ):
252
252
^
253
253
sequence.mlir:27:19: note: invalidated by this transform op that consumes its operand # 0 and invalidates all handles to payload IR entities associated with this operand and entities nested in them
254
254
%loop, %tiled = transform.structured.tile_using_forall %mm tile_sizes [4, 32]
@@ -263,12 +263,12 @@ module attributes {transform.with_named_sequence} {
263
263
transform.named_sequence @__transform_main(
264
264
%arg0: !transform.any_op,
265
265
%arg1: !transform.op<"linalg.matmul">,
266
- %arg2: ! transform.op< " linalg.elemwise_binary " > ) {
266
+ %arg2: !transform.op<"linalg.elementwise ">) {
267
267
// Since the %arg2 handle is associated with both elementwise operations,
268
268
// we need to split it into two handles so we can target only the second
269
269
// elementwise operation.
270
270
%add, %max = transform.split_handle %arg2
271
- : (! transform.op< " linalg.elemwise_binary " > )
271
+ : (!transform.op<"linalg.elementwise ">)
272
272
-> (!transform.any_op, !transform.any_op)
273
273
274
274
// The actual tiling transformation takes tile sizes as attributes. It
@@ -308,12 +308,12 @@ module attributes {transform.with_named_sequence} {
308
308
transform.named_sequence @__transform_main(
309
309
%arg0: !transform.any_op,
310
310
%arg1: !transform.op<"linalg.matmul">,
311
- %arg2: ! transform.op< " linalg.elemwise_binary " > ) {
311
+ %arg2: !transform.op<"linalg.elementwise ">) {
312
312
// Since the %arg2 handle is associated with both elementwise operations,
313
313
// we need to split it into two handles so we can target only the second
314
314
// elementwise operation.
315
315
%add, %max = transform.split_handle %arg2
316
- : (! transform.op< " linalg.elemwise_binary " > )
316
+ : (!transform.op<"linalg.elementwise ">)
317
317
-> (!transform.any_op, !transform.any_op)
318
318
319
319
// The actual tiling transformation takes tile sizes as attributes. It
@@ -384,7 +384,7 @@ test/Examples/transform/Ch1/invalidation-2.mlir:106:18: note: invalidated by thi
384
384
%func, %call = transform.loop.outline %outline_target {func_name = " outlined" }
385
385
^
386
386
test/Examples/transform/Ch1/invalidation-2.mlir:24:13: note: ancestor payload op
387
- %biased = linalg.elemwise_binary { fun = #linalg.binary_fn <add> }
387
+ %biased = linalg.elementwise kind= # linalg.elementwise_kind <add>
388
388
^
389
389
test/Examples/transform/Ch1/invalidation-2.mlir:24:13: note: nested payload op
390
390
%matmul = linalg.matmul ins(%lhs, %rhs: tensor< 512x512xf32> , tensor< 512x512xf32> )
0 commit comments