diff --git a/src/core/dev_api/openvino/core/so_extension.hpp b/src/core/dev_api/openvino/core/so_extension.hpp index 98fb1e9f67a..cbba0d29c68 100644 --- a/src/core/dev_api/openvino/core/so_extension.hpp +++ b/src/core/dev_api/openvino/core/so_extension.hpp @@ -28,8 +28,20 @@ private: std::shared_ptr m_so; }; +inline std::string resolve_extension_path(const std::string& path) { + std::string retvalue; + try { + const std::string absolute_path = ov::util::get_absolute_file_path(path); + retvalue = ov::util::file_exists(absolute_path) ? absolute_path : path; + } catch (const std::runtime_error&) { + retvalue = path; + } + return retvalue; +} + inline std::vector load_extensions(const std::string& path) { - auto so = ov::util::load_shared_object(path.c_str()); + const std::string resolved_path = resolve_extension_path(path); + auto so = ov::util::load_shared_object(resolved_path.c_str()); using CreateFunction = void(std::vector&); std::vector extensions; reinterpret_cast(ov::util::get_symbol(so, "create_extensions"))(extensions); diff --git a/src/inference/src/core.cpp b/src/inference/src/core.cpp index fd05fbaec54..9ee07f6246a 100644 --- a/src/inference/src/core.cpp +++ b/src/inference/src/core.cpp @@ -13,20 +13,6 @@ #include "openvino/runtime/iremote_context.hpp" #include "openvino/util/file_util.hpp" -namespace { -std::string resolve_extension_path(const std::string& path) { - std::string retvalue; - try { - const std::string absolute_path = ov::util::get_absolute_file_path(path); - retvalue = ov::util::file_exists(absolute_path) ? absolute_path : path; - } catch (const std::runtime_error&) { - retvalue = path; - } - return retvalue; -} - -} // namespace - namespace ov { std::string find_plugins_xml(const std::string& xml_file) { @@ -166,8 +152,7 @@ void Core::add_extension(const InferenceEngine::IExtensionPtr& extension) { void Core::add_extension(const std::string& library_path) { try { - const std::string path = resolve_extension_path(library_path); - add_extension(ov::detail::load_extensions(path)); + add_extension(ov::detail::load_extensions(library_path)); } catch (const std::runtime_error&) { try { // Try to load legacy extension @@ -186,8 +171,7 @@ void Core::add_extension(const std::string& library_path) { #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT void Core::add_extension(const std::wstring& library_path) { try { - const std::string path = resolve_extension_path(ov::util::wstring_to_string(library_path)); - add_extension(ov::detail::load_extensions(ov::util::string_to_wstring(path))); + add_extension(ov::detail::load_extensions(library_path)); } catch (const std::runtime_error&) { try { // Try to load legacy extension