mDesignated_outputs.clear();
std::map<std::string, int>().swap(mDesignated_outputs);
- ml_single_close(mSingle);
+ if (mSingle)
+ ml_single_close(mSingle);
if (mInputInfoHandle)
ml_tensors_info_destroy(mInputInfoHandle);
customOp += GetFileCustomProp(model_str);
LOGI("customOp: %s", customOp.c_str());
+ // Make sure to close previous handle because seg. fault can happen by nnstreamer sometime later
+ // if a new handle is created continuously without closing previous one - nnstreamer internally creates a new thread
+ // every time ml_single_open_full function is called, which in turn thread creation request can fail.
+ if (mSingle) {
+ ml_single_close(mSingle);
+ mSingle = NULL;
+ LOGI("Closed previous ML Single API handle.");
+ }
+
int err = ml_single_open_full(&mSingle, model_str.c_str(), in_info, out_info,
nnfw_type, nnfw_hw, customOp.c_str());
if (err != ML_ERROR_NONE) {