invalid.mlir
10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics
// -----
func @affine_apply_operand_non_index(%arg0 : i32) {
// Custom parser automatically assigns all arguments the `index` so we must
// use the generic syntax here to exercise the verifier.
// expected-error@+1 {{op operand #0 must be index, but got 'i32'}}
%0 = "affine.apply"(%arg0) {map = affine_map<(d0) -> (d0)>} : (i32) -> (index)
return
}
// -----
func @affine_apply_resul_non_index(%arg0 : index) {
// Custom parser automatically assigns `index` as the result type so we must
// use the generic syntax here to exercise the verifier.
// expected-error@+1 {{op result #0 must be index, but got 'i32'}}
%0 = "affine.apply"(%arg0) {map = affine_map<(d0) -> (d0)>} : (index) -> (i32)
return
}
// -----
#map = affine_map<(d0)[s0] -> (d0 + s0)>
func @affine_for_lower_bound_invalid_dim(%arg : index) {
affine.for %n0 = 0 to 7 {
%dim = addi %arg, %arg : index
// expected-error@+1 {{operand cannot be used as a dimension id}}
affine.for %n1 = 0 to #map(%dim)[%arg] {
}
}
return
}
// -----
#map = affine_map<(d0)[s0] -> (d0 + s0)>
func @affine_for_upper_bound_invalid_dim(%arg : index) {
affine.for %n0 = 0 to 7 {
%dim = addi %arg, %arg : index
// expected-error@+1 {{operand cannot be used as a dimension id}}
affine.for %n1 = #map(%dim)[%arg] to 7 {
}
}
return
}
// -----
func @affine_load_invalid_dim(%M : memref<10xi32>) {
"unknown"() ({
^bb0(%arg: index):
affine.load %M[%arg] : memref<10xi32>
// expected-error@-1 {{index must be a dimension or symbol identifier}}
br ^bb1
^bb1:
br ^bb1
}) : () -> ()
return
}
// -----
#map0 = affine_map<(d0)[s0] -> (d0 + s0)>
func @affine_for_lower_bound_invalid_sym() {
affine.for %i0 = 0 to 7 {
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.for %n0 = #map0(%i0)[%i0] to 7 {
}
}
return
}
// -----
#map0 = affine_map<(d0)[s0] -> (d0 + s0)>
func @affine_for_upper_bound_invalid_sym() {
affine.for %i0 = 0 to 7 {
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.for %n0 = 0 to #map0(%i0)[%i0] {
}
}
return
}
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func @affine_if_invalid_dim(%arg : index) {
affine.for %n0 = 0 to 7 {
%dim = addi %arg, %arg : index
// expected-error@+1 {{operand cannot be used as a dimension id}}
affine.if #set0(%dim)[%n0] {}
}
return
}
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func @affine_if_invalid_sym() {
affine.for %i0 = 0 to 7 {
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.if #set0(%i0)[%i0] {}
}
return
}
// -----
#set0 = affine_set<(i)[N] : (i >= 0, N - i >= 0)>
func @affine_if_invalid_dimop_dim(%arg0: index, %arg1: index, %arg2: index, %arg3: index) {
affine.for %n0 = 0 to 7 {
%0 = alloc(%arg0, %arg1, %arg2, %arg3) : memref<?x?x?x?xf32>
%c0 = constant 0 : index
%dim = dim %0, %c0 : memref<?x?x?x?xf32>
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.if #set0(%dim)[%n0] {}
}
return
}
// -----
func @affine_store_missing_l_square(%C: memref<4096x4096xf32>) {
%9 = constant 0.0 : f32
// expected-error@+1 {{expected '['}}
affine.store %9, %C : memref<4096x4096xf32>
return
}
// -----
// CHECK-LABEL: @affine_min
func @affine_min(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.min affine_map<(d0) -> (d0)> (%arg0, %arg1)
return
}
// -----
// CHECK-LABEL: @affine_min
func @affine_min(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.min affine_map<()[s0] -> (s0)> (%arg0, %arg1)
return
}
// -----
// CHECK-LABEL: @affine_min
func @affine_min(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.min affine_map<(d0) -> (d0)> ()
return
}
// -----
// CHECK-LABEL: @affine_max
func @affine_max(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.max affine_map<(d0) -> (d0)> (%arg0, %arg1)
return
}
// -----
// CHECK-LABEL: @affine_max
func @affine_max(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.max affine_map<()[s0] -> (s0)> (%arg0, %arg1)
return
}
// -----
// CHECK-LABEL: @affine_max
func @affine_max(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{operand count and affine map dimension and symbol count must match}}
%0 = affine.max affine_map<(d0) -> (d0)> ()
return
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{region argument count and num results of upper bounds, lower bounds, and steps must all match}}
affine.parallel (%i) = (0, 0) to (100, 100) step (10, 10) {
}
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{region argument count and num results of upper bounds, lower bounds, and steps must all match}}
affine.parallel (%i, %j) = (0) to (100, 100) step (10, 10) {
}
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{region argument count and num results of upper bounds, lower bounds, and steps must all match}}
affine.parallel (%i, %j) = (0, 0) to (100) step (10, 10) {
}
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
// expected-error@+1 {{region argument count and num results of upper bounds, lower bounds, and steps must all match}}
affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10) {
}
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
affine.for %x = 0 to 7 {
%y = addi %x, %x : index
// expected-error@+1 {{operand cannot be used as a dimension id}}
affine.parallel (%i, %j) = (0, 0) to (%y, 100) step (10, 10) {
}
}
return
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
affine.for %x = 0 to 7 {
%y = addi %x, %x : index
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.parallel (%i, %j) = (0, 0) to (symbol(%y), 100) step (10, 10) {
}
}
return
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<100x100xf32>
// expected-error@+1 {{reduction must be specified for each output}}
%1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) -> (f32) {
%2 = affine.load %0[%i, %j] : memref<100x100xf32>
affine.yield %2 : f32
}
return
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<100x100xf32>
// expected-error@+1 {{invalid reduction value: "bad"}}
%1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("bad") -> (f32) {
%2 = affine.load %0[%i, %j] : memref<100x100xf32>
affine.yield %2 : f32
}
return
}
// -----
// CHECK-LABEL: @affine_parallel
func @affine_parallel(%arg0 : index, %arg1 : index, %arg2 : index) {
%0 = alloc() : memref<100x100xi32>
%1 = affine.parallel (%i, %j) = (0, 0) to (100, 100) step (10, 10) reduce ("minf") -> (f32) {
%2 = affine.load %0[%i, %j] : memref<100x100xi32>
// expected-error@+1 {{types mismatch between yield op and its parent}}
affine.yield %2 : i32
}
return
}
// -----
func @vector_load_invalid_vector_type() {
%0 = alloc() : memref<100xf32>
affine.for %i0 = 0 to 16 step 8 {
// expected-error@+1 {{requires memref and vector types of the same elemental type}}
%1 = affine.vector_load %0[%i0] : memref<100xf32>, vector<8xf64>
}
return
}
// -----
func @vector_store_invalid_vector_type() {
%0 = alloc() : memref<100xf32>
%1 = constant dense<7.0> : vector<8xf64>
affine.for %i0 = 0 to 16 step 8 {
// expected-error@+1 {{requires memref and vector types of the same elemental type}}
affine.vector_store %1, %0[%i0] : memref<100xf32>, vector<8xf64>
}
return
}
// -----
func @vector_load_vector_memref() {
%0 = alloc() : memref<100xvector<8xf32>>
affine.for %i0 = 0 to 4 {
// expected-error@+1 {{requires memref and vector types of the same elemental type}}
%1 = affine.vector_load %0[%i0] : memref<100xvector<8xf32>>, vector<8xf32>
}
return
}
// -----
func @vector_store_vector_memref() {
%0 = alloc() : memref<100xvector<8xf32>>
%1 = constant dense<7.0> : vector<8xf32>
affine.for %i0 = 0 to 4 {
// expected-error@+1 {{requires memref and vector types of the same elemental type}}
affine.vector_store %1, %0[%i0] : memref<100xvector<8xf32>>, vector<8xf32>
}
return
}
// -----
func @affine_if_with_then_region_args(%N: index) {
%c = constant 200 : index
%i = constant 20: index
// expected-error@+1 {{affine.if' op region #0 should have no arguments}}
affine.if affine_set<(i)[N] : (i - 2 >= 0, 4 - i >= 0)>(%i)[%c] {
^bb0(%arg:i32):
%w = affine.apply affine_map<(d0,d1)[s0] -> (d0+d1+s0)> (%i, %i) [%N]
}
return
}
// -----
func @affine_if_with_else_region_args(%N: index) {
%c = constant 200 : index
%i = constant 20: index
// expected-error@+1 {{affine.if' op region #1 should have no arguments}}
affine.if affine_set<(i)[N] : (i - 2 >= 0, 4 - i >= 0)>(%i)[%c] {
%w = affine.apply affine_map<(d0,d1)[s0] -> (d0+d1+s0)> (%i, %i) [%N]
} else {
^bb0(%arg:i32):
%w = affine.apply affine_map<(d0,d1)[s0] -> (d0-d1+s0)> (%i, %i) [%N]
}
return
}
// -----
func @affine_for_iter_args_mismatch(%buffer: memref<1024xf32>) -> f32 {
%sum_0 = constant 0.0 : f32
// expected-error@+1 {{mismatch between the number of loop-carried values and results}}
%res = affine.for %i = 0 to 10 step 2 iter_args(%sum_iter = %sum_0) -> (f32, f32) {
%t = affine.load %buffer[%i] : memref<1024xf32>
affine.yield %t : f32
}
return %res : f32
}