brintos

brintos / llvm-project-archived public Read only

0
0
Text · 15.9 KiB · 58d4940 Raw
668 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics2 3func.func @elementsattr_non_tensor_type() -> () {4  "foo"(){bar = dense<[4]> : i32} : () -> () // expected-error {{elements literal must be a shaped type}}5}6 7// -----8 9func.func @elementsattr_non_ranked() -> () {10  "foo"(){bar = dense<[4]> : tensor<?xi32>} : () -> () // expected-error {{elements literal type must have static shape}}11}12 13// -----14 15func.func @elementsattr_shape_mismatch() -> () {16  "foo"(){bar = dense<[4]> : tensor<5xi32>} : () -> () // expected-error {{inferred shape of elements literal ([1]) does not match type ([5])}}17}18 19// -----20 21func.func @elementsattr_invalid() -> () {22  "foo"(){bar = dense<[4, [5]]> : tensor<2xi32>} : () -> () // expected-error {{tensor literal is invalid; ranks are not consistent between elements}}23}24 25// -----26 27func.func @elementsattr_badtoken() -> () {28  "foo"(){bar = dense<[tf_opaque]> : tensor<1xi32>} : () -> () // expected-error {{expected element literal of primitive type}}29}30 31// -----32 33func.func @elementsattr_floattype1() -> () {34  // expected-error@+1 {{expected integer elements, but parsed floating-point}}35  "foo"(){bar = dense<[4.0]> : tensor<1xi32>} : () -> ()36}37 38// -----39 40func.func @elementsattr_floattype1() -> () {41  // expected-error@+1 {{expected integer elements, but parsed floating-point}}42  "foo"(){bar = dense<4.0> : tensor<i32>} : () -> ()43}44 45// -----46 47func.func @elementsattr_floattype2() -> () {48  // expected-error@below {{unexpected decimal integer literal for a floating point value}}49  // expected-note@below {{add a trailing dot to make the literal a float}}50  "foo"(){bar = dense<[4]> : tensor<1xf32>} : () -> ()51}52 53// -----54 55func.func @elementsattr_toolarge1() -> () {56  "foo"(){bar = dense<[777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}57}58 59// -----60 61// expected-error@+1 {{parsed zero elements, but type ('tensor<i64>') expected at least 1}}62#attr = dense<> : tensor<i64>63 64// -----65 66// expected-error@+1 {{parsed 1 elements, but type ('complex<i64>') expected 2 elements}}67#attr = dense<0> : tensor<2xcomplex<i64>>68 69// -----70 71// expected-error@+1 {{parsed 2 elements, but type ('tensor<2xcomplex<i64>>') expected 4 elements}}72#attr = dense<[0, 1]> : tensor<2xcomplex<i64>>73 74// -----75 76// expected-error@+1 {{parsed 3 elements, but type ('tensor<2xcomplex<i64>>') expected 4 elements}}77#attr = dense<[0, (0, 1)]> : tensor<2xcomplex<i64>>78 79// -----80 81func.func @elementsattr_toolarge2() -> () {82  "foo"(){bar = dense<[-777]> : tensor<1xi8>} : () -> () // expected-error {{integer constant out of range}}83}84 85// -----86 87"foo"(){bar = dense<[()]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}88 89// -----90 91"foo"(){bar = dense<[(10)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ',' between complex elements}}92 93// -----94 95"foo"(){bar = dense<[(10,)]> : tensor<complex<i64>>} : () -> () // expected-error {{expected element literal of primitive type}}96 97// -----98 99"foo"(){bar = dense<[(10,10]> : tensor<complex<i64>>} : () -> () // expected-error {{expected ')' after complex elements}}100 101// -----102 103func.func @mi() {104  // expected-error @+1 {{expected element literal of primitive type}}105  "fooi64"(){bar = sparse<vector<1xi64>,[,[,1]106 107// -----108 109func.func @invalid_tensor_literal() {110  // expected-error @+1 {{expected 1-d tensor for sparse element values}}111  "foof16"(){bar = sparse<[[0, 0, 0]],  [[-2.0]]> : vector<1x1x1xf16>} : () -> ()112 113// -----114 115func.func @invalid_tensor_literal() {116  // expected-error @+1 {{expected element literal of primitive type}}117  "fooi16"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0,, [[0, 0, 0]], [-2.0]> : tensor<2x2x2xi16>} : () -> ()118 119// -----120 121func.func @invalid_tensor_literal() {122  // expected-error @+1 {{sparse index #0 is not contained within the value shape, with index=[1, 1], and type='tensor<1x1xi16>'}}123  "fooi16"(){bar = sparse<1, 10> : tensor<1x1xi16>} : () -> ()124 125// -----126 127func.func @invalid_sparse_indices() {128  // expected-error @+1 {{expected integer elements, but parsed floating-point}}129  "foo"(){bar = sparse<0.5, 1> : tensor<1xi16>} : () -> ()130}131 132// -----133 134func.func @invalid_sparse_values() {135  // expected-error @+1 {{expected integer elements, but parsed floating-point}}136  "foo"(){bar = sparse<0, 1.1> : tensor<1xi16>} : () -> ()137}138 139// -----140 141func.func @hexadecimal_float_leading_minus() {142  // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}143  "foo"() {value = -0x7fff : f16} : () -> ()144}145 146// -----147 148func.func @hexadecimal_float_literal_overflow() {149  // expected-error @+1 {{hexadecimal float constant out of range for type}}150  "foo"() {value = 0xffffffff : f16} : () -> ()151}152 153// -----154 155func.func @decimal_float_literal() {156  // expected-error @+2 {{unexpected decimal integer literal for a floating point value}}157  // expected-note @+1 {{add a trailing dot to make the literal a float}}158  "foo"() {value = 42 : f32} : () -> ()159}160 161// -----162 163func.func @float_in_int_tensor() {164  // expected-error @+1 {{expected integer elements, but parsed floating-point}}165  "foo"() {bar = dense<[42.0, 42]> : tensor<2xi32>} : () -> ()166}167 168// -----169 170func.func @float_in_bool_tensor() {171  // expected-error@below {{expected integer elements, but parsed floating-point}}172  "foo"() {bar = dense<[true, 42.0]> : tensor<2xi1>} : () -> ()173}174 175// -----176 177func.func @decimal_int_in_float_tensor() {178  // expected-error@below {{unexpected decimal integer literal for a floating point value}}179  // expected-note@below {{add a trailing dot to make the literal a float}}180  "foo"() {bar = dense<[42, 42.0]> : tensor<2xf32>} : () -> ()181}182 183// -----184 185func.func @bool_in_float_tensor() {186  // expected-error @+1 {{expected floating point literal}}187  "foo"() {bar = dense<[42.0, true]> : tensor<2xf32>} : () -> ()188}189 190// -----191 192func.func @hexadecimal_float_leading_minus_in_tensor() {193  // expected-error @+1 {{hexadecimal float literal should not have a leading minus}}194  "foo"() {bar = dense<-0x7FFFFFFF> : tensor<2xf32>} : () -> ()195}196 197// -----198 199// Check that we report an error when a value could be parsed, but does not fit200// into the specified type.201func.func @hexadecimal_float_too_wide_for_type_in_tensor() {202  // expected-error @+1 {{hexadecimal float constant out of range for type}}203  "foo"() {bar = dense<0x7FF0000000000000> : tensor<2xf32>} : () -> ()204}205 206// -----207 208// Check that we report an error when a value is too wide to be parsed.209func.func @hexadecimal_float_too_wide_in_tensor() {210  // expected-error @+1 {{hexadecimal float constant out of range for type}}211  "foo"() {bar = dense<0x7FFFFFF0000000000000> : tensor<2xf32>} : () -> ()212}213 214// -----215 216func.func @integer_too_wide_in_tensor() {217  // expected-error @+1 {{integer constant out of range for type}}218  "foo"() {bar = dense<0xFFFFFFFFFFFFFF> : tensor<2xi16>} : () -> ()219}220 221// -----222 223func.func @bool_literal_in_non_bool_tensor() {224  // expected-error @+1 {{expected i1 type for 'true' or 'false' values}}225  "foo"() {bar = dense<true> : tensor<2xi16>} : () -> ()226}227 228// -----229 230func.func @negative_value_in_unsigned_int_attr() {231  // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}232  "foo"() {bar = -5 : ui32} : () -> ()233}234 235// -----236 237func.func @negative_value_in_unsigned_vector_attr() {238  // expected-error @+1 {{expected unsigned integer elements, but parsed negative value}}239  "foo"() {bar = dense<[5, -5]> : vector<2xui32>} : () -> ()240}241 242// -----243 244func.func @large_bound() {245  "test.out_of_range_attribute"() {246    // expected-error @+1 {{integer constant out of range for attribute}}247    attr = -129 : i8248  } : () -> ()249  return250}251 252// -----253 254func.func @large_bound() {255  "test.out_of_range_attribute"() {256    // expected-error @+1 {{integer constant out of range for attribute}}257    attr = 256 : i8258  } : () -> ()259  return260}261 262// -----263 264func.func @large_bound() {265  "test.out_of_range_attribute"() {266    // expected-error @+1 {{integer constant out of range for attribute}}267    attr = -129 : si8268  } : () -> ()269  return270}271 272// -----273 274func.func @large_bound() {275  "test.out_of_range_attribute"() {276    // expected-error @+1 {{integer constant out of range for attribute}}277    attr = 129 : si8278  } : () -> ()279  return280}281 282// -----283 284func.func @large_bound() {285  "test.out_of_range_attribute"() {286    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}287    attr = -1 : ui8288  } : () -> ()289  return290}291 292// -----293 294func.func @large_bound() {295  "test.out_of_range_attribute"() {296    // expected-error @+1 {{integer constant out of range for attribute}}297    attr = 256 : ui8298  } : () -> ()299  return300}301 302// -----303 304func.func @large_bound() {305  "test.out_of_range_attribute"() {306    // expected-error @+1 {{integer constant out of range for attribute}}307    attr = -32769 : i16308  } : () -> ()309  return310}311 312// -----313 314func.func @large_bound() {315  "test.out_of_range_attribute"() {316    // expected-error @+1 {{integer constant out of range for attribute}}317    attr = 65536 : i16318  } : () -> ()319  return320}321 322// -----323 324func.func @large_bound() {325  "test.out_of_range_attribute"() {326    // expected-error @+1 {{integer constant out of range for attribute}}327    attr = -32769 : si16328  } : () -> ()329  return330}331 332// -----333 334func.func @large_bound() {335  "test.out_of_range_attribute"() {336    // expected-error @+1 {{integer constant out of range for attribute}}337    attr = 32768 : si16338  } : () -> ()339  return340}341 342// -----343 344func.func @large_bound() {345  "test.out_of_range_attribute"() {346    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}347    attr = -1 : ui16348  } : () -> ()349  return350}351 352// -----353 354func.func @large_bound() {355  "test.out_of_range_attribute"() {356    // expected-error @+1 {{integer constant out of range for attribute}}357    attr = 65536: ui16358  } : () -> ()359  return360}361 362// -----363 364func.func @large_bound() {365  "test.out_of_range_attribute"() {366    // expected-error @+1 {{integer constant out of range for attribute}}367    attr = -2147483649 : i32368  } : () -> ()369  return370}371 372// -----373 374func.func @large_bound() {375  "test.out_of_range_attribute"() {376    // expected-error @+1 {{integer constant out of range for attribute}}377    attr = 4294967296 : i32378  } : () -> ()379  return380}381 382// -----383 384func.func @large_bound() {385  "test.out_of_range_attribute"() {386    // expected-error @+1 {{integer constant out of range for attribute}}387    attr = -2147483649 : si32388  } : () -> ()389  return390}391 392// -----393 394func.func @large_bound() {395  "test.out_of_range_attribute"() {396    // expected-error @+1 {{integer constant out of range for attribute}}397    attr = 2147483648 : si32398  } : () -> ()399  return400}401 402// -----403 404func.func @large_bound() {405  "test.out_of_range_attribute"() {406    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}407    attr = -1 : ui32408  } : () -> ()409  return410}411 412// -----413 414func.func @large_bound() {415  "test.out_of_range_attribute"() {416    // expected-error @+1 {{integer constant out of range for attribute}}417    attr = 4294967296 : ui32418  } : () -> ()419  return420}421 422// -----423 424func.func @large_bound() {425  "test.out_of_range_attribute"() {426    // expected-error @+1 {{integer constant out of range for attribute}}427    attr = -9223372036854775809 : i64428  } : () -> ()429  return430}431 432// -----433 434func.func @large_bound() {435  "test.out_of_range_attribute"() {436    // expected-error @+1 {{integer constant out of range for attribute}}437    attr = 18446744073709551616 : i64438  } : () -> ()439  return440}441 442// -----443 444func.func @large_bound() {445  "test.out_of_range_attribute"() {446    // expected-error @+1 {{integer constant out of range for attribute}}447    attr = -9223372036854775809 : si64448  } : () -> ()449  return450}451 452// -----453 454func.func @large_bound() {455  "test.out_of_range_attribute"() {456    // expected-error @+1 {{integer constant out of range for attribute}}457    attr = 9223372036854775808 : si64458  } : () -> ()459  return460}461 462// -----463 464func.func @large_bound() {465  "test.out_of_range_attribute"() {466    // expected-error @+1 {{negative integer literal not valid for unsigned integer type}}467    attr = -1 : ui64468  } : () -> ()469  return470}471 472// -----473 474func.func @large_bound() {475  "test.out_of_range_attribute"() {476    // expected-error @+1 {{integer constant out of range for attribute}}477    attr = 18446744073709551616 : ui64478  } : () -> ()479  return480}481 482// -----483 484func.func @really_large_bound() {485  "test.out_of_range_attribute"() {486    // expected-error @+1 {{integer constant out of range for attribute}}487    attr = 79228162514264337593543950336 : ui96488  } : () -> ()489  return490}491 492// -----493 494func.func @really_large_bound() {495  "test.out_of_range_attribute"() {496    // expected-error @+1 {{integer constant out of range for attribute}}497    attr = 79228162514264337593543950336 : i96498  } : () -> ()499  return500}501 502// -----503 504func.func @really_large_bound() {505  "test.out_of_range_attribute"() {506    // expected-error @+1 {{integer constant out of range for attribute}}507    attr = 39614081257132168796771975168 : si96508  } : () -> ()509  return510}511 512// -----513 514func.func @duplicate_dictionary_attr_key() {515  // expected-error @+1 {{duplicate key 'a' in dictionary attribute}}516  "foo.op"() {a, a} : () -> ()517}518 519// -----520 521// expected-error@+1 {{expected ',' or ']'}}522"f"() { b = [@m:523 524// -----525 526"       // expected-error {{expected}}527"528 529// -----530 531// expected-error@+1 {{expected '"' in string literal}}532"J// -----533 534"       // expected-error {{expected}}535 536// -----537 538// expected-error@+1 {{expected '<' after 'dense_resource'}}539#attr = dense_resource>540 541// -----542 543// expected-error@+1 {{expected '>'}}544#attr = dense_resource<resource545 546// -----547 548// expected-error@+1 {{expected ':'}}549#attr = dense_resource<resource>550 551// -----552 553// expected-error@+1 {{`dense_resource` expected a shaped type}}554#attr = dense_resource<resource> : i32555 556// -----557 558// expected-error@below {{expected '<' after 'array'}}559#attr = array560 561// -----562 563// expected-error@below {{expected integer or float type}}564#attr = array<vector<i32>>565 566// -----567 568// expected-error@below {{element type bitwidth must be a multiple of 8}}569#attr = array<i7>570 571// -----572 573// expected-error@below {{expected ':' after dense array type}}574#attr = array<i8)575 576// -----577 578// expected-error@below {{expected '>' to close an array attribute}}579#attr = array<i8: 1)580 581// -----582 583// expected-error@below {{expected '[' after 'distinct'}}584#attr = distinct<585 586// -----587 588// expected-error@below {{expected distinct ID}}589#attr = distinct[i8590 591// -----592 593// expected-error@below {{expected an unsigned 64-bit integer}}594#attr = distinct[0xAAAABBBBEEEEFFFF1]595 596// -----597 598// expected-error@below {{expected ']' to close distinct ID}}599#attr = distinct[8)600 601// -----602 603// expected-error@below {{expected '<' after distinct ID}}604#attr = distinct[8](605 606// -----607 608// expected-error@below {{expected attribute}}609#attr = distinct[8]<attribute610 611// -----612 613// expected-error@below {{expected '>' to close distinct attribute}}614#attr = distinct[8]<@foo]615 616// -----617 618#attr = distinct[0]<42 : i32>619// expected-error@below {{referenced attribute does not match previous definition: 42 : i32}}620#attr1 = distinct[0]<43 : i32>621 622// -----623 624// Make sure the error is not printed on the return.625func.func @print_error_on_correct_line() {626  %0 = arith.constant627    // expected-error@below {{elements literal must be a shaped type}} 628    dense<[3]> : i32629  return630}631 632// -----633 634// Make sure the error is not printed on the return.635func.func @print_error_on_correct_line() {636  %0 = arith.constant 637    // expected-error@below {{elements literal must be a shaped type}}638    sparse<639     [640       [0, 1, 2, 3],641       [1, 1, 2, 3],642       [1, 2, 2, 3],643       [1, 2, 3, 4]644     ],645     [1, 1, 1, 1] > : i32646  return647}648 649// -----650 651// Make sure the error is not printed on the return.652func.func @print_error_on_correct_line() {653  %0 = arith.constant 654    // expected-error@below {{elements literal must be a shaped type}}655    sparse <> : i32656  return657}658 659// -----660 661// Prevent assertions when parsing a dense attribute expected to be a string 662// but encountering a different type. 663func.func @expect_to_parse_literal() {664  // expected-error@below {{expected string token, got 23}}665  %0 = arith.constant dense<[23]> : tensor<1x!unknown<>>666  return667}668