From: 오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 7 Nov 2018 06:18:40 +0000 (+0900) Subject: Introduce namespace in runtime load helper (#3494) X-Git-Tag: 0.3~461 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8217957cba9d09d299b4e7868565737c918e611;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce namespace in runtime load helper (#3494) Introduce namespace in runtime load helper Restore function name It protects naming conflict with upstream tensorflow Signed-off-by: Hyeongseok Oh --- diff --git a/include/NeuralNetworksLoadHelpers.h b/include/NeuralNetworksLoadHelpers.h index 16b1f35..06934cc 100644 --- a/include/NeuralNetworksLoadHelpers.h +++ b/include/NeuralNetworksLoadHelpers.h @@ -41,7 +41,7 @@ * @param[in] name Name of a function */ #define LOAD_FUNCTION(name) \ - static name##_fn fn = reinterpret_cast(loadNNAPIFunction(#name)); + static name##_fn fn = reinterpret_cast(nnfw::loadFunction(#name)); /** * @brief Run @c fn function. @c fn is created by @ref LOAD_FUNCTION @@ -59,12 +59,15 @@ */ #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); @@ -78,8 +81,8 @@ inline void* loadNNAPILibrary(const char* name) { * @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; } @@ -88,10 +91,10 @@ inline void* getNNAPILibraryHandle() { * @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) { @@ -114,8 +117,10 @@ inline void* loadNNAPIFunction(const char* name) { * @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__