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