From: Kwanghoon Son Date: Wed, 17 Aug 2022 04:31:56 +0000 (-0400) Subject: Add GetFileCustomProp X-Git-Tag: submit/tizen/20220817.072344^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F26%2F279726%2F2;p=platform%2Fcore%2Fmultimedia%2Finference-engine-mlapi.git Add GetFileCustomProp [Version] : 0.4.6 [Issue type] : new feature get customprop from file name {model_name}.custom Change-Id: I7305018ae35a03d3680c6dd8b98e128d3559c497 Signed-off-by: Kwanghoon Son --- diff --git a/packaging/inference-engine-mlapi.spec b/packaging/inference-engine-mlapi.spec index d37f2c9..a1cd8c1 100644 --- a/packaging/inference-engine-mlapi.spec +++ b/packaging/inference-engine-mlapi.spec @@ -1,6 +1,6 @@ Name: inference-engine-mlapi Summary: ML Single API backend of NNStreamer for MediaVision -Version: 0.4.5 +Version: 0.4.6 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/inference_engine_mlapi.cpp b/src/inference_engine_mlapi.cpp index 46fa41b..f378bd1 100644 --- a/src/inference_engine_mlapi.cpp +++ b/src/inference_engine_mlapi.cpp @@ -19,6 +19,7 @@ #include "inference_engine_mlapi_private.h" #include +#include #include #include #include @@ -292,7 +293,19 @@ namespace MLAPIImpl throw std::runtime_error("shouldn't be reach here"); } } + std::string InferenceMLAPI::GetFileCustomProp(std::string &path) + { + std::string custom; + std::string custom_file = path.substr(0, path.find_last_of(".")) + ".custom"; + if (IsFileReadable(custom_file)) { + std::ifstream fp(custom_file); + std::stringstream buffer; + buffer << fp.rdbuf(); + custom = buffer.str(); + } + return custom; + } std::string InferenceMLAPI::GetCustomProp() { if (mPluginType != INFERENCE_BACKEND_SNPE) @@ -365,6 +378,7 @@ namespace MLAPIImpl } } auto customOp = GetCustomProp(); + customOp += GetFileCustomProp(model_str); LOGI("customOp: %s", customOp.c_str()); int err = ml_single_open_full(&mSingle, model_str.c_str(), in_info, out_info, diff --git a/src/inference_engine_mlapi_private.h b/src/inference_engine_mlapi_private.h index 07d57ef..0bbfbbf 100644 --- a/src/inference_engine_mlapi_private.h +++ b/src/inference_engine_mlapi_private.h @@ -91,6 +91,7 @@ namespace MLAPIImpl std::tuple GetNNFWInfo(); std::string GetModelPath(const std::vector& model_paths); std::string GetCustomProp(); + std::string GetFileCustomProp(std::string& path); int GetTensorInfo(std::map& designated_layers, std::map &buffers, ml_tensors_data_h& dataHandle, ml_tensors_info_h& infoHandle);