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