Removing quite a bit of absl from iree/. (#6256)
The remaining usage after this is all Status/StatusOr-related.
diff --git a/bindings/python/iree/runtime/vm.cc b/bindings/python/iree/runtime/vm.cc
index 325ba1f..9eb53f7 100644
--- a/bindings/python/iree/runtime/vm.cc
+++ b/bindings/python/iree/runtime/vm.cc
@@ -6,8 +6,6 @@
#include "bindings/python/iree/runtime/vm.h"
-#include "absl/strings/str_cat.h"
-#include "absl/strings/str_join.h"
#include "absl/types/optional.h"
#include "bindings/python/iree/runtime/status_utils.h"
#include "iree/base/api.h"
@@ -86,7 +84,7 @@
CheckApiStatus(status, "Error creating vm context");
} else {
// Closed set of modules.
- absl::InlinedVector<iree_vm_module_t*, 8> module_handles;
+ std::vector<iree_vm_module_t*> module_handles;
module_handles.resize(modules->size());
for (size_t i = 0, e = module_handles.size(); i < e; ++i) {
module_handles[i] = (*modules)[i]->raw_ptr();
@@ -102,7 +100,7 @@
}
void VmContext::RegisterModules(std::vector<VmModule*> modules) {
- absl::InlinedVector<iree_vm_module_t*, 8> module_handles;
+ std::vector<iree_vm_module_t*> module_handles;
module_handles.resize(modules.size());
for (size_t i = 0, e = module_handles.size(); i < e; ++i) {
module_handles[i] = modules[i]->raw_ptr();
@@ -392,6 +390,20 @@
namespace {
+static std::string ToHexString(const uint8_t* data, size_t length) {
+ static constexpr char kHexChars[] = {'0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+ std::string s(length * 2, ' ');
+ for (size_t i = 0; i < length; ++i) {
+ s[2 * i + 0] = kHexChars[(data[i] & 0xF0) >> 4];
+ s[2 * i + 1] = kHexChars[(data[i] & 0x0F) >> 0];
+ }
+ return s;
+}
+static std::string ToHexString(uint32_t value) {
+ return ToHexString((const uint8_t*)&value, sizeof(value));
+}
+
void AppendListContents(std::string& out, iree_vm_list_t* list,
std::unordered_set<iree_vm_list_t*>& visited) {
for (iree_host_size_t i = 0, e = iree_vm_list_size(list); i < e; ++i) {
@@ -405,24 +417,27 @@
if (i > 0) out.append(", ");
if (iree_vm_variant_is_value(variant)) {
- absl::StrAppend(&out, variant.i32);
+ out += std::to_string(variant.i32);
} else if (iree_vm_variant_is_ref(variant)) {
// Pretty print a subset of ABI impacting known types.
if (iree_hal_buffer_isa(variant.ref)) {
auto* hal_buffer = iree_hal_buffer_deref(variant.ref);
assert(hal_buffer);
- absl::StrAppend(&out, "HalBuffer(",
- iree_hal_buffer_byte_length(hal_buffer), ")");
+ out += std::string("HalBuffer(") +
+ std::to_string(iree_hal_buffer_byte_length(hal_buffer)) + ")";
} else if (iree_hal_buffer_view_isa(variant.ref)) {
auto hal_bv = iree_hal_buffer_view_deref(variant.ref);
- absl::StrAppend(&out, "HalBufferView(");
- absl::InlinedVector<int32_t, 5> shape(
- iree_hal_buffer_view_shape_rank(hal_bv));
+ out += "HalBufferView(";
+ std::vector<int32_t> shape(iree_hal_buffer_view_shape_rank(hal_bv));
iree_hal_buffer_view_shape(hal_bv, shape.size(), shape.data(), nullptr);
- absl::StrAppend(&out, absl::StrJoin(shape, "x"), ":0x",
- absl::Hex(static_cast<uint32_t>(
- iree_hal_buffer_view_element_type(hal_bv))),
- ")");
+ for (size_t i = 0; i < shape.size(); ++i) {
+ if (i > 0) out += 'x';
+ out += std::to_string(shape[i]);
+ }
+ out += ":0x" +
+ ToHexString(static_cast<uint32_t>(
+ iree_hal_buffer_view_element_type(hal_bv))) +
+ ")";
} else if (iree_vm_list_isa(variant.ref)) {
out.append("List[");
iree_vm_list_t* sub_list = iree_vm_list_deref(variant.ref);
@@ -433,7 +448,7 @@
}
out.append("]");
} else {
- absl::StrAppend(&out, "Unknown(", variant.type.ref_type, ")");
+ out += "Unknown(" + std::to_string(variant.type.ref_type) + ")";
}
} else {
out.append("None");
@@ -447,8 +462,8 @@
// The variant list API requires mutability, so we const cast to it internally
// so we can maintain a const DebugString() for callers.
auto mutable_this = const_cast<VmVariantList*>(this);
- std::string s;
- absl::StrAppend(&s, "<VmVariantList(", size(), "): [");
+ std::string s =
+ std::string("<VmVariantList(") + std::to_string(size()) + "): [";
iree_vm_list_t* list = mutable_this->raw_ptr();
std::unordered_set<iree_vm_list_t*> visited;
visited.insert(list);