1 // RUN: mlir-opt %s -test-elements-attr-interface -verify-diagnostics
3 // Parsing external resources does not work on big-endian platforms currently
4 // XFAIL: target={{(s390x|sparc.*)-.*}}
6 // This test contains various `ElementsAttr` attributes, and tests the support
7 // for iterating the values of these attributes using various native C++ types.
8 // This tests that the abstract iteration of ElementsAttr works properly, and
9 // is properly failable when necessary.
11 // expected-error@below {{Test iterating `int64_t`: unable to iterate type}}
12 // expected-error@below {{Test iterating `uint64_t`: 10, 11, 12, 13, 14}}
13 // expected-error@below {{Test iterating `APInt`: 10, 11, 12, 13, 14}}
14 // expected-error@below {{Test iterating `IntegerAttr`: 10 : i64, 11 : i64, 12 : i64, 13 : i64, 14 : i64}}
15 arith.constant #test.i64_elements<[10, 11, 12, 13, 14]> : tensor<5xi64>
17 // expected-error@below {{Test iterating `int64_t`: 10, 11, 12, 13, 14}}
18 // expected-error@below {{Test iterating `uint64_t`: 10, 11, 12, 13, 14}}
19 // expected-error@below {{Test iterating `APInt`: 10, 11, 12, 13, 14}}
20 // expected-error@below {{Test iterating `IntegerAttr`: 10 : i64, 11 : i64, 12 : i64, 13 : i64, 14 : i64}}
21 arith.constant dense<[10, 11, 12, 13, 14]> : tensor<5xi64>
23 // This test is expected to only be called on integer elements.
24 // expected-error@below {{Test iterating `int64_t`: expected element type to be an integer type}}
25 // expected-error@below {{Test iterating `uint64_t`: expected element type to be an integer type}}
26 // expected-error@below {{Test iterating `APInt`: expected element type to be an integer type}}
27 // expected-error@below {{Test iterating `IntegerAttr`: expected element type to be an integer type}}
28 arith.constant dense<[1.1, 1.2, 1.3]> : tensor<3xf32>
30 // Check that we don't crash on empty element attributes.
31 // expected-error@below {{Test iterating `int64_t`: }}
32 // expected-error@below {{Test iterating `uint64_t`: }}
33 // expected-error@below {{Test iterating `APInt`: }}
34 // expected-error@below {{Test iterating `IntegerAttr`: }}
35 arith.constant dense<> : tensor<0xi64>
37 // Check that we handle an external constant parsed from the config.
38 // expected-error@below {{Test iterating `int64_t`: unable to iterate type}}
39 // expected-error@below {{Test iterating `uint64_t`: 1, 2, 3}}
40 // expected-error@below {{Test iterating `APInt`: unable to iterate type}}
41 // expected-error@below {{Test iterating `IntegerAttr`: unable to iterate type}}
42 arith.constant #test.e1di64_elements<blob1> : tensor<3xi64>
47 blob1: "0x08000000010000000000000002000000000000000300000000000000"
52 // expected-error@below {{Test iterating `int64_t`: 0, 0, 1}}
53 // expected-error@below {{Test iterating `uint64_t`: 0, 0, 1}}
54 // expected-error@below {{Test iterating `APInt`: 0, 0, 1}}
55 // expected-error@below {{Test iterating `IntegerAttr`: 0 : i64, 0 : i64, 1 : i64}}
56 arith.constant sparse<[[0, 0, 2]], 1> : vector <1x1x3xi64>