2019-06-25 05:35:21 +08:00
|
|
|
// RUN: mlir-opt %s -split-input-file -verify-diagnostics | FileCheck %s
|
2019-06-04 05:52:56 +08:00
|
|
|
|
2020-03-05 03:41:27 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test integer attributes
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @int_attrs_pass() {
|
|
|
|
"test.int_attrs"() {
|
|
|
|
// CHECK: any_i32_attr = 5 : ui32
|
|
|
|
any_i32_attr = 5 : ui32,
|
|
|
|
// CHECK-SAME: si32_attr = 7 : si32
|
|
|
|
si32_attr = 7 : si32,
|
|
|
|
// CHECK-SAME: ui32_attr = 6 : ui32
|
|
|
|
ui32_attr = 6 : ui32
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
"test.int_attrs"() {
|
|
|
|
// CHECK: any_i32_attr = 5 : si32
|
|
|
|
any_i32_attr = 5 : si32,
|
|
|
|
si32_attr = 7 : si32,
|
|
|
|
ui32_attr = 6 : ui32
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
"test.int_attrs"() {
|
|
|
|
// CHECK: any_i32_attr = 5 : i32
|
|
|
|
any_i32_attr = 5 : i32,
|
|
|
|
si32_attr = 7 : si32,
|
|
|
|
ui32_attr = 6 : ui32
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2020-03-26 02:51:34 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
[mlir] NFC: fix trivial typo in documents
Reviewers: mravishankar, antiagainst, nicolasvasilache, herhut, aartbik, mehdi_amini, bondhugula
Reviewed By: mehdi_amini, bondhugula
Subscribers: bondhugula, jdoerfert, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, Joonsoo, bader, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76993
2020-03-29 02:20:02 +08:00
|
|
|
// Check that the maximum and minimum integer attribute values are
|
2020-03-26 02:51:34 +08:00
|
|
|
// representable and preserved during a round-trip.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @int_attrs_pass() {
|
|
|
|
"test.in_range_attrs"() {
|
|
|
|
// CHECK: attr_00 = -128 : i8
|
|
|
|
attr_00 = -128 : i8,
|
|
|
|
// CHECK-SAME: attr_01 = 127 : i8
|
|
|
|
attr_01 = 127 : i8,
|
|
|
|
// CHECK-SAME: attr_02 = -128 : si8
|
|
|
|
attr_02 = -128 : si8,
|
|
|
|
// CHECK-SAME: attr_03 = 127 : si8
|
|
|
|
attr_03 = 127 : si8,
|
|
|
|
// CHECK-SAME: attr_04 = 255 : ui8
|
|
|
|
attr_04 = 255 : ui8,
|
|
|
|
// CHECK-SAME: attr_05 = -32768 : i16
|
|
|
|
attr_05 = -32768 : i16,
|
|
|
|
// CHECK-SAME: attr_06 = 32767 : i16
|
|
|
|
attr_06 = 32767 : i16,
|
|
|
|
// CHECK-SAME: attr_07 = -32768 : si16
|
|
|
|
attr_07 = -32768 : si16,
|
|
|
|
// CHECK-SAME: attr_08 = 32767 : si16
|
|
|
|
attr_08 = 32767 : si16,
|
|
|
|
// CHECK-SAME: attr_09 = 65535 : ui16
|
|
|
|
attr_09 = 65535 : ui16,
|
|
|
|
// CHECK-SAME: attr_10 = -2147483647 : i32
|
|
|
|
attr_10 = -2147483647 : i32,
|
|
|
|
// CHECK-SAME: attr_11 = 2147483646 : i32
|
|
|
|
attr_11 = 2147483646 : i32,
|
|
|
|
// CHECK-SAME: attr_12 = -2147483647 : si32
|
|
|
|
attr_12 = -2147483647 : si32,
|
|
|
|
// CHECK-SAME: attr_13 = 2147483646 : si32
|
|
|
|
attr_13 = 2147483646 : si32,
|
|
|
|
// CHECK-SAME: attr_14 = 4294967295 : ui32
|
|
|
|
attr_14 = 4294967295 : ui32,
|
|
|
|
// CHECK-SAME: attr_15 = -9223372036854775808 : i64
|
|
|
|
attr_15 = -9223372036854775808 : i64,
|
|
|
|
// CHECK-SAME: attr_16 = 9223372036854775807 : i64
|
|
|
|
attr_16 = 9223372036854775807 : i64,
|
|
|
|
// CHECK-SAME: attr_17 = -9223372036854775808 : si64
|
|
|
|
attr_17 = -9223372036854775808 : si64,
|
|
|
|
// CHECK-SAME: attr_18 = 9223372036854775807 : si64
|
|
|
|
attr_18 = 9223372036854775807 : si64,
|
|
|
|
// CHECK-SAME: attr_19 = 18446744073709551615 : ui64
|
Allow single-bit integer types to have signs. A signed one bit integer is either 0 or -1.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77832
2020-04-10 05:58:28 +08:00
|
|
|
attr_19 = 18446744073709551615 : ui64,
|
|
|
|
// CHECK-SAME: attr_20 = 1 : ui1
|
2020-04-10 06:25:53 +08:00
|
|
|
attr_20 = 1 : ui1,
|
Allow single-bit integer types to have signs. A signed one bit integer is either 0 or -1.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D77832
2020-04-10 05:58:28 +08:00
|
|
|
// CHECK-SAME: attr_21 = -1 : si1
|
Fix the MLIR integer attribute parser to be correct in the face of large integer attributes, it was previously artificially limited to 64 bits.
Reviewers: rriddle!
Subscribers: mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D78065
2020-04-14 07:37:00 +08:00
|
|
|
attr_21 = -1 : si1,
|
|
|
|
// CHECK-SAME: attr_22 = 79228162514264337593543950335 : ui96
|
|
|
|
attr_22 = 79228162514264337593543950335 : ui96,
|
|
|
|
// CHECK-SAME: attr_23 = -39614081257132168796771975168 : si96
|
|
|
|
attr_23 = -39614081257132168796771975168 : si96
|
2020-03-26 02:51:34 +08:00
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Check that positive values larger than 2^n-1 for signless integers
|
|
|
|
// are mapped to their negative signed counterpart. This behaviour is
|
|
|
|
// undocumented in the language specification, but it is what the
|
|
|
|
// parser currently does.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @int_attrs_pass() {
|
|
|
|
"test.i8_attr"() {
|
|
|
|
// CHECK: attr_00 = -1 : i8
|
|
|
|
attr_00 = 255 : i8,
|
|
|
|
// CHECK-SAME: attr_01 = -1 : i16
|
|
|
|
attr_01 = 65535 : i16,
|
|
|
|
// CHECK-SAME: attr_02 = -1 : i32
|
|
|
|
attr_02 = 4294967295 : i32,
|
|
|
|
// CHECK-SAME: attr_03 = -1 : i64
|
|
|
|
attr_03 = 18446744073709551615 : i64
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// -----
|
|
|
|
|
|
|
|
|
2020-03-05 03:41:27 +08:00
|
|
|
func @wrong_int_attrs_signedness_fail() {
|
|
|
|
// expected-error @+1 {{'si32_attr' failed to satisfy constraint: 32-bit signed integer attribute}}
|
|
|
|
"test.int_attrs"() {
|
|
|
|
any_i32_attr = 5 : i32,
|
|
|
|
si32_attr = 7 : ui32,
|
|
|
|
ui32_attr = 6 : ui32
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_int_attrs_signedness_fail() {
|
|
|
|
// expected-error @+1 {{'ui32_attr' failed to satisfy constraint: 32-bit unsigned integer attribute}}
|
|
|
|
"test.int_attrs"() {
|
|
|
|
any_i32_attr = 5 : i32,
|
|
|
|
si32_attr = 7 : si32,
|
|
|
|
ui32_attr = 6 : si32
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_int_attrs_type_fail() {
|
|
|
|
// expected-error @+1 {{'any_i32_attr' failed to satisfy constraint: 32-bit integer attribute}}
|
|
|
|
"test.int_attrs"() {
|
|
|
|
any_i32_attr = 5.0 : f32,
|
|
|
|
si32_attr = 7 : si32,
|
|
|
|
ui32_attr = 6 : ui32
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2019-06-04 05:52:56 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2019-08-04 07:58:26 +08:00
|
|
|
// Test Non-negative Int Attr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @non_negative_int_attr_pass() {
|
|
|
|
// CHECK: test.non_negative_int_attr
|
|
|
|
"test.non_negative_int_attr"() {i32attr = 5 : i32, i64attr = 10 : i64} : () -> ()
|
|
|
|
// CHECK: test.non_negative_int_attr
|
|
|
|
"test.non_negative_int_attr"() {i32attr = 0 : i32, i64attr = 0 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @negative_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i32attr' failed to satisfy constraint: 32-bit signless integer attribute whose value is non-negative}}
|
2019-08-04 07:58:26 +08:00
|
|
|
"test.non_negative_int_attr"() {i32attr = -5 : i32, i64attr = 10 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @negative_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i64attr' failed to satisfy constraint: 64-bit signless integer attribute whose value is non-negative}}
|
2019-08-04 07:58:26 +08:00
|
|
|
"test.non_negative_int_attr"() {i32attr = 5 : i32, i64attr = -10 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2019-08-23 01:36:01 +08:00
|
|
|
// Test Positive Int Attr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @positive_int_attr_pass() {
|
|
|
|
// CHECK: test.positive_int_attr
|
|
|
|
"test.positive_int_attr"() {i32attr = 5 : i32, i64attr = 10 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @positive_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i32attr' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive}}
|
2019-08-23 01:36:01 +08:00
|
|
|
"test.positive_int_attr"() {i32attr = 0 : i32, i64attr = 5: i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @positive_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i64attr' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}
|
2019-08-23 01:36:01 +08:00
|
|
|
"test.positive_int_attr"() {i32attr = 5 : i32, i64attr = 0: i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @positive_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i32attr' failed to satisfy constraint: 32-bit signless integer attribute whose value is positive}}
|
2019-08-23 01:36:01 +08:00
|
|
|
"test.positive_int_attr"() {i32attr = -10 : i32, i64attr = 5 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @positive_int_attr_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{'i64attr' failed to satisfy constraint: 64-bit signless integer attribute whose value is positive}}
|
2019-08-23 01:36:01 +08:00
|
|
|
"test.positive_int_attr"() {i32attr = 5 : i32, i64attr = -10 : i64} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2019-06-04 05:52:56 +08:00
|
|
|
// Test TypeArrayAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @correct_type_array_attr_pass() {
|
|
|
|
// CHECK: test.type_array_attr
|
2019-06-26 10:06:06 +08:00
|
|
|
"test.type_array_attr"() {attr = [i32, f32]} : () -> ()
|
2019-06-04 05:52:56 +08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @non_type_in_type_array_attr_fail() {
|
|
|
|
// expected-error @+1 {{'attr' failed to satisfy constraint: type array attribute}}
|
2019-06-26 10:06:06 +08:00
|
|
|
"test.type_array_attr"() {attr = [i32, 5 : i64]} : () -> ()
|
2019-06-04 05:52:56 +08:00
|
|
|
return
|
|
|
|
}
|
2019-06-28 11:48:53 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test StringAttr with custom type
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @string_attr_custom_type
|
|
|
|
func @string_attr_custom_type() {
|
|
|
|
// CHECK: "string_data" : !foo.string
|
2020-04-04 10:20:33 +08:00
|
|
|
test.string_attr_with_type "string_data" : !foo.string
|
2019-06-28 11:48:53 +08:00
|
|
|
return
|
|
|
|
}
|
2019-07-01 20:26:14 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test StrEnumAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @allowed_cases_pass
|
|
|
|
func @allowed_cases_pass() {
|
|
|
|
// CHECK: test.str_enum_attr
|
|
|
|
%0 = "test.str_enum_attr"() {attr = "A"} : () -> i32
|
|
|
|
// CHECK: test.str_enum_attr
|
|
|
|
%1 = "test.str_enum_attr"() {attr = "B"} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @disallowed_case_fail() {
|
|
|
|
// expected-error @+1 {{allowed string cases: 'A', 'B'}}
|
|
|
|
%0 = "test.str_enum_attr"() {attr = 7: i32} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test I32EnumAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @allowed_cases_pass
|
|
|
|
func @allowed_cases_pass() {
|
|
|
|
// CHECK: test.i32_enum_attr
|
|
|
|
%0 = "test.i32_enum_attr"() {attr = 5: i32} : () -> i32
|
|
|
|
// CHECK: test.i32_enum_attr
|
|
|
|
%1 = "test.i32_enum_attr"() {attr = 10: i32} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @disallowed_case7_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{allowed 32-bit signless integer cases: 5, 10}}
|
2019-07-01 20:26:14 +08:00
|
|
|
%0 = "test.i32_enum_attr"() {attr = 7: i32} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @disallowed_case7_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{allowed 32-bit signless integer cases: 5, 10}}
|
2019-07-01 20:26:14 +08:00
|
|
|
%0 = "test.i32_enum_attr"() {attr = 5: i64} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test I64EnumAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// CHECK-LABEL: func @allowed_cases_pass
|
|
|
|
func @allowed_cases_pass() {
|
|
|
|
// CHECK: test.i64_enum_attr
|
|
|
|
%0 = "test.i64_enum_attr"() {attr = 5: i64} : () -> i32
|
|
|
|
// CHECK: test.i64_enum_attr
|
|
|
|
%1 = "test.i64_enum_attr"() {attr = 10: i64} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @disallowed_case7_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{allowed 64-bit signless integer cases: 5, 10}}
|
2019-07-01 20:26:14 +08:00
|
|
|
%0 = "test.i64_enum_attr"() {attr = 7: i64} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @disallowed_case7_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{allowed 64-bit signless integer cases: 5, 10}}
|
2019-07-01 20:26:14 +08:00
|
|
|
%0 = "test.i64_enum_attr"() {attr = 5: i32} : () -> i32
|
|
|
|
return
|
|
|
|
}
|
2019-09-22 00:44:38 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test FloatElementsAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @correct_type_pass() {
|
|
|
|
"test.float_elements_attr"() {
|
|
|
|
// CHECK: scalar_f32_attr = dense<5.000000e+00> : tensor<2xf32>
|
|
|
|
// CHECK: tensor_f64_attr = dense<6.000000e+00> : tensor<4x8xf64>
|
|
|
|
scalar_f32_attr = dense<5.0> : tensor<2xf32>,
|
|
|
|
tensor_f64_attr = dense<6.0> : tensor<4x8xf64>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_element_type_pass() {
|
|
|
|
// expected-error @+1 {{failed to satisfy constraint: 32-bit float elements attribute of shape [2]}}
|
|
|
|
"test.float_elements_attr"() {
|
|
|
|
scalar_f32_attr = dense<5.0> : tensor<2xf64>,
|
|
|
|
tensor_f64_attr = dense<6.0> : tensor<4x8xf64>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @correct_type_pass() {
|
|
|
|
// expected-error @+1 {{failed to satisfy constraint: 64-bit float elements attribute of shape [4, 8]}}
|
|
|
|
"test.float_elements_attr"() {
|
|
|
|
scalar_f32_attr = dense<5.0> : tensor<2xf32>,
|
|
|
|
tensor_f64_attr = dense<6.0> : tensor<4xf64>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
2019-11-02 05:26:10 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test SymbolRefAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @fn() { return }
|
|
|
|
|
|
|
|
// CHECK: test.symbol_ref_attr
|
|
|
|
"test.symbol_ref_attr"() {symbol = @fn} : () -> ()
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// expected-error @+1 {{referencing to a 'FuncOp' symbol}}
|
|
|
|
"test.symbol_ref_attr"() {symbol = @foo} : () -> ()
|
2020-02-11 22:38:14 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test IntElementsAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2020-03-05 03:41:27 +08:00
|
|
|
func @correct_int_elements_attr_pass() {
|
2020-02-11 22:38:14 +08:00
|
|
|
"test.int_elements_attr"() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// CHECK: any_i32_attr = dense<5> : tensor<1x2x3x4xui32>,
|
|
|
|
any_i32_attr = dense<5> : tensor<1x2x3x4xui32>,
|
|
|
|
i32_attr = dense<5> : tensor<6xi32>
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
"test.int_elements_attr"() {
|
|
|
|
// CHECK: any_i32_attr = dense<5> : tensor<1x2x3x4xsi32>,
|
|
|
|
any_i32_attr = dense<5> : tensor<1x2x3x4xsi32>,
|
|
|
|
i32_attr = dense<5> : tensor<6xi32>
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
"test.int_elements_attr"() {
|
|
|
|
// CHECK: any_i32_attr = dense<5> : tensor<1x2x3x4xi32>,
|
|
|
|
any_i32_attr = dense<5> : tensor<1x2x3x4xi32>,
|
|
|
|
i32_attr = dense<5> : tensor<6xi32>
|
|
|
|
} : () -> ()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_int_elements_attr_type_fail() {
|
|
|
|
// expected-error @+1 {{'any_i32_attr' failed to satisfy constraint: 32-bit integer elements attribute}}
|
|
|
|
"test.int_elements_attr"() {
|
|
|
|
any_i32_attr = dense<5.0> : tensor<1x2x3x4xf32>,
|
|
|
|
i32_attr = dense<5> : tensor<6xi32>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_int_elements_attr_signedness_fail() {
|
|
|
|
// expected-error @+1 {{'i32_attr' failed to satisfy constraint: 32-bit signless integer elements attribute}}
|
|
|
|
"test.int_elements_attr"() {
|
|
|
|
any_i32_attr = dense<5> : tensor<1x2x3x4xi32>,
|
|
|
|
i32_attr = dense<5> : tensor<6xsi32>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Test Ranked IntElementsAttr
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
func @correct_type_pass() {
|
|
|
|
"test.ranked_int_elements_attr"() {
|
2020-02-11 22:38:14 +08:00
|
|
|
// CHECK: matrix_i64_attr = dense<6> : tensor<4x8xi64>
|
|
|
|
// CHECK: vector_i32_attr = dense<5> : tensor<2xi32>
|
|
|
|
matrix_i64_attr = dense<6> : tensor<4x8xi64>,
|
|
|
|
vector_i32_attr = dense<5> : tensor<2xi32>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_element_type_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{failed to satisfy constraint: 32-bit signless int elements attribute of shape [2]}}
|
|
|
|
"test.ranked_int_elements_attr"() {
|
2020-02-11 22:38:14 +08:00
|
|
|
matrix_i64_attr = dense<6> : tensor<4x8xi64>,
|
|
|
|
vector_i32_attr = dense<5> : tensor<2xi64>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_shape_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{failed to satisfy constraint: 64-bit signless int elements attribute of shape [4, 8]}}
|
|
|
|
"test.ranked_int_elements_attr"() {
|
2020-02-11 22:38:14 +08:00
|
|
|
matrix_i64_attr = dense<6> : tensor<4xi64>,
|
|
|
|
vector_i32_attr = dense<5> : tensor<2xi32>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
func @wrong_shape_fail() {
|
2020-03-05 03:41:27 +08:00
|
|
|
// expected-error @+1 {{failed to satisfy constraint: 32-bit signless int elements attribute of shape [2]}}
|
|
|
|
"test.ranked_int_elements_attr"() {
|
2020-02-11 22:38:14 +08:00
|
|
|
matrix_i64_attr = dense<6> : tensor<4x8xi64>,
|
|
|
|
vector_i32_attr = dense<5> : tensor<i32>
|
|
|
|
} : () -> ()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|