xref: /llvm-project/mlir/test/Dialect/Linalg/match-ops-invalid.mlir (revision 488f88b844739fb8dac6a05799a1e1ec450c0ad9)
1// RUN: mlir-opt %s --split-input-file --verify-diagnostics
2
3transform.sequence failures(suppress) {
4^bb0(%arg0: !transform.any_op):
5  // expected-error @below {{expected one body argument}}
6  transform.match.structured %arg0 : !transform.any_op {
7  ^bb1:
8    transform.match.structured.yield
9  }
10  transform.yield
11}
12
13// -----
14
15transform.sequence failures(suppress) {
16^bb0(%arg0: !transform.any_op):
17  // expected-error @below {{expected body argument to implement TransformHandleTypeInterface}}
18  transform.match.structured %arg0 : !transform.any_op {
19  ^bb1(%arg1: i32):
20    transform.match.structured.yield
21  }
22  transform.yield
23}
24
25// -----
26
27transform.sequence failures(suppress) {
28^bb0(%arg0: !transform.any_op):
29  // expected-error @below {{expects nested operations to implement MatchOpInterface}}
30  transform.match.structured %arg0 : !transform.any_op {
31  ^bb1(%arg1: !transform.any_op):
32    // expected-note @below {{offending operation}}
33    transform.test_consume_operand %arg1 : !transform.any_op
34    transform.match.structured.yield
35  }
36  transform.yield
37}
38// -----
39
40transform.sequence failures(suppress) {
41^bb0(%arg0: !transform.any_op):
42  // expected-error @below {{expects parent op to be 'transform.match.structured'}}
43  transform.match.structured.body %arg0 { passthrough } : !transform.any_op
44  transform.yield
45}
46
47
48// -----
49
50transform.sequence failures(suppress) {
51^bb0(%arg0: !transform.any_op):
52  transform.match.structured %arg0 : !transform.any_op {
53  ^bb1(%arg1: !transform.any_op):
54    // expected-error @below {{expected predicate to apply to the surrounding structured op}}
55    transform.match.structured.body %arg0 { passthrough } : !transform.any_op
56    transform.match.structured.yield
57  }
58  transform.yield
59}
60
61// -----
62
63transform.sequence failures(suppress) {
64^bb0(%arg0: !transform.any_op):
65  transform.match.structured %arg0 : !transform.any_op {
66  ^bb1(%arg1: !transform.any_op):
67    // expected-error @below {{only one of {"reduction_position", "passthrough", "elementwise", "contraction"} is allowed}}
68    transform.match.structured.body %arg1 { passthrough, reduction_position = 0 } : !transform.any_op
69    transform.match.structured.yield
70  }
71  transform.yield
72}
73
74// -----
75
76transform.sequence failures(suppress) {
77^bb0(%arg0: !transform.any_op):
78  transform.match.structured %arg0 : !transform.any_op {
79  ^bb1(%arg1: !transform.any_op):
80    // expected-error @below {{cannot request both 'all' and 'inverted' values in the list}}
81    "transform.match.structured.dim"(%arg1) { is_all, is_inverted, raw_dim_list = array<i64> } : (!transform.any_op) -> ()
82    transform.match.structured.yield
83  }
84  transform.yield
85}
86
87// -----
88
89transform.sequence failures(suppress) {
90^bb0(%arg0: !transform.any_op):
91  transform.match.structured %arg0 : !transform.any_op {
92  ^bb1(%arg1: !transform.any_op):
93    // expected-error @below {{cannot both request 'all' and specific values in the list}}
94    "transform.match.structured.dim"(%arg1) { is_all, raw_dim_list = array<i64: 0, 1> } : (!transform.any_op) -> ()
95    transform.match.structured.yield
96  }
97  transform.yield
98}
99// -----
100
101transform.sequence failures(suppress) {
102^bb0(%arg0: !transform.any_op):
103  transform.match.structured %arg0 : !transform.any_op {
104  ^bb1(%arg1: !transform.any_op):
105    // expected-error @below {{must request specific values in the list if 'all' is not specified}}
106    "transform.match.structured.dim"(%arg1) { raw_dim_list = array<i64> } : (!transform.any_op) -> ()
107    transform.match.structured.yield
108  }
109  transform.yield
110}
111
112// -----
113
114transform.sequence failures(suppress) {
115^bb0(%arg0: !transform.any_op):
116  transform.match.structured %arg0 : !transform.any_op {
117  ^bb1(%arg1: !transform.any_op):
118    // expected-error @below {{op expected the listed values to be unique}}
119    "transform.match.structured.dim"(%arg1) { raw_dim_list = array<i64: 0, 0> } : (!transform.any_op) -> ()
120    transform.match.structured.yield
121  }
122  transform.yield
123}
124
125// -----
126
127transform.sequence failures(suppress) {
128^bb0(%arg0: !transform.any_op):
129  transform.match.structured %arg0 : !transform.any_op {
130  ^bb1(%arg1: !transform.any_op):
131    // expected-error @below {{cannot request the same dimension to be both parallel and reduction}}
132    "transform.match.structured.dim"(%arg1) { is_all, parallel, reduction, raw_dim_list = array<i64> } : (!transform.any_op) -> ()
133    transform.match.structured.yield
134  }
135  transform.yield
136}
137
138// -----
139
140transform.sequence failures(suppress) {
141^bb0(%arg0: !transform.any_op):
142  transform.match.structured %arg0 : !transform.any_op {
143  ^bb1(%arg1: !transform.any_op):
144    // expected-error @below {{"permutation" and "projected_permutation" are mutually exclusive}}
145    transform.match.structured.input %arg1[all] { permutation, projected_permutation } : !transform.any_op
146    transform.match.structured.yield
147  }
148  transform.yield
149}
150// -----
151
152transform.sequence failures(suppress) {
153^bb0(%arg0: !transform.any_op):
154  transform.match.structured %arg0 : !transform.any_op {
155  ^bb1(%arg1: !transform.any_op):
156    // expected-error @below {{cannot bind multiple inputs/inits to the same value}}
157    transform.match.structured.input %arg1[0, 1] : (!transform.any_op) -> !transform.any_op
158    transform.match.structured.yield
159  }
160  transform.yield
161}
162
163// -----
164
165transform.sequence failures(suppress) {
166^bb0(%arg0: !transform.any_op):
167  transform.match.structured %arg0 : !transform.any_op {
168  ^bb1(%arg1: !transform.any_op):
169    // expected-error @below {{"permutation" and "projected_permutation" are mutually exclusive}}
170    transform.match.structured.init %arg1[all] { permutation, projected_permutation } : !transform.any_op
171    transform.match.structured.yield
172  }
173  transform.yield
174}
175// -----
176
177transform.sequence failures(suppress) {
178^bb0(%arg0: !transform.any_op):
179  transform.match.structured %arg0 : !transform.any_op {
180  ^bb1(%arg1: !transform.any_op):
181    // expected-error @below {{cannot bind multiple inputs/inits to the same value}}
182    transform.match.structured.init %arg1[0, 1] : (!transform.any_op) -> !transform.any_op
183    transform.match.structured.yield
184  }
185  transform.yield
186}
187
188// -----
189
190transform.sequence failures(suppress) {
191^bb0(%arg0: !transform.any_op):
192  transform.match.structured %arg0 : !transform.any_op {
193  ^bb1(%arg1: !transform.any_op):
194    // expected-error @below {{expects either the any/single keyword or the type value handle result type}}
195    transform.match.structured.result %arg1[0] : (!transform.any_op) -> !transform.any_op
196    transform.match.structured.yield
197  }
198  transform.yield
199}
200
201// -----
202
203transform.sequence failures(suppress) {
204^bb0(%arg0: !transform.any_op):
205  transform.match.structured %arg0 : !transform.any_op {
206  ^bb1(%arg1: !transform.any_op):
207    // expected-error @below {{expects either the any/single keyword or the type value handle result type}}
208    transform.match.structured.result %arg1[0] {any} : (!transform.any_op) -> !transform.any_value
209    transform.match.structured.yield
210  }
211  transform.yield
212}
213
214// -----
215
216transform.sequence failures(suppress) {
217^bb0(%arg0: !transform.any_op):
218  transform.match.structured %arg0 : !transform.any_op {
219  ^bb1(%arg1: !transform.any_op):
220    // expected-error @below {{'any' and 'single' are mutually exclusive}}
221    transform.match.structured.result %arg1[0] {any, single} : (!transform.any_op) -> !transform.any_op
222    transform.match.structured.yield
223  }
224  transform.yield
225}
226