xref: /llvm-project/mlir/test/Dialect/Vector/invalid.mlir (revision 35df525fd00c2037ef144189ee818b7d612241ff)
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2
3func.func @broadcast_to_scalar(%arg0: f32) -> f32 {
4  // expected-error@+1 {{custom op 'vector.broadcast' invalid kind of type specified}}
5  %0 = vector.broadcast %arg0 : f32 to f32
6}
7
8// -----
9
10func.func @broadcast_rank_too_high(%arg0: vector<4x4xf32>) {
11  // expected-error@+1 {{'vector.broadcast' op source rank higher than destination rank}}
12  %1 = vector.broadcast %arg0 : vector<4x4xf32> to vector<4xf32>
13}
14
15// -----
16
17func.func @broadcast_rank_too_high_0d(%arg0: vector<1xf32>) {
18  // expected-error@+1 {{'vector.broadcast' op source rank higher than destination rank}}
19  %1 = vector.broadcast %arg0 : vector<1xf32> to vector<f32>
20}
21
22// -----
23
24func.func @broadcast_dim1_mismatch(%arg0: vector<7xf32>) {
25  // expected-error@+1 {{'vector.broadcast' op dimension mismatch (7 vs. 3)}}
26  %1 = vector.broadcast %arg0 : vector<7xf32> to vector<3xf32>
27}
28
29// -----
30
31func.func @broadcast_dim2_mismatch(%arg0: vector<4x8xf32>) {
32  // expected-error@+1 {{'vector.broadcast' op dimension mismatch (4 vs. 1)}}
33  %1 = vector.broadcast %arg0 : vector<4x8xf32> to vector<1x8xf32>
34}
35
36// -----
37
38func.func @broadcast_scalable_unit_dim(%arg0: vector<[1]xf32>) {
39  // expected-error@+1 {{'vector.broadcast' op dimension mismatch ([1] vs. [4])}}
40  %0 = vector.broadcast %arg0 : vector<[1]xf32> to vector<[4]xf32>
41}
42
43// -----
44
45func.func @broadcast_fixed_to_scalable(%arg0: vector<2xf32>) {
46  // expected-error@+1 {{'vector.broadcast' op dimension mismatch (2 vs. [2])}}
47  %0 = vector.broadcast %arg0 : vector<2xf32> to vector<[2]xf32>
48}
49
50// -----
51
52func.func @broadcast_scalable_to_fixed(%arg0: vector<[1]xf32>) {
53  // expected-error@+1 {{'vector.broadcast' op dimension mismatch ([1] vs. 1)}}
54  %0 = vector.broadcast %arg0 : vector<[1]xf32> to vector<4x1xf32>
55}
56
57// -----
58
59func.func @broadcast_unknown(%arg0: memref<4x8xf32>) {
60  // expected-error@+1 {{'vector.broadcast' op source type is not a vector}}
61  %1 = vector.broadcast %arg0 : memref<4x8xf32> to vector<1x8xf32>
62}
63
64// -----
65
66func.func @fma_vector_4xi32(%arg0: vector<4xi32>) {
67  // expected-error@+1 {{'vector.fma' op operand #0 must be vector of floating-point value}}
68  %1 = vector.fma %arg0, %arg0, %arg0 : vector<4xi32>
69}
70
71// -----
72
73func.func @shuffle_elt_type_mismatch(%arg0: vector<2xf32>, %arg1: vector<2xi32>) {
74  // expected-error@+1 {{'vector.shuffle' op failed to verify that second operand v2 and result have same element type}}
75  %1 = vector.shuffle %arg0, %arg1 [0, 1] : vector<2xf32>, vector<2xi32>
76}
77
78// -----
79
80func.func @shuffle_rank_mismatch(%arg0: vector<2xf32>, %arg1: vector<4x2xf32>) {
81  // expected-error@+1 {{'vector.shuffle' op rank mismatch}}
82  %1 = vector.shuffle %arg0, %arg1 [0, 1] : vector<2xf32>, vector<4x2xf32>
83}
84
85// -----
86
87func.func @shuffle_rank_mismatch_0d(%arg0: vector<f32>, %arg1: vector<1xf32>) {
88  // expected-error@+1 {{'vector.shuffle' op rank mismatch}}
89  %1 = vector.shuffle %arg0, %arg1 [0, 1] : vector<f32>, vector<1xf32>
90}
91
92// -----
93
94func.func @shuffle_trailing_dim_size_mismatch(%arg0: vector<2x2xf32>, %arg1: vector<2x4xf32>) {
95  // expected-error@+1 {{'vector.shuffle' op dimension mismatch}}
96  %1 = vector.shuffle %arg0, %arg1 [0, 1] : vector<2x2xf32>, vector<2x4xf32>
97}
98
99// -----
100
101func.func @shuffle_index_out_of_range(%arg0: vector<2xf32>, %arg1: vector<2xf32>) {
102  // expected-error@+1 {{'vector.shuffle' op mask index #2 out of range}}
103  %1 = vector.shuffle %arg0, %arg1 [0, 4] : vector<2xf32>, vector<2xf32>
104}
105
106// -----
107
108func.func @shuffle_scalable_vec(%arg0: vector<[2]xf32>, %arg1: vector<[2]xf32>) {
109  // expected-error@+1 {{'vector.shuffle' op operand #0 must be fixed-length vector of any type values}}
110  %1 = vector.shuffle %arg0, %arg1 [0, 1, 2, 3] : vector<[2]xf32>, vector<[2]xf32>
111}
112
113// -----
114
115func.func @shuffle_empty_mask(%arg0: vector<2xf32>, %arg1: vector<2xf32>) {
116  // expected-error@+1 {{'vector.shuffle' op invalid mask length}}
117  %1 = vector.shuffle %arg0, %arg1 [] : vector<2xf32>, vector<2xf32>
118}
119
120// -----
121
122func.func @extract_element(%arg0: vector<f32>) {
123  %c = arith.constant 3 : i32
124  // expected-error@+1 {{expected position to be empty with 0-D vector}}
125  %1 = vector.extractelement %arg0[%c : i32] : vector<f32>
126}
127
128// -----
129
130func.func @extract_element(%arg0: vector<4xf32>) {
131  %c = arith.constant 3 : i32
132  // expected-error@+1 {{expected position for 1-D vector}}
133  %1 = vector.extractelement %arg0[] : vector<4xf32>
134}
135
136// -----
137
138func.func @extract_element(%arg0: vector<4x4xf32>) {
139  %c = arith.constant 3 : i32
140  // expected-error@+1 {{unexpected >1 vector rank}}
141  %1 = vector.extractelement %arg0[%c : i32] : vector<4x4xf32>
142}
143
144// -----
145
146func.func @extract_vector_type(%arg0: index) {
147  // expected-error@+1 {{invalid kind of type specified}}
148  %1 = vector.extract %arg0[] : index from index
149}
150
151// -----
152
153func.func @extract_position_rank_overflow(%arg0: vector<4x8x16xf32>) {
154  // expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
155  %1 = vector.extract %arg0[0, 0, 0, 0] : f32 from vector<4x8x16xf32>
156}
157
158// -----
159
160func.func @extract_position_rank_overflow_generic(%arg0: vector<4x8x16xf32>) {
161  // expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
162  %1 = "vector.extract" (%arg0) <{static_position = array<i64: 0, 0, 0, 0>}> : (vector<4x8x16xf32>) -> (vector<16xf32>)
163}
164
165// -----
166
167func.func @extract_position_overflow(%arg0: vector<4x8x16xf32>) {
168  // expected-error@+1 {{expected position attribute #2 to be a non-negative integer smaller than the corresponding vector dimension}}
169  %1 = vector.extract %arg0[0, 43, 0] : f32 from vector<4x8x16xf32>
170}
171
172// -----
173
174func.func @extract_precise_position_overflow(%arg0: vector<4x8x16xf32>) {
175  // expected-error@+1 {{expected position attribute #3 to be a non-negative integer smaller than the corresponding vector dimension}}
176  %1 = vector.extract %arg0[3, 7, 16] : f32 from vector<4x8x16xf32>
177}
178
179// -----
180
181func.func @extract_0d(%arg0: vector<f32>) {
182  // expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
183  %1 = vector.extract %arg0[0] : f32 from vector<f32>
184}
185
186// -----
187
188func.func @extract_position_overflow(%arg0: vector<4x8x16xf32>) {
189  // expected-error@+1 {{expected position attribute #3 to be a non-negative integer smaller than the corresponding vector dimension or poison (-1)}}
190  %1 = vector.extract %arg0[0, 0, -5] : f32 from vector<4x8x16xf32>
191}
192
193// -----
194
195func.func @insert_element(%arg0: f32, %arg1: vector<f32>) {
196  %c = arith.constant 3 : i32
197  // expected-error@+1 {{expected position to be empty with 0-D vector}}
198  %0 = vector.insertelement %arg0, %arg1[%c : i32] : vector<f32>
199}
200
201// -----
202
203func.func @insert_element(%arg0: f32, %arg1: vector<4xf32>) {
204  %c = arith.constant 3 : i32
205  // expected-error@+1 {{expected position for 1-D vector}}
206  %0 = vector.insertelement %arg0, %arg1[] : vector<4xf32>
207}
208
209// -----
210
211func.func @insert_element(%arg0: f32, %arg1: vector<4x4xf32>) {
212  %c = arith.constant 3 : i32
213  // expected-error@+1 {{unexpected >1 vector rank}}
214  %0 = vector.insertelement %arg0, %arg1[%c : i32] : vector<4x4xf32>
215}
216
217// -----
218
219func.func @insert_element_wrong_type(%arg0: i32, %arg1: vector<4xf32>) {
220  %c = arith.constant 3 : i32
221  // expected-error@+1 {{'vector.insertelement' op failed to verify that source operand type matches element type of result}}
222  %0 = "vector.insertelement" (%arg0, %arg1, %c) : (i32, vector<4xf32>, i32) -> (vector<4xf32>)
223}
224
225// -----
226
227func.func @insert_vector_type(%a: f32, %b: vector<4x8x16xf32>) {
228  // expected-error@+1 {{expected position attribute of rank no greater than dest vector rank}}
229  %1 = vector.insert %a, %b[3, 3, 3, 3, 3, 3] : f32 into vector<4x8x16xf32>
230}
231
232// -----
233
234func.func @insert_vector_type(%a: vector<4xf32>, %b: vector<4x8x16xf32>) {
235  // expected-error@+1 {{expected position attribute rank + source rank to match dest vector rank}}
236  %1 = vector.insert %a, %b[3] : vector<4xf32> into vector<4x8x16xf32>
237}
238
239// -----
240
241func.func @insert_vector_type(%a: f32, %b: vector<4x8x16xf32>) {
242  // expected-error@+1 {{expected position attribute rank to match the dest vector rank}}
243  %1 = vector.insert %a, %b[3, 3] : f32 into vector<4x8x16xf32>
244}
245
246// -----
247
248func.func @insert_position_overflow(%a: f32, %b: vector<4x8x16xf32>) {
249  // expected-error@+1 {{expected position attribute #3 to be a non-negative integer smaller than the corresponding dest vector dimension}}
250  %1 = vector.insert %a, %b[0, 0, -5] : f32 into vector<4x8x16xf32>
251}
252
253// -----
254
255func.func @insert_precise_position_overflow(%a: f32, %b: vector<4x8x16xf32>) {
256  // expected-error@+1 {{expected position attribute #1 to be a non-negative integer smaller than the corresponding dest vector dimension}}
257  %1 = vector.insert %a, %b[4, 7, 15] : f32 into vector<4x8x16xf32>
258}
259
260// -----
261
262func.func @insert_0d(%a: vector<f32>, %b: vector<4x8x16xf32>) {
263  // expected-error@+1 {{expected position attribute rank + source rank to match dest vector rank}}
264  %1 = vector.insert %a, %b[2, 6] : vector<f32> into vector<4x8x16xf32>
265}
266
267// -----
268
269func.func @insert_0d(%a: f32, %b: vector<f32>) {
270  // expected-error@+1 {{expected position attribute of rank no greater than dest vector rank}}
271  %1 = vector.insert %a, %b[0] : f32 into vector<f32>
272}
273
274// -----
275
276func.func @outerproduct_num_operands(%arg0: f32) {
277  // expected-error@+1 {{expected at least 2 operands}}
278  %1 = vector.outerproduct %arg0 : f32, f32
279}
280// -----
281
282func.func @outerproduct_non_vector_operand(%arg0: f32) {
283  // expected-error@+1 {{expected vector type for operand #1}}
284  %1 = vector.outerproduct %arg0, %arg0 : f32, f32
285}
286
287// -----
288
289func.func @outerproduct_operand_1(%arg0: vector<4xf32>, %arg1: vector<4x8xf32>) {
290  // expected-error@+1 {{expected 1-d vector for operand #1}}
291  %1 = vector.outerproduct %arg1, %arg1 : vector<4x8xf32>, vector<4x8xf32>
292}
293
294// -----
295
296func.func @outerproduct_operand_2(%arg0: vector<4xf32>, %arg1: vector<4x8xf32>) {
297  // expected-error@+1 {{expected 1-d vector for operand #2}}
298  %1 = vector.outerproduct %arg0, %arg1 : vector<4xf32>, vector<4x8xf32>
299}
300
301// -----
302
303func.func @outerproduct_result_generic(%arg0: vector<4xf32>, %arg1: vector<8xf32>) {
304  // expected-error@+1 {{expected 2-d vector result}}
305  %1 = "vector.outerproduct" (%arg0, %arg1) : (vector<4xf32>, vector<8xf32>) -> (vector<8xf32>)
306}
307
308// -----
309
310func.func @outerproduct_operand_1_dim_generic(%arg0: vector<4xf32>, %arg1: vector<8xf32>) {
311  // expected-error@+1 {{expected #1 operand dim to match result dim #1}}
312  %1 = "vector.outerproduct" (%arg0, %arg1) : (vector<4xf32>, vector<8xf32>) -> (vector<8x16xf32>)
313}
314
315// -----
316
317func.func @outerproduct_operand_2_dim_generic(%arg0: vector<4xf32>, %arg1: vector<8xf32>) {
318  // expected-error@+1 {{expected #2 operand dim to match result dim #2}}
319  %1 = "vector.outerproduct" (%arg0, %arg1) : (vector<4xf32>, vector<8xf32>) -> (vector<4x16xf32>)
320}
321
322// -----
323
324func.func @outerproduct_axpy_operand(%arg0: vector<4x8xf32>, %arg1: f32) {
325  // expected-error@+1 {{expected 1-d vector for operand #1}}
326  %1 = vector.outerproduct %arg0, %arg1 : vector<4x8xf32>, f32
327}
328
329// -----
330
331func.func @outerproduct_axpy_result_generic(%arg0: vector<4xf32>, %arg1: f32) {
332  // expected-error@+1 {{expected 1-d vector result}}
333  %1 = "vector.outerproduct" (%arg0, %arg1) : (vector<4xf32>, f32) -> (vector<4x8xf32>)
334}
335
336// -----
337
338func.func @outerproduct_axpy_operand_dim_generic(%arg0: vector<8xf32>, %arg1: f32) {
339  // expected-error@+1 {{expected #1 operand dim to match result dim #1}}
340  %1 = "vector.outerproduct" (%arg0, %arg1) : (vector<8xf32>, f32) -> (vector<16xf32>)
341}
342
343// -----
344
345func.func @outerproduct_operand_3_result_type_generic(%arg0: vector<4xf32>, %arg1: vector<8xf32>, %arg2: vector<4x16xf32>) {
346  // expected-error@+1 {{expected operand #3 of same type as result type}}
347  %1 = "vector.outerproduct" (%arg0, %arg1, %arg2) : (vector<4xf32>, vector<8xf32>, vector<4x16xf32>) -> (vector<4x8xf32>)
348}
349
350// -----
351
352func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
353  %c3 = arith.constant 3 : index
354  %cst = arith.constant 3.0 : f32
355  // expected-error@+1 {{requires two types}}
356  %0 = vector.transfer_read %arg0[%c3, %c3], %cst { permutation_map = affine_map<()->(0)> } : memref<?x?xf32>
357}
358
359// -----
360
361#map1 = affine_map<(d0, d1, d2) -> (d0, 0, 0)>
362func.func @main(%m:  memref<1xi32>, %2: vector<1x32xi1>) -> vector<1x32xi32> {
363  %0 = arith.constant 1 : index
364  %1 = arith.constant 1 : i32
365  // expected-error@+1 {{expected the same rank for the vector and the results of the permutation map}}
366  %3 = vector.transfer_read %m[%0], %1, %2 { permutation_map = #map1 } : memref<1xi32>, vector<1x32xi32>
367  return %3 : vector<1x32xi32>
368}
369
370// -----
371
372#map1 = affine_map<(d0, d1, d2) -> (d0, 0, 0)>
373func.func @test_vector.transfer_write(%m:  memref<1xi32>, %2: vector<1x32xi32>) -> vector<1x32xi32> {
374  %0 = arith.constant 1 : index
375  %1 = arith.constant 1 : i32
376  // expected-error@+1 {{expected the same rank for the vector and the results of the permutation map}}
377  %3 = vector.transfer_write %2, %m[%0], %1 { permutation_map = #map1 } : vector<1x32xi32>, memref<1xi32>
378  return %3 : vector<1x32xi32>
379}
380
381// -----
382
383func.func @test_vector.transfer_read(%arg0: vector<4x3xf32>) {
384  %c3 = arith.constant 3 : index
385  %f0 = arith.constant 0.0 : f32
386  %vf0 = vector.splat %f0 : vector<4x3xf32>
387  // expected-error@+1 {{ requires memref or ranked tensor type}}
388  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0 : vector<4x3xf32>, vector<1x1x2x3xf32>
389}
390
391// -----
392
393func.func @test_vector.transfer_read(%arg0: memref<4x3xf32>) {
394  %c3 = arith.constant 3 : index
395  %f0 = arith.constant 0.0 : f32
396  %vf0 = vector.splat %f0 : vector<4x3xf32>
397  // expected-error@+1 {{ requires vector type}}
398  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0 : memref<4x3xf32>, f32
399}
400
401// -----
402
403func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
404  %c3 = arith.constant 3 : index
405  %cst = arith.constant 3.0 : f32
406  // expected-error@+1 {{requires 2 indices}}
407  %0 = vector.transfer_read %arg0[%c3, %c3, %c3], %cst { permutation_map = affine_map<()->(0)> } : memref<?x?xf32>, vector<128xf32>
408}
409
410// -----
411
412func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
413  %c3 = arith.constant 3 : index
414  %cst = arith.constant 3.0 : f32
415  // expected-error@+1 {{requires 2 indices}}
416  %0 = vector.transfer_read %arg0[%c3], %cst { permutation_map = affine_map<()->(0)> } : memref<?x?xf32>, vector<128xf32>
417}
418
419// -----
420
421func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
422  %c3 = arith.constant 3 : index
423  %cst = arith.constant 3.0 : f32
424  // expected-error@+1 {{requires a permutation_map with input dims of the same rank as the source type}}
425  %0 = vector.transfer_read %arg0[%c3, %c3], %cst {permutation_map = affine_map<(d0)->(d0)>} : memref<?x?xf32>, vector<128xf32>
426}
427
428// -----
429
430func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
431  %c3 = arith.constant 3 : index
432  %cst = arith.constant 3.0 : f32
433  // expected-error@+1 {{requires a permutation_map with result dims of the same rank as the vector type}}
434  %0 = vector.transfer_read %arg0[%c3, %c3], %cst {permutation_map = affine_map<(d0, d1)->(d0, d1)>} : memref<?x?xf32>, vector<128xf32>
435}
436
437// -----
438
439func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
440  %c3 = arith.constant 3 : index
441  %cst = arith.constant 3.0 : f32
442  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
443  %0 = vector.transfer_read %arg0[%c3, %c3], %cst {permutation_map = affine_map<(d0, d1)->(d0 + d1)>} : memref<?x?xf32>, vector<128xf32>
444}
445
446// -----
447
448func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
449  %c3 = arith.constant 3 : index
450  %cst = arith.constant 3.0 : f32
451  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
452  %0 = vector.transfer_read %arg0[%c3, %c3], %cst {permutation_map = affine_map<(d0, d1)->(d0 + 1)>} : memref<?x?xf32>, vector<128xf32>
453}
454
455// -----
456
457func.func @test_vector.transfer_read(%arg0: memref<?x?xf32>) {
458  %c3 = arith.constant 3 : index
459  %cst = arith.constant 3.0 : f32
460  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
461  %0 = vector.transfer_read %arg0[%c3, %c3], %cst {permutation_map = affine_map<(d0, d1)->(1)>} : memref<?x?xf32>, vector<128xf32>
462}
463
464// -----
465
466func.func @test_vector.transfer_read(%arg0: memref<?x?x?xf32>) {
467  %c3 = arith.constant 3 : index
468  %cst = arith.constant 3.0 : f32
469  // expected-error@+1 {{requires a permutation_map that is a permutation (found one dim used more than once)}}
470  %0 = vector.transfer_read %arg0[%c3, %c3, %c3], %cst {permutation_map = affine_map<(d0, d1, d2)->(d0, d0)>} : memref<?x?x?xf32>, vector<3x7xf32>
471}
472
473// -----
474
475func.func @test_vector.transfer_read(%arg0: memref<?x?x?xf32>) {
476  %c1 = arith.constant 1 : i1
477  %c3 = arith.constant 3 : index
478  %cst = arith.constant 3.0 : f32
479  // expected-note@+1 {{prior use here}}
480  %mask = vector.splat %c1 : vector<3x8x7xi1>
481  // expected-error@+1 {{expects different type than prior uses: 'vector<3x7xi1>' vs 'vector<3x8x7xi1>'}}
482  %0 = vector.transfer_read %arg0[%c3, %c3, %c3], %cst, %mask {permutation_map = affine_map<(d0, d1, d2)->(d0, 0, d2)>} : memref<?x?x?xf32>, vector<3x8x7xf32>
483}
484
485// -----
486
487func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<4x3xf32>>) {
488  %c3 = arith.constant 3 : index
489  %f0 = arith.constant 0.0 : f32
490  %vf0 = vector.splat %f0 : vector<4x3xf32>
491  // expected-error@+1 {{requires source vector element and vector result ranks to match}}
492  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0 {permutation_map = affine_map<(d0, d1)->(d0, d1)>} : memref<?x?xvector<4x3xf32>>, vector<3xf32>
493}
494
495// -----
496
497func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<6xf32>>) {
498  %c3 = arith.constant 3 : index
499  %f0 = arith.constant 0.0 : f32
500  %vf0 = vector.splat %f0 : vector<6xf32>
501  // expected-error@+1 {{requires the bitwidth of the minor 1-D vector to be an integral multiple of the bitwidth of the minor 1-D vector of the source}}
502  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0 : memref<?x?xvector<6xf32>>, vector<3xf32>
503}
504
505// -----
506
507func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<2x3xf32>>) {
508  %c3 = arith.constant 3 : index
509  %f0 = arith.constant 0.0 : f32
510  %vf0 = vector.splat %f0 : vector<2x3xf32>
511  // expected-error@+1 {{ expects the in_bounds attr of same rank as permutation_map results: affine_map<(d0, d1) -> (d0, d1)>}}
512  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0 {in_bounds = [true], permutation_map = affine_map<(d0, d1)->(d0, d1)>} : memref<?x?xvector<2x3xf32>>, vector<1x1x2x3xf32>
513}
514
515// -----
516
517func.func @test_vector.transfer_read(%arg0: memref<?x?xvector<2x3xf32>>) {
518  %c3 = arith.constant 3 : index
519  %f0 = arith.constant 0.0 : f32
520  %vf0 = vector.splat %f0 : vector<2x3xf32>
521  %mask = vector.splat %c1 : vector<2x3xi1>
522  // expected-error@+1 {{does not support masks with vector element type}}
523  %0 = vector.transfer_read %arg0[%c3, %c3], %vf0, %mask {permutation_map = affine_map<(d0, d1)->(d0, d1)>} : memref<?x?xvector<2x3xf32>>, vector<1x1x2x3xf32>
524}
525
526// -----
527
528func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
529  %c3 = arith.constant 3 : index
530  %cst = arith.constant 3.0 : f32
531  // expected-error@+1 {{requires two types}}
532  vector.transfer_write %arg0, %arg0[%c3, %c3] : memref<?x?xf32>
533}
534
535// -----
536
537func.func @test_vector.transfer_write(%arg0: memref<vector<4x3xf32>>) {
538  %c3 = arith.constant 3 : index
539  %f0 = arith.constant 0.0 : f32
540  %vf0 = vector.splat %f0 : vector<4x3xf32>
541  // expected-error@+1 {{ requires vector type}}
542  vector.transfer_write %arg0, %arg0[%c3, %c3] : memref<vector<4x3xf32>>, vector<4x3xf32>
543}
544
545// -----
546
547func.func @test_vector.transfer_write(%arg0: vector<4x3xf32>) {
548  %c3 = arith.constant 3 : index
549  %f0 = arith.constant 0.0 : f32
550  %vf0 = vector.splat %f0 : vector<4x3xf32>
551  // expected-error@+1 {{ requires memref or ranked tensor type}}
552  vector.transfer_write %arg0, %arg0[%c3, %c3] : vector<4x3xf32>, f32
553}
554
555// -----
556
557func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
558  %c3 = arith.constant 3 : index
559  %cst = arith.constant dense<3.0> : vector<128 x f32>
560  // expected-error@+1 {{expected 5 operand types but had 4}}
561  %0 = "vector.transfer_write"(%cst, %arg0, %c3, %c3, %c3) {permutation_map = affine_map<()->(0)>} : (vector<128xf32>, memref<?x?xf32>, index, index) -> ()
562}
563
564// -----
565
566func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
567  %c3 = arith.constant 3 : index
568  %cst = arith.constant dense<3.0> : vector<128 x f32>
569  // expected-error@+1 {{requires 2 indices}}
570  vector.transfer_write %cst, %arg0[%c3, %c3, %c3] {permutation_map = affine_map<()->(0)>} : vector<128xf32>, memref<?x?xf32>
571}
572
573// -----
574
575func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
576  %c3 = arith.constant 3 : index
577  %cst = arith.constant dense<3.0> : vector<128 x f32>
578  // expected-error@+1 {{requires 2 indices}}
579  vector.transfer_write %cst, %arg0[%c3] {permutation_map = affine_map<()->(0)>} : vector<128xf32>, memref<?x?xf32>
580}
581
582// -----
583
584func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
585  %c3 = arith.constant 3 : index
586  %cst = arith.constant dense<3.0> : vector<128 x f32>
587  // expected-error@+1 {{requires a permutation_map with input dims of the same rank as the source type}}
588  vector.transfer_write %cst, %arg0[%c3, %c3] {permutation_map = affine_map<(d0)->(d0)>} : vector<128xf32>, memref<?x?xf32>
589}
590
591// -----
592
593func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
594  %c3 = arith.constant 3 : index
595  %cst = arith.constant dense<3.0> : vector<128 x f32>
596  // expected-error@+1 {{requires a permutation_map with result dims of the same rank as the vector type}}
597  vector.transfer_write %cst, %arg0[%c3, %c3] {permutation_map = affine_map<(d0, d1)->(d0, d1)>} : vector<128xf32>, memref<?x?xf32>
598}
599
600// -----
601
602func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
603  %c3 = arith.constant 3 : index
604  %cst = arith.constant dense<3.0> : vector<128 x f32>
605  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
606  vector.transfer_write %cst, %arg0[%c3, %c3] {permutation_map = affine_map<(d0, d1)->(d0 + d1)>} : vector<128xf32>, memref<?x?xf32>
607}
608
609// -----
610
611func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
612  %c3 = arith.constant 3 : index
613  %cst = arith.constant dense<3.0> : vector<128 x f32>
614  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
615  vector.transfer_write %cst, %arg0[%c3, %c3] {permutation_map = affine_map<(d0, d1)->(d0 + 1)>} : vector<128xf32>, memref<?x?xf32>
616}
617
618// -----
619
620func.func @test_vector.transfer_write(%arg0: memref<?x?xf32>) {
621  %c3 = arith.constant 3 : index
622  %cst = arith.constant dense<3.0> : vector<128 x f32>
623  // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}}
624  vector.transfer_write %cst, %arg0[%c3, %c3] {permutation_map = affine_map<(d0, d1)->(1)>} : vector<128xf32>, memref<?x?xf32>
625}
626
627// -----
628
629func.func @test_vector.transfer_write(%arg0: memref<?x?x?xf32>) {
630  %c3 = arith.constant 3 : index
631  %cst = arith.constant dense<3.0> : vector<3 x 7 x f32>
632  // expected-error@+1 {{requires a permutation_map that is a permutation (found one dim used more than once)}}
633  vector.transfer_write %cst, %arg0[%c3, %c3, %c3] {permutation_map = affine_map<(d0, d1, d2)->(d0, d0)>} : vector<3x7xf32>, memref<?x?x?xf32>
634}
635
636// -----
637
638func.func @test_vector.transfer_write(%arg0: memref<?xf32>, %arg1: vector<7xf32>) {
639  %c3 = arith.constant 3 : index
640  %cst = arith.constant 3.0 : f32
641  // expected-error@+1 {{should not have broadcast dimensions}}
642  vector.transfer_write %arg1, %arg0[%c3]
643      {permutation_map = affine_map<(d0) -> (0)>}
644      : vector<7xf32>, memref<?xf32>
645}
646
647// -----
648
649func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
650  // expected-error@+1 {{expected offsets of same size as destination vector rank}}
651  %1 = vector.insert_strided_slice %a, %b {offsets = [100], strides = [1, 1]} : vector<4x4xf32> into vector<4x8x16xf32>
652}
653
654// -----
655
656func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
657  // expected-error@+1 {{expected strides of same size as source vector rank}}
658  %1 = vector.insert_strided_slice %a, %b {offsets = [2, 2, 2], strides = [1]} : vector<4x4xf32> into vector<4x8x16xf32>
659}
660
661// -----
662
663func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
664  // expected-error@+1 {{expected source rank to be no greater than destination rank}}
665  %1 = vector.insert_strided_slice %b, %a {offsets = [2, 2], strides = [1, 1, 1]} : vector<4x8x16xf32> into vector<4x4xf32>
666}
667
668// -----
669
670func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
671  // expected-error@+1 {{op expected offsets dimension 0 to be confined to [0, 4)}}
672  %1 = vector.insert_strided_slice %a, %b {offsets = [100,100,100], strides = [1, 1]} : vector<4x4xf32> into vector<4x8x16xf32>
673}
674
675// -----
676
677func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
678  // expected-error@+1 {{op expected strides to be confined to [1, 2)}}
679  %1 = vector.insert_strided_slice %a, %b {offsets = [2, 2, 2], strides = [100, 100]} : vector<4x4xf32> into vector<4x8x16xf32>
680}
681
682// -----
683
684func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
685  // expected-error@+1 {{op expected sum(offsets, source vector shape) dimension 1 to be confined to [1, 9)}}
686  %1 = vector.insert_strided_slice %a, %b {offsets = [2, 7, 2], strides = [1, 1]} : vector<4x4xf32> into vector<4x8x16xf32>
687}
688
689// -----
690
691func.func @insert_strided_slice_scalable(%a : vector<1x1x[2]xi32>, %b: vector<1x4x[4]xi32>) -> vector<1x4x[4]xi32> {
692  // expected-error@+1 {{op expected size at idx=2 to match the corresponding base size from the input vector (2 vs 4)}}
693  %0 = vector.insert_strided_slice %a, %b {offsets = [0, 3, 0], strides = [1, 1, 1]} : vector<1x1x[2]xi32> into vector<1x4x[4]xi32>
694  return %0 : vector<1x4x[4]xi32>
695}
696
697// -----
698
699func.func @insert_strided_slice_scalable(%a : vector<1x1x4xi32>, %b: vector<1x4x[4]xi32>) -> vector<1x4x[4]xi32> {
700  // expected-error@+1 {{op mismatching scalable flags (at source vector idx=2)}}
701  %0 = vector.insert_strided_slice %a, %b {offsets = [0, 3, 0], strides = [1, 1, 1]} : vector<1x1x4xi32> into vector<1x4x[4]xi32>
702  return %0 : vector<1x4x[4]xi32>
703}
704
705// -----
706
707func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
708  // expected-error@+1 {{expected offsets, sizes and strides attributes of same size}}
709  %1 = vector.extract_strided_slice %arg0 {offsets = [100], sizes = [2, 2], strides = [1, 1]} : vector<4x8x16xf32> to vector<2x2x16xf32>
710}
711
712// -----
713
714func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
715  // expected-error@+1 {{expected offsets attribute of rank no greater than vector rank}}
716  %1 = vector.extract_strided_slice %arg0 {offsets = [2, 2, 2, 2], sizes = [2, 2, 2, 2], strides = [1, 1, 1, 1]} : vector<4x8x16xf32> to vector<2x2x16xf32>
717}
718
719// -----
720
721func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
722  // expected-error@+1 {{op expected offsets dimension 0 to be confined to [0, 4)}}
723  %1 = vector.extract_strided_slice %arg0 {offsets = [100], sizes = [100], strides = [100]} : vector<4x8x16xf32> to vector<100x8x16xf32>
724}
725
726// -----
727
728func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
729  // expected-error@+1 {{op expected sizes dimension 0 to be confined to [1, 5)}}
730  %1 = vector.extract_strided_slice %arg0 {offsets = [2], sizes = [100], strides = [100]} : vector<4x8x16xf32> to vector<100x8x16xf32>
731}
732
733// -----
734
735func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
736  // expected-error@+1 {{op expected strides to be confined to [1, 2)}}
737  %1 = vector.extract_strided_slice %arg0 {offsets = [2], sizes = [1], strides = [100]} : vector<4x8x16xf32> to vector<1x8x16xf32>
738}
739
740// -----
741
742func.func @extract_strided_slice_scalable(%arg0 : vector<1x4x[4]xi32>) -> vector<1x1x[2]xi32> {
743    // expected-error@+1 {{op expected size at idx=2 to match the corresponding base size from the input vector (2 vs 4)}}
744    %1 = vector.extract_strided_slice %arg0 {offsets = [0, 3, 0], sizes = [1, 1, 2], strides = [1, 1, 1]} : vector<1x4x[4]xi32> to vector<1x1x[2]xi32>
745    return %1 : vector<1x1x[2]xi32>
746  }
747
748// -----
749
750func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
751  // expected-error@+1 {{op expected strides to be confined to [1, 2)}}
752  %1 = vector.extract_strided_slice %arg0 {offsets = [2], sizes = [1], strides = [100]} : vector<4x8x16xf32> to vector<1x8x16xf32>
753}
754
755// -----
756
757func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
758  // expected-error@+1 {{op expected sum(offsets, sizes) dimension 0 to be confined to [1, 5)}}
759  %1 = vector.extract_strided_slice %arg0 {offsets = [2], sizes = [3], strides = [1]} : vector<4x8x16xf32> to vector<3x8x16xf32>
760}
761
762// -----
763
764func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
765  // expected-error@+1 {{op expected result type to be 'vector<2x8x16xf32>'}}
766  %1 = vector.extract_strided_slice %arg0 {offsets = [2], sizes = [2], strides = [1]} : vector<4x8x16xf32> to vector<3x1xf32>
767}
768
769// -----
770
771#contraction_accesses = [
772  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
773  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
774  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>,
775  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
776]
777#contraction_trait = {
778  indexing_maps = #contraction_accesses,
779  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
780}
781func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
782                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
783                  %arg4 : index) {
784  // expected-error@+1 {{expected an indexing map for each vector operand}}
785  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
786      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
787}
788
789// -----
790
791#contraction_accesses = [
792  affine_map<(b0, f0, f1, c0, c1) -> (c0, c0, c1, f0)>,
793  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
794  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
795]
796#contraction_trait = {
797  indexing_maps = #contraction_accesses,
798  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
799}
800func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
801                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
802                  %arg4 : index) {
803  // expected-error@+1 {{expected indexing map 0 to be a projected permutation of its inputs}}
804  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
805      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
806}
807
808// -----
809
810#contraction_accesses = [
811  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
812  affine_map<(b0, f0, f1, c0, c1)[s0] -> (b0, s0, c0, f1)>,
813  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
814]
815#contraction_trait = {
816  indexing_maps = #contraction_accesses,
817  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
818}
819func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
820                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
821                  %arg4 : index) {
822  // expected-error@+1 {{op expected indexing map 1 to have no symbols}}
823  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
824      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
825}
826
827// -----
828
829#contraction_accesses = [
830  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
831  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
832  affine_map<(b0, f0, f1, c1) -> (b0, f0, f1)>
833]
834#contraction_trait = {
835  indexing_maps = #contraction_accesses,
836  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
837}
838func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
839                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
840                  %arg4 : index) {
841  // expected-error@+1 {{expected indexing map 2 to have 5 number of inputs}}
842  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
843      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
844}
845
846// -----
847
848#contraction_accesses = [
849  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
850  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, f1)>,
851  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
852]
853#contraction_trait = {
854  indexing_maps = #contraction_accesses,
855  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
856}
857func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
858                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
859                  %arg4 : index) {
860  // expected-error@+1 {{expected indexing map 1 to have 4 number of outputs}}
861  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
862      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
863}
864
865// -----
866
867#contraction_accesses = [
868  affine_map<(b0, f0, f1, b1, b2) -> (b1, b0, b2, f0)>,
869  affine_map<(b0, f0, f1, b1, b2) -> (b0, b2, b1, f1)>,
870  affine_map<(b0, f0, f1, b1, b2) -> (b0, f0, f1)>
871]
872#contraction_trait = {
873  indexing_maps = #contraction_accesses,
874  iterator_types = ["parallel", "parallel", "parallel", "parallel", "parallel"]
875}
876func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
877                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
878                  %arg4 : index) {
879  // expected-error@+1 {{op expected at least one contracting dimension pair}}
880  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
881      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
882}
883
884// -----
885
886#contraction_accesses = [
887  affine_map<(b0, f0, f1, c0, c1) -> (c1, b0, c0, f0)>,
888  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
889  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
890]
891#contraction_trait = {
892  indexing_maps = #contraction_accesses,
893  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
894}
895func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
896                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
897                  %arg4 : index) {
898  // expected-error@+1 {{invalid contracting dimension map}}
899  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
900      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
901}
902
903// -----
904
905#contraction_accesses = [
906  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
907  affine_map<(b0, f0, f1, c0, c1) -> (f1, c1, c0, b0)>,
908  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
909]
910#contraction_trait = {
911  indexing_maps = #contraction_accesses,
912  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
913}
914func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
915                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
916                  %arg4 : index) {
917  // expected-error@+1 {{invalid batch dimension map}}
918  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
919      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
920}
921
922// -----
923
924#contraction_accesses = [
925  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
926  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
927  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
928]
929#contraction_trait = {
930  indexing_maps = #contraction_accesses,
931  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
932}
933func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
934                  %arg2: vector<88x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
935                  %arg4 : index) {
936  // expected-error@+1 {{invalid accumulator/result vector shape}}
937  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
938      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<88x15x5xf32>
939}
940
941// -----
942
943#contraction_accesses = [
944  affine_map<(b0, f0, f1, c0, c1) -> (c0, b0, c1, f0)>,
945  affine_map<(b0, f0, f1, c0, c1) -> (b0, c1, c0, f1)>,
946  affine_map<(b0, f0, f1, c0, c1) -> (b0, f0, f1)>
947]
948#contraction_trait = {
949  indexing_maps = #contraction_accesses,
950  iterator_types = ["parallel", "parallel", "parallel", "reduction", "reduction"]
951}
952func.func @contraction(%arg0: vector<7x8x16x15xf32>, %arg1: vector<8x16x7x5xf32>,
953                  %arg2: vector<8x15x5xf32>, %arg3 :  vector<8x15x8x5xf32>,
954                  %arg4 : index) {
955  %lhs_mask = vector.constant_mask [7, 8, 16, 15] : vector<7x8x16x15xi1>
956  %rhs_mask = vector.constant_mask [8, 16, 7, 5] : vector<8x16x7x5xi1>
957  // expected-error@+1 {{expected zero or exactly 2 vector mask operands}}
958  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2, %lhs_mask
959      : vector<7x8x16x15xf32>, vector<8x16x7x5xf32> into vector<8x15x5xf32>
960}
961
962// -----
963
964#contraction_accesses = [
965        affine_map<(i, j, k) -> (i, k)>,
966        affine_map<(i, j, k) -> (k, j)>,
967        affine_map<(i, j, k) -> (i, j)>
968      ]
969#contraction_trait = {
970        indexing_maps = #contraction_accesses,
971        iterator_types = ["parallel", "parallel", "reduction"]
972      }
973func.func @contraction(%arg0: vector<4x3xi32>,
974                  %arg1: vector<3x7xf32>,
975                  %arg2: vector<4x7xf32>) -> vector<4x7xf32> {
976  // expected-error@+1 {{'vector.contract' op failed to verify that lhs and rhs have same element type}}
977  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
978    : vector<4x3xi32>, vector<3x7xf32> into vector<4x7xf32>
979}
980
981// -----
982
983#contraction_accesses = [
984  affine_map<(m, n, k) -> (m, k)>,
985  affine_map<(m, n, k) -> (k, n)>,
986  affine_map<(m, n, k) -> (n, m)>
987]
988#contraction_trait = {
989  indexing_maps = #contraction_accesses,
990  iterator_types = ["parallel", "parallel", "reduction"]
991}
992func.func @contraction(%arg0: vector<2x1xf32>, %arg1: vector<1x3xf32>, %arg2: vector<2x3xf32>)
993-> vector<3x2xf32>
994{
995// expected-error@+1 {{invalid accumulator/result vector shape, expected: 'vector<3x2xf32>'}}
996  %0 = vector.contract #contraction_trait %arg0, %arg1, %arg2
997    : vector<2x1xf32>, vector<1x3xf32> into vector<2x3xf32>
998  return %0 : vector<2x3xf32>
999}
1000
1001// -----
1002
1003func.func @contract_with_dim_unused_by_lhs_and_rhs(%arg0 : vector<1x2xi32>, %arg1 : vector<2xi32>, %arg2 : vector<1xi32>) -> vector<1xi32> {
1004// expected-error@+1 {{'vector.contract' op expected all dimensions to be either a LHS or a RHS dimension}}
1005  %result = vector.contract {
1006    indexing_maps = [
1007      affine_map<(d0, d1, d2) -> (d0, d2)>,
1008      affine_map<(d0, d1, d2) -> (d2)>,
1009      affine_map<(d0, d1, d2) -> (d1)>
1010    ],
1011    iterator_types = ["reduction", "parallel", "reduction"],
1012    kind = #vector.kind<add>} %arg0, %arg1, %arg2 : vector<1x2xi32>, vector<2xi32> into vector<1xi32>
1013  return  %result : vector<1xi32>
1014}
1015
1016// -----
1017
1018func.func @create_mask_0d_no_operands() {
1019  %c1 = arith.constant 1 : index
1020  // expected-error@+1 {{must specify exactly one operand for 0-D create_mask}}
1021  %0 = vector.create_mask : vector<i1>
1022}
1023
1024// -----
1025
1026func.func @create_mask_0d_many_operands() {
1027  %c1 = arith.constant 1 : index
1028  %c2 = arith.constant 2 : index
1029  %c3 = arith.constant 3 : index
1030  // expected-error@+1 {{must specify exactly one operand for 0-D create_mask}}
1031  %0 = vector.create_mask %c1, %c2, %c3 : vector<i1>
1032}
1033
1034// -----
1035
1036func.func @create_mask() {
1037  %c2 = arith.constant 2 : index
1038  %c3 = arith.constant 3 : index
1039  // expected-error@+1 {{must specify an operand for each result vector dimension}}
1040  %0 = vector.create_mask %c3, %c2 : vector<4x3x7xi1>
1041}
1042
1043
1044// -----
1045
1046func.func @constant_mask_0d_no_attr() {
1047  // expected-error@+1 {{array attr must have length 1 for 0-D vectors}}
1048  %0 = vector.constant_mask [] : vector<i1>
1049}
1050
1051// -----
1052
1053func.func @constant_mask_0d_bad_attr() {
1054  // expected-error@+1 {{mask dim size must be either 0 or 1 for 0-D vectors}}
1055  %0 = vector.constant_mask [2] : vector<i1>
1056}
1057
1058// -----
1059
1060func.func @constant_mask() {
1061  // expected-error@+1 {{must specify array attr of size equal vector result rank}}
1062  %0 = vector.constant_mask [3, 2, 7] : vector<4x3xi1>
1063}
1064
1065// -----
1066
1067func.func @constant_mask_out_of_bounds() {
1068  // expected-error@+1 {{array attr of size out of bounds of vector result dimension size}}
1069  %0 = vector.constant_mask [-1, 2] : vector<4x3xi1>
1070}
1071
1072// -----
1073
1074func.func @constant_mask_out_of_bounds() {
1075  // expected-error@+1 {{array attr of size out of bounds of vector result dimension size}}
1076  %0 = vector.constant_mask [3, 4] : vector<4x3xi1>
1077}
1078
1079// -----
1080
1081func.func @constant_mask_with_zero_mask_dim_size() {
1082  // expected-error@+1 {{expected all mask dim sizes to be zeros, as a result of conjunction with zero mask dim}}
1083  %0 = vector.constant_mask [0, 2] : vector<4x3xi1>
1084}
1085
1086// -----
1087
1088func.func @constant_mask_scalable_non_zero_dim_size() {
1089  // expected-error@+1 {{only supports 'none set' or 'all set' scalable dimensions}}
1090  %0 = vector.constant_mask [2] : vector<[8]xi1>
1091}
1092
1093// -----
1094
1095func.func @print_no_result(%arg0 : f32) -> i32 {
1096  // expected-error@+1 {{cannot name an operation with no results}}
1097  %0 = vector.print %arg0 : f32
1098}
1099
1100// -----
1101
1102func.func private @print_needs_vector(%arg0: tensor<8xf32>) {
1103  // expected-error@+1 {{op operand #0 must be , but got 'tensor<8xf32>'}}
1104  vector.print %arg0 : tensor<8xf32>
1105  return
1106}
1107
1108// -----
1109
1110func.func @cannot_print_string_with_punctuation_set() {
1111  // expected-error@+1 {{`source` or `punctuation` are not set when printing strings}}
1112  vector.print str "Whoops!" punctuation <comma>
1113  return
1114}
1115
1116// -----
1117
1118func.func @cannot_print_string_with_source_set(%vec: vector<[4]xf32>) {
1119  // expected-error@+1 {{`source` or `punctuation` are not set when printing strings}}
1120  vector.print %vec: vector<[4]xf32> str "Yay!"
1121  return
1122}
1123
1124// -----
1125
1126func.func @shape_cast_wrong_element_type(%arg0 : vector<5x1x3x2xf32>) {
1127  // expected-error@+1 {{op source/result vectors must have same element type}}
1128  %0 = vector.shape_cast %arg0 : vector<5x1x3x2xf32> to vector<15x2xi32>
1129}
1130
1131// -----
1132
1133func.func @shape_cast_wrong_num_elements(%arg0 : vector<5x1x3x2xf32>) {
1134  // expected-error@+1 {{op source/result number of elements must match}}
1135  %0 = vector.shape_cast %arg0 : vector<5x1x3x2xf32> to vector<10x2xf32>
1136}
1137
1138// -----
1139
1140func.func @shape_cast_invalid_rank_reduction(%arg0 : vector<5x1x3x2xf32>) {
1141  // expected-error@+1 {{invalid shape cast}}
1142  %0 = vector.shape_cast %arg0 : vector<5x1x3x2xf32> to vector<2x15xf32>
1143}
1144
1145// -----
1146
1147func.func @shape_cast_invalid_rank_expansion(%arg0 : vector<15x2xf32>) {
1148  // expected-error@+1 {{invalid shape cast}}
1149  %0 = vector.shape_cast %arg0 : vector<15x2xf32> to vector<5x2x3x1xf32>
1150}
1151
1152// -----
1153
1154func.func @shape_cast_scalability_flag_is_dropped(%arg0 : vector<15x[2]xf32>) {
1155  // expected-error@+1 {{different number of scalable dims at source (1) and result (0)}}
1156  %0 = vector.shape_cast %arg0 : vector<15x[2]xf32> to vector<30xf32>
1157}
1158
1159// -----
1160
1161func.func @shape_cast_scalability_flag_is_dropped(%arg0 : vector<2x[15]x[2]xf32>) {
1162  // expected-error@+1 {{different number of scalable dims at source (2) and result (1)}}
1163  %0 = vector.shape_cast %arg0 : vector<2x[15]x[2]xf32> to vector<30x[2]xf32>
1164}
1165
1166// -----
1167
1168func.func @bitcast_not_vector(%arg0 : vector<5x1x3x2xf32>) {
1169  // expected-error@+1 {{'vector.bitcast' invalid kind of type specified}}
1170  %0 = vector.bitcast %arg0 : vector<5x1x3x2xf32> to f32
1171}
1172
1173// -----
1174
1175func.func @bitcast_rank_mismatch_to_0d(%arg0 : vector<1xf32>) {
1176  // expected-error@+1 {{op failed to verify that all of {source, result} have same rank}}
1177  %0 = vector.bitcast %arg0 : vector<1xf32> to vector<f32>
1178}
1179
1180// -----
1181
1182func.func @bitcast_rank_mismatch_from_0d(%arg0 : vector<f32>) {
1183  // expected-error@+1 {{op failed to verify that all of {source, result} have same rank}}
1184  %0 = vector.bitcast %arg0 : vector<f32> to vector<1xf32>
1185}
1186
1187// -----
1188
1189func.func @bitcast_rank_mismatch(%arg0 : vector<5x1x3x2xf32>) {
1190  // expected-error@+1 {{op failed to verify that all of {source, result} have same rank}}
1191  %0 = vector.bitcast %arg0 : vector<5x1x3x2xf32> to vector<5x3x2xf32>
1192}
1193
1194// -----
1195
1196func.func @bitcast_shape_mismatch(%arg0 : vector<5x1x3x2xf32>) {
1197  // expected-error@+1 {{op dimension size mismatch}}
1198  %0 = vector.bitcast %arg0 : vector<5x1x3x2xf32> to vector<5x2x3x2xf32>
1199}
1200
1201// -----
1202
1203func.func @bitcast_sizemismatch(%arg0 : vector<5x1x3x2xf32>) {
1204  // expected-error@+1 {{op source/result bitwidth of the minor 1-D vectors must be equal}}
1205  %0 = vector.bitcast %arg0 : vector<5x1x3x2xf32> to vector<5x1x3x3xf16>
1206}
1207
1208// -----
1209
1210func.func @reduce_unknown_kind(%arg0: vector<16xf32>) -> f32 {
1211  // expected-error@+2 {{custom op 'vector.reduction' failed to parse Vector_CombiningKindAttr parameter 'value' which is to be a `::mlir::vector::CombiningKind`}}
1212  // expected-error@+1 {{custom op 'vector.reduction' expected ::mlir::vector::CombiningKind to be one of: }}
1213  %0 = vector.reduction <joho>, %arg0 : vector<16xf32> into f32
1214}
1215
1216// -----
1217
1218func.func @reduce_elt_type_mismatch(%arg0: vector<16xf32>) -> i32 {
1219  // expected-error@+1 {{'vector.reduction' op failed to verify that source operand and result have same element type}}
1220  %0 = vector.reduction <add>, %arg0 : vector<16xf32> into i32
1221}
1222
1223// -----
1224
1225func.func @reduce_unsupported_attr(%arg0: vector<16xf32>) -> i32 {
1226  // expected-error@+1 {{expected '<'}}
1227  %0 = vector.reduction 1234, %arg0 : vector<16xf32> into i32
1228}
1229
1230// -----
1231
1232func.func @reduce_unsupported_third_argument(%arg0: vector<16xf32>, %arg1: f32) -> f32 {
1233  // expected-error@+1 {{expected ':'}}
1234  %0 = vector.reduction <add>, %arg0, %arg1, %arg1 : vector<16xf32> into f32
1235}
1236
1237// -----
1238
1239func.func @reduce_unsupported_rank(%arg0: vector<4x16xf32>) -> f32 {
1240  // expected-error@+1 {{'vector.reduction' op unsupported reduction rank: 2}}
1241  %0 = vector.reduction <add>, %arg0 : vector<4x16xf32> into f32
1242}
1243
1244// -----
1245
1246func.func @multi_reduce_invalid_type(%arg0: vector<4x16xf32>, %acc: vector<16xf32>) -> f32 {
1247  // expected-error@+1 {{'vector.multi_reduction' op destination type 'vector<16xf32>' is incompatible with source type 'vector<4x16xf32>'}}
1248  %0 = vector.multi_reduction <mul>, %arg0, %acc [1] : vector<4x16xf32> to vector<16xf32>
1249}
1250
1251// -----
1252
1253func.func @transpose_rank_mismatch_0d(%arg0: vector<f32>) {
1254  // expected-error@+1 {{'vector.transpose' op vector result rank mismatch: 1}}
1255  %0 = vector.transpose %arg0, [] : vector<f32> to vector<100xf32>
1256}
1257
1258// -----
1259
1260func.func @transpose_rank_mismatch(%arg0: vector<4x16x11xf32>) {
1261  // expected-error@+1 {{'vector.transpose' op vector result rank mismatch: 1}}
1262  %0 = vector.transpose %arg0, [2, 1, 0] : vector<4x16x11xf32> to vector<100xf32>
1263}
1264
1265// -----
1266
1267func.func @transpose_length_mismatch_0d(%arg0: vector<f32>) {
1268  // expected-error@+1 {{'vector.transpose' op transposition length mismatch: 1}}
1269  %0 = vector.transpose %arg0, [1] : vector<f32> to vector<f32>
1270}
1271
1272// -----
1273
1274func.func @transpose_length_mismatch(%arg0: vector<4x4xf32>) {
1275  // expected-error@+1 {{'vector.transpose' op transposition length mismatch: 3}}
1276  %0 = vector.transpose %arg0, [2, 0, 1] : vector<4x4xf32> to vector<4x4xf32>
1277}
1278
1279// -----
1280
1281func.func @transpose_index_oob(%arg0: vector<4x4xf32>) {
1282  // expected-error@+1 {{'vector.transpose' op transposition index out of range: 2}}
1283  %0 = vector.transpose %arg0, [2, 0] : vector<4x4xf32> to vector<4x4xf32>
1284}
1285
1286// -----
1287
1288func.func @transpose_index_dup(%arg0: vector<4x4xf32>) {
1289  // expected-error@+1 {{'vector.transpose' op duplicate position index: 0}}
1290  %0 = vector.transpose %arg0, [0, 0] : vector<4x4xf32> to vector<4x4xf32>
1291}
1292
1293// -----
1294
1295func.func @transpose_dim_size_mismatch(%arg0: vector<11x7x3x2xi32>) {
1296  // expected-error@+1 {{'vector.transpose' op dimension size mismatch at: 0}}
1297  %0 = vector.transpose %arg0, [3, 0, 1, 2] : vector<11x7x3x2xi32> to vector<2x3x7x11xi32>
1298}
1299
1300// -----
1301
1302func.func @flat_transpose_type_mismatch(%arg0: vector<16xf32>) {
1303  // expected-error@+1 {{'vector.flat_transpose' op failed to verify that source operand and result have same element type}}
1304  %0 = vector.flat_transpose %arg0 { rows = 4: i32, columns = 4: i32 } : vector<16xf32> -> vector<16xf64>
1305}
1306
1307// -----
1308
1309func.func @type_cast_layout(%arg0: memref<4x3xf32, affine_map<(d0, d1)[s0, s1, s2] -> (d0 * s0 + d1 * s1 + s2)>>) {
1310  // expected-error@+1 {{expects operand to be a memref with identity layout}}
1311  %0 = vector.type_cast %arg0: memref<4x3xf32, affine_map<(d0, d1)[s0, s1, s2] -> (d0 * s0 + d1 * s1 + s2)>> to memref<vector<4x3xf32>>
1312}
1313
1314// -----
1315
1316func.func @store_unsupported_layout(%memref : memref<200x100xf32, affine_map<(d0, d1) -> (200*d0 + 2*d1)>>,
1317                               %i : index, %j : index, %value : vector<8xf32>) {
1318  // expected-error@+1 {{'vector.store' op most minor memref dim must have unit stride}}
1319  vector.store %value, %memref[%i, %j] : memref<200x100xf32, affine_map<(d0, d1) -> (200*d0 + 2*d1)>>,
1320                                         vector<8xf32>
1321  return
1322}
1323
1324// -----
1325
1326func.func @vector_memref_mismatch(%memref : memref<200x100xvector<4xf32>>, %i : index,
1327                             %j : index, %value : vector<8xf32>) {
1328  // expected-error@+1 {{'vector.store' op base memref and valueToStore vector types should match}}
1329  vector.store %value, %memref[%i, %j] : memref<200x100xvector<4xf32>>, vector<8xf32>
1330}
1331
1332// -----
1333
1334func.func @store_base_type_mismatch(%base : memref<?xf64>, %value : vector<16xf32>) {
1335  %c0 = arith.constant 0 : index
1336  // expected-error@+1 {{'vector.store' op base and valueToStore element type should match}}
1337  vector.store %value, %base[%c0] : memref<?xf64>, vector<16xf32>
1338}
1339
1340// -----
1341
1342func.func @store_memref_index_mismatch(%base : memref<?xf32>, %value : vector<16xf32>) {
1343  // expected-error@+1 {{'vector.store' op requires 1 indices}}
1344  vector.store %value, %base[] : memref<?xf32>, vector<16xf32>
1345}
1346
1347// -----
1348
1349func.func @maskedload_base_type_mismatch(%base: memref<?xf64>, %mask: vector<16xi1>, %pass: vector<16xf32>) {
1350  %c0 = arith.constant 0 : index
1351  // expected-error@+1 {{'vector.maskedload' op base and result element type should match}}
1352  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf64>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1353}
1354
1355// -----
1356
1357func.func @maskedload_dim_mask_mismatch(%base: memref<?xf32>, %mask: vector<15xi1>, %pass: vector<16xf32>) {
1358  %c0 = arith.constant 0 : index
1359  // expected-error@+1 {{'vector.maskedload' op expected result shape to match mask shape}}
1360  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf32>, vector<15xi1>, vector<16xf32> into vector<16xf32>
1361}
1362
1363// -----
1364
1365func.func @maskedload_pass_thru_type_mask_mismatch(%base: memref<?xf32>, %mask: vector<16xi1>, %pass: vector<16xi32>) {
1366  %c0 = arith.constant 0 : index
1367  // expected-error@+1 {{'vector.maskedload' op expected pass_thru of same type as result type}}
1368  %0 = vector.maskedload %base[%c0], %mask, %pass : memref<?xf32>, vector<16xi1>, vector<16xi32> into vector<16xf32>
1369}
1370
1371// -----
1372
1373func.func @maskedload_memref_mismatch(%base: memref<?xf32>, %mask: vector<16xi1>, %pass: vector<16xf32>) {
1374  // expected-error@+1 {{'vector.maskedload' op requires 1 indices}}
1375  %0 = vector.maskedload %base[], %mask, %pass : memref<?xf32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1376}
1377
1378// -----
1379
1380func.func @maskedstore_base_type_mismatch(%base: memref<?xf64>, %mask: vector<16xi1>, %value: vector<16xf32>) {
1381  %c0 = arith.constant 0 : index
1382  // expected-error@+1 {{'vector.maskedstore' op base and valueToStore element type should match}}
1383  vector.maskedstore %base[%c0], %mask, %value : memref<?xf64>, vector<16xi1>, vector<16xf32>
1384}
1385
1386// -----
1387
1388func.func @maskedstore_dim_mask_mismatch(%base: memref<?xf32>, %mask: vector<15xi1>, %value: vector<16xf32>) {
1389  %c0 = arith.constant 0 : index
1390  // expected-error@+1 {{'vector.maskedstore' op expected valueToStore shape to match mask shape}}
1391  vector.maskedstore %base[%c0], %mask, %value : memref<?xf32>, vector<15xi1>, vector<16xf32>
1392}
1393
1394// -----
1395
1396func.func @maskedstore_memref_mismatch(%base: memref<?xf32>, %mask: vector<16xi1>, %value: vector<16xf32>) {
1397  %c0 = arith.constant 0 : index
1398  // expected-error@+1 {{'vector.maskedstore' op requires 1 indices}}
1399  vector.maskedstore %base[%c0, %c0], %mask, %value : memref<?xf32>, vector<16xi1>, vector<16xf32>
1400}
1401
1402// -----
1403
1404func.func @gather_base_type_mismatch(%base: memref<?xf64>, %indices: vector<16xi32>,
1405                                %mask: vector<16xi1>, %pass_thru: vector<16xf32>) {
1406  %c0 = arith.constant 0 : index
1407  // expected-error@+1 {{'vector.gather' op base and result element type should match}}
1408  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1409    : memref<?xf64>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1410}
1411
1412// -----
1413
1414func.func @gather_memref_mismatch(%base: memref<?x?xf64>, %indices: vector<16xi32>,
1415                             %mask: vector<16xi1>, %pass_thru: vector<16xf64>) {
1416  %c0 = arith.constant 0 : index
1417  // expected-error@+1 {{'vector.gather' op requires 2 indices}}
1418  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1419    : memref<?x?xf64>, vector<16xi32>, vector<16xi1>, vector<16xf64> into vector<16xf64>
1420}
1421
1422// -----
1423
1424func.func @gather_rank_mismatch(%base: memref<?xf32>, %indices: vector<16xi32>,
1425                           %mask: vector<16xi1>, %pass_thru: vector<16xf32>) {
1426  %c0 = arith.constant 0 : index
1427  // expected-error@+1 {{'vector.gather' op expected result dim to match indices dim}}
1428  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1429    : memref<?xf32>, vector<16xi32>, vector<16xi1>, vector<16xf32> into vector<2x16xf32>
1430}
1431
1432// -----
1433
1434func.func @gather_dim_indices_mismatch(%base: memref<?xf32>, %indices: vector<17xi32>,
1435                                  %mask: vector<16xi1>, %pass_thru: vector<16xf32>) {
1436  %c0 = arith.constant 0 : index
1437  // expected-error@+1 {{'vector.gather' op expected result dim to match indices dim}}
1438  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1439    : memref<?xf32>, vector<17xi32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1440}
1441
1442// -----
1443
1444func.func @gather_dim_mask_mismatch(%base: memref<?xf32>, %indices: vector<16xi32>,
1445                               %mask: vector<17xi1>, %pass_thru: vector<16xf32>) {
1446  %c0 = arith.constant 0 : index
1447  // expected-error@+1 {{'vector.gather' op expected result dim to match mask dim}}
1448  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1449    : memref<?xf32>, vector<16xi32>, vector<17xi1>, vector<16xf32> into vector<16xf32>
1450}
1451
1452// -----
1453
1454func.func @gather_pass_thru_type_mismatch(%base: memref<?xf32>, %indices: vector<16xi32>,
1455                                     %mask: vector<16xi1>, %pass_thru: vector<16xf64>) {
1456  %c0 = arith.constant 0 : index
1457  // expected-error@+1 {{'vector.gather' op expected pass_thru of same type as result type}}
1458  %0 = vector.gather %base[%c0][%indices], %mask, %pass_thru
1459    : memref<?xf32>, vector<16xi32>, vector<16xi1>, vector<16xf64> into vector<16xf32>
1460}
1461
1462// -----
1463
1464func.func @scatter_base_type_mismatch(%base: memref<?xf64>, %indices: vector<16xi32>,
1465                                 %mask: vector<16xi1>, %value: vector<16xf32>) {
1466  %c0 = arith.constant 0 : index
1467  // expected-error@+1 {{'vector.scatter' op base and valueToStore element type should match}}
1468  vector.scatter %base[%c0][%indices], %mask, %value
1469    : memref<?xf64>, vector<16xi32>, vector<16xi1>, vector<16xf32>
1470}
1471
1472// -----
1473
1474func.func @scatter_memref_mismatch(%base: memref<?x?xf64>, %indices: vector<16xi32>,
1475                              %mask: vector<16xi1>, %value: vector<16xf64>) {
1476  %c0 = arith.constant 0 : index
1477  // expected-error@+1 {{'vector.scatter' op requires 2 indices}}
1478  vector.scatter %base[%c0][%indices], %mask, %value
1479    : memref<?x?xf64>, vector<16xi32>, vector<16xi1>, vector<16xf64>
1480}
1481
1482// -----
1483
1484func.func @scatter_rank_mismatch(%base: memref<?xf32>, %indices: vector<16xi32>,
1485                            %mask: vector<16xi1>, %value: vector<2x16xf32>) {
1486  %c0 = arith.constant 0 : index
1487  // expected-error@+1 {{'vector.scatter' op operand #4 must be  of ranks 1, but got 'vector<2x16xf32>'}}
1488  vector.scatter %base[%c0][%indices], %mask, %value
1489    : memref<?xf32>, vector<16xi32>, vector<16xi1>, vector<2x16xf32>
1490}
1491
1492// -----
1493
1494func.func @scatter_dim_indices_mismatch(%base: memref<?xf32>, %indices: vector<17xi32>,
1495                                   %mask: vector<16xi1>, %value: vector<16xf32>) {
1496  %c0 = arith.constant 0 : index
1497  // expected-error@+1 {{'vector.scatter' op expected valueToStore dim to match indices dim}}
1498  vector.scatter %base[%c0][%indices], %mask, %value
1499    : memref<?xf32>, vector<17xi32>, vector<16xi1>, vector<16xf32>
1500}
1501
1502// -----
1503
1504func.func @scatter_dim_mask_mismatch(%base: memref<?xf32>, %indices: vector<16xi32>,
1505                                %mask: vector<17xi1>, %value: vector<16xf32>) {
1506  %c0 = arith.constant 0 : index
1507  // expected-error@+1 {{'vector.scatter' op expected valueToStore dim to match mask dim}}
1508  vector.scatter %base[%c0][%indices], %mask, %value
1509    : memref<?xf32>, vector<16xi32>, vector<17xi1>, vector<16xf32>
1510}
1511
1512// -----
1513
1514func.func @expand_base_type_mismatch(%base: memref<?xf64>, %mask: vector<16xi1>, %pass_thru: vector<16xf32>) {
1515  %c0 = arith.constant 0 : index
1516  // expected-error@+1 {{'vector.expandload' op base and result element type should match}}
1517  %0 = vector.expandload %base[%c0], %mask, %pass_thru : memref<?xf64>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1518}
1519
1520// -----
1521
1522func.func @expand_base_scalable(%base: memref<?xf32>, %mask: vector<[16]xi1>, %pass_thru: vector<[16]xf32>) {
1523  %c0 = arith.constant 0 : index
1524  // expected-error@+1 {{'vector.expandload' op operand #2 must be fixed-length vector of 1-bit signless integer values, but got 'vector<[16]xi1>}}
1525  %0 = vector.expandload %base[%c0], %mask, %pass_thru : memref<?xf32>, vector<[16]xi1>, vector<[16]xf32> into vector<[16]xf32>
1526}
1527
1528// -----
1529
1530func.func @expand_dim_mask_mismatch(%base: memref<?xf32>, %mask: vector<17xi1>, %pass_thru: vector<16xf32>) {
1531  %c0 = arith.constant 0 : index
1532  // expected-error@+1 {{'vector.expandload' op expected result dim to match mask dim}}
1533  %0 = vector.expandload %base[%c0], %mask, %pass_thru : memref<?xf32>, vector<17xi1>, vector<16xf32> into vector<16xf32>
1534}
1535
1536// -----
1537
1538func.func @expand_pass_thru_mismatch(%base: memref<?xf32>, %mask: vector<16xi1>, %pass_thru: vector<17xf32>) {
1539  %c0 = arith.constant 0 : index
1540  // expected-error@+1 {{'vector.expandload' op expected pass_thru of same type as result type}}
1541  %0 = vector.expandload %base[%c0], %mask, %pass_thru : memref<?xf32>, vector<16xi1>, vector<17xf32> into vector<16xf32>
1542}
1543
1544// -----
1545
1546func.func @expand_memref_mismatch(%base: memref<?x?xf32>, %mask: vector<16xi1>, %pass_thru: vector<16xf32>) {
1547  %c0 = arith.constant 0 : index
1548  // expected-error@+1 {{'vector.expandload' op requires 2 indices}}
1549  %0 = vector.expandload %base[%c0], %mask, %pass_thru : memref<?x?xf32>, vector<16xi1>, vector<16xf32> into vector<16xf32>
1550}
1551
1552// -----
1553
1554func.func @compress_base_type_mismatch(%base: memref<?xf64>, %mask: vector<16xi1>, %value: vector<16xf32>) {
1555  %c0 = arith.constant 0 : index
1556  // expected-error@+1 {{'vector.compressstore' op base and valueToStore element type should match}}
1557  vector.compressstore %base[%c0], %mask, %value : memref<?xf64>, vector<16xi1>, vector<16xf32>
1558}
1559
1560// -----
1561
1562func.func @compress_scalable(%base: memref<?xf32>, %mask: vector<[16]xi1>, %value: vector<[16]xf32>) {
1563  %c0 = arith.constant 0 : index
1564  // expected-error@+1 {{'vector.compressstore' op operand #2 must be fixed-length vector of 1-bit signless integer values, but got 'vector<[16]xi1>}}
1565  vector.compressstore %base[%c0], %mask, %value : memref<?xf32>, vector<[16]xi1>, vector<[16]xf32>
1566}
1567
1568// -----
1569
1570func.func @compress_dim_mask_mismatch(%base: memref<?xf32>, %mask: vector<17xi1>, %value: vector<16xf32>) {
1571  %c0 = arith.constant 0 : index
1572  // expected-error@+1 {{'vector.compressstore' op expected valueToStore dim to match mask dim}}
1573  vector.compressstore %base[%c0], %mask, %value : memref<?xf32>, vector<17xi1>, vector<16xf32>
1574}
1575
1576// -----
1577
1578func.func @compress_memref_mismatch(%base: memref<?x?xf32>, %mask: vector<16xi1>, %value: vector<16xf32>) {
1579  %c0 = arith.constant 0 : index
1580  // expected-error@+1 {{'vector.compressstore' op requires 2 indices}}
1581  vector.compressstore %base[%c0, %c0, %c0], %mask, %value : memref<?x?xf32>, vector<16xi1>, vector<16xf32>
1582}
1583
1584// -----
1585
1586func.func @scan_reduction_dim_constraint(%arg0: vector<2x3xi32>, %arg1: vector<3xi32>) -> vector<3xi32> {
1587  // expected-error@+1 {{'vector.scan' op reduction dimension 5 has to be less than 2}}
1588  %0:2 = vector.scan <add>, %arg0, %arg1 {inclusive = true, reduction_dim = 5} :
1589    vector<2x3xi32>, vector<3xi32>
1590  return %0#1 : vector<3xi32>
1591}
1592
1593// -----
1594
1595func.func @scan_ival_rank_constraint(%arg0: vector<2x3xi32>, %arg1: vector<1x3xi32>) -> vector<1x3xi32> {
1596  // expected-error@+1 {{initial value rank 2 has to be equal to 1}}
1597  %0:2 = vector.scan <add>, %arg0, %arg1 {inclusive = true, reduction_dim = 0} :
1598    vector<2x3xi32>, vector<1x3xi32>
1599  return %0#1 : vector<1x3xi32>
1600}
1601
1602// -----
1603
1604func.func @scan_incompatible_shapes(%arg0: vector<2x3xi32>, %arg1: vector<5xi32>) -> vector<2x3xi32> {
1605  // expected-error@+1 {{incompatible input/initial value shapes}}
1606  %0:2 = vector.scan <add>, %arg0, %arg1 {inclusive = true, reduction_dim = 0} :
1607    vector<2x3xi32>, vector<5xi32>
1608  return %0#0 : vector<2x3xi32>
1609}
1610
1611// -----
1612
1613func.func @scan_unsupported_kind(%arg0: vector<2x3xf32>, %arg1: vector<3xf32>) -> vector<2x3xf32> {
1614  // expected-error@+1 {{'vector.scan' op unsupported reduction type 'f32' for kind 'xor'}}
1615  %0:2 = vector.scan <xor>, %arg0, %arg1 {inclusive = true, reduction_dim = 0} :
1616    vector<2x3xf32>, vector<3xf32>
1617  return %0#0 : vector<2x3xf32>
1618}
1619
1620// -----
1621
1622func.func @invalid_splat(%v : f32) {
1623  // expected-error@+1 {{invalid kind of type specified}}
1624  vector.splat %v : memref<8xf32>
1625  return
1626}
1627
1628// -----
1629
1630func.func @vector_mask_multiple_ops(%t0: tensor<?xf32>, %t1: tensor<?xf32>, %idx: index, %val: vector<16xf32>, %m0: vector<16xi1>) {
1631  %ft0 = arith.constant 0.0 : f32
1632  // expected-error@+1 {{'vector.mask' op expects only one operation to mask}}
1633  vector.mask %m0 {
1634    vector.transfer_write %val, %t0[%idx] : vector<16xf32>, tensor<?xf32>
1635    vector.transfer_write %val, %t1[%idx] : vector<16xf32>, tensor<?xf32>
1636  } : vector<16xi1>
1637  return
1638}
1639
1640// -----
1641
1642func.func @vector_mask_shape_mismatch(%a: vector<8xi32>, %m0: vector<16xi1>) -> i32 {
1643  // expected-error@+1 {{'vector.mask' op expects a 'vector<8xi1>' mask for the maskable operation}}
1644  %0 = vector.mask %m0 { vector.reduction <add>, %a : vector<8xi32> into i32 } : vector<16xi1> -> i32
1645  return %0 : i32
1646}
1647
1648// -----
1649
1650func.func @vector_mask_passthru_type_mismatch(%t0: tensor<f32>, %m0: vector<i1>) -> vector<f32> {
1651  %ft0 = arith.constant 0.0 : f32
1652  // expected-error@+1 {{'vector.mask' op operand #0 must be vector of 1-bit signless integer values, but got 'vector<i1>'}}
1653  %0 = vector.mask %m0 { vector.transfer_read %t0[], %ft0 : tensor<f32>, vector<f32> } : vector<i1> -> vector<f32>
1654  return %0 : vector<f32>
1655}
1656
1657// -----
1658
1659// expected-note@+1 {{prior use here}}
1660func.func @vector_mask_passthru_type_mismatch(%t0: tensor<?xf32>, %idx: index, %m0: vector<16xi1>, %pt0: vector<16xi32>) -> vector<16xf32> {
1661  %ft0 = arith.constant 0.0 : f32
1662  // expected-error@+1 {{use of value '%pt0' expects different type than prior uses: 'vector<16xf32>' vs 'vector<16xi32>'}}
1663  %0 = vector.mask %m0, %pt0 { vector.transfer_read %t0[%idx], %ft0 : tensor<?xf32>, vector<16xf32> } : vector<16xi1> -> vector<16xf32>
1664  return %0 : vector<16xf32>
1665}
1666
1667// -----
1668
1669func.func @vector_mask_passthru_no_return(%val: vector<16xf32>, %t0: tensor<?xf32>, %idx: index, %m0: vector<16xi1>, %pt0: vector<16xf32>) {
1670  // expected-error@+1 {{'vector.mask' op expects result type to match maskable operation result type}}
1671  vector.mask %m0, %pt0 { vector.transfer_write %val, %t0[%idx] : vector<16xf32>, tensor<?xf32> } : vector<16xi1> -> vector<16xf32>
1672  return
1673}
1674// -----
1675
1676func.func @vector_mask_non_maskable_op(%a : vector<3x4xf32>) -> vector<3x4xf32> {
1677   %m0 = vector.constant_mask [2, 2] : vector<3x4xi1>
1678  // expected-error@+1 {{'vector.mask' op expects a MaskableOpInterface within the mask region}}
1679   %0 = vector.mask %m0 { arith.addf %a, %a : vector<3x4xf32> } : vector<3x4xi1> -> vector<3x4xf32>
1680   return %0 : vector<3x4xf32>
1681}
1682
1683// -----
1684
1685func.func @vector_mask_0d_mask(%arg0: tensor<2x4xi32>,
1686                               %idx0: index, %idx1: index,
1687                               %m0: vector<i1>) -> vector<1x1x4xi32> {
1688  %cst = arith.constant 0 : i32
1689  // expected-error@+1 {{'vector.mask' op operand #0 must be vector of 1-bit signless integer values, but got 'vector<i1>'}}
1690  %res = vector.mask %m0 {
1691    %0 = vector.transfer_read %arg0[%idx0, %idx1], %cst {permutation_map = affine_map<(d0, d1) -> (0, 0, 0)>}
1692      : tensor<2x4xi32>, vector<1x1x4xi32>
1693    vector.yield %0 : vector<1x1x4xi32>
1694  } : vector<i1> -> vector<1x1x4xi32>
1695  return %res : vector<1x1x4xi32>
1696}
1697
1698// -----
1699
1700func.func @vector_scalable_insert_unaligned(%subv: vector<4xi32>, %vec: vector<[16]xi32>) {
1701  // expected-error@+1 {{op failed to verify that position is a multiple of the source length.}}
1702  %0 = vector.scalable.insert %subv, %vec[2] : vector<4xi32> into vector<[16]xi32>
1703}
1704
1705// -----
1706
1707func.func @vector_scalable_extract_unaligned(%vec: vector<[16]xf32>) {
1708  // expected-error@+1 {{op failed to verify that position is a multiple of the result length.}}
1709  %0 = vector.scalable.extract %vec[5] : vector<4xf32> from vector<[16]xf32>
1710}
1711
1712// -----
1713
1714func.func @integer_vector_contract(%arg0: vector<16x32xsi8>, %arg1: vector<32x16xsi8>, %arg2: vector<16x16xsi32>) -> vector<16x16xsi32> {
1715  // expected-error@+1 {{op only supports signless integer types}}
1716  %0 = vector.contract {
1717    indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d2, d1)>, affine_map<(d0, d1, d2) -> (d0, d1)>],
1718    iterator_types = ["parallel", "parallel", "reduction"], kind = #vector.kind<add>
1719  } %arg0, %arg1, %arg2 : vector<16x32xsi8>, vector<32x16xsi8> into vector<16x16xsi32>
1720  return %0: vector<16x16xsi32>
1721}
1722
1723// -----
1724
1725func.func @invalid_outerproduct(%src : memref<?xf32>) {
1726  %idx = arith.constant 0 : index
1727  %0 = vector.load %src[%idx] : memref<?xf32>, vector<[4]xf32>
1728  %1 = vector.load %src[%idx] : memref<?xf32>, vector<4xf32>
1729
1730  // expected-error @+1 {{expected either both or only #2 operand dim to be scalable}}
1731  %op = vector.outerproduct %0, %1 : vector<[4]xf32>, vector<4xf32>
1732
1733  return
1734}
1735
1736// -----
1737
1738func.func @invalid_outerproduct1(%src : memref<?xf32>) {
1739  %idx = arith.constant 0 : index
1740  %0 = vector.load %src[%idx] : memref<?xf32>, vector<[4]x[4]xf32>
1741  %1 = vector.load %src[%idx] : memref<?xf32>, vector<[4]xf32>
1742
1743  // expected-error @+1 {{'vector.outerproduct' op expected 1-d vector for operand #1}}
1744  %op = vector.outerproduct %0, %1 : vector<[4]x[4]xf32>, vector<[4]xf32>
1745}
1746
1747// -----
1748
1749func.func @deinterleave_zero_dim_fail(%vec : vector<f32>) {
1750  // expected-error @+1 {{'vector.deinterleave' op operand #0 must be vector of any type values, but got 'vector<f32>}}
1751  %0, %1 = vector.deinterleave %vec : vector<f32> -> vector<f32>
1752  return
1753}
1754
1755// -----
1756
1757func.func @deinterleave_one_dim_fail(%vec : vector<1xf32>) {
1758  // expected-error @+1 {{'vector.deinterleave' op failed to verify that the trailing dimension of the source vector has an even number of elements}}
1759  %0, %1 = vector.deinterleave %vec : vector<1xf32> -> vector<1xf32>
1760  return
1761}
1762
1763// -----
1764
1765func.func @deinterleave_oversized_output_fail(%vec : vector<4xf32>) {
1766  // expected-error @+1 {{'vector.deinterleave' op failed to verify that the trailing dimension of the results is half the width of source trailing dimension}}
1767  %0, %1 = "vector.deinterleave" (%vec) : (vector<4xf32>) -> (vector<8xf32>, vector<8xf32>)
1768  return
1769}
1770
1771// -----
1772
1773func.func @deinterleave_output_dim_size_mismatch(%vec : vector<4xf32>) {
1774  // expected-error @+1 {{'vector.deinterleave' op failed to verify that the trailing dimension of the results is half the width of source trailing dimension}}
1775  %0, %1 = "vector.deinterleave" (%vec) : (vector<4xf32>) -> (vector<4xf32>, vector<2xf32>)
1776  return
1777}
1778
1779// -----
1780
1781func.func @deinterleave_n_dim_rank_fail(%vec : vector<2x3x4xf32>) {
1782  // expected-error @+1 {{'vector.deinterleave' op failed to verify that the trailing dimension of the results is half the width of source trailing dimension}}
1783  %0, %1 = "vector.deinterleave" (%vec) : (vector<2x3x4xf32>) -> (vector<2x3x4xf32>, vector<2x3x2xf32>)
1784  return
1785}
1786
1787// -----
1788
1789func.func @deinterleave_scalable_dim_size_fail(%vec : vector<2x[4]xf32>) {
1790  // expected-error @+1 {{'vector.deinterleave' op failed to verify that all of {res1, res2} have same type}}
1791  %0, %1 = "vector.deinterleave" (%vec) : (vector<2x[4]xf32>) -> (vector<2x[2]xf32>, vector<2x[1]xf32>)
1792  return
1793}
1794
1795// -----
1796
1797func.func @deinterleave_scalable_rank_fail(%vec : vector<2x[4]xf32>) {
1798  // expected-error @+1 {{'vector.deinterleave' op failed to verify that all of {res1, res2} have same type}}
1799  %0, %1 = "vector.deinterleave" (%vec) : (vector<2x[4]xf32>) -> (vector<2x[2]xf32>, vector<[2]xf32>)
1800  return
1801}
1802
1803// -----
1804
1805func.func @invalid_from_elements(%a: f32) {
1806  // expected-error @+1 {{'vector.from_elements' number of operands and types do not match: got 1 operands and 2 types}}
1807  vector.from_elements %a : vector<2xf32>
1808  return
1809}
1810
1811// -----
1812
1813// expected-note @+1 {{prior use here}}
1814func.func @invalid_from_elements(%a: f32, %b: i32) {
1815  // expected-error @+1 {{use of value '%b' expects different type than prior uses: 'f32' vs 'i32'}}
1816  vector.from_elements %a, %b : vector<2xf32>
1817  return
1818}
1819
1820// -----
1821
1822func.func @invalid_from_elements_scalable(%a: f32, %b: i32) {
1823  // expected-error @+1 {{'result' must be fixed-length vector of any type values, but got 'vector<[2]xf32>'}}
1824  vector.from_elements %a, %b : vector<[2]xf32>
1825  return
1826}
1827
1828// -----
1829
1830func.func @invalid_step_0d() {
1831  // expected-error @+1 {{vector.step' op result #0 must be vector of index values of ranks 1, but got 'vector<f32>'}}
1832  vector.step : vector<f32>
1833  return
1834}
1835
1836// -----
1837
1838func.func @invalid_step_2d() {
1839  // expected-error @+1 {{vector.step' op result #0 must be vector of index values of ranks 1, but got 'vector<2x4xf32>'}}
1840  vector.step : vector<2x4xf32>
1841  return
1842}
1843
1844// -----
1845
1846func.func @matrix_multiply_scalable(%a: vector<[4]xf64>, %b: vector<4xf64>) {
1847  // expected-error @+1 {{'vector.matrix_multiply' op operand #0 must be fixed-length vector of signless integer or signed integer or index or floating-point values of ranks 1, but got 'vector<[4]xf64>'}}
1848  %c = vector.matrix_multiply %a, %b {
1849    lhs_rows = 2: i32,
1850    lhs_columns = 2: i32 ,
1851    rhs_columns = 2: i32 }
1852  : (vector<[4]xf64>, vector<4xf64>) -> vector<4xf64>
1853
1854  return
1855}
1856
1857// -----
1858
1859func.func @flat_transpose_scalable(%arg0: vector<[16]xf32>) -> vector<[16]xf32> {
1860  // expected-error @+1 {{'vector.flat_transpose' op operand #0 must be fixed-length vector of signless integer or signed integer or index or floating-point values of ranks 1, but got 'vector<[16]xf32>'}}
1861  %0 = vector.flat_transpose %arg0 { rows = 4: i32, columns = 4: i32 }
1862     : vector<[16]xf32> -> vector<[16]xf32>
1863  return %0 : vector<[16]xf32>
1864}
1865