6 #include <unordered_map> 8 #include "caffe2/core/logging.h" 9 #include "foxi/onnxifi_loader.h" 15 onnxBackendID backend_id;
18 onnxifi_library* lib{
nullptr};
21 onnxBackendID backend_id,
25 : backend_id(backend_id), backend(backend), graph(graph), lib(lib) {}
32 backend_id = other.backend_id;
33 backend = other.backend;
36 other.backend_id = other.backend = other.graph = other.lib =
nullptr;
40 backend_id = other.backend_id;
41 backend = other.backend;
44 other.backend_id = other.backend = other.graph = other.lib =
nullptr;
52 err = lib->onnxReleaseGraph(graph);
53 if (err != ONNXIFI_STATUS_SUCCESS) {
54 LOG(ERROR) <<
"Error when calling onnxReleaseGraph";
58 err = lib->onnxReleaseBackend(backend);
59 if (err != ONNXIFI_STATUS_SUCCESS) {
60 LOG(ERROR) <<
"Error when calling onnxReleaseBackend";
64 err = lib->onnxReleaseBackendID(backend_id);
65 if (err != ONNXIFI_STATUS_SUCCESS) {
66 LOG(ERROR) <<
"Error when calling onnxReleaseBackendID";
72 using SharedPtrBackendGraphInfo = std::shared_ptr<BackendGraphInfo>;
84 SharedPtrBackendGraphInfo lookup(
const std::string& key);
92 SharedPtrBackendGraphInfo insert(
93 const std::string& key,
94 std::function<SharedPtrBackendGraphInfo()> creator);
96 void remove(
const std::string& key);
99 std::mutex backend_graph_map_lock_;
100 std::unordered_map<std::string, SharedPtrBackendGraphInfo> backend_graph_map_;
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...