OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
Migrate to std::fs::path dev and auto plugin (#34545)
Alicja Miloszewskae3195385d9ad
diff --git a/src/inference/dev_api/openvino/runtime/iplugin.hpp b/src/inference/dev_api/openvino/runtime/iplugin.hppindex 0c72b0bfa9e..2fb0b9899bc 100644--- a/src/inference/dev_api/openvino/runtime/iplugin.hpp+++ b/src/inference/dev_api/openvino/runtime/iplugin.hpp@@ -10,6 +10,7 @@#pragma once#include <memory>+#include <filesystem>#include "openvino/core/any.hpp"#include "openvino/core/deprecated.hpp"@@ -110,12 +111,12 @@ public:const ov::AnyMap& properties) const = 0;/**- * @brief Compiles model from ov::Model object- * @param model_path A path to model (path can be converted from unicode representation)+ * @brief Compiles a model from a file path+ * @param model_path A path to model* @param properties A ov::AnyMap of properties relevant only for this load operation* @return Created Compiled Model object*/- virtual std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ virtual std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const;/**diff --git a/src/inference/src/dev/iplugin.cpp b/src/inference/src/dev/iplugin.cppindex 588af7b2c75..ae34d432203 100644--- a/src/inference/src/dev/iplugin.cpp+++ b/src/inference/src/dev/iplugin.cpp@@ -78,11 +78,11 @@ const std::shared_ptr<ov::threading::ExecutorManager>& ov::IPlugin::get_executorreturn m_executor_manager;}-std::shared_ptr<ov::ICompiledModel> ov::IPlugin::compile_model(const std::string& model_path,+std::shared_ptr<ov::ICompiledModel> ov::IPlugin::compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const {auto core = get_core();OPENVINO_ASSERT(core);- const auto model = core->read_model(util::make_path(model_path), {}, properties);+ const auto model = core->read_model(model_path, {}, properties);auto local_properties = properties;if (!ov::is_virtual_device(get_device_name())) {CoreConfig::remove_core(local_properties);diff --git a/src/inference/src/dev/plugin.cpp b/src/inference/src/dev/plugin.cppindex aef53804097..e1ec6f83607 100644--- a/src/inference/src/dev/plugin.cpp+++ b/src/inference/src/dev/plugin.cpp@@ -56,7 +56,7 @@ ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<coov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const {- OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(ov::util::path_to_string(model_path), properties), m_so});+ OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(model_path, properties), m_so});}ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<const ov::Model>& model,diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cppindex 39dd60dac60..137c98d1c6b 100644--- a/src/inference/tests/functional/caching_test.cpp+++ b/src/inference/tests/functional/caching_test.cpp@@ -77,7 +77,7 @@ public:MockCachingIPluginBase() = default;~MockCachingIPluginBase() = default;- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& config) const override {// In GTEST, it is not possible to call base implementation inside of mocked class// Thus, we define a proxy callback and will usediff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cppindex 2ab231ef832..ed5bb2f0184 100644--- a/src/plugins/auto/src/auto_schedule.cpp+++ b/src/plugins/auto/src/auto_schedule.cpp@@ -323,7 +323,7 @@ void AutoSchedule::try_to_compile_model(AutoCompileContext& context, const std::try {auto compile_start_time = std::chrono::high_resolution_clock::now();if (!(m_context->m_model_path.empty())) {- context.m_compiled_model = m_context->m_ov_core->compile_model(ov::util::make_path(m_context->m_model_path),+ context.m_compiled_model = m_context->m_ov_core->compile_model(m_context->m_model_path,device,device_config);} else {diff --git a/src/plugins/auto/src/common.hpp b/src/plugins/auto/src/common.hppindex da65cbbefd2..7649a3cc25d 100644--- a/src/plugins/auto/src/common.hpp+++ b/src/plugins/auto/src/common.hpp@@ -5,6 +5,7 @@///////////////////////////////////////////////////////////////////////////////////////////////////#pragma once+#include <filesystem>#include <map>#include <string>@@ -210,7 +211,7 @@ public:bool m_runtime_fallback = true;bool m_bind_buffer = false;std::shared_ptr<ov::Model> m_model;- std::string m_model_path;+ std::filesystem::path m_model_path;std::shared_ptr<const ov::IPlugin> m_plugin;std::string m_str_devices;std::vector<std::string> m_str_devices_initial;diff --git a/src/plugins/auto/src/cumulative_schedule.cpp b/src/plugins/auto/src/cumulative_schedule.cppindex 6644322a83c..f7f7f3dc977 100644--- a/src/plugins/auto/src/cumulative_schedule.cpp+++ b/src/plugins/auto/src/cumulative_schedule.cpp@@ -193,9 +193,8 @@ void CumuSchedule::try_to_compile_model(AutoCompileContext& context, const std::}try {if (!(m_context->m_model_path.empty())) {- context.m_compiled_model = m_context->m_ov_core->compile_model(ov::util::make_path(m_context->m_model_path),- device,- device_config);+ context.m_compiled_model =+ m_context->m_ov_core->compile_model(m_context->m_model_path, device, device_config);} else {context.m_compiled_model = m_context->m_ov_core->compile_model(model, device, device_config);}diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cppindex 9e23fdff17f..373b5c8ca83 100644--- a/src/plugins/auto/src/plugin.cpp+++ b/src/plugins/auto/src/plugin.cpp@@ -372,12 +372,12 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<return compile_model_impl({}, model, properties, model_precision);}-std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::string& model_path,+std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const {return compile_model_impl(model_path, nullptr, properties);}-std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::string& model_path,+std::shared_ptr<ov::ICompiledModel> Plugin::compile_model_impl(const std::filesystem::path& model_path,const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties,const std::string& model_precision) const {@@ -724,7 +724,7 @@ void Plugin::register_priority(const unsigned int& priority, const std::string&std::string Plugin::get_device_list(ov::AnyMap& properties,const std::shared_ptr<const ov::Model>& model,- const std::string& model_path) const {+ const std::filesystem::path& model_path) const {std::string all_devices;std::string device_architecture;auto device_list_config = properties.find(ov::device::priorities.name());@@ -772,7 +772,7 @@ std::string Plugin::get_device_list(ov::AnyMap& properties,if (model)blobId = ov::ModelCache::compute_hash(model, dev_properties);else- blobId = ov::ModelCache::compute_hash(util::make_path(model_path), dev_properties);+ blobId = ov::ModelCache::compute_hash(model_path, dev_properties);const auto cached_model_path = ov::util::make_path(cache_dir) / (blobId + ".blob");bool is_blob_file_exist = ov::util::file_exists(cached_model_path);num_blob_files += is_blob_file_exist;diff --git a/src/plugins/auto/src/plugin.hpp b/src/plugins/auto/src/plugin.hppindex 28acb52c5ee..e6e2629da0b 100644--- a/src/plugins/auto/src/plugin.hpp+++ b/src/plugins/auto/src/plugin.hpp@@ -5,6 +5,7 @@///////////////////////////////////////////////////////////////////////////////////////////////////#pragma once+#include <filesystem>#include <map>#include <vector>#include <string>@@ -38,7 +39,7 @@ public:const ov::AnyMap& properties,const ov::SoPtr<ov::IRemoteContext>& context) const override;- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override;MOCKTESTMACRO bool is_meta_device(const std::string& priorities) const;@@ -47,7 +48,7 @@ public:MOCKTESTMACRO std::string get_device_list(ov::AnyMap& properties,const std::shared_ptr<const ov::Model>& model = nullptr,- const std::string& model_path = {}) const;+ const std::filesystem::path& model_path = {}) const;MOCKTESTMACRO std::list<DeviceInformation> get_valid_device(const std::vector<DeviceInformation>& meta_devices,const std::string& model_precision = "FP32") const;@@ -78,7 +79,7 @@ public:const ov::AnyMap& properties) const override;private:- std::shared_ptr<ov::ICompiledModel> compile_model_impl(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model_impl(const std::filesystem::path& model_path,const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties,const std::string& model_precision = "FP32") const;diff --git a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp b/src/plugins/auto/tests/functional/behavior/auto_func_test.cppindex f91a64a29b9..d5981ea70f2 100644--- a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp+++ b/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp@@ -378,7 +378,7 @@ public:return std::make_shared<MockCompiledModel>(model, shared_from_this(), properties);}- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override {OPENVINO_NOT_IMPLEMENTED;}diff --git a/src/plugins/auto/tests/unit/auto_unit_test.cpp b/src/plugins/auto/tests/unit/auto_unit_test.cppindex 0c9fca3c521..06864441901 100644--- a/src/plugins/auto/tests/unit/auto_unit_test.cpp+++ b/src/plugins/auto/tests/unit/auto_unit_test.cpp@@ -109,7 +109,7 @@ ov::mock_auto_plugin::tests::BaseTest::BaseTest(const MODELTYPE modelType) {ON_CALL(*plugin, get_device_list).WillByDefault([this](ov::AnyMap& config,const std::shared_ptr<const ov::Model>& model,- const std::string& model_path) {+ const std::filesystem::path& model_path) {return plugin->Plugin::get_device_list(config, model, {});});ON_CALL(*plugin, parse_meta_devices)diff --git a/src/plugins/auto/tests/unit/get_device_list.cpp b/src/plugins/auto/tests/unit/get_device_list.cppindex 8cfeb7556f5..92df244f6b9 100644--- a/src/plugins/auto/tests/unit/get_device_list.cpp+++ b/src/plugins/auto/tests/unit/get_device_list.cpp@@ -35,7 +35,7 @@ public:ON_CALL(*plugin, get_device_list).WillByDefault([this](ov::AnyMap& config,const std::shared_ptr<const ov::Model>& model,- const std::string& model_path) {+ const std::filesystem::path& model_path) {return plugin->Plugin::get_device_list(config);});}diff --git a/src/plugins/auto/tests/unit/include/gmock_plugin.hpp b/src/plugins/auto/tests/unit/include/gmock_plugin.hppindex 0ca9d7d2b8b..a516468c049 100644--- a/src/plugins/auto/tests/unit/include/gmock_plugin.hpp+++ b/src/plugins/auto/tests/unit/include/gmock_plugin.hpp@@ -5,6 +5,7 @@#pragma once#include <gmock/gmock.h>+#include <filesystem>#include <iostream>#include "openvino/runtime/core.hpp"@@ -18,7 +19,7 @@ class MockAutoPlugin : public Plugin {public:MOCK_METHOD((std::string),get_device_list,- ((ov::AnyMap&), const std::shared_ptr<const ov::Model>&, const std::string&),+ ((ov::AnyMap&), const std::shared_ptr<const ov::Model>&, const std::filesystem::path&),(const, override));MOCK_METHOD((bool), is_meta_device, ((const std::string&)), (const, override));MOCK_METHOD((std::list<DeviceInformation>),diff --git a/src/plugins/hetero/tests/functional/hetero_tests.cpp b/src/plugins/hetero/tests/functional/hetero_tests.cppindex ab37768d942..602c3466876 100644--- a/src/plugins/hetero/tests/functional/hetero_tests.cpp+++ b/src/plugins/hetero/tests/functional/hetero_tests.cpp@@ -465,7 +465,7 @@ public:return std::make_shared<MockCompiledModel>(model, shared_from_this(), properties);}- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override {OPENVINO_NOT_IMPLEMENTED;}diff --git a/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.cpp b/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.cppindex 72fae871d11..04d02a17f55 100644--- a/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.cpp+++ b/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.cpp@@ -157,9 +157,9 @@ void MockPluginBase<DeviceType>::create_implementation() {return mock_compiled_model;});- ON_CALL(*this, compile_model(testing::A<const std::string&>(), testing::_))+ ON_CALL(*this, compile_model(testing::A<const std::filesystem::path&>(), testing::_)).WillByDefault(- [](const std::string& model_path, const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {+ [](const std::filesystem::path& model_path, const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {OPENVINO_NOT_IMPLEMENTED;});ON_CALL(*this, compile_model(testing::A<const std::shared_ptr<const ov::Model>&>(), testing::_, testing::_))diff --git a/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.hpp b/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.hppindex 880d267af1c..0c79b90f803 100644--- a/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.hpp+++ b/src/plugins/intel_npu/tests/functional/behavior/npuw/test_engine/mocks/mock_plugins.hpp@@ -6,6 +6,7 @@#include <gtest/gtest.h>#include <gmock/gmock.h>+#include <filesystem>#include <memory>#include <utility>@@ -112,7 +113,7 @@ public:std::shared_ptr<ov::ICompiledModel>(const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties));MOCK_CONST_METHOD2_T(compile_model,- std::shared_ptr<ov::ICompiledModel>(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel>(const std::filesystem::path& model_path,const ov::AnyMap& properties));MOCK_CONST_METHOD3_T(compile_model,std::shared_ptr<ov::ICompiledModel>(const std::shared_ptr<const ov::Model>& model,diff --git a/src/plugins/proxy/src/plugin.cpp b/src/plugins/proxy/src/plugin.cppindex 0b9f511bf89..535e494f2d0 100644--- a/src/plugins/proxy/src/plugin.cpp+++ b/src/plugins/proxy/src/plugin.cpp@@ -394,7 +394,7 @@ std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::compile_model(const std::return std::make_shared<ov::proxy::CompiledModel>(device_model, plugin, remote_context);}-std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::compile_model(const std::string& model_path,+std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const {auto dev_name = get_fallback_device(get_device_from_config(properties));auto device_config = construct_device_config(dev_name, m_configs, properties);diff --git a/src/plugins/proxy/src/plugin.hpp b/src/plugins/proxy/src/plugin.hppindex d0ff2bfd6c2..9ec6f10e347 100644--- a/src/plugins/proxy/src/plugin.hpp+++ b/src/plugins/proxy/src/plugin.hpp@@ -3,6 +3,7 @@//#pragma once+#include <filesystem>#include <memory>#include <shared_mutex>@@ -26,7 +27,7 @@ public:std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties) const override;- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override;std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,diff --git a/src/plugins/proxy/tests/proxy_tests.cpp b/src/plugins/proxy/tests/proxy_tests.cppindex bc73ca065cb..fcc3e84280b 100644--- a/src/plugins/proxy/tests/proxy_tests.cpp+++ b/src/plugins/proxy/tests/proxy_tests.cpp@@ -371,7 +371,7 @@ public:return std::make_shared<MockCompiledModel>(model, shared_from_this(), properties);}- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override {OPENVINO_NOT_IMPLEMENTED;}diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cppindex 0b58c9fa9b9..1f0410f8dd1 100644--- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp+++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp@@ -32,7 +32,7 @@ public:OPENVINO_NOT_IMPLEMENTED;}- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override {if (m_plugin)return m_plugin->compile_model(model_path, properties);@@ -147,7 +147,7 @@ std::shared_ptr<ov::ICompiledModel> MockPlugin::compile_model(const std::shared_return m_plugin->compile_model(model, properties);}-std::shared_ptr<ov::ICompiledModel> MockPlugin::compile_model(const std::string& model_path,+std::shared_ptr<ov::ICompiledModel> MockPlugin::compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const {set_parameters_if_need();return m_plugin->compile_model(model_path, properties);diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hppindex 4cbaf6dc000..70df435735b 100644--- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp+++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp@@ -4,6 +4,7 @@#pragma once+#include <filesystem>#include <map>#include <string>@@ -19,7 +20,7 @@ public:std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,const ov::AnyMap& properties) const override;- std::shared_ptr<ov::ICompiledModel> compile_model(const std::string& model_path,+ std::shared_ptr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,const ov::AnyMap& properties) const override;std::shared_ptr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,diff --git a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hppindex 8f72a32023e..7d0c63d307e 100644--- a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp+++ b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp@@ -6,6 +6,7 @@#include <gmock/gmock.h>+#include <filesystem>#include <map>#include <string>@@ -25,7 +26,10 @@ public:compile_model,(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&),(const));- MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>, compile_model, (const std::string&, const ov::AnyMap&), (const));+ MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,+ compile_model,+ (const std::filesystem::path&, const ov::AnyMap&),+ (const));MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,compile_model,(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&, const ov::SoPtr<ov::IRemoteContext>&),