* @param[in] name Name of a function
*/
#define LOAD_FUNCTION(name) \
- static name##_fn fn = reinterpret_cast<name##_fn>(loadNNAPIFunction(#name));
+ static name##_fn fn = reinterpret_cast<name##_fn>(nnfw::loadFunction(#name));
/**
* @brief Run @c fn function. @c fn is created by @ref LOAD_FUNCTION
*/
#define EXECUTE_FUNCTION_RETURN(...) return fn != nullptr ? fn(__VA_ARGS__) : 0;
+namespace nnfw
+{
+
/**
* @brief Load NN API library
* @param[in] name path of NN API library
* @return a symbol table handle of NN API library
*/
-inline void* loadNNAPILibrary(const char* name) {
+inline void* loadLibrary(const char* name) {
// TODO: change RTLD_LOCAL? Assumes there can be multiple instances of nn
// api RT
void* handle = dlopen(name, RTLD_LAZY | RTLD_LOCAL);
* @brief Load libneuralnetworks.so and return handle of library
* @return a symbol table handle of NN API library
*/
-inline void* getNNAPILibraryHandle() {
- static void* handle = loadNNAPILibrary("libneuralnetworks.so");
+inline void* getLibraryHandle() {
+ static void* handle = loadLibrary("libneuralnetworks.so");
return handle;
}
* @param[in] name Name of function
* @return function pointer
*/
-inline void* loadNNAPIFunction(const char* name) {
+inline void* loadFunction(const char* name) {
void* fn = nullptr;
- if (getNNAPILibraryHandle() != nullptr) {
- fn = dlsym(getNNAPILibraryHandle(), name);
+ if (getLibraryHandle() != nullptr) {
+ fn = dlsym(getLibraryHandle(), name);
}
if (fn == nullptr)
{
* @return @c true if loading is successful, otherwise @c false.
*/
inline bool NNAPIExists() {
- static bool nnapi_is_available = getNNAPILibraryHandle();
+ static bool nnapi_is_available = getLibraryHandle();
return nnapi_is_available;
}
+} // namespace nnfw
+
#endif // __NEURAL_NETWORKS_LOAD_HELPER_H__