From: Tae-Young Chung Date: Thu, 11 Jul 2019 01:19:06 +0000 (+0900) Subject: Add INFERENCE_TARGET_CUSTOM and change constructor to get parameter of string type X-Git-Tag: submit/tizen/20190823.012236~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a919956cec0e933875a39f185b187ca6c5f5347;p=platform%2Fcore%2Fmultimedia%2Finference-engine-interface.git Add INFERENCE_TARGET_CUSTOM and change constructor to get parameter of string type Change-Id: Ib2f1f159911e0dc0d0f1abbbf5807b354b24576b Signed-off-by: Tae-Young Chung --- diff --git a/common/inference_engine_common_impl.cpp b/common/inference_engine_common_impl.cpp index 24afee2..758bd5a 100644 --- a/common/inference_engine_common_impl.cpp +++ b/common/inference_engine_common_impl.cpp @@ -37,15 +37,10 @@ extern "C" { namespace InferenceEngineInterface { namespace Common { -const char* engineLibs[] = { - "libinference-engine-caffe.so", - "libinference-engine-tf.so", - "libinference-engine-tflite.so"}; - -InferenceEngineCommon::InferenceEngineCommon(inference_backend_type_e backend) : - mBackend(backend) +InferenceEngineCommon::InferenceEngineCommon(std::string backend) { LOGE("ENTER"); + mBackendLibName = "libinference-engine-" + backend + ".so"; LOGE("LEAVE"); } @@ -65,9 +60,9 @@ int InferenceEngineCommon::Init(std::string configFile, { LOGW("ENTER"); char *error = NULL; - handle = dlopen(engineLibs[mBackend], RTLD_LAZY); + handle = dlopen(mBackendLibName.c_str(), RTLD_LAZY); if (!handle) { - LOGE("Fail to dlopen %s", engineLibs[mBackend]); + LOGE("Fail to dlopen %s", mBackendLibName.c_str()); LOGE("Error: %s\n", dlerror()); return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED; } diff --git a/include/inference_engine_common_impl.h b/include/inference_engine_common_impl.h index f797103..f94596e 100644 --- a/include/inference_engine_common_impl.h +++ b/include/inference_engine_common_impl.h @@ -28,7 +28,8 @@ namespace Common { class InferenceEngineCommon { public: - InferenceEngineCommon(inference_backend_type_e backend); + + InferenceEngineCommon(std::string backend); ~InferenceEngineCommon(); @@ -65,7 +66,7 @@ public: private: void *handle; IInferenceEngineCommon *engine; - inference_backend_type_e mBackend; + std::string mBackendLibName; std::vector mUserListName; }; diff --git a/include/inference_engine_type.h b/include/inference_engine_type.h index 10ba9e7..5860582 100644 --- a/include/inference_engine_type.h +++ b/include/inference_engine_type.h @@ -29,22 +29,6 @@ extern "C" { * inference engine API. */ -/** - * @brief Enumeration for inference backend. - * - * @since_tizen 5.5 - * - * @see mv_inference_prepare() - */ -typedef enum { - INFERENCE_BACKEND_NONE = -1, - INFERENCE_BACKEND_OPENCV, /**< OpenCV */ - INFERENCE_BACKEND_CAFFE, /**< Caffe */ - INFERENCE_BACKEND_TF, /**< TensorFlow */ - INFERENCE_BACKEND_TFLite, /**< TensorFlow-Lite */ - INFERENCE_BACKEND_MAX -} inference_backend_type_e; - /** * @brief Enumeration for inference target. * @@ -52,10 +36,11 @@ typedef enum { * */ typedef enum { - INFERENCE_TARGET_NONE = -1, + INFERENCE_TARGET_NONE = -1, INFERENCE_TARGET_CPU, /**< CPU */ - INFERENCE_TARGET_GPU, /**< GPU*/ - INFERENCE_TARGET_MAX + INFERENCE_TARGET_GPU, /**< GPU */ + INFERENCE_TARGET_CUSTOM, /**< NPU */ + INFERENCE_TARGET_MAX } inference_target_type_e; typedef enum { @@ -101,4 +86,4 @@ typedef struct _InferenceResults{ } #endif /* __cplusplus */ -#endif /* __INFERENCE_ENGINE_TYPE_H__ */ \ No newline at end of file +#endif /* __INFERENCE_ENGINE_TYPE_H__ */ diff --git a/include/inference_engine_vision_impl.h b/include/inference_engine_vision_impl.h index b50fbfb..0ba444f 100644 --- a/include/inference_engine_vision_impl.h +++ b/include/inference_engine_vision_impl.h @@ -30,7 +30,7 @@ namespace Vision { class InferenceEngineVision { public: - InferenceEngineVision(inference_backend_type_e backend); + InferenceEngineVision(std::string backend); ~InferenceEngineVision(); @@ -73,13 +73,13 @@ public: int GetInferenceResult(std::vector>& dimInfo, std::vector& results); int GetNumberOfOutputs(); - + void SetUserListName(std::string userlist); private: void *handle; IInferenceEngineVision *engine; - inference_backend_type_e mBackend; + std::string mBackendLibName; std::vector mUserListName; }; @@ -87,4 +87,4 @@ private: } /* Vision */ } /* InferenceEngineInterface */ -#endif /* __INFERENCE_ENGINE_VISION_IMPL_H__ */ \ No newline at end of file +#endif /* __INFERENCE_ENGINE_VISION_IMPL_H__ */ diff --git a/packaging/inference-engine-interface.spec b/packaging/inference-engine-interface.spec index b3d6ac3..9a0da02 100644 --- a/packaging/inference-engine-interface.spec +++ b/packaging/inference-engine-interface.spec @@ -1,7 +1,7 @@ Name: inference-engine-interface Summary: Interface of inference engines Version: 0.0.1 -Release: 1 +Release: 2 Group: Multimedia/Framework License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -98,4 +98,4 @@ rm -rf %{buildroot} %files vision-devel %{_includedir}/media/*.h %{_libdir}/pkgconfig/*vision.pc -%{_libdir}/lib*-vision.so \ No newline at end of file +%{_libdir}/lib*-vision.so diff --git a/vision/inference_engine_vision_impl.cpp b/vision/inference_engine_vision_impl.cpp index 9487e7a..47c980a 100644 --- a/vision/inference_engine_vision_impl.cpp +++ b/vision/inference_engine_vision_impl.cpp @@ -38,16 +38,10 @@ extern "C" { namespace InferenceEngineInterface { namespace Vision { -const char* engineLibs[] = { - "libinference-engine-opencv.so", - "libinference-engine-caffe.so", - "libinference-engine-tf.so", - "libinference-engine-tflite.so"}; - -InferenceEngineVision::InferenceEngineVision(inference_backend_type_e backend) : - mBackend(backend) +InferenceEngineVision::InferenceEngineVision(std::string backend) { LOGE("ENTER"); + mBackendLibName = "libinference-engine-" + backend + ".so"; LOGE("LEAVE"); } @@ -67,20 +61,21 @@ int InferenceEngineVision::Init(std::string configFile, { LOGW("ENTER"); char *error = NULL; - handle = dlopen(engineLibs[mBackend], RTLD_LAZY); + handle = dlopen(mBackendLibName.c_str(), RTLD_LAZY); + LOGE("dlopen %s", mBackendLibName.c_str()); if (!handle) { - LOGE("Fail to dlopen %s", engineLibs[mBackend]); + LOGE("Fail to dlopen %s", mBackendLibName.c_str()); LOGE("Error: %s\n", dlerror()); return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED; } - + init_t* EngineInit = (init_t *)dlsym(handle, "EngineVisionInit"); if ((error = dlerror()) != NULL) { LOGE("Error: %s\n", error); dlclose(handle); return INFERENCE_ENGINE_ERROR_INTERNAL; } - + engine = EngineInit(configFile, weightFile, userFile); if (engine == NULL) { LOGE("Fail to EngineInit");