Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[core] Make the internal implementation of Core.compile_model(fs::path) the base implementation (#33740)

Alicja Miloszewskacd2cfd3e308c
diff --git a/src/inference/dev_api/openvino/runtime/icore.hpp b/src/inference/dev_api/openvino/runtime/icore.hpp
index c94704d5d16..928868da246 100644
--- a/src/inference/dev_api/openvino/runtime/icore.hpp
+++ b/src/inference/dev_api/openvino/runtime/icore.hpp
@@ -113,7 +113,7 @@ public:
* operation
* @return A pointer to compiled model
*/
- virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path,
+ virtual ov::SoPtr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,
const std::string& device_name,
const ov::AnyMap& config) const = 0;
diff --git a/src/inference/include/openvino/runtime/core.hpp b/src/inference/include/openvino/runtime/core.hpp
index 007141da46b..f953b819fed 100644
--- a/src/inference/include/openvino/runtime/core.hpp
+++ b/src/inference/include/openvino/runtime/core.hpp
@@ -259,16 +259,20 @@ public:
*/
CompiledModel compile_model(const std::string& model_path, const AnyMap& properties = {});
- template <class Path, std::enable_if_t<std::is_same_v<Path, std::filesystem::path>>* = nullptr>
- auto compile_model(const Path& model_path, const AnyMap& properties = {}) const {
- if constexpr (std::is_same_v<typename Path::value_type, wchar_t>)
- return compile_model(model_path.wstring(), properties);
- else
- return compile_model(model_path.string(), properties);
+ CompiledModel compile_model(const std::filesystem::path& model_path, const AnyMap& properties = {});
+
+ template <class Path, std::enable_if_t<std::is_constructible_v<std::string, Path>>* = nullptr>
+ CompiledModel compile_model(const Path& model_path, const AnyMap& properties = {}) {
+ return compile_model(std::string(model_path), properties);
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
CompiledModel compile_model(const std::wstring& model_path, const AnyMap& properties = {});
+
+ template <class Path, std::enable_if_t<std::is_constructible_v<std::wstring, Path>>* = nullptr>
+ CompiledModel compile_model(const Path& model_path, const AnyMap& properties = {}) {
+ return compile_model(std::wstring(model_path), properties);
+ }
#endif
/// @}
@@ -280,7 +284,7 @@ public:
* especially for cases when caching is enabled and cached model is available
*
* @tparam Properties Should be the pack of `std::pair<std::string, ov::Any>` types
- * @param model_path path to model with string or wstring
+ * @param model_path path to model
* @param properties Optional pack of pairs: (property name, property value) relevant only for this
* load operation
*
@@ -294,11 +298,9 @@ public:
}
template <class Path, class... Properties, std::enable_if_t<std::is_same_v<Path, std::filesystem::path>>* = nullptr>
- auto compile_model(const Path& model_path, Properties&&... properties) {
- if constexpr (std::is_same_v<typename Path::value_type, wchar_t>)
- return compile_model(model_path.wstring(), std::forward<Properties>(properties)...);
- else
- return compile_model(model_path.string(), std::forward<Properties>(properties)...);
+ util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(const Path& model_path,
+ Properties&&... properties) {
+ return compile_model(model_path, AnyMap{std::forward<Properties>(properties)...});
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
@@ -328,18 +330,24 @@ public:
const std::string& device_name,
const AnyMap& properties = {});
- template <class Path, std::enable_if_t<std::is_same_v<Path, std::filesystem::path>>* = nullptr>
- auto compile_model(const Path& model_path, const std::string& device_name, const AnyMap& properties = {}) {
- if constexpr (std::is_same_v<typename Path::value_type, wchar_t>)
- return compile_model(model_path.wstring(), device_name, properties);
- else
- return compile_model(model_path.string(), device_name, properties);
+ CompiledModel compile_model(const std::filesystem::path& model_path,
+ const std::string& device_name,
+ const AnyMap& properties = {});
+
+ template <class Path, std::enable_if_t<std::is_constructible_v<std::string, Path>>* = nullptr>
+ CompiledModel compile_model(const Path& model_path, const std::string& device_name, const AnyMap& properties = {}) {
+ return compile_model(std::string(model_path), device_name, properties);
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
CompiledModel compile_model(const std::wstring& model_path,
const std::string& device_name,
const AnyMap& properties = {});
+
+ template <class Path, std::enable_if_t<std::is_constructible_v<std::wstring, Path>>* = nullptr>
+ CompiledModel compile_model(const Path& model_path, const std::string& device_name, const AnyMap& properties = {}) {
+ return compile_model(std::wstring(model_path), device_name, properties);
+ }
#endif
/// @}
@@ -366,11 +374,10 @@ public:
}
template <class Path, class... Properties, std::enable_if_t<std::is_same_v<Path, std::filesystem::path>>* = nullptr>
- auto compile_model(const Path& model_path, const std::string& device_name, Properties&&... properties) {
- if constexpr (std::is_same_v<typename Path::value_type, wchar_t>)
- return compile_model(model_path.wstring(), device_name, std::forward<Properties>(properties)...);
- else
- return compile_model(model_path.string(), device_name, std::forward<Properties>(properties)...);
+ util::EnableIfAllStringAny<CompiledModel, Properties...> compile_model(const Path& model_path,
+ const std::string& device_name,
+ Properties&&... properties) {
+ return compile_model(model_path, device_name, AnyMap{std::forward<Properties>(properties)...});
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
diff --git a/src/inference/src/cpp/core.cpp b/src/inference/src/cpp/core.cpp
index 393752e8f37..d08b6bed0b0 100644
--- a/src/inference/src/cpp/core.cpp
+++ b/src/inference/src/cpp/core.cpp
@@ -113,24 +113,36 @@ CompiledModel Core::compile_model(const std::shared_ptr<const ov::Model>& model,
});
}
-CompiledModel Core::compile_model(const std::string& model_path, const AnyMap& config) {
+CompiledModel Core::compile_model(const std::filesystem::path& model_path, const AnyMap& config) {
OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
return compile_model(model_path, ov::default_device_name, config);
}
+CompiledModel Core::compile_model(const std::filesystem::path& model_path,
+ const std::string& device_name,
+ const AnyMap& config) {
+ OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
+ OV_CORE_CALL_STATEMENT({
+ auto exec = _impl->compile_model(model_path, device_name, config);
+ return {exec._ptr, exec._so};
+ });
+}
+
+CompiledModel Core::compile_model(const std::string& model_path, const AnyMap& config) {
+ OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
+ return compile_model(ov::util::make_path(model_path), ov::default_device_name, config);
+}
+
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
CompiledModel Core::compile_model(const std::wstring& model_path, const AnyMap& config) {
OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
- return compile_model(ov::util::wstring_to_string(model_path), config);
+ return compile_model(ov::util::make_path(model_path), config);
}
#endif
CompiledModel Core::compile_model(const std::string& model_path, const std::string& device_name, const AnyMap& config) {
OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
- OV_CORE_CALL_STATEMENT({
- auto exec = _impl->compile_model(model_path, device_name, config);
- return {exec._ptr, exec._so};
- });
+ return compile_model(ov::util::make_path(model_path), device_name, config);
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
@@ -138,7 +150,7 @@ CompiledModel Core::compile_model(const std::wstring& model_path,
const std::string& device_name,
const AnyMap& config) {
OV_ITT_SCOPED_REGION_BASE(ov::itt::domains::OV, "Compile model");
- return compile_model(ov::util::wstring_to_string(model_path), device_name, config);
+ return compile_model(ov::util::make_path(model_path), device_name, config);
}
#endif
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index d5b386097a9..bb319299f76 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -228,7 +228,7 @@ std::filesystem::path extract_weight_path(const std::string& compiled_properties
}
}
-using model_hint_t = std::variant<std::shared_ptr<const ov::Model>, std::string>;
+using model_hint_t = std::variant<std::shared_ptr<const ov::Model>, std::filesystem::path>;
ov::SoPtr<ov::ICompiledModel> import_compiled_model(const ov::Plugin& plugin,
const ov::SoPtr<ov::IRemoteContext>& context,
@@ -257,13 +257,13 @@ ov::SoPtr<ov::ICompiledModel> import_compiled_model(const ov::Plugin& plugin,
cfg[ov::hint::model.name()] = model_ptr;
}
},
- [&cfg, &plugin](const std::string& model_path) {
+ [&cfg, &plugin](const std::filesystem::path& model_path) {
if (cfg.count(ov::weights_path.name()) == 0 &&
ov::util::contains(plugin.get_property(ov::supported_properties), ov::weights_path)) {
std::filesystem::path weights_path{model_path};
weights_path.replace_extension(".bin");
if (ov::util::file_exists(weights_path)) {
- cfg[ov::weights_path.name()] = weights_path.string();
+ cfg[ov::weights_path.name()] = ov::util::path_to_string(weights_path);
}
}
}};
@@ -899,7 +899,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
return res;
}
-ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& model_path,
+ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::filesystem::path& model_path,
const std::string& device_name,
const ov::AnyMap& config) const {
OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::LoadTime, "Core::compile_model::Path");
@@ -915,7 +915,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::string& mod
// Skip caching for proxy plugin. HW plugin will load network from the cache
CoreConfig::remove_core(parsed.m_config);
emplace_cache_dir_if_supported(parsed.m_config, plugin, cache_dir);
- CacheContent cache_content{cache_manager, parsed.m_core_config.get_enable_mmap(), util::make_path(model_path)};
+ CacheContent cache_content{cache_manager, parsed.m_core_config.get_enable_mmap(), model_path};
cache_content.m_blob_id =
ov::ModelCache::compute_hash(cache_content.m_model_path, create_compile_config(plugin, parsed.m_config));
const auto lock = m_cache_guard.get_hash_lock(cache_content.m_blob_id);
@@ -1732,7 +1732,10 @@ std::shared_ptr<ov::Model> ov::CoreImpl::read_model(const std::string& modelPath
OV_ITT_SCOPE(FIRST_INFERENCE, ov::itt::domains::ReadTime, "CoreImpl::read_model from file");
auto local_core_config = m_core_config;
local_core_config.set(properties, {});
- return ov::util::read_model(modelPath, binPath, get_extensions_copy(), local_core_config.get_enable_mmap());
+ return ov::util::read_model(ov::util::make_path(modelPath),
+ ov::util::make_path(binPath),
+ get_extensions_copy(),
+ local_core_config.get_enable_mmap());
}
std::shared_ptr<ov::Model> ov::CoreImpl::read_model(const std::string& model,
diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp
index 71ce6781789..27ec21ffbbe 100644
--- a/src/inference/src/dev/core_impl.hpp
+++ b/src/inference/src/dev/core_impl.hpp
@@ -314,7 +314,7 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& config = {}) const override;
- ov::SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path,
+ ov::SoPtr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,
const std::string& device_name,
const ov::AnyMap& config) const override;
diff --git a/src/inference/src/dev/plugin.cpp b/src/inference/src/dev/plugin.cpp
index 8be7ba6e249..48d8f4284fb 100644
--- a/src/inference/src/dev/plugin.cpp
+++ b/src/inference/src/dev/plugin.cpp
@@ -9,6 +9,7 @@
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"
#include "openvino/util/common_util.hpp"
+#include "openvino/util/file_util.hpp"
#define OV_PLUGIN_CALL_STATEMENT(...) \
OPENVINO_ASSERT(m_ptr != nullptr, "OpenVINO Runtime Plugin was not initialized."); \
@@ -53,9 +54,9 @@ ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::shared_ptr<co
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(model, properties), m_so});
}
-ov::SoPtr<ov::ICompiledModel> ov::Plugin::compile_model(const std::string& model_path,
+ov::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(model_path, properties), m_so});
+ OV_PLUGIN_CALL_STATEMENT(return {m_ptr->compile_model(ov::util::path_to_string(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/src/dev/plugin.hpp b/src/inference/src/dev/plugin.hpp
index 7855de4b13f..2f2cdbb2867 100644
--- a/src/inference/src/dev/plugin.hpp
+++ b/src/inference/src/dev/plugin.hpp
@@ -45,7 +45,8 @@ public:
SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const;
- SoPtr<ov::ICompiledModel> compile_model(const std::string& model_path, const ov::AnyMap& properties) const;
+ SoPtr<ov::ICompiledModel> compile_model(const std::filesystem::path& model_path,
+ const ov::AnyMap& properties) const;
SoPtr<ov::ICompiledModel> compile_model(const std::shared_ptr<const ov::Model>& model,
const ov::SoPtr<ov::IRemoteContext>& context,
@@ -84,4 +85,3 @@ public:
};
} // namespace ov
-
diff --git a/src/inference/src/model_reader.cpp b/src/inference/src/model_reader.cpp
index 169a50b6029..9d079f389c1 100644
--- a/src/inference/src/model_reader.cpp
+++ b/src/inference/src/model_reader.cpp
@@ -113,31 +113,19 @@ void update_v10_model(std::shared_ptr<ov::Model>& model, bool frontendMode = fal
namespace ov {
namespace util {
-std::shared_ptr<ov::Model> read_model(const std::string& modelPath,
- const std::string& binPath,
+std::shared_ptr<ov::Model> read_model(const std::filesystem::path& model_path,
+ const std::filesystem::path& bin_path,
const std::vector<ov::Extension::Ptr>& extensions,
bool enable_mmap) {
- // Fix unicode name
-#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
- std::wstring model_path = ov::util::string_to_wstring(modelPath.c_str());
-#else
- std::string model_path = modelPath;
-#endif
-
// Try to load with FrontEndManager
ov::frontend::FrontEndManager manager;
ov::frontend::FrontEnd::Ptr FE;
ov::frontend::InputModel::Ptr inputModel;
- ov::AnyVector params{model_path};
+ ov::AnyVector params{model_path.native()};
- if (!binPath.empty()) {
-#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
- const std::wstring& weights_path = ov::util::string_to_wstring(binPath.c_str());
-#else
- const std::string& weights_path = binPath;
-#endif
- params.emplace_back(weights_path);
+ if (!bin_path.empty()) {
+ params.emplace_back(bin_path.native());
}
params.emplace_back(enable_mmap);
@@ -153,14 +141,13 @@ std::shared_ptr<ov::Model> read_model(const std::string& modelPath,
return model;
}
- const auto fileExt = modelPath.substr(modelPath.find_last_of(".") + 1);
std::string FEs;
for (const auto& fe_name : manager.get_available_front_ends())
FEs += fe_name + " ";
OPENVINO_THROW("Unable to read the model: ",
- modelPath,
+ model_path,
" Please check that model format: ",
- fileExt,
+ model_path.extension(),
" is supported and the model is correct.",
" Available frontends: ",
FEs);
diff --git a/src/inference/src/model_reader.hpp b/src/inference/src/model_reader.hpp
index e8d377e1c59..19538ba924a 100644
--- a/src/inference/src/model_reader.hpp
+++ b/src/inference/src/model_reader.hpp
@@ -17,15 +17,15 @@ namespace util {
/**
* @brief Reads model
- * @param modelPath path to Model file
- * @param binPath optional path for model weights. If empty for IR we will find bin file with the model name.
+ * @param model_path path to Model file
+ * @param bin_path optional path for model weights. If empty for IR we will find bin file with the model name.
* if bin file with the same name was not found, will load IR without weights.
* @param extensions vector with OpenVINO extensions
* @param enable_mmap boolean to enable/disable `mmap` use in Frontend
* @return Shared pointer to ov::Model
*/
-std::shared_ptr<ov::Model> read_model(const std::string& modelPath,
- const std::string& binPath,
+std::shared_ptr<ov::Model> read_model(const std::filesystem::path& model_path,
+ const std::filesystem::path& bin_path,
const std::vector<ov::Extension::Ptr>& extensions,
bool enable_mmap);
diff --git a/src/inference/tests/functional/ov_core_test.cpp b/src/inference/tests/functional/ov_core_test.cpp
index f361dd788aa..1112b2ee59b 100644
--- a/src/inference/tests/functional/ov_core_test.cpp
+++ b/src/inference/tests/functional/ov_core_test.cpp
@@ -239,4 +239,29 @@ TEST_F(CoreBaseTest, compile_model_with_std_fs_path) {
}
#endif
}
+
+TEST_P(UnicodePathTest, core_compile_model) {
+ const std::string model_name = "test-model";
+ const auto prefix_dir = utils::generateTestFilePrefix();
+ const auto test_dir = std::filesystem::path(prefix_dir) / fs_path_from_variant();
+
+ const auto model_path = test_dir / std::filesystem::path(model_name + ".xml");
+ const auto weight_path = test_dir / std::filesystem::path(model_name + ".bin");
+ ov::test::utils::generate_test_model(model_path, weight_path);
+
+ ov::Core core;
+ {
+ const auto model = core.compile_model(model_path);
+ EXPECT_TRUE(model);
+ }
+ {
+ const auto devices = core.get_available_devices();
+
+ const auto model = core.compile_model(model_path, devices.at(0), ov::AnyMap{});
+ EXPECT_TRUE(model);
+ }
+
+ std::filesystem::remove_all(prefix_dir);
+}
+
} // namespace ov::test
diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp
index d3b9e89ff87..2ab231ef832 100644
--- a/src/plugins/auto/src/auto_schedule.cpp
+++ b/src/plugins/auto/src/auto_schedule.cpp
@@ -323,8 +323,9 @@ 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(m_context->m_model_path, device, device_config);
+ context.m_compiled_model = m_context->m_ov_core->compile_model(ov::util::make_path(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/cumulative_schedule.cpp b/src/plugins/auto/src/cumulative_schedule.cpp
index 6c16ead49a4..6644322a83c 100644
--- a/src/plugins/auto/src/cumulative_schedule.cpp
+++ b/src/plugins/auto/src/cumulative_schedule.cpp
@@ -6,6 +6,7 @@
#include "cumulative_schedule.hpp"
#include "async_infer_request.hpp"
#include "plugin.hpp"
+#include "openvino/util/file_util.hpp"
// ------------------------------CumuSchedule----------------------------
namespace ov {
@@ -192,7 +193,9 @@ 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(m_context->m_model_path, device, device_config);
+ context.m_compiled_model = m_context->m_ov_core->compile_model(ov::util::make_path(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/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp
index 9a1d8af766b..419cd6dac73 100644
--- a/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp
+++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/unicode_utils.hpp
@@ -164,3 +164,11 @@ extern const std::vector<std::wstring> test_unicode_postfix_vector;
} // namespace test
} // namespace ov
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
+
+namespace ov::test {
+class UnicodePathTest : public testing::Test, public ::testing::WithParamInterface<utils::StringPathVariant> {
+protected:
+ std::filesystem::path get_path_param() const;
+ std::filesystem::path fs_path_from_variant() const;
+};
+} // namespace ov::test
diff --git a/src/tests/test_utils/common_test_utils/src/unicode_utils.cpp b/src/tests/test_utils/common_test_utils/src/unicode_utils.cpp
index 1ee127e2dec..b89222bc391 100644
--- a/src/tests/test_utils/common_test_utils/src/unicode_utils.cpp
+++ b/src/tests/test_utils/common_test_utils/src/unicode_utils.cpp
@@ -24,3 +24,48 @@ const std::vector<std::wstring> test_unicode_postfix_vector = {L"unicode_Яㅎ
} // namespace ov
#endif // OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
+
+namespace ov::test {
+
+std::filesystem::path UnicodePathTest::get_path_param() const {
+ return std::visit(
+ [](const auto& p) {
+ // Use OV util to hide some platform details with path creation
+ return ov::util::make_path(p);
+ },
+ GetParam());
+}
+std::filesystem::path UnicodePathTest::fs_path_from_variant() const {
+ return std::visit(
+ [](const auto& p) {
+ return std::filesystem::path(p);
+ },
+ GetParam());
+}
+
+INSTANTIATE_TEST_SUITE_P(string_paths,
+ UnicodePathTest,
+ testing::Values("test_encoder/test_encoder.encrypted/",
+ "test_encoder/test_encoder.encrypted"));
+
+INSTANTIATE_TEST_SUITE_P(u16_paths,
+ UnicodePathTest,
+ testing::Values(u"test_encoder/dot.folder", u"test_encoder/dot.folder/"));
+
+INSTANTIATE_TEST_SUITE_P(u32_paths,
+ UnicodePathTest,
+ testing::Values(U"test_encoder/dot.folder", U"test_encoder/dot.folder/"));
+
+INSTANTIATE_TEST_SUITE_P(wstring_paths,
+ UnicodePathTest,
+ testing::Values(L"test_encoder/test_encoder.encrypted",
+ L"test_encoder/test_encoder.encrypted/"));
+
+#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
+INSTANTIATE_TEST_SUITE_P(
+ unicode_paths,
+ UnicodePathTest,
+ testing::Values("这是.folder", L"这是_folder", L"这是_folder/", u"这是_folder/", U"这是_folder/"));
+#endif
+
+} // namespace ov::test
diff --git a/src/tests/test_utils/common_test_utils/tests/file_util_test.cpp b/src/tests/test_utils/common_test_utils/tests/file_util_test.cpp
index c4585c2cf9f..c2031475ec7 100644
--- a/src/tests/test_utils/common_test_utils/tests/file_util_test.cpp
+++ b/src/tests/test_utils/common_test_utils/tests/file_util_test.cpp
@@ -13,6 +13,7 @@
#include "common_test_utils/common_utils.hpp"
#include "common_test_utils/file_utils.hpp"
+#include "common_test_utils/unicode_utils.hpp"
#include "openvino/core/visibility.hpp"
#include "openvino/util/file_util.hpp"
@@ -635,43 +636,7 @@ TEST_F(FileUtilTest, androidWithCutFileSizeTest) {
}
#endif
-class FileUtilTestP : public FileUtilTest, public ::testing::WithParamInterface<utils::StringPathVariant> {
-protected:
- std::filesystem::path get_path_param() const {
- return std::visit(
- [](const auto& p) {
- // Use OV util to hide some platform details with path creation
- return ov::util::make_path(p);
- },
- GetParam());
- }
-};
-
-INSTANTIATE_TEST_SUITE_P(string_paths,
- FileUtilTestP,
- testing::Values("test_encoder/test_encoder.encrypted/",
- "test_encoder/test_encoder.encrypted"));
-INSTANTIATE_TEST_SUITE_P(u16_paths,
- FileUtilTestP,
- testing::Values(u"test_encoder/dot.folder", u"test_encoder/dot.folder/"));
-
-INSTANTIATE_TEST_SUITE_P(u32_paths,
- FileUtilTestP,
- testing::Values(U"test_encoder/dot.folder", U"test_encoder/dot.folder/"));
-
-INSTANTIATE_TEST_SUITE_P(wstring_paths,
- FileUtilTestP,
- testing::Values(L"test_encoder/test_encoder.encrypted",
- L"test_encoder/test_encoder.encrypted/"));
-
-#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
-INSTANTIATE_TEST_SUITE_P(
- unicode_paths,
- FileUtilTestP,
- testing::Values("这是.folder", L"这是_folder", L"这是_folder/", u"这是_folder/", U"这是_folder/"));
-#endif
-
-TEST_P(FileUtilTestP, create_directories) {
+TEST_P(UnicodePathTest, create_directories) {
const auto test_dir = utils::generateTestFilePrefix();
const auto path = std::filesystem::path(test_dir) / get_path_param();
const auto exp_path = std::filesystem::path(test_dir) / utils::to_fs_path(GetParam());
diff --git a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp
index 1cc1b81f508..9c1967fa12b 100644
--- a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp
+++ b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_icore.hpp
@@ -44,7 +44,7 @@ public:
(const));
MOCK_METHOD(ov::SoPtr<ov::ICompiledModel>,
compile_model,
- (const std::string&, const std::string&, const ov::AnyMap&),
+ (const std::filesystem::path&, const std::string&, const ov::AnyMap&),
(const));
MOCK_METHOD(ov::SoPtr<ov::ICompiledModel>,
compile_model,