brintos

brintos / llvm-project-archived public Read only

0
0
Text · 75.8 KiB · 1f554e6 Raw
1960 lines · plain
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics2 3func.func @load_number_of_indices(%v : memref<f32>) {4  // expected-error @+2 {{incorrect number of indices for load}}5  %c0 = arith.constant 0 : index6  memref.load %v[%c0] : memref<f32>7}8 9// -----10 11func.func @store_number_of_indices(%v : memref<f32>) {12  // expected-error @+3 {{store index operand count not equal to memref rank}}13  %c0 = arith.constant 0 : index14  %f0 = arith.constant 0.0 : f3215  memref.store %f0, %v[%c0] : memref<f32>16}17 18// -----19 20func.func @yield_parent(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {21  // expected-error @+1 {{op expected parent op with LinalgOp interface}}22  linalg.yield %arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>23}24 25// -----26 27func.func @index_parent() {28  // expected-error @+1 {{op expected parent op with LinalgOp interface}}29  linalg.index 0 : index30}31 32// -----33 34func.func @index_dim_lower_than_number_of_loops(%arg0: memref<f32>) {35  // expected-error @+6 {{op expected dim (2) to be lower than the number of loops (0) of the enclosing LinalgOp}}36  linalg.generic {37      indexing_maps =  [ affine_map<() -> ()> ],38      iterator_types = []}39      outs(%arg0 : memref<f32>) {40    ^bb(%0: f32):41      linalg.index 2 : index42      linalg.yield %0 : f3243  }44}45 46// -----47 48func.func @index_dim_negative(%arg0: memref<f32>) {49  // expected-error @+6 {{op attribute 'dim' failed to satisfy constraint: 64-bit signless integer attribute whose minimum value is 0}}50  linalg.generic {51      indexing_maps =  [ affine_map<() -> ()> ],52      iterator_types = []}53      outs(%arg0 : memref<f32>) {54    ^bb(%0: f32):55      linalg.index -1 : index56      linalg.yield %0 : f3257  }58}59 60// -----61 62func.func @generic_no_region(%arg0: memref<f32>) {63  // expected-error @+4 {{expected '{' to begin a region}}64  linalg.generic {65    indexing_maps =  [ affine_map<() -> (0)> ],66    iterator_types = []67  } ins(%arg0 : memref<f32>)68}69 70// -----71 72func.func @generic_mismatched_num_returns(%arg0: memref<f32>) {73  // expected-error @+6 {{op expected number of yield values (0) to match the number of inits / outs operands of the enclosing LinalgOp (1)}}74  linalg.generic {75      indexing_maps =  [ affine_map<() -> ()> ],76      iterator_types = []}77      outs(%arg0 : memref<f32>) {78    ^bb(%0: f32):79      linalg.yield80  }81}82 83// -----84 85func.func @generic_wrong_dim_in_map(%arg0: memref<1xi32>) {86  // expected-error @+1 {{op expected indexing_map #0 to have 1 dim(s) to match the number of loops}}87  linalg.generic {88    indexing_maps =  [ affine_map<() -> (0)> ],89    iterator_types = ["parallel"]}90      outs(%arg0 : memref<1xi32>) {91    ^bb(%i : i32):92    linalg.yield %i : i3293  }94}95 96// -----97 98func.func @generic_wrong_iterator(%arg0: memref<1xi32>) {99  // expected-error @+4 {{unexpected iterator_type (random)}}100  linalg.generic {101    indexing_maps =  [ affine_map<(i) -> (i)> ],102    iterator_types = ["random"]}103      outs(%arg0 : memref<1xi32>) {104    ^bb(%i : i32):105    linalg.yield %i : i32106  }107}108 109// -----110 111func.func @generic_one_d_view(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {112  // expected-error @+1 {{expected operand rank (1) to match the result rank of indexing_map #0 (2)}}113  linalg.generic {114    indexing_maps =  [ affine_map<() -> (0, 0)> ],115    iterator_types = []}116      outs(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>) {117    ^bb(%f : f32):118      linalg.yield %f: f32119  }120}121 122// -----123 124func.func @generic_scalar_view(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {125  %cst = arith.constant 0.0 : f32126  // expected-error @+1 {{expected operand rank (0) to match the result rank of indexing_map #0 (1)}}127  linalg.generic {128    indexing_maps =  [ affine_map<() -> (0)>, affine_map<() -> (0, 0)> ],129    iterator_types = []}130      ins(%cst : f32)131      outs(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>) {132    ^bb(%0 : f32, %1 : f32):133      linalg.yield %0: f32134  }135}136 137// -----138 139func.func @generic_result_0_element_type(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {140  // expected-error @+7 {{'linalg.yield' op type of yield operand 1 ('i4') doesn't match the element type of the enclosing linalg.generic op ('f32')}}141  linalg.generic {142    indexing_maps =  [ affine_map<(i) -> (i)> ],143    iterator_types = ["parallel"]}144      outs(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>) {145    ^bb(%0: f32):146      %1 = arith.constant 1: i4147      linalg.yield %1: i4148  }149}150 151// -----152 153func.func @generic_singular_maps(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>, %arg1: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {154  // expected-error @+1 {{invalid indexing maps are non-invertible: ((d0, d1) -> (d0 + d1, d0 + d1))}}155  linalg.generic {156    indexing_maps =  [157      affine_map<(i, j) -> (i + j)>,158      affine_map<(i, j) -> (i + j)>159    ],160    iterator_types = ["parallel","parallel"]}161    ins(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>)162   outs(%arg1 : memref<?xf32, affine_map<(i)[off]->(off + i)>>) {163  ^bb(%0: f32, %1: f32):164      linalg.yield %1: f32165  }166}167 168////////////////////////////////////////////////////////////////////////////////169///////////////////////////// Region tests /////////////////////////////////////170////////////////////////////////////////////////////////////////////////////////171 172// -----173 174func.func @generic_empty_region(%arg0: memref<f32>) {175  %f0 = arith.constant 0.0: f32176  // expected-error @+1 {{op expects region #0 to have 0 or 1 blocks}}177  linalg.generic {178    indexing_maps =  [ affine_map<() -> ()>, affine_map<() -> ()> ],179    iterator_types = []}180      ins(%arg0 : memref<f32>)181     outs(%arg0 : memref<f32>) {182    ^bb1:183      linalg.yield %f0: f32184    ^bb2:185      linalg.yield %f0: f32186  }187}188 189// -----190 191func.func @generic_empty_region(%arg0: memref<f32>) {192  %f0 = arith.constant 0.0: f32193  // expected-error @+1 {{op expects to have 1 region with 1 block}}194  linalg.generic {195    indexing_maps =  [ affine_map<() -> ()> , affine_map<() -> ()> ],196    iterator_types = []}197    ins(%arg0 : memref<f32>)198   outs(%arg0 : memref<f32>) {199  }200}201 202// -----203 204func.func @generic_mismatched_num_arguments(%arg0: memref<f32>) {205  // expected-error @+6 {{'linalg.yield' op expected number of yield values (1) to match the number of inits / outs operands of the enclosing LinalgOp (2)}}206  linalg.generic {207      indexing_maps =  [ affine_map<() -> ()>, affine_map<() -> ()> ],208      iterator_types = []}209      outs(%arg0, %arg0 : memref<f32>, memref<f32>) {210    ^bb(%f: f32):211      linalg.yield %f: f32212  }213}214 215// -----216 217func.func @generic_shaped_operand_block_arg_type(%arg0: memref<f32>) {218  // expected-error @+6 {{'linalg.yield' op type of yield operand 1 ('i1') doesn't match the element type of the enclosing linalg.generic op ('f32')}}219  linalg.generic {220    indexing_maps =  [ affine_map<() -> ()> ],221    iterator_types = []}222      outs(%arg0 : memref<f32>) {223    ^bb(%i: i1):224    linalg.yield %i : i1225  }226}227 228// -----229 230func.func @generic_scalar_operand_block_arg_type(%arg0: tensor<f32>) {231  // expected-error @+6 {{'linalg.yield' op type of yield operand 1 ('i1') doesn't match the element type of the enclosing linalg.generic op ('f32')}}232  linalg.generic {233    indexing_maps =  [ affine_map<() -> ()> ],234    iterator_types = []}235      outs(%arg0 : tensor<f32>) {236    ^bb(%i: i1):237    linalg.yield %i : i1238  } -> tensor<f32>239}240 241// -----242 243func.func @generic_result_0_element_type(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>) {244  // expected-error @+7 {{type of yield operand 1 ('i1') doesn't match the element type of the enclosing linalg.generic op ('f32')}}245  linalg.generic {246    indexing_maps = [ affine_map<(i) -> (i)> ],247    iterator_types = ["parallel"]}248      outs(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>) {249    ^bb(%i: f32):250      %0 = arith.constant 0: i1251      linalg.yield %0: i1252  }253}254 255// -----256 257func.func @generic_result_tensor_type(%arg0: memref<?xf32, affine_map<(i)[off]->(off + i)>>,258                                 %arg1: tensor<?xf32>) {259  // expected-error @+1 {{expected type of operand #1 ('tensor<?xf32>') to match type of corresponding result ('tensor<f32>')}}260  %0 = linalg.generic {261    indexing_maps = [ affine_map<(i) -> (i)> , affine_map<(i) -> (i)> ],262    iterator_types = ["parallel"]}263       ins(%arg0 : memref<?xf32, affine_map<(i)[off]->(off + i)>>)264      outs(%arg1 : tensor<?xf32>) {265    ^bb(%i: f32, %j: f32):266      linalg.yield %i: f32267  } -> tensor<f32>268}269 270// -----271 272func.func @generic(%arg0: memref<?x?xf32>) {273  // expected-error @+6 {{block with no terminator, has %0 = "arith.addf"(%arg1, %arg1) <{fastmath = #arith.fastmath<none>}> : (f32, f32) -> f32}}274  linalg.generic  {275    indexing_maps = [ affine_map<(i, j) -> (i, j)> ],276    iterator_types = ["parallel", "parallel"]}277      outs(%arg0 : memref<?x?xf32>) {278    ^bb(%0: f32) :279      %1 = arith.addf %0, %0: f32280  }281  return282}283 284// -----285 286// This test is currently disabled: subject to verifier ordering issues.287// Instead, when the ranks are not greater than 2, an assertion will be triggered288// in LinalgStructuredOps.td::ConvOp::iterator_types() for now because the289// verifier inspects the iterator_types. This is slated to become an290// autogenerated op in the future, alleviating the issue.291// func @conv_rank_limit(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: memref<?xf32>) {292//   // DISABLED_expected -error @+1 {{expects memref ranks to be greater than 2}}293//   linalg.conv(%arg0, %arg1, %arg2) : memref<?xf32>, memref<?xf32>, memref<?xf32>294// }295//296// // -----297 298func.func @named_ops(%a3: memref<?x?x?xf32>, %b3: memref<?x?xf32>, %c3: memref<?x?x?xf32>) {299  // expected-error @+1 {{expected operand rank (2) to match the result rank of indexing_map #1 (3)}}300  linalg.batch_matmul ins(%a3, %b3: memref<?x?x?xf32>, memref<?x?xf32>)301                     outs(%c3 : memref<?x?x?xf32>)302  return303}304 305// -----306 307func.func @incorrect_region_arg_count(%m: memref<?x?xf32>) {308  // expected-error @+3 {{region expects 3 args, got 2}}309  %res = linalg.matmul ins(%m, %m : memref<?x?xf32>, memref<?x?xf32>)310                       -> (tensor<?x?xf32>, tensor<?x?xf32>)311  return312}313 314// -----315 316func.func @matching_inits(%m: memref<?x?xf32>, %t: tensor<?x?xf32>) {317  // expected-error @+1 {{expected type of operand #2 ('tensor<?x?xf32>') to match type of corresponding result ('tensor<?xf32>')}}318  %res = linalg.matmul ins(%m, %m : memref<?x?xf32>, memref<?x?xf32>)319                      outs(%t : tensor<?x?xf32>)320                        -> tensor<?xf32>321  return322}323 324// -----325 326func.func @illegal_fill_tensor_no_return(%arg0 : index, %arg1 : index, %arg2 : f32)327{328  %0 = tensor.empty(%arg0, %arg1) : tensor<?x?xf32>329  // expected-error @+1 {{expected the number of tensor results (0) to be equal to the number of output tensors (1)}}330  linalg.fill ins(%arg2 : f32) outs(%0 : tensor<?x?xf32>)331}332 333// -----334 335func.func @illegal_fill_memref_with_tensor_return336  (%arg0 : memref<?x?xf32>, %arg1 : f32) -> tensor<?x?xf32>337{338  // expected-error @+1 {{expected the number of tensor results (1) to be equal to the number of output tensors (0)}}339  %0 = linalg.fill ins(%arg1 : f32) outs(%arg0 : memref<?x?xf32>) -> tensor<?x?xf32>340  return %0 : tensor<?x?xf32>341}342 343// -----344 345func.func @illegal_fill_tensor_with_memref_return346  (%arg0 : tensor<?x?xf32>, %arg1 : f32) -> memref<?x?xf32>347{348  // expected-error @+1 {{result #0 must be variadic of ranked tensor of any type values, but got 'memref<?x?xf32>'}}349  %0 = linalg.fill ins(%arg1 : f32) outs(%arg0 : tensor<?x?xf32>) -> memref<?x?xf32>350  return %0 : memref<?x?xf32>351}352 353// -----354 355func.func @illegal_fill_element_type_truncation(%arg0 : tensor<2xf32>, %arg1 : f64) -> tensor<2xf32>356{357  // expected-error @+1 {{'linalg.fill' op expected fill value type ('f64') to match output element type ('f32')}}358  %0 = linalg.fill ins(%arg1 : f64) outs(%arg0 : tensor<2xf32>) -> tensor<2xf32>359  return %0 : tensor<2xf32>360}361 362// -----363 364func.func @illegal_fill_element_type_extension(%arg0 : tensor<2xi32>, %arg1 : i16) -> tensor<2xi32>365{366  // expected-error @+1 {{'linalg.fill' op expected fill value type ('i16') to match output element type ('i32')}}367  %0 = linalg.fill ins(%arg1 : i16) outs(%arg0 : tensor<2xi32>) -> tensor<2xi32>368  return %0 : tensor<2xi32>369}370 371// -----372 373func.func @illegal_fill_value_type(%arg0 : tensor<2x2xf32>, %arg1 : tensor<2xf32>) -> tensor<2x2xf32>374{375  // expected-error @+1 {{expected op with scalar input}}376  %0 = linalg.fill ins(%arg1 : tensor<2xf32>) outs(%arg0 : tensor<2x2xf32>) -> tensor<2x2xf32>377  return %0 : tensor<2x2xf32>378}379 380// -----381 382func.func @invalid_static_matmul(%arg0: memref<2x4xf32>, %arg1: memref<3x4xf32>, %arg2: memref<2x4xf32>) {383  // expected-error @+1 {{inferred input/output operand #1 has shape's dimension #0 to be 4, but found 3}}384  linalg.matmul ins(%arg0, %arg1 : memref<2x4xf32>, memref<3x4xf32>)385                      outs(%arg2 :memref<2x4xf32>)386  return387}388 389// -----390 391func.func @invalid_scalar_input_matmul(%arg0: f32, %arg1: memref<3x4xf32>, %arg2: memref<2x4xf32>) {392  // expected-error @+1 {{'linalg.matmul' op expected operand rank (0) to match the result rank of indexing_map #0 (2)}}393  linalg.matmul ins(%arg0, %arg1 : f32, memref<3x4xf32>)394                outs(%arg2 : memref<2x4xf32>)395  return396}397 398// -----399 400func.func @invalid_scalar_output_matmul(%arg0: memref<2x3xf32>, %arg1: memref<3x4xf32>, %arg2: f32) {401  // expected-error @+1 {{'linalg.matmul' op operand #2 must be variadic of shaped of any type values, but got 'f32'}}402  linalg.matmul ins(%arg0, %arg1 : memref<2x3xf32>, memref<3x4xf32>)403                outs(%arg2 : f32)404  return405}406 407// -----408 409func.func @invalid_indexing_maps_matmul(%arg0: memref<2x4xf32>, %arg1: memref<3x4xf32>, %arg2: memref<2x4xf32>) {410  // expected-error @+1 {{expected attribute value}}411  linalg.matmul indexing_maps = [412                       ,413                       affine_map<(d0, d1, d2) -> (d2, d1)>,414                       affine_map<(d0, d1, d2) -> (d0, d1)>415                      ]416                      ins(%arg0, %arg1 : memref<2x4xf32>, memref<3x4xf32>)417                      outs(%arg2 :memref<2x4xf32>)418  return419}420 421// -----422 423func.func @invalid_matmul_dim_a(%arg0: memref<5x5xf32>, %arg1: memref<5x5xf32>, %arg2: memref<5x5xf32>) {424  // expected-error @+1 {{Unexpected dim expression in map result}}425  linalg.matmul indexing_maps = [426                       affine_map<(d0, d1, d2) -> (d1, d2)>,427                       affine_map<(d0, d1, d2) -> (d2, d1)>,428                       affine_map<(d0, d1, d2) -> (d0, d1)>429                     ]430                     ins(%arg0, %arg1 : memref<5x5xf32>, memref<5x5xf32>) outs(%arg2: memref<5x5xf32>)431  return432}433 434// -----435 436func.func @invalid_matmul_dim_b(%arg0: memref<5x5xf32>, %arg1: memref<5x5xf32>, %arg2: memref<5x5xf32>) {437  // expected-error @+1 {{Unexpected dim expression in map result}}438  linalg.matmul indexing_maps = [439                       affine_map<(d0, d1, d2) -> (d0, d2)>,440                       affine_map<(d0, d1, d2) -> (d2, d0)>,441                       affine_map<(d0, d1, d2) -> (d0, d1)>442                     ]443                     ins(%arg0, %arg1 : memref<5x5xf32>, memref<5x5xf32>) outs(%arg2: memref<5x5xf32>)444  return445}446 447// -----448 449func.func @invalid_transpose_a_matmul(%lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) -> tensor<4x64xf32> {450  // expected-error @+1 {{inferred input/output operand #1 has shape's dimension #0 to be 4, but found 1}}451  %0 = linalg.matmul indexing_maps = [452                       affine_map<(d0, d1, d2) -> (d2, d0)>,453                       affine_map<(d0, d1, d2) -> (d2, d1)>,454                       affine_map<(d0, d1, d2) -> (d0, d1)>455                      ]456                      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)457                      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>458  return %0: tensor<4x64xf32>459}460 461// -----462 463func.func @invalid_transpose_b_matmul(%lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) -> tensor<4x64xf32> {464  // expected-error @+1 {{inferred input/output operand #1 has shape's dimension #1 to be 1, but found 64}}465  %0 = linalg.matmul indexing_maps = [466                       affine_map<(d0, d1, d2) -> (d0, d2)>,467                       affine_map<(d0, d1, d2) -> (d1, d2)>,468                       affine_map<(d0, d1, d2) -> (d0, d1)>469                      ]470                      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)471                      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>472  return %0: tensor<4x64xf32>473}474 475// -----476 477func.func @invalid_bcast_a(%arg0: memref<3xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {478  // expected-error @+1 {{'linalg.matmul' op Invalid broadcast requested, should be (d2)}}479  linalg.matmul indexing_maps = [480                       affine_map<(d0, d1, d2) -> (d0)>,481                       affine_map<(d0, d1, d2) -> (d1, d2)>,482                       affine_map<(d0, d1, d2) -> (d0, d1)>483                     ]484                     ins(%arg0, %arg1 : memref<3xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>)485  return486}487 488// -----489 490func.func @invalid_bcast_b(%arg0: memref<3x5xf32>, %arg1: memref<7xf32>, %arg2: memref<3x7xf32>) {491  // expected-error @+1 {{'linalg.matmul' op Invalid broadcast requested, should be (d2)}}492  linalg.matmul indexing_maps = [493                       affine_map<(d0, d1, d2) -> (d0, d2)>,494                       affine_map<(d0, d1, d2) -> (d1)>,495                       affine_map<(d0, d1, d2) -> (d0, d1)>496                     ]497                     ins(%arg0, %arg1 : memref<3x5xf32>, memref<7xf32>) outs(%arg2: memref<3x7xf32>)498  return499}500 501// -----502 503func.func @invalid_bcast_a_rank_mismatch(%arg0: memref<3x5xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {504  // expected-error @+1 {{'linalg.matmul' op expected operand rank (2) to match the result rank of indexing_map #0 (1)}}505  linalg.matmul indexing_maps = [506                       affine_map<(d0, d1, d2) -> (d2)>,507                       affine_map<(d0, d1, d2) -> (d2, d1)>,508                       affine_map<(d0, d1, d2) -> (d0, d1)>509                     ]510                     ins(%arg0, %arg1 : memref<3x5xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>)511  return512}513 514// -----515 516func.func @invalid_bcast_b_rank_mismatch(%arg0: memref<3x5xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {517  // expected-error @+1 {{'linalg.matmul' op expected operand rank (2) to match the result rank of indexing_map #1 (1)}}518  linalg.matmul indexing_maps = [519                       affine_map<(d0, d1, d2) -> (d0, d2)>,520                       affine_map<(d0, d1, d2) -> (d2)>,521                       affine_map<(d0, d1, d2) -> (d0, d1)>522                     ]523                     ins(%arg0, %arg1 : memref<3x5xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>)524  return525}526 527// -----528 529func.func @invalid_matmul_bcast_b_transpose_a(%arg0: memref<5x3xf32>, %arg1: memref<7xf32>, %arg2: memref<3x7xf32>) {530  // expected-error @+1 {{inferred input/output operand #1 has shape's dimension #0 to be 5, but found 7}}531  linalg.matmul indexing_maps = [532                       affine_map<(d0, d1, d2) -> (d2, d0)>,533                       affine_map<(d0, d1, d2) -> (d2)>,534                       affine_map<(d0, d1, d2) -> (d0, d1)>535                     ]536                     ins(%arg0, %arg1 : memref<5x3xf32>, memref<7xf32>) outs(%arg2: memref<3x7xf32>)537  return538}539 540// -----541 542func.func @invalid_matmul_bcast_b_transpose_a_wrong_dim(%arg0: memref<3x5xf32>, %arg1: memref<5xf32>, %arg2: memref<3x7xf32>) {543  // expected-error @+1 {{'linalg.matmul' op Unexpected dim expression in map result.}}544  linalg.matmul indexing_maps = [545                       affine_map<(d0, d1, d2) -> (d1, d2)>,546                       affine_map<(d0, d1, d2) -> (d2)>,547                       affine_map<(d0, d1, d2) -> (d0, d1)>548                     ]549                     ins(%arg0, %arg1 : memref<3x5xf32>, memref<5xf32>) outs(%arg2: memref<3x7xf32>)550  return551}552 553// -----554 555func.func @invalid_indexing_maps_placement_matmul(%lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {556  // expected-error @+2 {{custom op 'indexing_maps' is unknown (tried 'func.indexing_maps' as well)}}557  linalg.matmul ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>) outs(%init : tensor<4x64xf32>)558                        indexing_maps = [559                       affine_map<(d0, d1, d2) -> (d0, d2)>,560                       affine_map<(d0, d1, d2) -> (d2, d1)>,561                       affine_map<(d0, d1, d2) -> (d0, d1)>562                      ]563  return564}565 566// -----567 568func.func @invalid_indexing_maps_placement_contraction(569    %lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {570  // expected-error @+3 {{custom op 'linalg.contract' expected 'indexing_maps' attribute}}571  // NB: indexing_maps should be provided before ins and outs572  linalg.contract573      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)574      outs(%init : tensor<4x64xf32>)575      indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>,576                       affine_map<(d0, d1, d2) -> (d2, d1)>,577                       affine_map<(d0, d1, d2) -> (d0, d1)>]578  return579}580 581// -----582 583func.func @invalid_affine_map_in_indexing_maps_contraction(584    %lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {585  // expected-error @+1 {{provided affine_map is not a projected permutation}}586  linalg.contract587      indexing_maps = [affine_map<(d0, d1, d2) -> (d0 + d2, d2)>,588                       affine_map<(d0, d1, d2) -> (d2, d1)>,589                       affine_map<(d0, d1, d2) -> (d0, d1)>]590      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)591      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>592  return593}594 595// -----596 597func.func @differing_iteration_space_of_affine_maps_contraction(598    %lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {599  // expected-error @+1 {{iteration spaces of provided affine_maps differ}}600  linalg.contract601      indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>,602                       affine_map<(d0, d1, d2, d3) -> (d2, d1)>,603                       affine_map<(d0, d1, d2) -> (d0, d1)>]604      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)605      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>606  return607}608 609// -----610 611func.func @mismatched_ranks_affine_map_and_operand_contraction(612    %lhs: tensor<4x1x2xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {613  // expected-error @+1 {{ranks of shaped operand and results of corresponding affine_map differ}}614  linalg.contract615      indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>,616                       affine_map<(d0, d1, d2) -> (d2, d1)>,617                       affine_map<(d0, d1, d2) -> (d0, d1)>]618      ins(%lhs, %rhs : tensor<4x1x2xf32>, tensor<1x64xf32>)619      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>620  return621}622// -----623 624func.func @mismatch_type_affine_map_and_operand_contraction(625    %lhs: f32, %rhs: tensor<4x64xf32>, %init: tensor<4x64xf32>) {626  // expected-error @+1 {{affine_map specifies shaped access while operand has non-shaped type}}627  linalg.contract628      indexing_maps = [affine_map<(d0, d1) -> (d0)>,629                       affine_map<(d0, d1) -> (d0, d1)>,630                       affine_map<(d0, d1) -> (d0, d1)>]631      ins(%lhs, %rhs : f32, tensor<4x64xf32>)632      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>633  return634}635 636// -----637 638func.func @unused_iteration_space_dim_contraction(639    %lhs: tensor<4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {640  // expected-error @+1 {{iteration space dim at index 3 not used to access any operand}}641  linalg.contract642      indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d2)>,643                       affine_map<(d0, d1, d2, d3) -> (d2, d1)>,644                       affine_map<(d0, d1, d2, d3) -> (d0, d1)>]645      ins(%lhs, %rhs : tensor<4x1xf32>, tensor<1x64xf32>)646      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>647  return648}649 650// -----651 652func.func @unused_iteration_space_dim_contraction(653    %lhs: tensor<8x4x1xf32>, %rhs: tensor<1x64xf32>, %init: tensor<4x64xf32>) {654  // expected-error @+1 {{iteration space dim at index 3 is neither a contracting dim nor of parallel iteration type}}655  linalg.contract656      indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,657                       affine_map<(d0, d1, d2, d3) -> (d2, d1)>,658                       affine_map<(d0, d1, d2, d3) -> (d0, d1)>]659      ins(%lhs, %rhs : tensor<8x4x1xf32>, tensor<1x64xf32>)660      outs(%init : tensor<4x64xf32>) -> tensor<4x64xf32>661  return662}663 664// -----665 666func.func @invalid_static_2d_conv(%input : memref<1x3x4x2xf32>, %filter: memref<3x2x2x1xf32>, %output: memref<1x2x3x1xf32>) {667  // expected-error @+1 {{inferred input/output operand #0 has shape's dimension #1 to be greater than or equal to 4, but found 3}}668  linalg.conv_2d_nhwc_hwcf669    { dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}670    ins(%input, %filter : memref<1x3x4x2xf32>, memref<3x2x2x1xf32>)671    outs(%output : memref<1x2x3x1xf32>)672  return673}674 675// -----676 677#attrs = {678        indexing_maps = [679                affine_map<(i) -> (3 - i)>,680                affine_map<(i) -> (i)>681        ],682        iterator_types = ["parallel"]683}684 685func.func @invalid_reverse(%A: memref<5xf32>, %B: memref<5xf32>) {686  // expected-error @+1 {{unexpected result less than 0 at expression #0 in}}687  linalg.generic #attrs ins(%A: memref<5xf32>) outs(%B: memref<5xf32>) {688                ^bb0(%a: f32, %b: f32):689                linalg.yield %a : f32690        }691        return692}693 694// -----695 696func.func @map_binary_wrong_yield_operands(697    %lhs: tensor<64xf32>, %rhs: tensor<64xf32>, %init: tensor<64xf32>)698    -> tensor<64xf32> {699   %add = linalg.map700          ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>)701          outs(%init:tensor<64xf32>)702          (%lhs_elem: f32, %rhs_elem: f32, %out: f32) {703            %0 = arith.addf %lhs_elem, %rhs_elem: f32704            // expected-error @+1{{'linalg.yield' op expected number of yield values (2) to match the number of inits / outs operands of the enclosing LinalgOp (1)}}705            linalg.yield %0, %0: f32, f32706          }707  func.return %add : tensor<64xf32>708}709 710// -----711 712func.func @map_input_mapper_arity_mismatch(713    %lhs: tensor<64xf32>, %rhs: tensor<64xf32>, %init: tensor<64xf32>)714    -> tensor<64xf32> {715  // expected-error@+1{{'linalg.map' op expects number of operands to match the arity of mapper, but got: 3 and 4}}716  %add = linalg.map717      ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>)718      outs(%init:tensor<64xf32>)719      (%lhs_elem: f32, %rhs_elem: f32, %out: f32, %extra_elem: f32) {720        %0 = arith.addf %lhs_elem, %rhs_elem: f32721        linalg.yield %0: f32722      }723  func.return %add : tensor<64xf32>724}725 726// -----727 728func.func @map_input_mapper_type_mismatch(729    %lhs: tensor<64xf32>, %rhs: tensor<64xf32>, %init: tensor<64xf32>)730    -> tensor<64xf32> {731    // expected-error@+1{{'linalg.map' op expected element type of input 'f32' to match bbArg type 'f64'}}732  %add = linalg.map733      ins(%lhs, %rhs : tensor<64xf32>, tensor<64xf32>)734      outs(%init:tensor<64xf32>)735      (%lhs_elem: f64, %rhs_elem: f64, %out: f32) {736        %0 = arith.addf %lhs_elem, %rhs_elem: f64737        linalg.yield %0: f64738      }739  func.return %add : tensor<64xf32>740}741 742// -----743 744func.func @map_input_output_shape_mismatch(745    %lhs: tensor<64x64xf32>, %rhs: tensor<64x64xf32>, %init: tensor<32xf32>)746    -> tensor<32xf32> {747    // expected-error@+1{{'linalg.map' op expected shape of input (64, 64) to match shape of output (32)}}748  %add = linalg.map749      ins(%lhs, %rhs : tensor<64x64xf32>, tensor<64x64xf32>)750      outs(%init:tensor<32xf32>)751      (%lhs_elem: f32, %rhs_elem: f32, %out: f32) {752        %0 = arith.addf %lhs_elem, %rhs_elem: f32753        linalg.yield %0: f32754      }755  func.return %add : tensor<32xf32>756}757 758// -----759 760func.func @map_no_operands1() {761  // expected-error @+1 {{'linalg.map' op expected 1 or more operands, but found 0}}762  linalg.map { arith.addf }763}764 765// -----766 767func.func @map_no_operands2() {768  // expected-error @+1 {{'linalg.map' op expected 1 or more operands, but found 0}}769  "linalg.map"() ({770    ^bb0:771  }) : () -> ()772}773 774// -----775 776func.func @map_no_operands3(777    %lhs: tensor<64xf32>, %rhs: tensor<64xf32>, %init: tensor<64xf32>)778    -> tensor<64xf32> {779  // expected-error @+1 {{cannot name an operation with no results}}780  %add = linalg.map { arith.addf }781  func.return %add : tensor<64xf32>782}783 784// -----785 786func.func @reduce_input_vs_init_dimension_mismatch(787    %input: tensor<16x32x64xf32>,788    %init: tensor<16x64xf32>)  -> tensor<16x64xf32> {789  // expected-error @+1 {{'linalg.reduce' op init dimensions [16, 64] doesn't match input dimensions after reduction [16, 32]}}790  %reduce = linalg.reduce791      ins(%input:tensor<16x32x64xf32>)792      outs(%init:tensor<16x64xf32>)793      dimensions = [2]794      (%in: f32, %out: f32) {795        %0 = arith.addf %in, %out: f32796        linalg.yield %0: f32797      }798  func.return %reduce : tensor<16x64xf32>799}800 801// -----802 803func.func @reduce_dimensions_out_of_range(%input: tensor<16x32x64xf32>,804    %init: tensor<16x64xf32>)  -> tensor<16x64xf32> {805  // expected-error @+1 {{'linalg.reduce' op dimensions for reduction should be in the range [0, 2].}}806  %reduce = linalg.reduce807      ins(%input:tensor<16x32x64xf32>)808      outs(%init:tensor<16x64xf32>)809      dimensions = [3]810      (%in: f32, %out: f32) {811        %0 = arith.addf %in, %out: f32812        linalg.yield %0: f32813      }814  func.return %reduce : tensor<16x64xf32>815}816 817// -----818 819func.func @reduce_duplicate_dimensions(%input: tensor<16x32x64xf32>,820    %init: tensor<16xf32>)  -> tensor<16xf32> {821  // expected-error @+1 {{'linalg.reduce' op attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute should be in increasing order}}822  %reduce = linalg.reduce823      ins(%input:tensor<16x32x64xf32>)824      outs(%init:tensor<16xf32>)825      dimensions = [1, 1]826      (%in: f32, %out: f32) {827        %0 = arith.addf %in, %out: f32828        linalg.yield %0: f32829      }830  func.return %reduce : tensor<16xf32>831}832 833// -----834 835func.func @reduce_non_increasing_dimensions(%input: tensor<16x32x64xf32>,836    %init: tensor<16xf32>)  -> tensor<16xf32> {837  // expected-error @+1 {{'linalg.reduce' op attribute 'dimensions' failed to satisfy constraint: i64 dense array attribute should be in increasing order}}838  %reduce = linalg.reduce839      ins(%input:tensor<16x32x64xf32>)840      outs(%init:tensor<16xf32>)841      dimensions = [2, 1]842      (%in: f32, %out: f32) {843        %0 = arith.addf %in, %out: f32844        linalg.yield %0: f32845      }846  func.return %reduce : tensor<16xf32>847}848 849// -----850 851func.func @reduce_reduced_input_init_rank_mismatch(%input: tensor<16x32x64xf32>,852    %init: tensor<16x64xf32>)  -> tensor<16x64xf32> {853  // expected-error @+1 {{'linalg.reduce' op number of dimensions after reduction 1 doesn't match the init rank 2}}854  %reduce = linalg.reduce855      ins(%input:tensor<16x32x64xf32>)856      outs(%init:tensor<16x64xf32>)857      dimensions = [1, 2]858      (%in: f32, %out: f32) {859        %0 = arith.addf %in, %out: f32860        linalg.yield %0: f32861      }862  func.return %reduce : tensor<16x64xf32>863}864 865// -----866 867func.func @reduce_wrong_number_of_block_arguments(868    %input1: tensor<16x32x64xf32>,869    %init1: tensor<16x64xf32>, %input2: tensor<16x32x64xf32>,870    %init2: tensor<16x64xf32>)  -> (tensor<16x64xf32>, tensor<16x64xf32>) {871  // expected-error @+1{{'linalg.reduce' op mismatching number of operands and block arguments}}872  %reduce, %reduce2 = linalg.reduce873      ins(%input1, %input2 : tensor<16x32x64xf32>, tensor<16x32x64xf32>)874      outs(%init1, %init2 : tensor<16x64xf32>, tensor<16x64xf32>)875      dimensions = [1]876      (%in: f32, %out: f32) {877        %0 = arith.addf %in, %out: f32878        linalg.yield %0: f32879      }880  func.return %reduce, %reduce2 : tensor<16x64xf32>, tensor<16x64xf32>881}882 883// -----884 885func.func @reduce_wrong_block_argument_input_type(886    %input1: tensor<16x32x64xf32>,887    %init1: tensor<16x64xf32>, %input2: tensor<16x32x64xf32>,888    %init2: tensor<16x64xf32>)  -> (tensor<16x64xf32>, tensor<16x64xf32>) {889  // expected-error @+1{{'linalg.reduce' op input element type 'f32' does not match corresponding block argument type 'f64'}}890  %reduce, %reduce2 = linalg.reduce891      ins(%input1, %input2 : tensor<16x32x64xf32>, tensor<16x32x64xf32>)892      outs(%init1, %init2 : tensor<16x64xf32>, tensor<16x64xf32>)893      dimensions = [1]894      (%in1: f32, %in2: f64, %out1: f32, %out2: f64) {895        %0 = arith.addf %in1, %out1: f32896        %1 = arith.addf %in2, %out2: f64897        linalg.yield %0, %1: f32, f64898      }899  func.return %reduce, %reduce2 : tensor<16x64xf32>, tensor<16x64xf32>900}901 902// -----903 904func.func @reduce_wrong_block_argument_output_type(905    %input1: tensor<16x32x64xf32>,906    %init1: tensor<16x64xf32>, %input2: tensor<16x32x64xf32>,907    %init2: tensor<16x64xf64>)  -> (tensor<16x64xf32>, tensor<16x64xf32>) {908  // expected-error @+1{{'linalg.reduce' op output element type 'f64' does not match corresponding block argument type 'f32'}}909  %reduce, %reduce2 = linalg.reduce910      ins(%input1, %input2 : tensor<16x32x64xf32>, tensor<16x32x64xf32>)911      outs(%init1, %init2 : tensor<16x64xf32>, tensor<16x64xf64>)912      dimensions = [1]913      (%in1: f32, %in2: f32, %out1: f32, %out2: f32) {914        %0 = arith.addf %in1, %out1: f32915        linalg.yield %0, %out2: f32, f32916      }917  func.return %reduce, %reduce2 : tensor<16x64xf32>, tensor<16x64xf64>918}919 920// -----921 922func.func @reduce_different_input_shapes(%input1: tensor<16x32x64xf32>,923    %init1: tensor<16x64xf32>, %input2: tensor<17x32x64xf32>,924    %init2: tensor<17x64xf32>)  -> (tensor<16x64xf32>, tensor<17x64xf32>) {925  // expected-error @+1{{'linalg.reduce' op expects all inputs to have the same shapes. Shape at input-index 1 is not equal to the shape at input-index 0.}}926  %reduce, %reduce2 = linalg.reduce927      ins(%input1, %input2 : tensor<16x32x64xf32>, tensor<17x32x64xf32>)928      outs(%init1, %init2 : tensor<16x64xf32>, tensor<17x64xf32>)929      dimensions = [1]930      (%in1: f32, %in2: f32, %out1: f32, %out2: f32) {931        %0 = arith.addf %in1, %out1: f32932        %1 = arith.addf %in2, %out2: f32933        linalg.yield %0, %1: f32, f32934      }935  func.return %reduce, %reduce2 : tensor<16x64xf32>, tensor<17x64xf32>936}937 938// -----939 940func.func @reduce_different_output_shapes(%input1: tensor<16x32x64xf32>,941    %init1: tensor<16x64xf32>, %input2: tensor<16x32x64xf32>,942    %init2: tensor<17x64xf32>)  -> (tensor<16x64xf32>, tensor<17x64xf32>) {943  // expected-error @+1{{'linalg.reduce' op expects all outputs to have the same shapes. Shape at output-index 1 is not equal to the shape at output-index 0.}}944  %reduce, %reduce2 = linalg.reduce945      ins(%input1, %input2 : tensor<16x32x64xf32>, tensor<16x32x64xf32>)946      outs(%init1, %init2 : tensor<16x64xf32>, tensor<17x64xf32>)947      dimensions = [1]948      (%in1: f32, %in2: f32, %out1: f32, %out2: f32) {949        %0 = arith.addf %in1, %out1: f32950        %1 = arith.addf %in2, %out2: f32951        linalg.yield %0, %1: f32, f32952      }953  func.return %reduce, %reduce2 : tensor<16x64xf32>, tensor<17x64xf32>954}955 956// -----957 958func.func @transpose_invalid_permutation(%input: tensor<16x32x64xf32>,959    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {960  // expected-error @+1 {{'linalg.transpose' op permutation is not valid}}961  %transpose = linalg.transpose962      ins(%input:tensor<16x32x64xf32>)963      outs(%init:tensor<32x64x16xf32>)964      permutation = [1, 1, 2]965  func.return %transpose : tensor<32x64x16xf32>966}967 968// -----969 970func.func @transpose_out_of_range_permutation(%input: tensor<16x32x64xf32>,971    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {972  // expected-error @+1 {{'linalg.transpose' op permutation is not valid}}973  %transpose = linalg.transpose974      ins(%input:tensor<16x32x64xf32>)975      outs(%init:tensor<32x64x16xf32>)976      permutation = [1, 2, 3]977  func.return %transpose : tensor<32x64x16xf32>978}979 980// -----981 982func.func @transpose_negative_permutation(%input: tensor<16x32x64xf32>,983    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {984  // expected-error @+1 {{'linalg.transpose' op permutation is not valid}}985  %transpose = linalg.transpose986      ins(%input:tensor<16x32x64xf32>)987      outs(%init:tensor<32x64x16xf32>)988      permutation = [1, 2, -1]989  func.return %transpose : tensor<32x64x16xf32>990}991// -----992func.func @transpose_permutated_dims_mismatch(%input: tensor<16x32x64xf32>,993    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {994  // expected-error @+1 {{'linalg.transpose' op dim(result, 0) = 32 doesn't match dim(input, permutation[0]) = 16}}995  %transpose = linalg.transpose996      ins(%input:tensor<16x32x64xf32>)997      outs(%init:tensor<32x64x16xf32>)998      permutation = [0, 1, 2]999  func.return %transpose : tensor<32x64x16xf32>1000}1001 1002// -----1003 1004func.func @transpose_rank_permutation_size_mismatch(1005    %input: tensor<16x32x64xf32>,1006    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {1007  // expected-error @+1 {{'linalg.transpose' op size of permutation 2 does not match the argument rank 3}}1008  %transpose = linalg.transpose1009      ins(%input:tensor<16x32x64xf32>)1010      outs(%init:tensor<32x64x16xf32>)1011      permutation = [1, 0]1012  func.return %transpose : tensor<32x64x16xf32>1013}1014 1015// -----1016 1017func.func @transpose_input_init_rank_mismatch(%input: tensor<16x32xf32>,1018    %init: tensor<32x64x16xf32>) -> tensor<32x64x16xf32> {1019  // expected-error @+1 {{'linalg.transpose' op input rank 2 does not match init rank 3}}1020  %transpose = linalg.transpose1021      ins(%input:tensor<16x32xf32>)1022      outs(%init:tensor<32x64x16xf32>)1023      permutation = [1, 0, 2]1024  func.return %transpose : tensor<32x64x16xf32>1025}1026 1027// -----1028 1029func.func @transpose_no_operands1() {1030  // expected-error @+1 {{'linalg.transpose' op expected 2 operands, but found 0}}1031  linalg.transpose permutation = [1, 0, 2]1032}1033 1034// -----1035 1036func.func @transpose_no_operands2() {1037  // expected-error @+1 {{'linalg.transpose' op expected 2 operands, but found 0}}1038  "linalg.transpose"() <{permutation = array<i64: 1, 0, 2>}> ({1039    ^bb0:1040  }) : () -> ()1041}1042 1043// -----1044 1045func.func @transpose_no_operands3() -> tensor<32x64x16xf32> {1046  // expected-error @+1 {{cannot name an operation with no results}}1047  %transpose = linalg.transpose permutation = [1, 0, 2]1048  func.return %transpose : tensor<32x64x16xf32>1049}1050 1051// -----1052 1053func.func @broadcast_input_dims_rank_mismatch(1054    %input: tensor<4x16xf32>, %init: tensor<4x8x16xf32>)1055    -> tensor<4x8x16xf32> {1056  // expected-error @+1 {{'linalg.broadcast' op input rank plus added dimensions does not match init rank. }}1057  %bcast = linalg.broadcast1058      ins(%input:tensor<4x16xf32>)1059      outs(%init:tensor<4x8x16xf32>)1060      dimensions = [1, 2]1061  func.return %bcast : tensor<4x8x16xf32>1062}1063 1064// -----1065 1066func.func @broadcast_unsorted_dims(1067    %input: tensor<4x16xf32>, %init: tensor<4x8x16xf32>)1068    -> tensor<4x8x16xf32> {1069  // expected-error @+1 {{'linalg.broadcast' op dimension 0 is out of range. expected range: [0, 2], got: 5}}1070  %bcast = linalg.broadcast1071      ins(%input:tensor<4x16xf32>)1072      outs(%init:tensor<4x8x16xf32>)1073      dimensions = [5]1074  func.return %bcast : tensor<4x8x16xf32>1075}1076 1077// -----1078 1079func.func @broadcast_mapped_dim_mismatch(1080    %input: tensor<4x16xf32>, %init: tensor<5x8x16xf32>)1081    -> tensor<5x8x16xf32> {1082  // expected-error @+1 {{'linalg.broadcast' op input dim 0 should match init dim 0. input: 4, init: 5}}1083  %bcast = linalg.broadcast1084      ins(%input:tensor<4x16xf32>)1085      outs(%init:tensor<5x8x16xf32>)1086      dimensions = [1]1087  func.return %bcast : tensor<5x8x16xf32>1088}1089 1090// -----1091 1092func.func @broadcast_size_1_extension_not_supported(1093    %input: tensor<1x16xf32>, %init: tensor<4x?x16xf32>)1094    -> tensor<4x?x16xf32> {1095  // expected-error @+1 {{'linalg.broadcast' op input dim 0 should match init dim 0. input: 1, init: 4}}1096  %bcast = linalg.broadcast1097      ins(%input:tensor<1x16xf32>)1098      outs(%init:tensor<4x?x16xf32>)1099      dimensions = [1]1100  func.return %bcast : tensor<4x?x16xf32>1101}1102 1103// -----1104 1105func.func @broadcast_no_operands1() {1106  // expected-error @+1 {{'linalg.broadcast' op expected 2 operands, but found 0}}1107  linalg.broadcast dimensions = [1]1108}1109 1110// -----1111 1112func.func @broadcast_no_operands2() {1113  // expected-error @+1 {{'linalg.broadcast' op expected 2 operands, but found 0}}1114  "linalg.broadcast"() <{dimensions = array<i64: 1>}> ({1115    ^bb0:1116  }) : () -> ()1117}1118 1119// -----1120 1121func.func @broadcast_no_operands3()1122    -> tensor<4x?x16xf32> {1123  // expected-error @+1 {{cannot name an operation with no results}}1124  %broadcast = linalg.broadcast dimensions = [1]1125  func.return %broadcast : tensor<32x64x16xf32>1126}1127 1128// -----1129 1130func.func @missing_iterator_types() {1131  // expected-error @below {{expected "iterator_types" array attribute}}1132  linalg.generic {} ins() outs()1133  return1134}1135 1136// -----1137 1138func.func @illegal_softmax_output_shape(%arg0: tensor<2x16x32xf32>) -> tensor<2x16xf32> {1139  %0 = tensor.empty() : tensor<2x16xf32>1140  // expected-error @+1 {{incompatible output shape}}1141  %1 = linalg.softmax dimension(2) ins(%arg0 : tensor<2x16x32xf32>)1142                                   outs(%0: tensor<2x16xf32>)1143    -> tensor<2x16xf32>1144  return %1 : tensor<2x16xf32>1145}1146 1147// -----1148 1149func.func @mmt4d_dims_mismatch(%A: tensor<16x16x8x1xf32>,1150                               %B: tensor<16x16x8x1xf32>,1151                               %C_in: tensor<16x16x8x1xf32>) -> tensor<16x16x8x1xf32> {1152    // expected-error @+1 {{inferred input/output operand #2 has shape's dimension #3 to be 8, but found 1}}1153    %res = linalg.mmt4d1154                     ins(%A, %B: tensor<16x16x8x1xf32>, tensor<16x16x8x1xf32>)1155                     outs(%C_in: tensor<16x16x8x1xf32>)1156                     -> tensor<16x16x8x1xf32>1157    return %res : tensor<16x16x8x1xf32>1158}1159 1160// -----1161 1162func.func @mmt4d_rank_mismatch(%A: tensor<16x16x8x1xf32>,1163                 %B: tensor<16x16x8x1xf32>,1164                 %C_in: tensor<8x8xf32>) -> tensor<8x8xf32> {1165    // expected-error @+1 {{expected operand rank (2) to match the result rank of indexing_map #2 (4)}}1166    %res = linalg.mmt4d1167                     ins(%A, %B: tensor<16x16x8x1xf32>, tensor<16x16x8x1xf32>)1168                     outs(%C_in: tensor<8x8xf32>)1169                     -> tensor<8x8xf32>1170    return %res : tensor<8x8xf32>1171}1172 1173// -----1174 1175func.func @mixed_semantics(%a: tensor<?x?xf32>, %b: tensor<?x?xf32>, %c: memref<?x?xf32>) {1176  // expected-error @+1 {{expected to have pure tensor or buffer semantics}}1177  linalg.matmul ins(%a, %b: tensor<?x?xf32>, tensor<?x?xf32>)1178               outs(%c: memref<?x?xf32>)1179  return1180}1181 1182// -----1183 1184func.func @winograd_filter_transform_height(%arg0: tensor<2x4x3x5xf32>, %arg1: tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32> {1185  // expected-error @+1 {{expect filter height either equals to r or 1}}1186  %0 = linalg.winograd_filter_transform fmr(F_4_3) ins(%arg0 : tensor<2x4x3x5xf32>) outs(%arg1 : tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32>1187  return %0 : tensor<6x6x5x2xf32>1188}1189 1190// -----1191 1192func.func @winograd_filter_transform_width(%arg0: tensor<2x3x4x5xf32>, %arg1: tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32> {1193  // expected-error @+1 {{expect filter width either equals to r or 1}}1194  %0 = linalg.winograd_filter_transform fmr(F_4_3) ins(%arg0 : tensor<2x3x4x5xf32>) outs(%arg1 : tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32>1195  return %0 : tensor<6x6x5x2xf32>1196}1197 1198// -----1199 1200func.func @winograd_filter_transform(%arg0: tensor<2x1x1x5xf32>, %arg1: tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32> {1201  // expected-error @+1 {{expect either filter height or width equals to r}}1202  %0 = linalg.winograd_filter_transform fmr(F_4_3) ins(%arg0 : tensor<2x1x1x5xf32>) outs(%arg1 : tensor<6x6x5x2xf32>) -> tensor<6x6x5x2xf32>1203  return %0 : tensor<6x6x5x2xf32>1204}1205 1206// -----1207 1208func.func @winograd_filter_dyn(%arg0: tensor<?x3x3x?xf32>, %arg1: tensor<6x5x?x?xf32>) -> tensor<6x5x?x?xf32> {1209  // expected-error @+1 {{the output shape is not expected}}1210  %0 = linalg.winograd_filter_transform fmr(F_4_3) ins(%arg0 : tensor<?x3x3x?xf32>) outs(%arg1 : tensor<6x5x?x?xf32>) -> tensor<6x5x?x?xf32>1211  return %0 : tensor<6x5x?x?xf32>1212}1213 1214// -----1215 1216func.func @winograd_input_transform_height(%arg0: tensor<2x13x14x5xf32>, %arg1: tensor<6x6x3x3x2x5xf32>) -> tensor<6x6x3x3x2x5xf32> {1217  // expected-error @+1 {{the output shape is not expected}}1218  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x13x14x5xf32>) outs(%arg1 : tensor<6x6x3x3x2x5xf32>) -> tensor<6x6x3x3x2x5xf32>1219  return %0 : tensor<6x6x3x3x2x5xf32>1220}1221 1222// -----1223 1224func.func @winograd_input_transform_width(%arg0: tensor<2x14x13x5xf32>, %arg1: tensor<6x6x3x3x2x5xf32>) -> tensor<6x6x3x3x2x5xf32> {1225  // expected-error @+1 {{the output shape is not expected}}1226  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x14x13x5xf32>) outs(%arg1 : tensor<6x6x3x3x2x5xf32>) -> tensor<6x6x3x3x2x5xf32>1227  return %0 : tensor<6x6x3x3x2x5xf32>1228}1229 1230// -----1231 1232func.func @winograd_input_transform_output_tileH(%arg0: tensor<2x14x14x5xf32>, %arg1: tensor<6x6x2x3x2x5xf32>) -> tensor<6x6x2x3x2x5xf32> {1233  // expected-error @+1 {{the output shape is not expected}}1234  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x14x14x5xf32>) outs(%arg1 : tensor<6x6x2x3x2x5xf32>) -> tensor<6x6x2x3x2x5xf32>1235  return %0 : tensor<6x6x2x3x2x5xf32>1236}1237 1238// -----1239 1240func.func @winograd_input_transform_output_tileW(%arg0: tensor<2x14x14x5xf32>, %arg1: tensor<6x6x3x2x2x5xf32>) -> tensor<6x6x3x2x2x5xf32> {1241  // expected-error @+1 {{the output shape is not expected}}1242  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x14x14x5xf32>) outs(%arg1 : tensor<6x6x3x2x2x5xf32>) -> tensor<6x6x3x2x2x5xf32>1243  return %0 : tensor<6x6x3x2x2x5xf32>1244}1245 1246// -----1247 1248func.func @winograd_input_transform_output_height(%arg0: tensor<2x14x14x5xf32>, %arg1: tensor<5x6x3x3x2x5xf32>) -> tensor<5x6x3x3x2x5xf32> {1249  // expected-error @+1 {{the output shape is not expected}}1250  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x14x14x5xf32>) outs(%arg1 : tensor<5x6x3x3x2x5xf32>) -> tensor<5x6x3x3x2x5xf32>1251  return %0 : tensor<5x6x3x3x2x5xf32>1252}1253 1254// -----1255 1256func.func @winograd_input_transform_output_width(%arg0: tensor<2x14x14x5xf32>, %arg1: tensor<6x5x3x3x2x5xf32>) -> tensor<6x5x3x3x2x5xf32> {1257  // expected-error @+1 {{the output shape is not expected}}1258  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<2x14x14x5xf32>) outs(%arg1 : tensor<6x5x3x3x2x5xf32>) -> tensor<6x5x3x3x2x5xf32>1259  return %0 : tensor<6x5x3x3x2x5xf32>1260}1261 1262// -----1263 1264func.func @winograd_input_dyn(%arg0: tensor<?x?x?x?xf32>, %arg1: tensor<6x5x?x?x?x?xf32>) -> tensor<6x5x?x?x?x?xf32> {1265  // expected-error @+1 {{the output shape is not expected}}1266  %0 = linalg.winograd_input_transform fmr(F_4_3) ins(%arg0 : tensor<?x?x?x?xf32>) outs(%arg1 : tensor<6x5x?x?x?x?xf32>) -> tensor<6x5x?x?x?x?xf32>1267  return %0 : tensor<6x5x?x?x?x?xf32>1268}1269 1270// -----1271 1272func.func @winograd_output_transform_input_height(%arg0: tensor<5x6x3x3x2x2xf32>, %arg1: tensor<2x12x12x2xf32>) -> tensor<2x12x12x2xf32> {1273  // expected-error @+1 {{expect input height equals to input tile size}}1274  %0 = linalg.winograd_output_transform fmr(F_4_3) ins(%arg0 : tensor<5x6x3x3x2x2xf32>) outs(%arg1 : tensor<2x12x12x2xf32>) -> tensor<2x12x12x2xf32>1275  return %0 : tensor<2x12x12x2xf32>1276}1277 1278// -----1279 1280func.func @winograd_output_transform_input_width(%arg0: tensor<6x5x3x3x2x2xf32>, %arg1: tensor<2x12x12x2xf32>) -> tensor<2x12x12x2xf32> {1281  // expected-error @+1 {{expect input width equals to input tile size}}1282  %0 = linalg.winograd_output_transform fmr(F_4_3) ins(%arg0 : tensor<6x5x3x3x2x2xf32>) outs(%arg1 : tensor<2x12x12x2xf32>) -> tensor<2x12x12x2xf32>1283  return %0 : tensor<2x12x12x2xf32>1284}1285 1286// -----1287 1288func.func @winograd_output_transform_output_height(%arg0: tensor<6x6x3x3x2x2xf32>, %arg1: tensor<2x11x12x2xf32>) -> tensor<2x11x12x2xf32> {1289  // expected-error @+1 {{the output shape is not expected}}1290  %0 = linalg.winograd_output_transform fmr(F_4_3) ins(%arg0 : tensor<6x6x3x3x2x2xf32>) outs(%arg1 : tensor<2x11x12x2xf32>) -> tensor<2x11x12x2xf32>1291  return %0 : tensor<2x11x12x2xf32>1292}1293 1294// -----1295 1296func.func @winograd_output_transform_output_width(%arg0: tensor<6x6x3x3x2x2xf32>, %arg1: tensor<2x12x11x2xf32>) -> tensor<2x12x11x2xf32> {1297  // expected-error @+1 {{the output shape is not expected}}1298  %0 = linalg.winograd_output_transform fmr(F_4_3) ins(%arg0 : tensor<6x6x3x3x2x2xf32>) outs(%arg1 : tensor<2x12x11x2xf32>) -> tensor<2x12x11x2xf32>1299  return %0 : tensor<2x12x11x2xf32>1300}1301 1302// -----1303 1304func.func @indexing_map_size_mismatch_batch_matmul(%arg0: memref<?x?x?xf32>,1305     %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1306     // expected-error @+1 {{Indexing_map attribute must have 3 affine maps}}1307     linalg.batch_matmul indexing_maps = [1308      affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1309      affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>1310    ]1311    ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1312    outs(%arg2: memref<?x?x?xf32>)1313    return1314}1315 1316// -----1317 1318func.func @indexing_map_size_one_batch_matmul(%arg0: memref<?x?x?xf32>,1319     %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1320     // expected-error @+1 {{Indexing_map attribute must have 3 affine maps}}1321     linalg.batch_matmul indexing_maps = [1322      affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1323    ]1324    ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1325    outs(%arg2: memref<?x?x?xf32>)1326    return1327 1328}1329 1330// -----1331 1332func.func @missing_indexing_map_batch_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1333  // expected-error @+1 {{expected attribute value}}1334  linalg.batch_matmul indexing_maps = [1335                       ,1336                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1337                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1338                      ]1339                      ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1340                      outs(%arg2 :memref<?x?x?xf32>)1341  return1342}1343 1344// -----1345 1346func.func @invalid_dim_expr_batch_matmul_a(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1347  // expected-error @+1 {{Unexpected result dim expression (outside the set of default result dims)}}1348  linalg.batch_matmul indexing_maps = [1349                       affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,1350                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1351                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1352                     ]1353                     ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2 :memref<?x?x?xf32>)1354  return1355}1356 1357// -----1358 1359func.func @invalid_dim_expr_batch_matmul_b(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1360  // expected-error @+1 {{Unexpected result dim expression (outside the set of default result dims)}}1361  linalg.batch_matmul indexing_maps = [1362                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1363                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d1)>,1364                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1365                     ]1366                     ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2 :memref<?x?x?xf32>)1367  return1368}1369 1370// -----1371 1372func.func @invalid_bcast_batch_matmul_a(%arg0: memref<?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1373  // expected-error @+1 {{'linalg.batch_matmul' op Invalid broadcast requested}}1374  linalg.batch_matmul indexing_maps = [1375                       affine_map<(d0, d1, d2, d3) -> (d0)>,1376                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1377                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1378                     ]1379                     ins(%arg0, %arg1 : memref<?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)1380  return1381}1382 1383// -----1384 1385func.func @invalid_single_dim_bcast_expr_batch_matmul_a(%arg0: memref<?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1386  // expected-error @+1 {{'linalg.batch_matmul' op Invalid broadcast requested}}1387  linalg.batch_matmul indexing_maps = [1388                       affine_map<(d0, d1, d2, d3) -> (d3, d0)>,1389                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1390                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1391                     ]1392                     ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)1393  return1394}1395 1396// -----1397 1398func.func @invalid_single_dim_bcast_expr_batch_matmul_B(%A: memref<?x?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?x?xf32>) {1399  // expected-error @+1 {{'linalg.batch_matmul' op Invalid broadcast requested}}1400  linalg.batch_matmul indexing_maps = [1401                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1402                       affine_map<(d0, d1, d2, d3) -> (d3, d0)>,1403                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1404                     ]1405                     ins(%A, %B : memref<?x?x?xf32>, memref<?x?xf32>) outs(%C: memref<?x?x?xf32>)1406  return1407}1408 1409// -----1410 1411func.func @invalid_bcast_batch_matmul_b(%arg0: memref<?x?x?xf32>, %arg1: memref<?xf32>, %arg2: memref<?x?x?xf32>) {1412  // expected-error @+1 {{'linalg.batch_matmul' op Invalid broadcast requested}}1413  linalg.batch_matmul indexing_maps = [1414                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1415                       affine_map<(d0, d1, d2, d3) -> (d2)>,1416                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1417                     ]1418                     ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?xf32>) outs(%arg2: memref<?x?x?xf32>)1419  return1420}1421 1422// -----1423 1424func.func @invalid_batch_dim_batch_matmul_a(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1425  // expected-error @+1 {{'linalg.batch_matmul' op Invalid batch dimension expression}}1426  linalg.batch_matmul indexing_maps = [1427                       affine_map<(d0, d1, d2, d3) -> (d1, d0, d3)>,1428                       affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1429                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1430                     ]1431                     ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2 :memref<?x?x?xf32>)1432  return1433}1434 1435// -----1436 1437func.func @invalid_batch_dim_batch_matmul_b(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1438  // expected-error @+1 {{'linalg.batch_matmul' op Invalid batch dimension expression}}1439  linalg.batch_matmul indexing_maps = [1440                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1441                       affine_map<(d0, d1, d2, d3) -> (d2, d3, d0)>,1442                       affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1443                     ]1444                     ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2 :memref<?x?x?xf32>)1445  return1446}1447 1448// -----1449 1450func.func @invalid_A_map_result_num_batch_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1451  // expected-error @+1 {{'linalg.batch_matmul' op no. of result dim expressions exceeds 3.}}1452  linalg.batch_matmul indexing_maps = [1453                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d3, d3)>,1454                            affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1455                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1456                           ]1457    ins(%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>)1458    outs(%arg2: memref<?x?xf32>)1459    return1460}1461 1462// -----1463 1464func.func @invalid_B_map_result_num_batch_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1465  // expected-error @+1 {{'linalg.batch_matmul' op no. of result dim expressions exceeds 3.}}1466  linalg.batch_matmul indexing_maps = [1467                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1468                            affine_map<(d0, d1, d2, d3) -> (d0, d3, d2, d3)>,1469                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1470                           ]1471    ins(%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>)1472    outs(%arg2: memref<?x?xf32>)1473    return1474}1475 1476// -----1477 1478func.func @invalid_C_map_result_num_batch_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1479  // expected-error @+1 {{'linalg.batch_matmul' op expects 3 dims, but got (2).}}1480  linalg.batch_matmul indexing_maps = [1481                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1482                            affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1483                            affine_map<(d0, d1, d2, d3) -> (d1, d2)>1484                           ]1485    ins(%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>)1486    outs(%arg2: memref<?x?xf32>)1487    return1488}1489 1490// -----1491 1492func.func @invalid_C_map_result_dim_batch_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1493  // expected-error @+1 {{'linalg.batch_matmul' op Invalid output map result dimension.}}1494  linalg.batch_matmul indexing_maps = [1495                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1496                            affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1497                            affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1498                           ]1499    ins(%arg0, %arg1: memref<?x?x?xf32>, memref<?x?x?xf32>)1500    outs(%arg2: memref<?x?x?xf32>)1501    return1502}1503 1504 1505// -----1506 1507//===----------------------------------------------------------------------===//1508// linalg.batch_reduce_matmul1509//===----------------------------------------------------------------------===//1510 1511func.func @missing_one_indexing_map(%arg0: memref<?x?x?xf32>,1512     %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1513     // expected-error @+1 {{Indexing_map attribute must have 3 affine maps}}1514     linalg.batch_reduce_matmul1515         indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1516                          affine_map<(batch, m, n, k) -> (batch, n, k)>]1517         ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1518         outs(%arg2: memref<?x?xf32>)1519     return1520}1521 1522// -----1523 1524func.func @missing_two_indexing_map(%arg0: memref<?x?x?xf32>,1525     %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1526     // expected-error @+1 {{Indexing_map attribute must have 3 affine maps}}1527     linalg.batch_reduce_matmul1528         indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>]1529         ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1530         outs(%arg2: memref<?x?xf32>)1531     return1532 1533}1534 1535// -----1536 1537func.func @missing_indexing_map(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1538  // expected-error @+1 {{expected attribute value}}1539  linalg.batch_reduce_matmul indexing_maps = [1540                       ,1541                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1542                       affine_map<(batch, m, n, k) -> (m, n)>]1543      ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>)1544      outs(%arg2 :memref<?x?xf32>)1545  return1546}1547 1548// -----1549 1550func.func @invalid_dim_expr_A(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1551  // expected-error @+1 {{Unexpected result dim expression (outside the set of default result dims)}}1552  linalg.batch_reduce_matmul1553      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, n, k)>,1554                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1555                       affine_map<(batch, m, n, k) -> (m, n)>]1556      ins(%A, %B : memref<?x?x?xf32>, memref<?x?x?xf32>)1557      outs(%C :memref<?x?xf32>)1558  return1559}1560 1561// -----1562 1563func.func @invalid_dim_expr_B(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1564  // expected-error @+1 {{Unexpected result dim expression (outside the set of default result dims)}}1565  linalg.batch_reduce_matmul1566      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1567                       affine_map<(batch, m, n, k) -> (batch, k, m)>,1568                       affine_map<(batch, m, n, k) -> (m, n)>]1569      ins(%A, %B : memref<?x?x?xf32>, memref<?x?x?xf32>)1570      outs(%C :memref<?x?xf32>)1571  return1572}1573 1574// -----1575 1576func.func @invalid_bcast_A(%A: memref<?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1577  // expected-error @+1 {{Invalid broadcast requested}}1578  linalg.batch_reduce_matmul1579      indexing_maps = [affine_map<(batch, m, n, k) -> (batch)>,1580                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1581                       affine_map<(batch, m, n, k) -> (m, n)>]1582      ins(%A, %B : memref<?xf32>, memref<?x?x?xf32>)1583      outs(%C: memref<?x?xf32>)1584  return1585}1586 1587// -----1588 1589func.func @invalid_multi_dim_bcast_expr_A(%A: memref<?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1590  // expected-error @+1 {{Invalid broadcast requested}}1591  linalg.batch_reduce_matmul1592      indexing_maps = [affine_map<(batch, m, n, k) -> (k, batch)>,1593                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1594                       affine_map<(batch, m, n, k) -> (m, n)>]1595      ins(%A, %B : memref<?x?xf32>, memref<?x?x?xf32>)1596      outs(%C: memref<?x?xf32>)1597  return1598}1599 1600// -----1601 1602func.func @invalid_multi_dim_bcast_expr_B(%A: memref<?x?x?xf32>, %B: memref<?x?xf32>, %C: memref<?x?xf32>) {1603  // expected-error @+1 {{Invalid broadcast requested}}1604  linalg.batch_reduce_matmul1605      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1606                       affine_map<(batch, m, n, k) -> (k, batch)>,1607                       affine_map<(batch, m, n, k) -> (m, n)>]1608      ins(%A, %B : memref<?x?x?xf32>, memref<?x?xf32>)1609      outs(%C: memref<?x?xf32>)1610  return1611}1612 1613// -----1614 1615func.func @invalid_bcast_B(%A: memref<?x?x?xf32>, %B: memref<?xf32>, %C: memref<?x?xf32>) {1616  // expected-error @+1 {{Invalid broadcast requested}}1617  linalg.batch_reduce_matmul1618      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1619                       affine_map<(batch, m, n, k) -> (n)>,1620                       affine_map<(batch, m, n, k) -> (batch, m, n)>]1621      ins(%A, %B : memref<?x?x?xf32>, memref<?xf32>)1622      outs(%C: memref<?x?xf32>)1623  return1624}1625 1626// -----1627 1628func.func @invalid_batch_dim_A(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1629  // expected-error @+1 {{Invalid batch dimension expression}}1630  linalg.batch_reduce_matmul1631      indexing_maps = [affine_map<(batch, m, n, k) -> (m, batch, k)>,1632                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1633                       affine_map<(batch, m, n, k) -> (m, n)>]1634      ins(%A, %B : memref<?x?x?xf32>, memref<?x?x?xf32>)1635      outs(%C :memref<?x?xf32>)1636  return1637}1638 1639// -----1640 1641func.func @invalid_batch_dim_B(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1642  // expected-error @+1 {{Invalid batch dimension expression}}1643  linalg.batch_reduce_matmul1644      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1645                       affine_map<(batch, m, n, k) -> (n, k, batch)>,1646                       affine_map<(batch, m, n, k) -> (m, n)>]1647      ins(%A, %B : memref<?x?x?xf32>, memref<?x?x?xf32>)1648      outs(%C :memref<?x?xf32>)1649  return1650}1651 1652// -----1653 1654func.func @invalid_A_map_result_num(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1655  // expected-error @+1 {{no. of result dim expressions exceeds 3.}}1656  linalg.batch_reduce_matmul1657      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k, k)>,1658                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1659                       affine_map<(batch, m, n, k) -> (m, n)>]1660      ins(%A, %B: memref<?x?x?xf32>, memref<?x?x?xf32>)1661      outs(%C: memref<?x?xf32>)1662  return1663}1664 1665// -----1666 1667func.func @invalid_B_map_result_num(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1668  // expected-error @+1 {{no. of result dim expressions exceeds 3.}}1669  linalg.batch_reduce_matmul1670      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1671                       affine_map<(batch, m, n, k) -> (batch, k, n, k)>,1672                       affine_map<(batch, m, n, k) -> (m, n)>]1673      ins(%A, %B: memref<?x?x?xf32>, memref<?x?x?xf32>)1674      outs(%C: memref<?x?xf32>)1675  return1676}1677 1678// -----1679 1680func.func @invalid_C_map_result_num(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1681  // expected-error @+1 {{expects 2 dims, but got (1).}}1682  linalg.batch_reduce_matmul1683      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1684                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1685                       affine_map<(batch, m, n, k) -> (m)>]1686      ins(%A, %B: memref<?x?x?xf32>, memref<?x?x?xf32>)1687      outs(%C: memref<?x?xf32>)1688  return1689}1690 1691// -----1692 1693func.func @invalid_C_map_result_dim(%A: memref<?x?x?xf32>, %B: memref<?x?x?xf32>, %C: memref<?x?xf32>) {1694  // expected-error @+1 {{Invalid output map result dimension.}}1695  linalg.batch_reduce_matmul1696      indexing_maps = [affine_map<(batch, m, n, k) -> (batch, m, k)>,1697                       affine_map<(batch, m, n, k) -> (batch, k, n)>,1698                       affine_map<(batch, m, n, k) -> (m, k)>]1699      ins(%A, %B: memref<?x?x?xf32>, memref<?x?x?xf32>)1700      outs(%C: memref<?x?xf32>)1701  return1702}1703 1704// -----1705 1706//===----------------------------------------------------------------------===//1707// linalg.pack1708//===----------------------------------------------------------------------===//1709 1710func.func @pack_invalid_no_padding_no_full_tiles(%input: tensor<256x128xf32>, %output: tensor<8x8x16x33xf32>) -> tensor<8x8x16x33xf32> {1711  // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}1712  %0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [16, 33] into %output : tensor<256x128xf32>  -> tensor<8x8x16x33xf32>1713  return %0 : tensor<8x8x16x33xf32>1714}1715 1716// -----1717 1718func.func @pack_invalid_no_padding_no_full_tiles_dyn_tiles(%input: tensor<256x128xf32>, %output: tensor<10x8x?x?xf32>, %tile_size_0: index, %tile_size_1: index) -> tensor<10x8x?x?xf32> {1719  // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}1720  %0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [%tile_size_0, %tile_size_1] into %output : tensor<256x128xf32>  -> tensor<10x8x?x?xf32>1721  return %0 : tensor<10x8x?x?xf32>1722}1723 1724// -----1725 1726func.func @pack_invalid_no_padding_no_full_tiles_dyn_tiles_outperm(%input: tensor<256x128xf32>, %output: tensor<8x10x?x?xf32>, %tile_size_0: index, %tile_size_1: index) -> tensor<8x10x?x?xf32> {1727  // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}1728  %0 = linalg.pack %input outer_dims_perm = [1, 0] inner_dims_pos = [1, 0] inner_tiles = [%tile_size_0, %tile_size_1] into %output : tensor<256x128xf32>  -> tensor<8x10x?x?xf32>1729  return %0 : tensor<8x10x?x?xf32>1730}1731 1732// -----1733 1734func.func @pad_and_pack_invalid_type(%input: tensor<13x15xf32>, %output: tensor<2x8x8x2xf32>, %pad: i32) -> tensor<2x8x8x2xf32> {1735  // expected-error@+1 {{expected padding_value has 'f32' but got: 'i32'}}1736  %0 = linalg.pack %input padding_value(%pad: i32) inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %output : tensor<13x15xf32> -> tensor<2x8x8x2xf32>1737  return %0 : tensor<2x8x8x2xf32>1738}1739 1740// -----1741 1742func.func @pack_invalid_inner_dims_pos_vector(%input: tensor<256x128xf32>, %output: tensor<8x8x32x16xf32>) -> tensor<8x8x32x16xf32> {1743  // expected-error@+1 {{invalid inner_dims_pos vector}}1744  %0 = linalg.pack %input inner_dims_pos = [2, 0] inner_tiles = [2, 2] into %output : tensor<256x128xf32> -> tensor<8x8x32x16xf32>1745  return %0 : tensor<8x8x32x16xf32>1746}1747 1748// -----1749 1750func.func @pack_invalid_duplicate_element_in_inner_dims(%input: tensor<256x128xf32>, %output: tensor<8x8x32x16xf32>) -> tensor<8x8x32x16xf32> {1751  // expected-error@+1 {{invalid inner_dims_pos vector}}1752  %0 = linalg.pack %input inner_dims_pos = [1, 1] inner_tiles = [2, 2] into %output : tensor<256x128xf32> -> tensor<8x8x32x16xf32>1753  return %0 : tensor<8x8x32x16xf32>1754}1755 1756// -----1757 1758func.func @pack_invalid_duplicate_element_in_outer_perm(%input: tensor<256x128xf32>, %output: tensor<8x8x32x16xf32>) -> tensor<8x8x32x16xf32> {1759  // expected-error@+1 {{invalid outer_dims_perm vector}}1760  %0 = linalg.pack %input outer_dims_perm = [1, 1] inner_dims_pos = [0, 1] inner_tiles = [2, 2] into %output : tensor<256x128xf32> -> tensor<8x8x32x16xf32>1761  return %0 : tensor<8x8x32x16xf32>1762}1763 1764// -----1765 1766func.func @pack_invalid_output_rank(%input: tensor<256x128xf32>, %output: tensor<64x32x16xf32>) -> tensor<64x32x16xf32> {1767  // expected-error@+1 {{packed rank != (unpacked rank + num tiling factors), got 3 != 4}}1768  %0 = linalg.pack %input inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %output : tensor<256x128xf32> -> tensor<64x32x16xf32>1769  return %0 : tensor<64x32x16xf32>1770}1771 1772// -----1773 1774func.func @pack_invalid(%input: tensor<256x128xf32>, %output: tensor<8x8x32x16xf32>) -> tensor<8x8x32x16xf32> {1775  // expected-error@+1 {{invalid zero tile factor}}1776  %0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [0, 2] into %output : tensor<256x128xf32> -> tensor<8x8x32x16xf32>1777  return %0 : tensor<8x8x32x16xf32>1778}1779 1780// -----1781 1782func.func @pack_mismatch_inner_tile_size_and_output_shape(1783  %input : tensor<?x?xf32>, %output : tensor<?x?x8x8xf32>) -> tensor<?x?x8x8xf32> {1784  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1785  %0 = linalg.pack %input inner_dims_pos = [0, 1] inner_tiles = [8, 4] into %output : tensor<?x?xf32> -> tensor<?x?x8x8xf32>1786  return %0 : tensor<?x?x8x8xf32>1787}1788 1789// -----1790 1791func.func @pack_dynamic_inner_tile_size_and_static_output_shape(1792  %input : tensor<?x?xf32>, %output : tensor<?x?x8x8xf32>) -> tensor<?x?x8x8xf32> {1793  %c8 = arith.constant 8 : index1794  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1795  %0 = linalg.pack %input inner_dims_pos = [0, 1] inner_tiles = [8, %c8] into %output : tensor<?x?xf32> -> tensor<?x?x8x8xf32>1796  return %0 : tensor<?x?x8x8xf32>1797}1798 1799// -----1800 1801func.func @pack_static_inner_tile_size_and_dynamic_output_shape(1802  %input : tensor<?x?xf32>, %output : tensor<?x?x8x?xf32>) -> tensor<?x?x8x?xf32> {1803  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1804  %0 = linalg.pack %input inner_dims_pos = [0, 1] inner_tiles = [8, 8] into %output : tensor<?x?xf32> -> tensor<?x?x8x?xf32>1805  return %0 : tensor<?x?x8x?xf32>1806}1807 1808// -----1809 1810func.func @pack_invalid_outer_dims_perm(%source: tensor<128x256xf32>, %dest: tensor<16x4x32x16xf32>) -> tensor<16x4x32x16xf32> {1811  // expected-error@+1 {{outer_dims_perm must be a permutation or empty}}1812  %0 = linalg.pack %source outer_dims_perm = [0] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %dest : tensor<128x256xf32> -> tensor<16x4x32x16xf32>1813  return %0 : tensor<16x4x32x16xf32>1814}1815 1816// -----1817 1818//===----------------------------------------------------------------------===//1819// linalg.unpack1820//===----------------------------------------------------------------------===//1821 1822func.func @unpack_invalid_output_rank(%input: tensor<256x128xf32>, %output: tensor<64x32x16xf32>) -> tensor<256x128xf32> {1823  // expected-error@+1 {{packed rank != (unpacked rank + num tiling factors), got 3 != 4}}1824  %0 = linalg.unpack %output inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %input : tensor<64x32x16xf32> -> tensor<256x128xf32>1825  return %0 : tensor<256x128xf32>1826}1827 1828// -----1829 1830func.func @unpack_invalid_out_of_bound_outer_perm(%input: tensor<256x128xf32>, %output: tensor<8x8x32x16xf32>) -> tensor<8x8x32x16xf32> {1831  // expected-error@+1 {{invalid outer_dims_perm vector}}1832  %0 = linalg.unpack %output outer_dims_perm = [2, 1] inner_dims_pos = [0, 1] inner_tiles = [2, 2] into %input : tensor<8x8x32x16xf32> -> tensor<256x128xf32>1833  return %0 : tensor<256x128xf32>1834}1835 1836// -----1837 1838func.func @unpack_invalid_outer_dims_perm(%source: tensor<128x256xf32>, %dest: tensor<16x4x32x16xf32>) -> tensor<128x256xf32> {1839  // expected-error@+1 {{outer_dims_perm must be a permutation or empty}}1840  %0 = linalg.unpack %dest outer_dims_perm = [1] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %source : tensor<16x4x32x16xf32> -> tensor<128x256xf32>1841  return %0 : tensor<128x256xf32>1842}1843 1844// -----1845 1846func.func @pack_with_artificial_padding(%input: tensor<9xf32>, %output: tensor<3x8xf32>) -> tensor<3x8xf32> {1847  %cst = arith.constant 0.0 : f321848  // expected-error@+1 {{expected 'tensor<2x8xf32>' for the packed domain value, got 'tensor<3x8xf32>'}}1849  %0 = linalg.pack %input padding_value(%cst : f32) inner_dims_pos = [0]1850      inner_tiles = [8] into %output1851      : tensor<9xf32> -> tensor<3x8xf32>1852  return %0 : tensor<3x8xf32>1853}1854 1855// -----1856 1857// The outer dims in the output tensor are incorrectly/unexpectedly transposed.1858// This could be fixed by adding `outer_dims_perm = [1, 0]` (the default value assumes no transpose).1859func.func @pack_invalid_result_shape(%input: tensor<256x128xf32>, %output: tensor<4x16x32x16xf32>) -> tensor<4x16x32x16xf32> {1860  // expected-error@+1 {{expected 'tensor<16x4x32x16xf32>' for the packed domain value, got 'tensor<4x16x32x16xf32>'}}1861  %0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [32, 16] into %output : tensor<256x128xf32> -> tensor<4x16x32x16xf32>1862  return %0 : tensor<4x16x32x16xf32>1863}1864 1865// -----1866 1867func.func @pack_invalid_result_shape(%input: tensor<256x128xf32>, %output: tensor<8x7x16x32xf32>) -> tensor<8x7x16x32xf32> {1868  // expected-error@+1 {{expected 'tensor<8x8x16x32xf32>' for the packed domain value, got 'tensor<8x7x16x32xf32>'}}1869  %0 = linalg.pack %input inner_dims_pos = [1, 0] inner_tiles = [16, 32] into %output : tensor<256x128xf32> -> tensor<8x7x16x32xf32>1870  return %0 : tensor<8x7x16x32xf32>1871}1872 1873// -----1874 1875func.func @unpack_with_artifical_tiles_that_are_dropped(%input: tensor<3x8xf32>, %output: tensor<9xf32>) -> tensor<9xf32> {1876  // expected-error@+1 {{expected 'tensor<2x8xf32>' for the packed domain value, got 'tensor<3x8xf32>'}}1877  %0 = linalg.unpack %input inner_dims_pos = [0] inner_tiles = [8] into %output1878      : tensor<3x8xf32> -> tensor<9xf32>1879  return %0 : tensor<9xf32>1880}1881 1882// -----1883 1884func.func @unpack_invalid_source_shape(%output: tensor<256x128xf32>, %input: tensor<8x8x4x32xf32>) -> tensor<256x128xf32> {1885  // expected-error@+1 {{expected 'tensor<8x32x4x32xf32>' for the packed domain value, got 'tensor<8x8x4x32xf32>'}}1886  %0 = linalg.unpack %input inner_dims_pos = [1, 0] inner_tiles = [4, 32] into %output : tensor<8x8x4x32xf32> -> tensor<256x128xf32>1887  return %0 : tensor<256x128xf32>1888}1889 1890// -----1891 1892func.func @unpack_mismatch_inner_tile_size_and_output_shape(1893  %input : tensor<?x?x8x8xf32>, %output : tensor<?x?xf32>) -> tensor<?x?xf32> {1894  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1895  %0 = linalg.unpack %input inner_dims_pos = [0, 1] inner_tiles = [8, 4] into %output : tensor<?x?x8x8xf32> -> tensor<?x?xf32>1896  return %0 : tensor<?x?xf32>1897}1898 1899// -----1900 1901func.func @unpack_dynamic_inner_tile_size_and_static_output_shape(1902  %input : tensor<?x?x8x4xf32>, %output : tensor<?x?xf32>) -> tensor<?x?xf32> {1903  %c8 = arith.constant 8 : index1904  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1905  %0 = linalg.unpack %input inner_dims_pos = [0, 1] inner_tiles = [%c8, 4] into %output : tensor<?x?x8x4xf32> -> tensor<?x?xf32>1906  return %0 : tensor<?x?xf32>1907}1908 1909// -----1910 1911func.func @unpack_static_inner_tile_size_and_dynamic_output_shape(1912  %input : tensor<?x?x?x4xf32>, %output : tensor<?x?xf32>) -> tensor<?x?xf32> {1913  // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}1914  %0 = linalg.unpack %input inner_dims_pos = [0, 1] inner_tiles = [8, 4] into %output : tensor<?x?x?x4xf32> -> tensor<?x?xf32>1915  return %0 : tensor<?x?xf32>1916}1917 1918// -----1919 1920//===----------------------------------------------------------------------===//1921// linalg.reduce1922//===----------------------------------------------------------------------===//1923 1924 1925func.func @reduce_non_operation_name(%arg0: tensor<4xf32>, %arg1: tensor<f32>) -> tensor<f32> {1926  // expected-error @below {{expected bare identifier or keyword}}1927  %0 = linalg.reduce {@reduce_fusion_elementwise} ins(1928    %arg0: tensor<4xf32>) outs(%arg1: tensor<f32>) dimensions = [0]1929  return %0 : tensor<f32>1930}1931 1932// -----1933 1934 1935//===----------------------------------------------------------------------===//1936// Tests for generic infrastructure for named Ops. The actual Ops used are1937// secondary - we merely want to ensure that the diagnostic infra triggers1938// correctly.1939//===----------------------------------------------------------------------===//1940 1941module {1942  func.func @add_invalid_mixed_types(%in_f32: memref<3xf32>, %in_i32 : memref< 3xi32>, %out_f32: memref<3xf32>, %arg3: memref<3xf32>) {1943    // expected-error @below {{Cannot build binary Linalg operation: expects allComplex, allFloatingPoint, or allInteger, got 'f32' and 'i32'}}1944    linalg.add ins(%in_f32, %in_i32 : memref<3xf32>, memref< 3xi32>) outs(%out_f32 : memref<3xf32>)1945    return1946  }1947}1948 1949// -----1950 1951func.func @matmul_invalid_mixed_types(%t: tensor<?xf16>, %f: vector<4xf16>)1952  -> (tensor<?xf16>, vector<4xf16>)1953{1954  // expected-warning @unknown {{could not cast operand of type 'f16' to 'vector<4xf16>'}}1955  // expected-error @below {{Cannot build binary Linalg operation: expects allComplex, allFloatingPoint, or allInteger, got 'vector<4xf16>' and 'f16'}}1956  %0 = linalg.matmul ins(%t, %t : tensor<?xf16>, tensor<?xf16>)1957                                outs(%f : vector<4xf16>) -> tensor<?xf16>1958  func.return %0, %f : tensor<?xf16>, vector<4xf16>1959}1960