[Mlir-commits] [mlir] Reimplementing target description concept using DLTI attribute (PR #92138)
Renato Golin
llvmlistbot at llvm.org
Wed Jun 5 04:00:00 PDT 2024
================
@@ -90,3 +90,132 @@ module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown
// expected-note at above {{enclosing op with data layout}}
"test.op_with_data_layout"() { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"unknown.unknown", 32>>} : () -> ()
}
+
+// -----
+
+// expected-error at below {{'dlti.target_system_desc_spec' is expected to be a #dlti.target_system_desc_spec attribute}}
+"test.unknown_op"() { dlti.target_system_desc_spec = 42 } : () -> ()
+
+// -----
+
+// expected-error at below {{invalid kind of attribute specified}}
+"test.unknown_op"() { dlti.target_system_desc_spec = #dlti.target_system_desc_spec<[]> } : () -> ()
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires key: dlti.device_id and its value of ui32 type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_type", "CPU">>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires key: dlti.device_type and its value of string type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0: ui32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires key: dlti.device_id and its value of ui32 type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0: i32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires key: dlti.device_type and its value of string type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0 : ui32>,
+ #dlti.dl_entry<"dlti.device_type", 0: i32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{repeated layout entry key: dlti.device_id}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0 : ui32>,
+ #dlti.dl_entry<"dlti.device_id", 1 : ui32>,
+ #dlti.dl_entry<"dlti.device_type", "CPU">,
+ #dlti.dl_entry<"dlti.L1_cache_size", 4096 : i32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{repeated layout entry key: dlti.device_type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0 : ui32>,
+ #dlti.dl_entry<"dlti.device_type", "CPU">,
+ #dlti.dl_entry<"dlti.device_type", "GPU">,
+ #dlti.dl_entry<"dlti.L1_cache_size", 4096 : i32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires value of key: dlti.L1_cache_size_in_bytes to be of ui32 type}}
+ dlti.target_system_desc_spec = #dlti.target_system_desc_spec<
+ #dlti.target_device_desc_spec<
+ #dlti.dl_entry<"dlti.device_id", 0 : ui32>,
+ #dlti.dl_entry<"dlti.device_type", "CPU">,
+ #dlti.dl_entry<"dlti.L1_cache_size_in_bytes", 4096.1 : f32>>
+ >} {}
+
+// -----
+
+module attributes {
+ // expected-error at +2 {{target_device_desc_spec requires value of key: dlti.max_vector_op_width to be of ui32 type}}
----------------
rengolin wrote:
I don't see how we can make this a generic documentation when adding new properties without having to change the table-gen description also. For now I'd say let's keep it simple and not worry about it (ie. let compiler developers see the error and fix it). The long term plan is to make this much simpler by having more robust target information structures that don't need to expand all of their properties in a map, so this issue will become irrelevant when actual users start to rely on this.
https://github.com/llvm/llvm-project/pull/92138
More information about the Mlir-commits
mailing list