brintos

brintos / llvm-project-archived public Read only

0
0
Text · 30.7 KiB · 26bcf94 Raw
1024 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s2 3func.func @not_enough_sizes(%sz : index) {4  // expected-error@+1 {{expected 6 or more operands, but found 5}}5  "gpu.launch"(%sz, %sz, %sz, %sz, %sz) ({6    gpu.return7  }) {operandSegmentSizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0>} : (index, index, index, index, index) -> ()8  return9}10 11// -----12 13func.func @no_region_attrs(%sz : index) {14  // expected-error@+1 {{unexpected number of region arguments}}15  "gpu.launch"(%sz, %sz, %sz, %sz, %sz, %sz) ({16  ^bb1(%bx: index, %by: index, %bz: index,17       %tx: index, %ty: index, %tz: index):18    gpu.terminator19  }) {operandSegmentSizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0>} : (index, index, index, index, index, index) -> ()20  return21}22 23// -----24 25func.func @launch_requires_gpu_return(%sz : index) {26  // @expected-note@+1 {{in 'gpu.launch' body region}}27  gpu.launch blocks(%bx, %by, %bz) in (%sbx = %sz, %sby = %sz, %sbz = %sz)28             threads(%tx, %ty, %tz) in (%stx = %sz, %sty = %sz, %stz = %sz) {29    // @expected-error@+2 {{expected 'gpu.terminator' or a terminator with successors}}30    %one = arith.constant 1 : i3231    "gpu.yield"(%one) : (i32) -> ()32  }33  return34}35 36// -----37 38func.func @launch_func_too_few_operands(%sz : index) {39  // expected-error@+1 {{expected 6 or more operands}}40  "gpu.launch_func"(%sz, %sz, %sz, %sz, %sz)41      {operandSegmentSizes = array<i32: 0, 1, 1, 1, 1, 1, 0, 0>}42      : (index, index, index, index, index) -> ()43  return44}45 46// -----47 48func.func @launch_func_missing_parent_module_attribute(%sz : index) {49  // expected-error@+1 {{expected the closest surrounding module to have the 'gpu.container_module' attribute}}50  gpu.launch_func @foo::@bar blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)51  return52}53 54// -----55 56module attributes {gpu.container_module} {57  func.func @launch_func_missing_callee_attribute(%sz : index) {58    // expected-error@+1 {{'gpu.launch_func' op requires attribute 'kernel'}}59    "gpu.launch_func"(%sz, %sz, %sz, %sz, %sz, %sz)60        {operandSegmentSizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0>}61        : (index, index, index, index, index, index) -> ()62    return63  }64}65 66// -----67 68module attributes {gpu.container_module} {69  func.func @launch_func_no_function_attribute(%sz : index) {70    // expected-error@+1 {{custom op 'gpu.launch_func' invalid kind of attribute specified}}71    gpu.launch_func "foo" blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)72    return73  }74}75 76// -----77 78module attributes {gpu.container_module} {79  func.func @launch_func_undefined_module(%sz : index) {80    // expected-error@+1 {{kernel container 'kernels' is undefined}}81    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)82    return83  }84}85 86// -----87 88module attributes {gpu.container_module} {89  module @kernels {90    // expected-error@+1 {{'gpu.func' op expects parent op 'gpu.module'}}91    gpu.func @kernel_1(%arg1 : !llvm.ptr) {92      gpu.return93    }94  }95}96 97// -----98 99module attributes {gpu.container_module} {100  module @kernels {101  }102 103  func.func @launch_func_missing_module_attribute(%sz : index) {104    // expected-error@+1 {{kernel module 'kernels' is undefined}}105    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)106    return107  }108}109 110// -----111 112module attributes {gpu.container_module} {113  gpu.module @kernels { }114 115  func.func @launch_func_undefined_function(%sz : index) {116    // expected-error@+1 {{kernel function '@kernels::@kernel_1' is undefined}}117    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)118    return119  }120}121 122// -----123 124module attributes {gpu.container_module} {125  gpu.module @kernels {126    // expected-note@+1 {{see the kernel definition here}}127    memref.global "private" @kernel_1 : memref<4xi32>128  }129 130  func.func @launch_func_undefined_function(%sz : index) {131    // expected-error@+1 {{referenced kernel '@kernels::@kernel_1' is not a function}}132    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)133    return134  }135}136 137// -----138 139module attributes {gpu.container_module} {140  module @kernels {141    gpu.func @kernel_1(%arg1 : !llvm.ptr) kernel {142      gpu.return143    }144  }145 146  func.func @launch_func_missing_kernel_attr(%sz : index, %arg : !llvm.ptr) {147    // expected-error@+1 {{kernel module 'kernels' is undefined}}148    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz) args(%arg : !llvm.ptr)149    return150  }151}152 153// -----154 155module attributes {gpu.container_module} {156  gpu.module @kernels {157    gpu.func @kernel_1(%arg1 : !llvm.ptr) {158      gpu.return159    }160  }161 162  func.func @launch_func_missing_kernel_attr(%sz : index, %arg : !llvm.ptr) {163    // expected-error@+1 {{kernel function is missing the 'gpu.kernel' attribute}}164    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz) args(%arg : !llvm.ptr)165    return166  }167}168 169// -----170 171module attributes {gpu.container_module} {172  gpu.module @kernels {173    gpu.func @kernel_1(%arg1 : !llvm.ptr) kernel {174      gpu.return175    }176  }177 178  func.func @launch_func_kernel_operand_size(%sz : index, %arg : !llvm.ptr) {179    // expected-error@+1 {{got 2 kernel operands but expected 1}}180    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz) args(%arg : !llvm.ptr, %arg : !llvm.ptr)181    return182  }183}184 185// -----186 187module attributes {gpu.container_module} {188  gpu.module @kernels {189    gpu.func @kernel_1(%arg1 : f32) kernel {190      gpu.return191    }192  }193 194  func.func @launch_func_kernel_operand_types(%sz : index, %arg : f32) {195    // expected-err@+1 {{type of function argument 0 does not match}}196    gpu.launch_func @kernels::@kernel_1 blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz) args(%arg : f32)197    return198  }199}200 201// -----202 203module attributes {gpu.container_module} {204  func.func @launch_func_kernel_operand_attr(%sz : index) {205    // expected-error@+1 {{expected ')' in argument list}}206    gpu.launch_func @foo::@bar blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz) args(%sz : index {foo})207    return208  }209}210 211// -----212 213func.func @reduce_bad_type(%arg0 : vector<4xf32>) {214  // expected-error@+1 {{'gpu.all_reduce' op operand #0 must be Integer or Float}}215  %res = gpu.all_reduce add %arg0 {} : (vector<4xf32>) -> vector<4xf32>216  return217}218 219// -----220 221func.func @reduce_no_op_no_body(%arg0 : f32) {222  // expected-error@+1 {{expected either an op attribute or a non-empty body}}223  %res = "gpu.all_reduce"(%arg0) ({}) : (f32) -> (f32)224  return225}226 227// -----228 229func.func @reduce_op_and_body(%arg0 : f32) {230  // expected-error@+1 {{expected either an op attribute or a non-empty body}}231  %res = "gpu.all_reduce"(%arg0) ({232  ^bb(%lhs : f32, %rhs : f32):233    "gpu.yield"(%lhs) : (f32) -> ()234  }) {op = #gpu<all_reduce_op add>} : (f32) -> (f32)235  return236}237 238// -----239 240func.func @reduce_invalid_op(%arg0 : f32) {241  // expected-error@+1 {{invalid op kind}}242  %res = gpu.all_reduce foo %arg0 {} : (f32) -> (f32)243  return244}245 246// -----247 248func.func @reduce_invalid_op_type_minsi(%arg0 : f32) {249  // expected-error@+1 {{`minsi` reduction operation is not compatible with type 'f32'}}250  %res = gpu.all_reduce minsi %arg0 {} : (f32) -> (f32)251  return252}253 254// -----255 256func.func @reduce_invalid_op_type_minui(%arg0 : f32) {257  // expected-error@+1 {{`minui` reduction operation is not compatible with type 'f32'}}258  %res = gpu.all_reduce minui %arg0 {} : (f32) -> (f32)259  return260}261 262// -----263 264func.func @reduce_invalid_op_type_maxsi(%arg0 : f32) {265  // expected-error@+1 {{`maxsi` reduction operation is not compatible with type 'f32'}}266  %res = gpu.all_reduce maxsi %arg0 {} : (f32) -> (f32)267  return268}269 270// -----271 272func.func @reduce_invalid_op_type_maxui(%arg0 : f32) {273  // expected-error@+1 {{`maxui` reduction operation is not compatible with type 'f32'}}274  %res = gpu.all_reduce maxui %arg0 {} : (f32) -> (f32)275  return276}277 278// -----279 280func.func @reduce_invalid_op_type_and(%arg0 : f32) {281  // expected-error@+1 {{`and` reduction operation is not compatible with type 'f32'}}282  %res = gpu.all_reduce and %arg0 {} : (f32) -> (f32)283  return284}285 286// -----287 288func.func @reduce_invalid_op_type_or(%arg0 : f32) {289  // expected-error@+1 {{`or` reduction operation is not compatible with type 'f32'}}290  %res = gpu.all_reduce or %arg0 {} : (f32) -> (f32)291  return292}293 294// -----295 296func.func @reduce_invalid_op_type_xor(%arg0 : f32) {297  // expected-error@+1 {{`xor` reduction operation is not compatible with type 'f32'}}298  %res = gpu.all_reduce xor %arg0 {} : (f32) -> (f32)299  return300}301 302// -----303 304func.func @reduce_invalid_op_type_minnumf(%arg0 : i32) {305  // expected-error@+1 {{`minnumf` reduction operation is not compatible with type 'i32'}}306  %res = gpu.all_reduce minnumf %arg0 {} : (i32) -> (i32)307  return308}309 310// -----311 312func.func @reduce_invalid_op_type_maxnumf(%arg0 : i32) {313  // expected-error@+1 {{`maxnumf` reduction operation is not compatible with type 'i32'}}314  %res = gpu.all_reduce maxnumf %arg0 {} : (i32) -> (i32)315  return316}317 318// -----319 320func.func @reduce_invalid_op_type_minimumf(%arg0 : i32) {321  // expected-error@+1 {{`minimumf` reduction operation is not compatible with type 'i32'}}322  %res = gpu.all_reduce minimumf %arg0 {} : (i32) -> (i32)323  return324}325 326// -----327 328func.func @reduce_invalid_op_type_maximumf(%arg0 : i32) {329  // expected-error@+1 {{`maximumf` reduction operation is not compatible with type 'i32'}}330  %res = gpu.all_reduce maximumf %arg0 {} : (i32) -> (i32)331  return332}333 334// -----335 336func.func @subgroup_reduce_zero_cluster_size(%arg0 : vector<4xf32>) {337  // expected-error@+1 {{cluster size 0 is not a power of two}}338  %res = gpu.subgroup_reduce add %arg0 cluster(size = 0) : (vector<4xf32>) -> vector<4xf32>339  return340}341 342// -----343 344func.func @subgroup_reduce_npot_cluster_size(%arg0 : vector<4xf32>) {345  // expected-error@+1 {{cluster size 3 is not a power of two}}346  %res = gpu.subgroup_reduce add %arg0 cluster(size = 3) : (vector<4xf32>) -> vector<4xf32>347  return348}349 350// -----351 352func.func @subgroup_reduce_zero_cluster_stride(%arg0 : vector<4xf32>) {353  // expected-error@+1 {{cluster stride 0 is not a power of two}}354  %res = gpu.subgroup_reduce add %arg0 cluster(size = 4, stride = 0) : (vector<4xf32>) -> vector<4xf32>355  return356}357 358// -----359 360func.func @subgroup_reduce_cluster_stride_without_size(%arg0 : vector<4xf32>) {361  // expected-error@+1 {{cluster stride can only be specified if cluster size is specified}}362  %res = gpu.subgroup_reduce add %arg0 { cluster_stride = 2 : i32 } : (vector<4xf32>) -> vector<4xf32>363  return364}365 366 367// -----368 369func.func @subgroup_reduce_bad_type(%arg0 : vector<2x2xf32>) {370  // expected-error@+1 {{'gpu.subgroup_reduce' op operand #0 must be Integer or Float or fixed-length vector of}}371  %res = gpu.subgroup_reduce add %arg0 : (vector<2x2xf32>) -> vector<2x2xf32>372  return373}374 375// -----376 377func.func @subgroup_reduce_bad_type_scalable(%arg0 : vector<[2]xf32>) {378  // expected-error@+1 {{'gpu.subgroup_reduce' op operand #0 must be Integer or Float or fixed-length vector of}}379  %res = gpu.subgroup_reduce add %arg0 : (vector<[2]xf32>) -> vector<[2]xf32>380  return381}382 383// -----384 385func.func @subgroup_reduce_invalid_op_type_and(%arg0 : f32) {386  // expected-error@+1 {{`and` reduction operation is not compatible with type 'f32'}}387  %res = gpu.subgroup_reduce and %arg0 : (f32) -> (f32)388  return389}390 391// -----392 393func.func @subgroup_reduce_invalid_op_type_maxnumf(%arg0 : i32) {394  // expected-error@+1 {{`maxnumf` reduction operation is not compatible with type 'i32'}}395  %res = gpu.subgroup_reduce maxnumf %arg0 : (i32) -> (i32)396  return397}398 399// -----400 401func.func @reduce_incorrect_region_arguments(%arg0 : f32) {402  // expected-error@+1 {{expected two region arguments}}403  %res = gpu.all_reduce %arg0 {404  ^bb(%lhs : f32):405    "gpu.yield"(%lhs) : (f32) -> ()406  } : (f32) -> (f32)407  return408}409 410// -----411 412func.func @reduce_incorrect_region_arguments(%arg0 : f32) {413  // expected-error@+1 {{incorrect region argument type}}414  %res = gpu.all_reduce %arg0 {415  ^bb(%lhs : f32, %rhs : i32):416    "gpu.yield"(%lhs) : (f32) -> ()417  } : (f32) -> (f32)418  return419}420 421// -----422 423func.func @reduce_incorrect_yield(%arg0 : f32) {424  // expected-error@+1 {{expected one gpu.yield operand}}425  %res = gpu.all_reduce %arg0 {426  ^bb(%lhs : f32, %rhs : f32):427    "gpu.yield"(%lhs, %rhs) : (f32, f32) -> ()428  } : (f32) -> (f32)429  return430}431 432// -----433 434func.func @reduce_incorrect_yield(%arg0 : f32) {435  // expected-error@+1 {{incorrect gpu.yield type}}436  %res = gpu.all_reduce %arg0 {437  ^bb(%lhs : f32, %rhs : f32):438    %one = arith.constant 1 : i32439    "gpu.yield"(%one) : (i32) -> ()440  } : (f32) -> (f32)441  return442}443 444// -----445 446func.func @reduce_incorrect_yield(%arg0 : f32) {447  // expected-error@+1 {{expected gpu.yield op in region}}448  %res = gpu.all_reduce %arg0 {449  ^bb(%lhs : f32, %rhs : f32):450    "test.finish" () : () -> ()451  } : (f32) -> (f32)452  return453}454 455// -----456 457func.func @shuffle_mismatching_type(%arg0 : f32, %arg1 : i32, %arg2 : i32) {458  // expected-error@+1 {{op failed to verify that all of {value, shuffleResult} have same type}}459  %shfl, %pred = "gpu.shuffle"(%arg0, %arg1, %arg2) { mode = #gpu<shuffle_mode xor> } : (f32, i32, i32) -> (i32, i1)460  return461}462 463// -----464 465func.func @shuffle_unsupported_type(%arg0 : index, %arg1 : i32, %arg2 : i32) {466  // expected-error@+1 {{op operand #0 must be Integer or Float or fixed-length vector of Integer or Float values of ranks 1, but got 'index'}}467  %shfl, %pred = gpu.shuffle xor %arg0, %arg1, %arg2 : index468  return469}470 471// -----472 473func.func @shuffle_unsupported_type_vec(%arg0 : vector<[4]xf32>, %arg1 : i32, %arg2 : i32) {474  // expected-error@+1 {{op operand #0 must be Integer or Float or fixed-length vector of Integer or Float values of ranks 1, but got 'vector<[4]xf32>'}}475  %shfl, %pred = gpu.shuffle xor %arg0, %arg1, %arg2 : vector<[4]xf32>476  return477}478 479// -----480 481func.func @rotate_mismatching_type(%arg0 : f32) {482  // expected-error@+1 {{op failed to verify that all of {value, rotateResult} have same type}}483  %rotate, %valid = "gpu.rotate"(%arg0) { offset = 4 : i32, width = 16 : i32 } : (f32) -> (i32, i1)484  return485}486 487// -----488 489func.func @rotate_unsupported_type(%arg0 : index) {490  // expected-error@+1 {{op operand #0 must be Integer or Float or fixed-length vector of Integer or Float values of ranks 1, but got 'index'}}491  %rotate, %valid = gpu.rotate %arg0, 4, 16 : index492  return493}494 495// -----496 497func.func @rotate_unsupported_type_vec(%arg0 : vector<[4]xf32>) {498  %offset = arith.constant 4 : i32499  %width = arith.constant 16 : i32500  // expected-error@+1 {{op operand #0 must be Integer or Float or fixed-length vector of Integer or Float values of ranks 1, but got 'vector<[4]xf32>'}}501  %rotate, %valid = gpu.rotate %arg0, 4, 16 : vector<[4]xf32>502  return503}504 505// -----506 507func.func @rotate_unsupported_width(%arg0 : f32) {508  // expected-error@+1 {{'gpu.rotate' op attribute 'width' failed to satisfy constraint: 32-bit signless integer attribute whose value is a power of two > 0}}509  %rotate, %valid = "gpu.rotate"(%arg0) { offset = 4 : i32, width = 15 : i32 } : (f32) -> (f32, i1)510  return511}512 513// -----514 515func.func @rotate_unsupported_offset(%arg0 : f32) {516  // expected-error@+1 {{op offset must be in the range [0, 16)}}517  %rotate, %valid = "gpu.rotate"(%arg0) { offset = 16 : i32, width = 16 : i32 }: (f32) -> (f32, i1)518  return519}520 521// -----522 523func.func @rotate_unsupported_offset_minus(%arg0 : f32) {524  // expected-error@+1 {{'gpu.rotate' op attribute 'offset' failed to satisfy constraint: 32-bit signless integer attribute whose minimum value is 0}}525  %rotate, %valid = "gpu.rotate"(%arg0) { offset = -1 : i32, width = 16 : i32 } : (f32) -> (f32, i1)526  return527}528 529// -----530 531module {532  gpu.module @gpu_funcs {533    // expected-error @+1 {{custom op 'gpu.func' gpu.func requires named arguments}}534    gpu.func @kernel_1(f32, f32) {535    ^bb0(%arg0: f32):536      gpu.return537    }538  }539}540 541// -----542 543module {544  gpu.module @gpu_funcs {545    // expected-error @+1 {{attribute 'function_type' failed to satisfy constraint: type attribute of function type}}546    "gpu.func"() ({547      gpu.return548    }) {sym_name="kernel_1", function_type=f32} : () -> ()549  }550}551 552// -----553 554module {555  gpu.module @gpu_funcs {556    // expected-error @below {{'gpu.func' op expected memref type in attribution}}557    gpu.func @kernel() workgroup(%0: i32) {558      gpu.return559    }560  }561}562 563// -----564 565module {566  gpu.module @gpu_funcs {567    // expected-error @below {{'gpu.func' op expected memory space workgroup in attribution}}568    gpu.func @kernel() workgroup(%0: memref<4xf32, #gpu.address_space<private>>) {569      gpu.return570    }571  }572}573 574// -----575 576module {577  gpu.module @gpu_funcs {578    // expected-error @below {{'gpu.func' op expected memory space private in attribution}}579    gpu.func @kernel() private(%0: memref<4xf32, #gpu.address_space<workgroup>>) {580      gpu.return581    }582  }583}584 585// -----586 587module {588  gpu.module @gpu_funcs {589    // expected-note @+1 {{return type declared here}}590    gpu.func @kernel() {591      %0 = arith.constant 0 : index592      // expected-error @+1 {{'gpu.return' op expected 0 result operands}}593      gpu.return %0 : index594    }595  }596}597 598// -----599 600module {601  gpu.module @gpu_funcs {602    // expected-error @+1 {{'gpu.func' op expected void return type for kernel function}}603    gpu.func @kernel() -> index kernel {604      %0 = arith.constant 0 : index605      gpu.return606    }607  }608}609 610// -----611 612module {613  gpu.module @gpu_funcs {614    // expected-error @+1 {{'gpu.func' op expected at least 5 arguments to body region}}615    "gpu.func"() ({616    ^bb0(%arg0: f32, %arg1: memref<?xf32>, %arg2: memref<5xf32, 3>, %arg3: memref<5xf32, 5>):617      "gpu.return"() : () -> ()618    } ) {function_type = (f32, memref<?xf32>) -> (), gpu.kernel, sym_name = "kernel_1", workgroup_attributions = 3: i64} : () -> ()619  }620}621 622// -----623 624module {625  gpu.module @gpu_funcs {626    // expected-error @+1 {{expected body with at least one block}}627    "gpu.func"() ({}) {function_type = () -> (), gpu.kernel, sym_name = "kernel"} : () -> ()628  }629}630 631// -----632 633func.func @sync_wait_with_result() {634  // expected-error @+1 {{cannot name an operation with no results}}635  %t = gpu.wait636}637 638// -----639 640func.func @async_wait_without_result() {641  // expected-error @+1 {{custom op 'gpu.wait' needs to be named when marked 'async'}}642  gpu.wait async643}644 645// -----646 647func.func @memcpy_incompatible_type(%dst : memref<?xf32>, %src : memref<?xi32>) {648  // expected-error @+1 {{'gpu.memcpy' op arguments have incompatible element type}}649  gpu.memcpy %dst, %src  : memref<?xf32>, memref<?xi32>650}651 652// -----653 654func.func @memcpy_incompatible_shape(%dst : memref<7xf32>, %src : memref<9xf32>) {655  // expected-error @+1 {{'gpu.memcpy' op arguments have incompatible shape}}656  gpu.memcpy %dst, %src  : memref<7xf32>, memref<9xf32>657}658 659// -----660 661func.func @memset_incompatible_shape(%dst : memref<?xf32>, %value : i32) {662  // expected-error @+1 {{'gpu.memset' op failed to verify that all of {dst, value} have same element type}}663  gpu.memset %dst, %value  : memref<?xf32>, i32664}665 666// -----667 668func.func @mmamatrix_invalid_shape(){669    %wg = memref.alloca() {alignment = 32} : memref<32x32xf16, 3>670    %i = arith.constant 16 : index671    // expected-error @+1 {{MMAMatrixType must have exactly two dimensions}}672    %0 = gpu.subgroup_mma_load_matrix %wg[%i, %i] {leadDimension = 32 : index} : memref<32x32xf16, 3> -> !gpu.mma_matrix<16x16x16xf16, "AOp">673    return674}675 676// -----677 678func.func @mmamatrix_operand_type(){679    %wg = memref.alloca() {alignment = 32} : memref<32x32xf16, 3>680    %i = arith.constant 16 : index681    // expected-error @+1 {{operand expected to be one of AOp, BOp or COp}}682    %0 = gpu.subgroup_mma_load_matrix %wg[%i, %i] {leadDimension = 32 : index} : memref<32x32xf16, 3> -> !gpu.mma_matrix<16x16xf16, "EOp">683    return684}685 686// -----687 688func.func @mmamatrix_invalid_element_type(){689    %wg = memref.alloca() {alignment = 32} : memref<32x32xf16, 3>690    %i = arith.constant 16 : index691    // expected-error @+1 {{MMAMatrixType elements must be SI8, UI8, I32, F16, F32, or F64}}692    %0 = gpu.subgroup_mma_load_matrix %wg[%i, %i] {leadDimension = 32 : index} : memref<32x32xf16, 3> -> !gpu.mma_matrix<16x16xbf16, "AOp">693    return694}695 696// -----697 698#layout_map_col_major = affine_map<(i, j) -> (j, i)>699 700func.func @mmaLoadOp_identity_layout(){701    %wg = memref.alloca() {alignment = 32} : memref<32x32xf16, #layout_map_col_major, 3>702    %i = arith.constant 16 : index703    // expected-error @+1 {{expected source memref most minor dim must have unit stride}}704    %0 = gpu.subgroup_mma_load_matrix %wg[%i, %i] {leadDimension = 32 : index} : memref<32x32xf16, #layout_map_col_major, 3> -> !gpu.mma_matrix<16x16xf16, "AOp">705    return706}707 708// -----709 710func.func @mma_invalid_memref_type(%src: memref<32x4xvector<4x8xf32>>, %i: index) {711    // expected-error @+1 {{operand #0 must be memref of 8-bit signless integer or 32-bit signless integer or 16-bit float or 32-bit float or 64-bit float or vector of 8-bit signless integer or 32-bit signless integer or 16-bit float or 32-bit float or 64-bit float values of ranks 1 values}}712    %0 = gpu.subgroup_mma_load_matrix %src[%i, %i] {leadDimension = 4 : index} : memref<32x4xvector<4x8xf32>> -> !gpu.mma_matrix<16x16xf16, "AOp">713    return714}715 716// -----717 718#layout_map_col_major = affine_map<(i, j) -> (j, i)>719 720func.func @wmmaStoreOp_invalid_map(%arg0 : !gpu.mma_matrix<16x16xf16, "COp">) -> () {721    %sg = memref.alloca(){alignment = 32} : memref<32x32xf16, #layout_map_col_major, 3>722    %i = arith.constant 16 : index723    %j = arith.constant 16 : index724    // expected-error @+1 {{expected destination memref most minor dim must have unit stride}}725    gpu.subgroup_mma_store_matrix %arg0, %sg[%i,%j] {leadDimension= 32 : index} : !gpu.mma_matrix<16x16xf16, "COp">, memref<32x32xf16,#layout_map_col_major, 3>726    return727}728 729// -----730 731func.func @wmmaStoreOp_invalid_store_operand(%arg0 : !gpu.mma_matrix<16x16xf16, "AOp">) -> () {732    %sg = memref.alloca(){alignment = 32} : memref<32x32xf16, 3>733    %i = arith.constant 16 : index734    %j = arith.constant 16 : index735    // expected-error @+1 {{expected the operand matrix being stored to have 'COp' operand type}}736    gpu.subgroup_mma_store_matrix %arg0, %sg[%i,%j] {leadDimension= 32 : index} : !gpu.mma_matrix<16x16xf16, "AOp">, memref<32x32xf16, 3>737    return738}739 740// -----741 742func.func @wmmaMmaOp_invalid_operand_order(%A : !gpu.mma_matrix<16x16xf16, "AOp">, %B : !gpu.mma_matrix<16x16xf16, "BOp">, %C : !gpu.mma_matrix<16x16xf16, "COp">) -> () {743    // expected-error @+1 {{operands must be in the order AOp, BOp, COp}}744    %D = gpu.subgroup_mma_compute %B, %A, %C : !gpu.mma_matrix<16x16xf16, "BOp">, !gpu.mma_matrix<16x16xf16, "AOp"> -> !gpu.mma_matrix<16x16xf16, "COp">745    return746}747 748// -----749 750func.func @wmmaMmaOp_invalid_operand_shapes(%A : !gpu.mma_matrix<16x32xf16, "AOp">, %B : !gpu.mma_matrix<16x16xf16, "BOp">, %C : !gpu.mma_matrix<16x16xf16, "COp">) -> () {751    // expected-error @+1 {{operand shapes do not satisfy matmul constraints}}752    %D = gpu.subgroup_mma_compute %A, %B, %C : !gpu.mma_matrix<16x32xf16, "AOp">, !gpu.mma_matrix<16x16xf16, "BOp"> -> !gpu.mma_matrix<16x16xf16, "COp">753    return754}755 756// -----757 758// Number of symbol operand count less than memref symbol count.759func.func @alloc() {760   // expected-error@+1 {{symbol operand count does not equal memref symbol count}}761   %1 = gpu.alloc() : memref<2x4xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>, 1>762   return763}764 765// -----766 767// Number of symbol operand count greater than memref symbol count.768func.func @alloc() {769   %0 = arith.constant 7 : index770   // expected-error@+1 {{symbol operand count does not equal memref symbol count}}771   %1 = gpu.alloc()[%0] : memref<2x4xf32, 1>772   return773}774 775// -----776 777// Number of dynamic dimension operand count greater than memref dynamic dimension count.778func.func @alloc() {779   %0 = arith.constant 7 : index780   // expected-error@+1 {{dimension operand count does not equal memref dynamic dimension count}}781   %1 = gpu.alloc(%0, %0) : memref<2x?xf32, 1>782   return783}784 785// -----786 787// Number of dynamic dimension operand count less than memref dynamic dimension count.788func.func @alloc() {789   %0 = arith.constant 7 : index790   // expected-error@+1 {{dimension operand count does not equal memref dynamic dimension count}}791   %1 = gpu.alloc(%0) : memref<2x?x?xf32, 1>792   return793}794 795// -----796 797module attributes {gpu.container_module} {798  // expected-error@+1 {{'func.func' op gpu.known_block_size must be a dense i32 array}}799  func.func @kernel() attributes {gpu.known_block_size = 32 : i32} {800    func.return801  }802}803 804// -----805 806module attributes {gpu.container_module} {807  gpu.module @kernel {808    // expected-error@+1 {{'gpu.func' op attribute 'known_block_size' failed to satisfy constraint: i32 dense array attribute with 3 elements (if present)}}809    gpu.func @kernel() kernel attributes {known_block_size = array<i32: 2, 1>} {810      gpu.return811    }812  }813}814 815// -----816 817module {818  // expected-error@+1 {{'func.func' op gpu.known_block_size must contain exactly 3 elements}}819  func.func @kernel() attributes {gpu.known_block_size = array<i32: 2, 1>} {820    func.return821  }822}823 824// -----825 826module {827  // expected-error @+1 {{'gpu.module' op attribute 'targets' failed to satisfy constraint: array of GPU target attributes with at least 1 elements}}828  gpu.module @gpu_funcs [] {829  }830}831 832// -----833 834module {835  // expected-error @+1 {{'gpu.module' op attribute 'targets' failed to satisfy constraint: array of GPU target attributes with at least 1 elements}}836  gpu.module @gpu_funcs [1] {837  }838}839 840// -----841 842module {843  // expected-error @+1 {{'gpu.binary' op attribute 'objects' failed to satisfy constraint: an array of GPU object attributes with at least 1 elements}}844  gpu.binary @binary []845}846 847// -----848 849module {850  // expected-error @+1 {{'gpu.binary' op attribute 'offloadingHandler' failed to satisfy constraint: any attribute with the `OffloadingTranslationAttrTrait` trait.}}851  gpu.binary @binary <1> [#gpu.object<#nvvm.target, "">]852}853 854// -----855 856func.func @main() {857  %shmemSize = arith.constant 10000 : i32858  %c1 = arith.constant 1 : index859  gpu.launch blocks(%bx, %by, %bz) in (%sbx = %c1, %sby = %c1, %sbz = %c1)860             threads(%tx, %ty, %tz) in (%stx = %c1, %sty = %c1, %stz = %c1)861             dynamic_shared_memory_size %shmemSize862  {863    // expected-error @below {{'gpu.dynamic_shared_memory' op address space must be address_space<workgroup>}}864    %0 = gpu.dynamic_shared_memory : memref<?xi8>865    gpu.terminator866  }867  return868}869 870 871// -----872 873func.func @main() {874  %shmemSize = arith.constant 8192 : i32875  %c1 = arith.constant 1 : index876  gpu.launch blocks(%bx, %by, %bz) in (%sbx = %c1, %sby = %c1, %sbz = %c1)877             threads(%tx, %ty, %tz) in (%stx = %c1, %sty = %c1, %stz = %c1)878             dynamic_shared_memory_size %shmemSize879  {880    // expected-error @below {{'gpu.dynamic_shared_memory' op result memref type must be memref<?xi8, #gpu.address_space<workgroup>>}}881    %0 = gpu.dynamic_shared_memory : memref<1xi8, #gpu.address_space<workgroup>>882    gpu.terminator883  }884  return885}886 887// -----888 889func.func @main(%arg0 : index) {890  %shmemSize = arith.constant 8192 : i32891  %c1 = arith.constant 1 : index892  gpu.launch blocks(%bx, %by, %bz) in (%sbx = %c1, %sby = %c1, %sbz = %c1)893             threads(%tx, %ty, %tz) in (%stx = %c1, %sty = %c1, %stz = %c1)894             dynamic_shared_memory_size %shmemSize895  {896    // expected-error @below {{'gpu.dynamic_shared_memory' op address space must be address_space<workgroup>}}897    %0 = gpu.dynamic_shared_memory : memref<?xi8, #gpu.address_space<private>>898    gpu.terminator899  }900  return901}902 903// -----904 905func.func @main(%arg0 : index) {906  %shmemSize = arith.constant 8192 : i32907  %c1 = arith.constant 1 : index908  gpu.launch blocks(%bx, %by, %bz) in (%sbx = %c1, %sby = %c1, %sbz = %c1)909             threads(%tx, %ty, %tz) in (%stx = %c1, %sty = %c1, %stz = %c1)910             dynamic_shared_memory_size %shmemSize911  {912    // expected-error @below {{'gpu.dynamic_shared_memory' op result #0 must be 1D memref of 8-bit signless integer values, but got 'memref<?xf32, #gpu.address_space<workgroup>}}913    %0 = gpu.dynamic_shared_memory : memref<?xf32, #gpu.address_space<workgroup>>914    gpu.terminator915  }916  return917}918 919// -----920 921module attributes {gpu.container_module} {922  // expected-error@+1 {{expected attribute value}}923  gpu.module @kernel <> {924  }925}926 927// -----928 929gpu.binary @binary [#gpu.object<#rocdl.target<chip = "gfx900">,930  // expected-error@+1{{expected all kernels to be uniquely named}}931    kernels = #gpu.kernel_table<[932      #gpu.kernel_metadata<"kernel", (i32) -> ()>,933      #gpu.kernel_metadata<"kernel", (i32, f32) -> (), metadata = {sgpr_count = 255}>934  // expected-error@below{{failed to parse GPU_ObjectAttr parameter 'kernels' which is to be a `KernelTableAttr`}}935    ]>,936    bin = "BLOB">937  ]938 939// -----940 941func.func @warp_wrong_num_outputs(%laneid: index) {942  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op expected same number of yield operands and return values.}}943  %2 = gpu.warp_execute_on_lane_0(%laneid)[64] -> (vector<4xi32>) {944  }945  return946}947 948// -----949 950func.func @warp_wrong_num_inputs(%laneid: index) {951  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op expected same number op arguments and block arguments.}}952  gpu.warp_execute_on_lane_0(%laneid)[64] {953  ^bb0(%arg0 : vector<128xi32>) :954  }955  return956}957 958// -----959 960func.func @warp_wrong_return_distribution(%laneid: index) {961  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op incompatible distribution dimensions from 'vector<128xi32>' to 'vector<4xi32>'}}962  %2 = gpu.warp_execute_on_lane_0(%laneid)[64] -> (vector<4xi32>) {963    %0 = arith.constant dense<2>: vector<128xi32>964    gpu.yield %0 : vector<128xi32>965  }966  return967}968 969 970// -----971 972func.func @warp_wrong_arg_distribution(%laneid: index, %v0 : vector<4xi32>) {973  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op incompatible distribution dimensions from 'vector<128xi32>' to 'vector<4xi32>'}}974  gpu.warp_execute_on_lane_0(%laneid)[64]975  args(%v0 : vector<4xi32>) {976   ^bb0(%arg0 : vector<128xi32>) :977  }978  return979}980 981// -----982 983func.func @warp_2_distributed_dims(%laneid: index) {984  // expected-error@+1 {{incompatible distribution dimensions from 'vector<128x128xi32>' to 'vector<4x4xi32>' with warp size = 32}}985  %2 = gpu.warp_execute_on_lane_0(%laneid)[32] -> (vector<4x4xi32>) {986    %0 = arith.constant dense<2>: vector<128x128xi32>987    gpu.yield %0 : vector<128x128xi32>988  }989  return990}991 992// -----993 994func.func @warp_2_distributed_dims(%laneid: index) {995  // expected-error@+1 {{expected expanded vector dimension #1 (8) to be a multipler of the distributed vector dimension (3)}}996  %2 = gpu.warp_execute_on_lane_0(%laneid)[32] -> (vector<1x3xi32>) {997    %0 = arith.constant dense<2>: vector<4x8xi32>998    gpu.yield %0 : vector<4x8xi32>999  }1000  return1001}1002 1003// -----1004 1005func.func @warp_mismatch_rank(%laneid: index) {1006  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op expected distributed vectors to have same rank and element type.}}1007  %2 = gpu.warp_execute_on_lane_0(%laneid)[32] -> (vector<4x4xi32>) {1008    %0 = arith.constant dense<2>: vector<128xi32>1009    gpu.yield %0 : vector<128xi32>1010  }1011  return1012}1013 1014// -----1015 1016func.func @warp_mismatch_rank(%laneid: index) {1017  // expected-error@+1 {{'gpu.warp_execute_on_lane_0' op expected vector type for distributed operands.}}1018  %2 = gpu.warp_execute_on_lane_0(%laneid)[32] -> (i32) {1019    %0 = arith.constant dense<2>: vector<128xi32>1020    gpu.yield %0 : vector<128xi32>1021  }1022  return1023}1024