1// RUN: mlir-opt %s -test-elements-attr-interface -verify-diagnostics 2 3// Parsing external resources does not work on big-endian platforms currently 4// XFAIL: s390x- 5 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. 10 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}} 15arith.constant #test.i64_elements<[10, 11, 12, 13, 14]> : tensor<5xi64> 16 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}} 21arith.constant dense<[10, 11, 12, 13, 14]> : tensor<5xi64> 22 23// expected-error@below {{Test iterating `int64_t`: unable to iterate type}} 24// expected-error@below {{Test iterating `uint64_t`: unable to iterate type}} 25// expected-error@below {{Test iterating `APInt`: unable to iterate type}} 26// expected-error@below {{Test iterating `IntegerAttr`: unable to iterate type}} 27arith.constant opaque<"_", "0xDEADBEEF"> : tensor<5xi64> 28 29// Check that we don't crash on empty element attributes. 30// expected-error@below {{Test iterating `int64_t`: }} 31// expected-error@below {{Test iterating `uint64_t`: }} 32// expected-error@below {{Test iterating `APInt`: }} 33// expected-error@below {{Test iterating `IntegerAttr`: }} 34arith.constant dense<> : tensor<0xi64> 35 36// expected-error@below {{Test iterating `int8_t`: 10, 11, -12, 13, 14}} 37arith.constant [:i8 10, 11, -12, 13, 14] 38// expected-error@below {{Test iterating `int16_t`: 10, 11, -12, 13, 14}} 39arith.constant [:i16 10, 11, -12, 13, 14] 40// expected-error@below {{Test iterating `int32_t`: 10, 11, -12, 13, 14}} 41arith.constant [:i32 10, 11, -12, 13, 14] 42// expected-error@below {{Test iterating `int64_t`: 10, 11, -12, 13, 14}} 43arith.constant [:i64 10, 11, -12, 13, 14] 44// expected-error@below {{Test iterating `float`: 10.00, 11.00, -12.00, 13.00, 14.00}} 45arith.constant [:f32 10., 11., -12., 13., 14.] 46// expected-error@below {{Test iterating `double`: 10.00, 11.00, -12.00, 13.00, 14.00}} 47arith.constant [:f64 10., 11., -12., 13., 14.] 48 49// Check that we handle an external constant parsed from the config. 50// expected-error@below {{Test iterating `int64_t`: unable to iterate type}} 51// expected-error@below {{Test iterating `uint64_t`: 1, 2, 3}} 52// expected-error@below {{Test iterating `APInt`: unable to iterate type}} 53// expected-error@below {{Test iterating `IntegerAttr`: unable to iterate type}} 54arith.constant #test.e1di64_elements<blob1> : tensor<3xi64> 55 56{-# 57 dialect_resources: { 58 test: { 59 blob1: "0x08000000010000000000000002000000000000000300000000000000" 60 } 61 } 62#-} 63