[caffe2] Warning fix based for updated caffe2 v1.6.0-rc1
authorParichay Kapoor <pk.kapoor@samsung.com>
Thu, 16 Jul 2020 09:59:05 +0000 (18:59 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 23 Jul 2020 00:41:13 +0000 (09:41 +0900)
Update caffe2 extension to remove warning based on api update
for version 1.6.0-rc1

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
ext/nnstreamer/tensor_filter/tensor_filter_caffe2.cc

index 407ec5c..a55490c 100644 (file)
@@ -97,6 +97,10 @@ Caffe2Core::Caffe2Core (const char * _model_path, const char *_model_path_sub)
 
   gst_tensors_info_init (&inputTensorMeta);
   gst_tensors_info_init (&outputTensorMeta);
+
+  if (!GlobalInitAlreadyRun () && !GlobalInit ()) {
+    throw std::runtime_error ("Failed to initialize caffe2.");
+  }
 }
 
 /**
@@ -473,10 +477,17 @@ caffe2_loadModelFile (const GstTensorFilterProperties * prop,
     caffe2_close (prop, private_data);
   }
 
-  core = new Caffe2Core (init_model, pred_model);
-  if (core == NULL) {
+  try {
+    core = new Caffe2Core (init_model, pred_model);
+  } catch (std::bad_alloc &e) {
     ml_loge ("Failed to allocate memory for filter subplugin: Caffe2\n");
     return -1;
+  } catch (std::runtime_error &e) {
+    ml_loge ("Error for subplugin Caffe2: %s.", e.what ());
+    return -1;
+  } catch (...) {
+    ml_loge ("Unknown error thrown for subplugin Caffe2.");
+    return -1;
   }
 
   if (core->init (prop) != 0) {