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