Removing usage of the abseil c++ library from IREE. (#6259)
Python abseil is still used within IREE and the tensorflow tools use
the C++ one for interop but that's fine as it's restricted to that
workspace and fetched using bazel magic.
Assuming this works the next change will remove the submodule.
diff --git a/bindings/python/iree/runtime/CMakeLists.txt b/bindings/python/iree/runtime/CMakeLists.txt
index 0185f8c..3369de0 100644
--- a/bindings/python/iree/runtime/CMakeLists.txt
+++ b/bindings/python/iree/runtime/CMakeLists.txt
@@ -27,7 +27,6 @@
iree::modules::hal
iree::vm
iree::vm::bytecode_module
- absl::optional
)
iree_py_library(
diff --git a/bindings/python/iree/runtime/binding.h b/bindings/python/iree/runtime/binding.h
index 180e90e..c015e76 100644
--- a/bindings/python/iree/runtime/binding.h
+++ b/bindings/python/iree/runtime/binding.h
@@ -7,25 +7,13 @@
#ifndef IREE_BINDINGS_PYTHON_IREE_BINDING_H_
#define IREE_BINDINGS_PYTHON_IREE_BINDING_H_
+#include <optional>
#include <vector>
-#include "absl/types/optional.h"
#include "iree/base/api.h"
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
-namespace pybind11 {
-namespace detail {
-#if !defined(ABSL_HAVE_STD_OPTIONAL)
-// Make absl::optional act like the future C++17 optional for pybind11.
-// If ABSL_HAVE_STD_OPTIONAL is defined then absl::optional == std::optional
-// and the default type caster is sufficient.
-template <typename T>
-struct type_caster<absl::optional<T>> : optional_caster<absl::optional<T>> {};
-#endif
-} // namespace detail
-} // namespace pybind11
-
namespace iree {
namespace python {
diff --git a/bindings/python/iree/runtime/vm.cc b/bindings/python/iree/runtime/vm.cc
index 9eb53f7..003dac6 100644
--- a/bindings/python/iree/runtime/vm.cc
+++ b/bindings/python/iree/runtime/vm.cc
@@ -6,7 +6,6 @@
#include "bindings/python/iree/runtime/vm.h"
-#include "absl/types/optional.h"
#include "bindings/python/iree/runtime/status_utils.h"
#include "iree/base/api.h"
#include "iree/base/status.h"
@@ -75,7 +74,7 @@
//------------------------------------------------------------------------------
VmContext VmContext::Create(VmInstance* instance,
- absl::optional<std::vector<VmModule*>> modules) {
+ std::optional<std::vector<VmModule*>> modules) {
iree_vm_context_t* context;
if (!modules) {
// Simple create with open allowed modules.
@@ -147,14 +146,14 @@
return VmModule::CreateRetained(module);
}
-absl::optional<iree_vm_function_t> VmModule::LookupFunction(
+std::optional<iree_vm_function_t> VmModule::LookupFunction(
const std::string& name, iree_vm_function_linkage_t linkage) {
iree_vm_function_t f;
auto status = iree_vm_module_lookup_function_by_name(
raw_ptr(), linkage, {name.data(), name.size()}, &f);
if (iree_status_is_not_found(status)) {
iree_status_ignore(status);
- return absl::nullopt;
+ return std::nullopt;
}
CheckApiStatus(status, "Error looking up function");
return f;
@@ -525,7 +524,7 @@
py::class_<VmContext>(m, "VmContext")
.def(py::init(&VmContext::Create), py::arg("instance"),
- py::arg("modules") = absl::optional<std::vector<VmModule*>>())
+ py::arg("modules") = std::optional<std::vector<VmModule*>>())
.def("register_modules", &VmContext::RegisterModules)
.def_property_readonly("context_id", &VmContext::context_id)
.def("invoke", &VmContext::Invoke);
diff --git a/bindings/python/iree/runtime/vm.h b/bindings/python/iree/runtime/vm.h
index 25bbfff..33da644 100644
--- a/bindings/python/iree/runtime/vm.h
+++ b/bindings/python/iree/runtime/vm.h
@@ -7,7 +7,8 @@
#ifndef IREE_BINDINGS_PYTHON_IREE_RT_VM_H_
#define IREE_BINDINGS_PYTHON_IREE_RT_VM_H_
-#include "absl/types/optional.h"
+#include <optional>
+
#include "bindings/python/iree/runtime/binding.h"
#include "bindings/python/iree/runtime/hal.h"
#include "iree/base/api.h"
@@ -117,7 +118,7 @@
public:
static VmModule FromFlatbufferBlob(py::buffer flatbuffer_blob);
- absl::optional<iree_vm_function_t> LookupFunction(
+ std::optional<iree_vm_function_t> LookupFunction(
const std::string& name, iree_vm_function_linkage_t linkage);
std::string name() const {
@@ -132,7 +133,7 @@
// static, disallowing further module registration (and may be more
// efficient).
static VmContext Create(VmInstance* instance,
- absl::optional<std::vector<VmModule*>> modules);
+ std::optional<std::vector<VmModule*>> modules);
// Registers additional modules. Only valid for non static contexts (i.e.
// those created without modules.