ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nnkit Namespace Reference

Namespaces

namespace  support
 

Data Structures

struct  Action
 
struct  Backend
 
class  BackendPlugin
 
struct  CmdlineArguments
 
struct  TensorContext
 
class  VectorArguments
 

Functions

std::unique_ptr< BackendPluginmake_backend_plugin (const std::string &path)
 

Function Documentation

◆ make_backend_plugin()

std::unique_ptr< BackendPlugin > nnkit::make_backend_plugin ( const std::string &  path)

Definition at line 52 of file BackendPlugin.cpp.

53{
54 if (path.empty())
55 {
56 throw std::runtime_error{"Backend library does not defined"};
57 }
58
59 void *handle;
60 BackendPlugin::Entry entry;
61
62 // NOTE Some backend (such as tflite) needs multithreading support (std::thread).
63 //
64 // std::thread in libstdc++.so includes weak symbols for pthread_XXX functions,
65 // and these weak symbols should be overridden by strong symbols in libpthread.so.
66 // If not, std::thread will not work correctly.
67 //
68 // RTLD_GLOBAL flag is necessary to allow weak symbols to be overridden.
69 handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
70 if (handle == nullptr)
71 {
72 std::cerr << dlerror() << std::endl;
73 exit(1);
74 }
75
76 char *error;
77 entry = reinterpret_cast<BackendPlugin::Entry>(dlsym(handle, "make_backend"));
78 if ((error = dlerror()) != nullptr)
79 {
80 dlclose(handle);
81 std::cerr << error << std::endl;
82 exit(1);
83 }
84
85 return std::make_unique<BackendPlugin>(handle, entry);
86}
int entry(const int argc, char **argv)
Definition Driver.cpp:53
Severity error(void)
Definition Severity.h:76

References entry().

Referenced by main().