Updating iree_status_t usage and adding tons of error messages.
Progress on #265.
diff --git a/bindings/python/pyiree/common/status_utils.cc b/bindings/python/pyiree/common/status_utils.cc
index e1b7a93..e4f0a9b 100644
--- a/bindings/python/pyiree/common/status_utils.cc
+++ b/bindings/python/pyiree/common/status_utils.cc
@@ -57,9 +57,11 @@
pybind11::error_already_set ApiStatusToPyExc(iree_status_t status,
const char* message) {
- assert(status != IREE_STATUS_OK);
- auto full_message = absl::StrCat(message, ": ", static_cast<int>(status));
+ assert(!iree_status_is_ok(status));
+ auto full_message = absl::StrCat(
+ message, ": ", iree_status_code_string(iree_status_code(status)));
PyErr_SetString(ApiStatusToPyExcClass(status), full_message.c_str());
+ iree_status_ignore(status);
return pybind11::error_already_set();
}
diff --git a/bindings/python/pyiree/common/status_utils.h b/bindings/python/pyiree/common/status_utils.h
index 3f4956d..a6a1ece 100644
--- a/bindings/python/pyiree/common/status_utils.h
+++ b/bindings/python/pyiree/common/status_utils.h
@@ -57,7 +57,7 @@
const char* message);
inline void CheckApiStatus(iree_status_t status, const char* message) {
- if (status == IREE_STATUS_OK) {
+ if (iree_status_is_ok(status)) {
return;
}
throw ApiStatusToPyExc(status, message);
diff --git a/bindings/python/pyiree/rt/hal.cc b/bindings/python/pyiree/rt/hal.cc
index 5c3fe08..f271071 100644
--- a/bindings/python/pyiree/rt/hal.cc
+++ b/bindings/python/pyiree/rt/hal.cc
@@ -32,7 +32,7 @@
~HalMappedMemory() {
if (bv_) {
iree_hal_buffer_t* buffer = iree_hal_buffer_view_buffer(bv_);
- CHECK_EQ(iree_hal_buffer_unmap(buffer, &mapped_memory_), IREE_STATUS_OK);
+ IREE_CHECK_OK(iree_hal_buffer_unmap(buffer, &mapped_memory_));
iree_hal_buffer_view_release(bv_);
}
}
diff --git a/bindings/python/pyiree/rt/vm.cc b/bindings/python/pyiree/rt/vm.cc
index 0f79099..a46088a 100644
--- a/bindings/python/pyiree/rt/vm.cc
+++ b/bindings/python/pyiree/rt/vm.cc
@@ -117,7 +117,8 @@
attrs.push_back({});
auto status = iree_vm_get_function_reflection_attr(
f, i, &attrs.back().first, &attrs.back().second);
- if (status == IREE_STATUS_NOT_FOUND) {
+ if (iree_status_is_not_found(status) {
+ iree_status_ignore(status);
attrs.pop_back();
break;
}
@@ -165,7 +166,7 @@
{static_cast<const uint8_t*>(buffer_info.ptr),
static_cast<iree_host_size_t>(buffer_info.size)},
deallocator, IREE_ALLOCATOR_SYSTEM, &module);
- if (status != IREE_STATUS_OK) {
+ if (!iree_status_is_ok(status)) {
deallocator.free(raw_ptr, nullptr);
}
@@ -178,7 +179,8 @@
iree_vm_function_t f;
auto status = iree_vm_module_lookup_function_by_name(
raw_ptr(), linkage, {name.data(), name.size()}, &f);
- if (status == IREE_STATUS_NOT_FOUND) {
+ if (iree_status_is_not_found(status)) {
+ iree_status_ignore(status);
return absl::nullopt;
}
CheckApiStatus(status, "Error looking up function");
@@ -236,10 +238,10 @@
}
void SetupVmBindings(pybind11::module m) {
- CHECK_EQ(IREE_STATUS_OK, iree_vm_register_builtin_types());
- CHECK_EQ(IREE_STATUS_OK, iree_hal_module_register_types());
- CHECK_EQ(IREE_STATUS_OK, iree_tensorlist_module_register_types());
- CHECK_EQ(IREE_STATUS_OK, iree_strings_module_register_types());
+ IREE_CHECK_OK(iree_vm_register_builtin_types());
+ IREE_CHECK_OK(iree_hal_module_register_types());
+ IREE_CHECK_OK(iree_tensorlist_module_register_types());
+ IREE_CHECK_OK(iree_strings_module_register_types());
// Built-in module creation.
m.def("create_hal_module", &CreateHalModule);