@@ -273,6 +273,13 @@ std::filesystem::path get_cache_model_path(const ov::AnyMap& config) {
273273 return it == config.end () ? std::filesystem::path{} : it->second .as <std::filesystem::path>();
274274}
275275
276+ std::vector<ov::Extension::Ptr> try_get_extensions (const std::filesystem::path& path) {
277+ try {
278+ return ov::detail::load_extensions (path.native ());
279+ } catch (const std::runtime_error&) {
280+ return {};
281+ }
282+ }
276283} // namespace
277284
278285bool ov::is_config_applicable (const std::string& user_device_name, const std::string& subprop_device_name) {
@@ -626,9 +633,8 @@ void ov::CoreImpl::register_plugins_in_registry(const std::string& xml_config_fi
626633
627634 if (extensionsNode) {
628635 FOREACH_CHILD (extensionNode, extensionsNode, " extension" ) {
629- ov::util::FilePath extensionLocation =
630- ov::util::to_file_path (pugixml::get_str_attr (extensionNode, " location" ).c_str ());
631- listOfExtentions.push_back (extensionLocation);
636+ const auto extension_location = pugixml::get_str_attr (extensionNode, " location" );
637+ listOfExtentions.push_back (ov::util::make_path (extension_location));
632638 }
633639 }
634640
@@ -805,17 +811,17 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const {
805811 // add plugin as extension itself
806812 std::lock_guard<std::mutex> g_lock (get_mutex ());
807813
814+ std::vector<ov::Extension::Ptr> ext;
808815 if (desc.extensionCreateFunc ) { // static OpenVINO case
809816 try {
810- std::vector<ov::Extension::Ptr> ext;
811817 desc.extensionCreateFunc (ext);
812- add_extensions_unsafe (ext, deviceName);
813818 } catch (const ov::Exception&) {
814819 // the same extension can be registered multiple times - ignore it!
815820 }
816821 } else {
817- try_to_register_plugin_extensions (desc.libraryLocation , deviceName );
822+ ext = try_get_extensions (desc.libraryLocation );
818823 }
824+ std::move (ext.begin (), ext.end (), std::back_inserter (pluginRegistry.at (deviceName).extensions ));
819825
820826 return plugins.emplace (deviceName, plugin).first ->second ;
821827 } catch (const ov::Exception& ex) {
@@ -1305,9 +1311,7 @@ void ov::CoreImpl::unload_plugin(const std::string& deviceName) {
13051311 if (it == plugins.end ()) {
13061312 OPENVINO_THROW (" Device with \" " , deviceName, " \" name is not registered in the OpenVINO Runtime" );
13071313 }
1308-
1309- remove_extensions_for_device_unsafe (deviceName);
1310-
1314+ pluginRegistry[deviceName].extensions .clear ();
13111315 plugins.erase (deviceName);
13121316}
13131317
@@ -1455,43 +1459,33 @@ void ov::CoreImpl::set_property_for_device(const ov::AnyMap& configMap, const st
14551459 });
14561460 }
14571461}
1458- void ov::CoreImpl::add_extensions_unsafe (const std::vector<ov::Extension::Ptr>& exts,
1459- const std::string& device_name) const {
1462+ void ov::CoreImpl::add_extensions_unsafe (const std::vector<ov::Extension::Ptr>& exts) const {
14601463 for (const auto & ext : exts) {
1461- extensions.emplace_back (ext, device_name );
1464+ extensions.emplace_back (ext);
14621465 auto ext_obj = ext;
14631466 if (auto so_ext = std::dynamic_pointer_cast<ov::detail::SOExtension>(ext_obj))
14641467 ext_obj = so_ext->extension ();
14651468 if (auto op_base_ext = std::dynamic_pointer_cast<ov::BaseOpExtension>(ext_obj)) {
14661469 for (const auto & attached_ext : op_base_ext->get_attached_extensions ()) {
1467- extensions.emplace_back (attached_ext, device_name );
1470+ extensions.emplace_back (attached_ext);
14681471 }
14691472 }
14701473 }
14711474}
14721475
1473- void ov::CoreImpl::remove_extensions_for_device_unsafe (const std::string& device_name) const {
1474- extensions.erase (std::remove_if (extensions.begin (),
1475- extensions.end (),
1476- [&device_name](const auto & item) {
1477- return item.second == device_name;
1478- }),
1479- extensions.end ());
1480- }
1481-
14821476std::vector<ov::Extension::Ptr> ov::CoreImpl::get_extensions_copy () const {
14831477 std::lock_guard<std::mutex> lock (get_mutex ());
1484- std::vector<ov::Extension::Ptr> only_extensions;
1485- only_extensions. reserve (extensions. size () );
1486- for (const auto & item : extensions ) {
1487- only_extensions. push_back (item. first );
1478+ auto only_extensions = extensions ;
1479+ auto ext_it = std::back_inserter (only_extensions );
1480+ for (const auto & [_, plugin_desc] : pluginRegistry ) {
1481+ std::copy (plugin_desc. extensions . begin (), plugin_desc. extensions . end (), ext_it );
14881482 }
14891483 return only_extensions;
14901484};
14911485
1492- void ov::CoreImpl::add_extension (const std::vector<ov::Extension::Ptr>& extensions, const std::string& device_name ) {
1486+ void ov::CoreImpl::add_extension (const std::vector<ov::Extension::Ptr>& extensions) {
14931487 std::lock_guard<std::mutex> lock (get_mutex ());
1494- add_extensions_unsafe (extensions, device_name );
1488+ add_extensions_unsafe (extensions);
14951489}
14961490
14971491bool ov::CoreImpl::device_supports_model_caching (const std::string& device_name) const {
0 commit comments