From 709e146666db3c27844ac32b23b581194b2c7749 Mon Sep 17 00:00:00 2001 From: Kwanghoon Son Date: Wed, 17 Aug 2022 00:31:56 -0400 Subject: [PATCH] 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 --- packaging/inference-engine-mlapi.spec | 2 +- src/inference_engine_mlapi.cpp | 14 ++++++++++++++ src/inference_engine_mlapi_private.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) 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); -- 2.7.4