Add INFERENCE_TARGET_CUSTOM and change constructor to get parameter of string type 73/209773/2
authorTae-Young Chung <ty83.chung@samsung.com>
Thu, 11 Jul 2019 01:19:06 +0000 (10:19 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Thu, 11 Jul 2019 03:00:14 +0000 (12:00 +0900)
Change-Id: Ib2f1f159911e0dc0d0f1abbbf5807b354b24576b
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
common/inference_engine_common_impl.cpp
include/inference_engine_common_impl.h
include/inference_engine_type.h
include/inference_engine_vision_impl.h
packaging/inference-engine-interface.spec
vision/inference_engine_vision_impl.cpp

index 24afee277da1bd7c069c5e57174b5ea52a2d291f..758bd5a3414f1555bf6dcb13b1b1c51adc44e947 100644 (file)
@@ -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;
     }
index f797103cd26766ebfcaae4b99b79598a780848a3..f94596ef3a3dffe0ac47fb0082afe873445cfa6e 100644 (file)
@@ -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<std::string> mUserListName;
 
 };
index 10ba9e7f8710738b17da39577a1d7d459e8f417f..5860582fe4a3fa8b37945e3ff454b1534399f775 100644 (file)
@@ -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__ */
index b50fbfbf614f7273ffbd36d1d77dc4de9c9f7260..0ba444fc6cf1053895d0624a08ae4b2b506b177b 100644 (file)
@@ -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<std::vector<int>>& dimInfo, std::vector<float*>& results);
 
     int GetNumberOfOutputs();
-    
+
     void SetUserListName(std::string userlist);
 
 private:
     void *handle;
     IInferenceEngineVision *engine;
-    inference_backend_type_e mBackend;
+    std::string mBackendLibName;
     std::vector<std::string> 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__ */
index b3d6ac371f5c832689bc6d7867d2692561ed803e..9a0da028ce5c144c364f35e767ad2ce2888323cc 100644 (file)
@@ -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
index 9487e7aca5a75dcffa4180d7001c22d322731653..47c980ad76bf1025568a1ebb871aaedafef41f99 100644 (file)
@@ -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");