Allow to load extension by relative path in frontends, node factory (#21486)
This commit is contained in:
parent
0520216481
commit
d217847714
@ -28,8 +28,20 @@ private:
|
|||||||
std::shared_ptr<void> m_so;
|
std::shared_ptr<void> 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<Extension::Ptr> load_extensions(const std::string& path) {
|
inline std::vector<Extension::Ptr> 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<Extension::Ptr>&);
|
using CreateFunction = void(std::vector<Extension::Ptr>&);
|
||||||
std::vector<Extension::Ptr> extensions;
|
std::vector<Extension::Ptr> extensions;
|
||||||
reinterpret_cast<CreateFunction*>(ov::util::get_symbol(so, "create_extensions"))(extensions);
|
reinterpret_cast<CreateFunction*>(ov::util::get_symbol(so, "create_extensions"))(extensions);
|
||||||
|
@ -13,20 +13,6 @@
|
|||||||
#include "openvino/runtime/iremote_context.hpp"
|
#include "openvino/runtime/iremote_context.hpp"
|
||||||
#include "openvino/util/file_util.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 {
|
namespace ov {
|
||||||
|
|
||||||
std::string find_plugins_xml(const std::string& xml_file) {
|
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) {
|
void Core::add_extension(const std::string& library_path) {
|
||||||
try {
|
try {
|
||||||
const std::string path = resolve_extension_path(library_path);
|
add_extension(ov::detail::load_extensions(library_path));
|
||||||
add_extension(ov::detail::load_extensions(path));
|
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
try {
|
try {
|
||||||
// Try to load legacy extension
|
// Try to load legacy extension
|
||||||
@ -186,8 +171,7 @@ void Core::add_extension(const std::string& library_path) {
|
|||||||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||||
void Core::add_extension(const std::wstring& library_path) {
|
void Core::add_extension(const std::wstring& library_path) {
|
||||||
try {
|
try {
|
||||||
const std::string path = resolve_extension_path(ov::util::wstring_to_string(library_path));
|
add_extension(ov::detail::load_extensions(library_path));
|
||||||
add_extension(ov::detail::load_extensions(ov::util::string_to_wstring(path)));
|
|
||||||
} catch (const std::runtime_error&) {
|
} catch (const std::runtime_error&) {
|
||||||
try {
|
try {
|
||||||
// Try to load legacy extension
|
// Try to load legacy extension
|
||||||
|
Loading…
Reference in New Issue
Block a user