Cleaning up function reflection attrs. (#9648)
This makes the attr queries consistent with the other API methods and
removes "reflection" from the name. Also plumbs through module attrs and
enables support for unit attrs (empty values).
Fixes #1979.
diff --git a/runtime/bindings/python/vm.cc b/runtime/bindings/python/vm.cc
index 440732b..ecd4a27 100644
--- a/runtime/bindings/python/vm.cc
+++ b/runtime/bindings/python/vm.cc
@@ -41,17 +41,16 @@
py::dict GetFunctionReflectionDict(iree_vm_function_t& f) {
py::dict attrs;
- for (int i = 0;; ++i) {
- iree_string_view_t key;
- iree_string_view_t value;
- auto status = iree_vm_get_function_reflection_attr(f, i, &key, &value);
- if (iree_status_is_not_found(status)) {
+ for (iree_host_size_t i = 0;; ++i) {
+ iree_string_pair_t attr;
+ auto status = iree_vm_function_get_attr(f, i, &attr);
+ if (iree_status_is_out_of_range(status)) {
iree_status_ignore(status);
break;
}
CheckApiStatus(status, "Error getting reflection attr");
- py::str key_str(key.data, key.size);
- py::str value_str(value.data, value.size);
+ py::str key_str(attr.key.data, attr.key.size);
+ py::str value_str(attr.value.data, attr.value.size);
attrs[std::move(key_str)] = std::move(value_str);
}
return attrs;
diff --git a/runtime/bindings/tflite/interpreter.c b/runtime/bindings/tflite/interpreter.c
index 74a6398..f7c47cd 100644
--- a/runtime/bindings/tflite/interpreter.c
+++ b/runtime/bindings/tflite/interpreter.c
@@ -292,11 +292,11 @@
static iree_status_t _TfLiteInterpreterPopulateIO(
TfLiteInterpreter* interpreter) {
iree_vm_function_t main_fn = interpreter->model->exports._main;
- iree_string_view_t io_names_attr = iree_vm_function_reflection_attr(
+ iree_string_view_t io_names_attr = iree_vm_function_lookup_attr_by_name(
&main_fn, iree_make_cstring_view("tfl.io.names"));
- iree_string_view_t io_types_attr = iree_vm_function_reflection_attr(
+ iree_string_view_t io_types_attr = iree_vm_function_lookup_attr_by_name(
&main_fn, iree_make_cstring_view("tfl.io.types"));
- iree_string_view_t io_quant_attr = iree_vm_function_reflection_attr(
+ iree_string_view_t io_quant_attr = iree_vm_function_lookup_attr_by_name(
&main_fn, iree_make_cstring_view("tfl.io.quant"));
// Setup static tensor metadata.