From 5d734d2afe8407eae59fef512a4901029a66e2c7 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 12:14:23 +0000 Subject: [PATCH 01/53] path_join migration sdt --- src/common/util/CMakeLists.txt | 4 +++- .../util/include/openvino/util/file_path.hpp | 23 +++++++++++++++++++ .../util/include/openvino/util/file_util.hpp | 8 ++++++- src/common/util/src/file_util.cpp | 8 +++++-- src/core/tests/check.cpp | 2 +- 5 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/common/util/include/openvino/util/file_path.hpp diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 6b5cf4b7a64192..4a86205e518372 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -37,7 +37,9 @@ add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) add_library(openvino::util ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME util) -target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml) +# TODO: make lib linkage portable e.g.: openvino/src/bindings/python/thirdparty/pybind11/tests/CMakeLists.txt +target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml stdc++fs ) +set(STD_FS_LIB stdc++fs) if (WIN32) target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi) endif() diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp new file mode 100644 index 00000000000000..5e7fce595709df --- /dev/null +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +namespace ov { +namespace util { + +namespace fs = std::experimental::filesystem; +using Path = fs::path; + + +auto File = [](std::FILE* file) { + auto deleter = [](std::FILE* file){ std::fclose(file); }; + return std::unique_ptr { file, deleter }; +}; + +} // namespace util +} // namespace ov diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 88b9110abeced8..68a8801fc41876 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -11,6 +11,8 @@ #include #include "openvino/util/util.hpp" +#include "openvino/util/file_path.hpp" + namespace ov { namespace util { @@ -255,9 +257,13 @@ inline bool file_exists(const std::string& path) { return file_exists(path.c_str()); } +inline bool file_exists(const ov::util::Path& path) { + return ov::util::fs::exists(path); +} + std::string get_file_ext(const std::string& path); std::string get_directory(const std::string& path); -std::string path_join(const std::vector& paths); +ov::util::Path path_join(const std::vector& paths); void iterate_files(const std::string& path, const std::function& func, diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index c9bf331bbfe6d3..cc65103517c702 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -172,10 +172,14 @@ std::wstring join_paths(const std::wstring& s1, const std::wstring& s2) { return rc; } #endif + +ov::util::Path join_paths(const ov::util::Path& s1, const ov::util::Path& s2) { + return s1 / s2; +} } // namespace -std::string ov::util::path_join(const std::vector& paths) { - std::string result; +ov::util::Path ov::util::path_join(const std::vector& paths) { + ov::util::Path result{}; if (paths.empty()) { return result; } diff --git a/src/core/tests/check.cpp b/src/core/tests/check.cpp index 5c4979da3cdfe7..2ef888cba49b66 100644 --- a/src/core/tests/check.cpp +++ b/src/core/tests/check.cpp @@ -55,7 +55,7 @@ TEST(check, ov_throw_exception_check_relative_path_to_source) { } using namespace testing; const auto path = ov::util::path_join({"src", "core", "tests", "check.cpp"}); - const auto exp_native_slash = "Exception from " + path + ":"; + const auto exp_native_slash = "Exception from " + path.native() + ":"; const auto exp_fwd_slash = "Exception from src/core/tests/check.cpp:"; OV_EXPECT_THROW(OPENVINO_THROW("Test message"), ov::Exception, From 8ade84b533ea639a76217c5e6612eb0a7d33d238 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 12:17:08 +0000 Subject: [PATCH 02/53] test LoadModelMemoryToCore use file descriptor wrapper --- .../paddle/tests/read_paddle_model_test.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/frontends/paddle/tests/read_paddle_model_test.cpp b/src/frontends/paddle/tests/read_paddle_model_test.cpp index 31c524d44b4ab1..7b4b1dd317259b 100644 --- a/src/frontends/paddle/tests/read_paddle_model_test.cpp +++ b/src/frontends/paddle/tests/read_paddle_model_test.cpp @@ -24,17 +24,16 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) { "conv2d_relu/conv2d_relu.pdiparams"); ov::Core core; - auto read_file = [&](const std::string& file_name, size_t& size) { - FILE* sFile = fopen(file_name.c_str(), "r"); - fseek(sFile, 0, SEEK_END); - size = ftell(sFile); + auto read_file = [&](const ov::util::Path& file_name, size_t& size) { + auto sFile = ov::util::File(fopen(file_name.c_str(), "r")); + fseek(sFile.get(), 0, SEEK_END); + size = ftell(sFile.get()); uint8_t* ss = (uint8_t*)malloc(size); - rewind(sFile); - const size_t length = fread(&ss[0], 1, size, sFile); + rewind(sFile.get()); + const size_t length = fread(&ss[0], 1, size, sFile.get()); if (size != length) { std::cerr << "file size is not correct\n"; } - fclose(sFile); return ss; }; From 4a8e27e6d3f0c8fd751cc902c6170947848fd7a6 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 13:56:31 +0000 Subject: [PATCH 03/53] file_util migrate: path_to_string, get_file_name, get_file_ext, iterate_files, join_paths --- .../util/include/openvino/util/file_util.hpp | 13 ++- src/common/util/src/file_util.cpp | 94 +++---------------- 2 files changed, 21 insertions(+), 86 deletions(-) diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 68a8801fc41876..1d7314384c346a 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -89,6 +89,11 @@ template ::type, ov::util::Path>::value>::type* = nullptr> +std::string path_to_string(const Path& path) { + return path.string(); +} #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** @@ -124,7 +129,7 @@ std::string sanitize_path(const std::string& path); /// \brief Returns the name with extension for a given path /// \param path The path to the output file -std::string get_file_name(const std::string& path); +ov::util::Path get_file_name(const ov::util::Path& path); /** * @brief Interface function to get absolute path of file @@ -261,12 +266,12 @@ inline bool file_exists(const ov::util::Path& path) { return ov::util::fs::exists(path); } -std::string get_file_ext(const std::string& path); +ov::util::Path get_file_ext(const ov::util::Path& path); std::string get_directory(const std::string& path); ov::util::Path path_join(const std::vector& paths); -void iterate_files(const std::string& path, - const std::function& func, +void iterate_files(const ov::util::Path& path, + const std::function& func, bool recurse = false, bool include_links = false); diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index cc65103517c702..12664e4bc4470c 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -64,31 +64,12 @@ # endif #endif -std::string ov::util::get_file_name(const std::string& s) { - std::string rc = s; - // Linux-style separator - auto pos = s.find_last_of('/'); - if (pos != std::string::npos) { - rc = s.substr(pos + 1); - return rc; - } - // Windows-style separator - pos = s.find_last_of('\\'); - if (pos != std::string::npos) { - rc = s.substr(pos + 1); - } - return rc; +ov::util::Path ov::util::get_file_name(const ov::util::Path& s) { + return s.filename(); } -std::string ov::util::get_file_ext(const std::string& s) { - std::string rc = get_file_name(s); - auto pos = rc.find_last_of('.'); - if (pos != std::string::npos) { - rc = rc.substr(pos); - } else { - rc = ""; - } - return rc; +ov::util::Path ov::util::get_file_ext(const ov::util::Path& s) { + return s.extension(); } std::string ov::util::get_directory(const std::string& s) { @@ -122,57 +103,6 @@ std::wstring ov::util::get_directory(const std::wstring& s) { #endif namespace { - -std::string join_paths(const std::string& s1, const std::string& s2) { - std::string rc; - if (s2.size() > 0) { - if (s2[0] == '/') { - rc = s2; - } else if (s1.size() > 0) { - rc = s1; - if (rc[rc.size() - 1] != '/') { -#ifndef _WIN32 - rc += '/'; -#else - rc += '\\'; -#endif - } - rc += s2; - } else { - rc = s2; - } - } else { - rc = s1; - } - return rc; -} - -#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT -std::wstring join_paths(const std::wstring& s1, const std::wstring& s2) { - std::wstring rc; - if (s2.size() > 0) { - if (s2[0] == '/') { - rc = s2; - } else if (s1.size() > 0) { - rc = s1; - if (rc[rc.size() - 1] != '/') { -# ifndef _WIN32 - rc += '/'; -# else - rc += '\\'; -# endif - } - rc += s2; - } else { - rc = s2; - } - } else { - rc = s1; - } - return rc; -} -#endif - ov::util::Path join_paths(const ov::util::Path& s1, const ov::util::Path& s2) { return s1 / s2; } @@ -198,7 +128,7 @@ std::wstring ov::util::path_join_w(const std::vector& paths) { } result = paths[0]; for (size_t i = 1; i < paths.size(); i++) { - result = join_paths(result, paths[i]); + result = join_paths(result, paths[i]).wstring(); } return result; } @@ -253,12 +183,12 @@ static void iterate_files_worker(const std::string& path, } #endif -void ov::util::iterate_files(const std::string& path, - const std::function& func, +void ov::util::iterate_files(const ov::util::Path& path, + const std::function& func, bool recurse, bool include_links) { - std::vector files; - std::vector dirs; + std::vector files; + std::vector dirs; #ifdef _WIN32 # ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT std::wstring pathw = string_to_wstring(path); @@ -311,7 +241,7 @@ void ov::util::iterate_files(const std::string& path, #else iterate_files_worker( path, - [&files, &dirs](const std::string& file, bool is_dir) { + [&files, &dirs](const ov::util::Path& file, bool is_dir) { if (is_dir) { dirs.push_back(file); } else { @@ -323,10 +253,10 @@ void ov::util::iterate_files(const std::string& path, #endif for (const auto& f : files) { - func(f, false); + func(f.native(), false); } for (const auto& f : dirs) { - func(f, true); + func(f.native(), true); } } From 3d6e049075b8200d087c0b80720ba45bb89c1d75 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:03:39 +0000 Subject: [PATCH 04/53] imporove tmp_path_item initialization --- .../op_conformance_runner/include/utils/models.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index 03609515f684ef..bc8de3caaed8f4 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -62,11 +62,9 @@ get_model_paths(const std::vector& conformance_ir_paths, } #endif for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val, ov::test::utils::FileSeparator)) { - auto tmp_path_item = path_item; - auto pos = tmp_path_item.find('-'); - if (pos != std::string::npos) { - tmp_path_item = tmp_path_item.substr(0, pos); - } + auto pos = path_item.find('-'); + auto tmp_path_item = pos == std::string::npos ? path_item : path_item.substr(0, pos); + if (op_filelist.find(tmp_path_item) != op_filelist.end()) { op_filelist[tmp_path_item].push_back({val, get_ref_path(val)}); is_op = true; From 3debdc0aff011ab5eeee307af870b66f70595298 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:05:59 +0000 Subject: [PATCH 05/53] CheckpointV1Reader migrate std::path --- .../tensorflow/src/checkpoint_v1_reader.cpp | 12 +++++------- .../tensorflow/src/checkpoint_v1_reader.hpp | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp b/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp index d506759fd33716..fa5f8b2a2d78b6 100644 --- a/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp +++ b/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp @@ -6,7 +6,6 @@ #include "checkpoint_utils.hpp" #include "openvino/frontend/exception.hpp" -#include "openvino/util/file_util.hpp" #include "ov_tensorflow/saved_tensor_slice.pb.h" #include "tf_utils.hpp" @@ -17,13 +16,12 @@ using namespace ov::frontend::tensorflow; namespace { -std::vector list_files_in_dir(const std::string& directory_path) { - std::vector res; +std::vector list_files_in_dir(const ov::util::Path& directory_path) { + std::vector res; try { ov::util::iterate_files( directory_path, - [&res](const std::string& file_path, bool is_dir) { - auto file = ov::util::get_file_name(file_path); + [&res](const ov::util::Path& file_path, bool is_dir) { if (!is_dir) { res.push_back(file_path); } @@ -41,7 +39,7 @@ CheckpointV1Reader::CheckpointV1Reader(const std::string& checkpoints) : m_check void CheckpointV1Reader::initialize() { // figure out if the input is a file or a directory of checkpoints - std::vector checkpoints_paths; + std::vector checkpoints_paths; if (ov::util::directory_exists(m_checkpoints)) { checkpoints_paths = list_files_in_dir(m_checkpoints); } else if (ov::util::file_exists(m_checkpoints)) { @@ -58,7 +56,7 @@ void CheckpointV1Reader::initialize() { std::make_shared(checkpoint_path, std::ifstream::in | std::ifstream::binary); FRONT_END_GENERAL_CHECK( shard_stream && shard_stream->is_open(), - "[TensorFlow Frontend] incorrect model: checkpoint file " + checkpoint_path + "does not exist"); + "[TensorFlow Frontend] incorrect model: checkpoint file " + checkpoint_path.native() + "does not exist"); const int32_t shard_ind = static_cast(m_shards.size()); m_shards.push_back(shard_stream); m_shard_names.push_back(checkpoint_path); diff --git a/src/frontends/tensorflow/src/checkpoint_v1_reader.hpp b/src/frontends/tensorflow/src/checkpoint_v1_reader.hpp index 944930a5bbfdf6..dbf5de3bf63946 100644 --- a/src/frontends/tensorflow/src/checkpoint_v1_reader.hpp +++ b/src/frontends/tensorflow/src/checkpoint_v1_reader.hpp @@ -12,6 +12,7 @@ #include "checkpoint_utils.hpp" #include "openvino/core/any.hpp" #include "openvino/frontend/exception.hpp" +#include "openvino/util/file_util.hpp" #include "ov_tensorflow/saved_tensor_slice.pb.h" #include "ov_tensorflow/tensor_shape.pb.h" #include "ov_tensorflow/types.pb.h" @@ -33,7 +34,7 @@ struct VariableInfo { // reads checkpoints of v1 version // it parses value, shape and type for Variable nodes class CheckpointV1Reader { - const std::string m_checkpoints; + const ov::util::Path m_checkpoints; // a map from Variable name to its informations std::unordered_map m_variables_info_map; // a vector of streams for shards, where shard is one checkpoint file From 9b6be8d24b1a8ccdaaeb805342f130bfa3866b2d Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:08:09 +0000 Subject: [PATCH 06/53] plugin_loader: get_name_from_file, find_plugins migration to std path --- src/frontends/common/src/plugin_loader.cpp | 34 +++++++++++----------- src/frontends/common/src/plugin_loader.hpp | 8 ++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/frontends/common/src/plugin_loader.cpp b/src/frontends/common/src/plugin_loader.cpp index 16eb5705e5f69c..40fe887e851706 100644 --- a/src/frontends/common/src/plugin_loader.cpp +++ b/src/frontends/common/src/plugin_loader.cpp @@ -76,19 +76,18 @@ void load_static_plugins(std::vector& res) { #endif // OPENVINO_STATIC_LIBRARY -// TODO: change to std::filesystem for C++17 -static std::vector list_files(const std::string& path) { - std::vector res; +static std::vector list_files(const ov::util::Path& path) { + std::vector res{}; try { - const auto prefix = std::string(FRONTEND_LIB_PREFIX); - const auto suffix = std::string(FRONTEND_LIB_SUFFIX); + const auto prefix = ov::util::Path{FRONTEND_LIB_PREFIX}; + const auto suffix = ov::util::Path{FRONTEND_LIB_SUFFIX}; ov::util::iterate_files( path, - [&res, &prefix, &suffix](const std::string& file_path, bool is_dir) { + [&res, &prefix, &suffix](const ov::util::Path& file_path, bool is_dir) { auto file = ov::util::get_file_name(file_path); - if (!is_dir && (prefix.empty() || file.compare(0, prefix.length(), prefix) == 0) && - file.length() > suffix.length() && - file.rfind(suffix) == (file.length() - std::string(suffix).length())) { + if (!is_dir && (prefix.empty() || file.native().compare(0, prefix.native().length(), prefix) == 0) && + file.native().length() > suffix.native().length() && + file.native().rfind(suffix) == (file.native().length() - suffix.native().length())) { res.push_back(file_path); } }, @@ -100,7 +99,7 @@ static std::vector list_files(const std::string& path) { return res; } -void ov::frontend::find_plugins(const std::string& dir_name, std::vector& res) { +void ov::frontend::find_plugins(const ov::util::Path& dir_name, std::vector& res) { #ifdef OPENVINO_STATIC_LIBRARY load_static_plugins(res); #endif // OPENVINO_STATIC_LIBRARY @@ -120,13 +119,14 @@ void ov::frontend::find_plugins(const std::string& dir_name, std::vector& res); +void find_plugins(const ov::util::Path& dir_name, std::vector& res); } // namespace frontend } // namespace ov From 03d02b220b73746ad3103fb55019092b3d9a2293 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:08:57 +0000 Subject: [PATCH 07/53] get_filelist_recursive, read_lst_file migration to std path --- .../op_conformance_utils/utils/file.hpp | 10 ++++--- .../op_conformance_utils/src/utils/file.cpp | 30 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/tests/functional/plugin/conformance/op_conformance_utils/include/op_conformance_utils/utils/file.hpp b/src/tests/functional/plugin/conformance/op_conformance_utils/include/op_conformance_utils/utils/file.hpp index 40a70655e8a67f..228dc0edb19b60 100644 --- a/src/tests/functional/plugin/conformance/op_conformance_utils/include/op_conformance_utils/utils/file.hpp +++ b/src/tests/functional/plugin/conformance/op_conformance_utils/include/op_conformance_utils/utils/file.hpp @@ -8,15 +8,17 @@ #include #include +#include "openvino/util/file_util.hpp" + namespace ov { namespace util { -std::vector -get_filelist_recursive(const std::vector& dir_paths, +std::vector +get_filelist_recursive(const std::vector& dir_paths, const std::vector& patterns); -std::vector -read_lst_file(const std::vector& file_paths, +std::vector +read_lst_file(const std::vector& file_paths, const std::vector& patterns = {std::regex(".*")}); std::string replace_extension(std::string file, const std::string& new_extension); diff --git a/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp b/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp index a3595e00ed972b..e45428ef650d02 100644 --- a/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp +++ b/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp @@ -7,27 +7,24 @@ #include #include -#include "openvino/util/file_util.hpp" - namespace ov { namespace util { -std::vector -get_filelist_recursive(const std::vector& dir_paths, +std::vector +get_filelist_recursive(const std::vector& dir_paths, const std::vector& patterns) { - std::vector result; + std::vector result; for (auto&& dir_path : dir_paths) { if (!ov::util::directory_exists(dir_path)) { - std::string msg = "Input directory (" + dir_path + ") doesn't not exist!"; + std::string msg = "Input directory (" + dir_path.native() + ") doesn't not exist!"; throw std::runtime_error(msg); } ov::util::iterate_files( dir_path, - [&result, &patterns](const std::string& file_path, bool is_dir) { - auto file = ov::util::get_file_name(file_path); + [&result, &patterns](const ov::util::Path& file_path, bool is_dir) { if (ov::util::file_exists(file_path)) { for (const auto& pattern : patterns) { - if (std::regex_match(file_path, pattern)) { + if (std::regex_match(file_path.c_str(), pattern)) { result.push_back(file_path); break; } @@ -40,13 +37,13 @@ get_filelist_recursive(const std::vector& dir_paths, return result; } -std::vector -read_lst_file(const std::vector& file_paths, +std::vector +read_lst_file(const std::vector& file_paths, const std::vector& patterns) { - std::vector res; + std::vector res; for (const auto& file_path : file_paths) { if (!ov::util::file_exists(file_path)) { - std::string msg = "Input directory (" + file_path + ") doesn't not exist!"; + std::string msg = "Input directory (" + file_path.native() + ") doesn't not exist!"; throw std::runtime_error(msg); } std::ifstream file(file_path); @@ -55,7 +52,7 @@ read_lst_file(const std::vector& file_paths, while (getline(file, buffer)) { if (buffer.find("#") == std::string::npos && !buffer.empty()) { for (const auto& pattern : patterns) { - if (std::regex_match(file_path, pattern)) { + if (std::regex_match(file_path.native(), pattern)) { res.emplace_back(buffer); break; } @@ -63,10 +60,9 @@ read_lst_file(const std::vector& file_paths, } } } else { - std::string msg = "Error in opening file: " + file_path; + std::string msg = "Error in opening file: " + file_path.native(); throw std::runtime_error(msg); } - file.close(); } return res; } @@ -96,4 +92,4 @@ split_str(std::string paths, const char delimiter) { } } // namespace util -} // namespace ov \ No newline at end of file +} // namespace ov From 0198ed7201701abb6c39720971b3d3f3bf525782 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:10:03 +0000 Subject: [PATCH 08/53] cache, models fix --- .../plugin/conformance/subgraphs_dumper/src/utils/cache.cpp | 4 ++-- .../op_conformance_runner/include/utils/models.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp index e10579dcae8143..93b4877860735e 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp @@ -30,7 +30,7 @@ std::pair, std::pair &dirs, const std::string& regexp) { std::vector models, full_content, not_read_model; for (const auto& dir : dirs) { - std::vector dir_content; + std::vector dir_content; if (ov::util::directory_exists(dir)) { dir_content = ov::util::get_filelist_recursive({dir}, FROTEND_REGEXP); } else if (ov::util::file_exists(dir) && std::regex_match(dir, std::regex(".*" + std::string(LST_EXTENSION)))) { @@ -119,4 +119,4 @@ std::map> cache_models( } } // namespace util -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index bc8de3caaed8f4..42f021987fa96b 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -44,7 +44,7 @@ get_model_paths(const std::vector& conformance_ir_paths, std::vector filelist; // Looking for any applicable files in a folders for (const auto& conformance_ir_path : conformance_ir_paths) { - std::vector tmp_buf; + std::vector tmp_buf; if (ov::util::directory_exists(conformance_ir_path)) { tmp_buf = ov::util::get_filelist_recursive({conformance_ir_path}, {std::regex(R"(.*\.xml)")}); } else if (ov::util::file_exists(conformance_ir_path)) { @@ -61,7 +61,7 @@ get_model_paths(const std::vector& conformance_ir_paths, val.replace(it, it + 1, ov::test::utils::FileSeparator); } #endif - for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val, ov::test::utils::FileSeparator)) { + for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val.native(), ov::test::utils::FileSeparator)) { auto pos = path_item.find('-'); auto tmp_path_item = pos == std::string::npos ? path_item : path_item.substr(0, pos); @@ -86,4 +86,4 @@ get_model_paths(const std::vector& conformance_ir_paths, } // namespace op_conformance } // namespace test -} // namespace ov \ No newline at end of file +} // namespace ov From 974743310c280ab188905b06604e77af889b5ed1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:23:26 +0000 Subject: [PATCH 09/53] directory_exists migration --- src/common/util/include/openvino/util/file_util.hpp | 2 +- src/common/util/src/file_util.cpp | 9 ++------- .../op_conformance_runner/include/utils/models.hpp | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 1d7314384c346a..051ea7212177b0 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -168,7 +168,7 @@ void create_directory_recursive(const std::wstring& path); * @param path - path to directory * @return true if directory exists, false otherwise */ -bool directory_exists(const std::string& path); +bool directory_exists(const ov::util::Path& path); #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT /** diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index 12664e4bc4470c..d21730b6166f3b 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -377,13 +377,8 @@ void ov::util::create_directory_recursive(const std::string& path) { } } -bool ov::util::directory_exists(const std::string& path) { - struct stat sb; - - if (stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) { - return true; - } - return false; +bool ov::util::directory_exists(const ov::util::Path& path) { + return ov::util::fs::is_directory(path); } #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index 42f021987fa96b..d8b56099e4fed9 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -31,7 +31,7 @@ inline std::string get_ref_path(const std::string& model_path) { // vector inline std::vector> -get_model_paths(const std::vector& conformance_ir_paths, +get_model_paths(const std::vector& conformance_ir_paths, const std::string& operation_name = "undefined") { // This is required to prevent re-scan folders each call in case there is nothing found // {{ op_name, {irs} }} From 44a00be92cbd9e2091a89133a6076ab288af3966 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 14:45:52 +0000 Subject: [PATCH 10/53] revert conformance_ir_paths migration --- .../test_runner/op_conformance_runner/include/utils/models.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index d8b56099e4fed9..42f021987fa96b 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -31,7 +31,7 @@ inline std::string get_ref_path(const std::string& model_path) { // vector inline std::vector> -get_model_paths(const std::vector& conformance_ir_paths, +get_model_paths(const std::vector& conformance_ir_paths, const std::string& operation_name = "undefined") { // This is required to prevent re-scan folders each call in case there is nothing found // {{ op_name, {irs} }} From 6ba6ba0a6022ef4ea3b3f465b790ae6ef221f5c2 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 13 Sep 2024 15:22:28 +0000 Subject: [PATCH 11/53] code format --- src/common/util/include/openvino/util/file_path.hpp | 8 +++++--- src/common/util/include/openvino/util/file_util.hpp | 8 ++++---- src/frontends/common/src/plugin_loader.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 5e7fce595709df..2ba639f0e8874a 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -4,8 +4,8 @@ #pragma once -#include #include +#include namespace ov { namespace util { @@ -15,8 +15,10 @@ using Path = fs::path; auto File = [](std::FILE* file) { - auto deleter = [](std::FILE* file){ std::fclose(file); }; - return std::unique_ptr { file, deleter }; + auto deleter = [](std::FILE* file) { + std::fclose(file); + }; + return std::unique_ptr{file, deleter}; }; } // namespace util diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index 051ea7212177b0..a0298c8b1d3522 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -10,9 +10,8 @@ #include #include -#include "openvino/util/util.hpp" #include "openvino/util/file_path.hpp" - +#include "openvino/util/util.hpp" namespace ov { namespace util { @@ -89,8 +88,9 @@ template ::type, ov::util::Path>::value>::type* = nullptr> +template < + class Path, + typename std::enable_if::type, ov::util::Path>::value>::type* = nullptr> std::string path_to_string(const Path& path) { return path.string(); } diff --git a/src/frontends/common/src/plugin_loader.cpp b/src/frontends/common/src/plugin_loader.cpp index 40fe887e851706..70b263344579c9 100644 --- a/src/frontends/common/src/plugin_loader.cpp +++ b/src/frontends/common/src/plugin_loader.cpp @@ -79,8 +79,8 @@ void load_static_plugins(std::vector& res) { static std::vector list_files(const ov::util::Path& path) { std::vector res{}; try { - const auto prefix = ov::util::Path{FRONTEND_LIB_PREFIX}; - const auto suffix = ov::util::Path{FRONTEND_LIB_SUFFIX}; + const auto prefix = ov::util::Path{FRONTEND_LIB_PREFIX}; + const auto suffix = ov::util::Path{FRONTEND_LIB_SUFFIX}; ov::util::iterate_files( path, [&res, &prefix, &suffix](const ov::util::Path& file_path, bool is_dir) { @@ -120,8 +120,8 @@ void ov::frontend::find_plugins(const ov::util::Path& dir_name, std::vector Date: Mon, 16 Sep 2024 12:31:44 +0000 Subject: [PATCH 12/53] fix filesystem lib include --- src/common/util/CMakeLists.txt | 34 +++++++++++++++++-- .../util/include/openvino/util/file_path.hpp | 5 +-- .../include/openvino/util/ov_filesystem.hpp | 17 ++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/common/util/include/openvino/util/ov_filesystem.hpp diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 4a86205e518372..b0fa46d2fab1c4 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -37,9 +37,37 @@ add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${PUBLIC_HEADERS}) add_library(openvino::util ALIAS ${TARGET_NAME}) set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME util) -# TODO: make lib linkage portable e.g.: openvino/src/bindings/python/thirdparty/pybind11/tests/CMakeLists.txt -target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml stdc++fs ) -set(STD_FS_LIB stdc++fs) +file( + WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + "#include \nint main(int argc, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}" + ) + try_compile( + STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMPILE_DEFINITIONS -std=c++17) + try_compile( + STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMPILE_DEFINITIONS -std=c++17 + LINK_LIBRARIES stdc++fs) + try_compile( + STD_FS_NEEDS_CXXFS ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMPILE_DEFINITIONS -std=c++17 + LINK_LIBRARIES c++fs) + +if(${STD_FS_NEEDS_STDCXXFS}) + set(STD_FS_LIB stdc++fs) +elseif(${STD_FS_NEEDS_CXXFS}) + set(STD_FS_LIB c++fs) +elseif(${STD_FS_NO_LIB_NEEDED}) + set(STD_FS_LIB "") +else() + message(WARNING "Unknown C++17 compiler - not passing -lstdc++fs") + set(STD_FS_LIB "") +endif() + +target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml ${STD_FS_LIB} ) if (WIN32) target_link_libraries(${TARGET_NAME} PRIVATE Shlwapi) endif() diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 2ba639f0e8874a..75279865976f1e 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -4,13 +4,14 @@ #pragma once -#include #include +#include "ov_filesystem.hpp" + namespace ov { namespace util { -namespace fs = std::experimental::filesystem; +namespace fs = std_fs; using Path = fs::path; diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp new file mode 100644 index 00000000000000..94dab4fd6fffda --- /dev/null +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2024 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) +# if (__cplusplus <= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG <= 201703L) && (_MSC_VER <= 1913)) +# if __has_include() +# include +namespace std_fs = std::experimental::filesystem; +# endif +# elif __has_include() +# include +namespace std_fs = std::filesystem; +# endif +#endif From 5ebddf6d2ed7dbad1e23cd45114aba17ea3c1f84 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 16 Sep 2024 12:57:25 +0000 Subject: [PATCH 13/53] define include variables --- src/common/util/include/openvino/util/ov_filesystem.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 94dab4fd6fffda..583c2feca37789 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -8,10 +8,14 @@ # if (__cplusplus <= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG <= 201703L) && (_MSC_VER <= 1913)) # if __has_include() # include +# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM namespace std_fs = std::experimental::filesystem; # endif # elif __has_include() # include namespace std_fs = std::filesystem; +# else +# error "No std filesystem lib avaliable!" # endif #endif From 17e73274e1a0780546ac2ba3b231bd10e181ea52 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 16 Sep 2024 13:24:07 +0000 Subject: [PATCH 14/53] File factory as a function --- src/common/util/include/openvino/util/file_path.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 75279865976f1e..f93cbb2ae30b15 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -15,12 +15,13 @@ namespace fs = std_fs; using Path = fs::path; -auto File = [](std::FILE* file) { - auto deleter = [](std::FILE* file) { - std::fclose(file); - }; - return std::unique_ptr{file, deleter}; +auto deleter = [](std::FILE* file) { + std::fclose(file); }; +std::unique_ptr File(std::FILE* file){ + return {file, deleter}; +} + } // namespace util } // namespace ov From 771ff7ac879a3a520b21ce9dc76877bdfd6ea2e9 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Tue, 17 Sep 2024 16:17:23 +0000 Subject: [PATCH 15/53] update ov_filesystem include --- src/common/util/include/openvino/util/file_path.hpp | 4 +++- src/common/util/src/file_util.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index f93cbb2ae30b15..2c6f6f98af0339 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -5,8 +5,10 @@ #pragma once #include +#include -#include "ov_filesystem.hpp" +#include "openvino/util/ov_filesystem.hpp" +//#include "openvino/util/util.hpp" namespace ov { namespace util { diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index d21730b6166f3b..9a214da9de5f7a 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -3,6 +3,7 @@ // #include "openvino/util/file_util.hpp" +#include "openvino/util/file_path.hpp" #include From ac9ad1630e5f9b4fc0a08c4838014e9c0fc65ad1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Tue, 17 Sep 2024 16:45:27 +0000 Subject: [PATCH 16/53] revert ov::util::File --- src/common/util/include/openvino/util/file_path.hpp | 13 ++++++------- .../paddle/tests/read_paddle_model_test.cpp | 11 ++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 2c6f6f98af0339..2b050a09200b79 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -16,14 +16,13 @@ namespace util { namespace fs = std_fs; using Path = fs::path; +// auto deleter = [](std::FILE* file) { +// std::fclose(file); +// }; -auto deleter = [](std::FILE* file) { - std::fclose(file); -}; - -std::unique_ptr File(std::FILE* file){ - return {file, deleter}; -} +// std::unique_ptr File(std::FILE* file){ +// return {file, deleter}; +// } } // namespace util } // namespace ov diff --git a/src/frontends/paddle/tests/read_paddle_model_test.cpp b/src/frontends/paddle/tests/read_paddle_model_test.cpp index 7b4b1dd317259b..830db6486b6d18 100644 --- a/src/frontends/paddle/tests/read_paddle_model_test.cpp +++ b/src/frontends/paddle/tests/read_paddle_model_test.cpp @@ -25,15 +25,16 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) { ov::Core core; auto read_file = [&](const ov::util::Path& file_name, size_t& size) { - auto sFile = ov::util::File(fopen(file_name.c_str(), "r")); - fseek(sFile.get(), 0, SEEK_END); - size = ftell(sFile.get()); + FILE* sFile = fopen(file_name.c_str(), "r"); + fseek(sFile, 0, SEEK_END); + size = ftell(sFile); uint8_t* ss = (uint8_t*)malloc(size); - rewind(sFile.get()); - const size_t length = fread(&ss[0], 1, size, sFile.get()); + rewind(sFile); + const size_t length = fread(&ss[0], 1, size, sFile); if (size != length) { std::cerr << "file size is not correct\n"; } + fclose(sFile); return ss; }; From 9abb3f24e83061a2f587a5970ad2dc233f194ffe Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 19 Sep 2024 10:05:57 +0000 Subject: [PATCH 17/53] advanced experimental include --- .../include/openvino/util/ov_filesystem.hpp | 62 +++++++++++++++---- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 583c2feca37789..afa48916a11011 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -4,18 +4,54 @@ #pragma once -#if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) -# if (__cplusplus <= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG <= 201703L) && (_MSC_VER <= 1913)) -# if __has_include() -# include -# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -namespace std_fs = std::experimental::filesystem; -# endif -# elif __has_include() -# include -namespace std_fs = std::filesystem; -# else -# error "No std filesystem lib avaliable!" +#if !(defined(_MSC_VER) && __cplusplus == 199711L) +# if __cplusplus >= 201103L +# define CPP_VER_11 +# if __cplusplus >= 201402L +# define CPP_VER_14 +# if __cplusplus >= 201703L +# define CPP_VER_17 +# if __cplusplus >= 202002L +# define CPP_VER_20 +# endif +# endif +# endif +# endif +#elif defined(_MSC_VER) && __cplusplus == 199711L +# if _MSVC_LANG >= 201103L +# define CPP_VER_11 +# if _MSVC_LANG >= 201402L +# define CPP_VER_14 +# if _MSVC_LANG > 201402L +# define CPP_VER_17 +# if _MSVC_LANG >= 202002L +# define CPP_VER_20 +# endif +# endif +# endif +# endif +#endif + +#ifdef __has_include +# if defined(CPP_VER_17) && (__has_include()) && (!__has_include()) +# define HAS_FILESYSTEM 1 +# elif defined(CPP_VER_11) && (__has_include()) +# define HAS_EXP_FILESYSTEM 1 # endif +#elif defined(_MSC_VER) && defined(CPP_VER_17) +# define HAS_FILESYSTEM 1 +#elif defined(_MSC_VER) && defined(CPP_VER_11) +# define HAS_EXP_FILESYSTEM 1 +# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM +#endif + +#if !defined(HAS_FILESYSTEM) && !defined(HAS_EXP_FILESYSTEM) +# error "Neither #include nor #include is available." +#elif defined(HAS_FILESYSTEM) +#include +namespace std_fs = std::filesystem; +#elif defined(HAS_EXP_FILESYSTEM) +#include +namespace std_fs = std::experimental::filesystem; #endif From 3f3cd8beb0e8d4e895d3f5783174a59fd5a77795 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 19 Sep 2024 10:16:58 +0000 Subject: [PATCH 18/53] clang foramt --- .../include/openvino/util/ov_filesystem.hpp | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index afa48916a11011..31b079bea37dea 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -6,30 +6,30 @@ #if !(defined(_MSC_VER) && __cplusplus == 199711L) # if __cplusplus >= 201103L -# define CPP_VER_11 -# if __cplusplus >= 201402L -# define CPP_VER_14 -# if __cplusplus >= 201703L -# define CPP_VER_17 -# if __cplusplus >= 202002L -# define CPP_VER_20 -# endif -# endif -# endif +# define CPP_VER_11 +# if __cplusplus >= 201402L +# define CPP_VER_14 +# if __cplusplus >= 201703L +# define CPP_VER_17 +# if __cplusplus >= 202002L +# define CPP_VER_20 +# endif +# endif +# endif # endif #elif defined(_MSC_VER) && __cplusplus == 199711L -# if _MSVC_LANG >= 201103L -# define CPP_VER_11 -# if _MSVC_LANG >= 201402L -# define CPP_VER_14 -# if _MSVC_LANG > 201402L -# define CPP_VER_17 -# if _MSVC_LANG >= 202002L -# define CPP_VER_20 -# endif -# endif -# endif -# endif +# if _MSVC_LANG >= 201103L +# define CPP_VER_11 +# if _MSVC_LANG >= 201402L +# define CPP_VER_14 +# if _MSVC_LANG > 201402L +# define CPP_VER_17 +# if _MSVC_LANG >= 202002L +# define CPP_VER_20 +# endif +# endif +# endif +# endif #endif #ifdef __has_include @@ -49,9 +49,9 @@ #if !defined(HAS_FILESYSTEM) && !defined(HAS_EXP_FILESYSTEM) # error "Neither #include nor #include is available." #elif defined(HAS_FILESYSTEM) -#include +# include namespace std_fs = std::filesystem; #elif defined(HAS_EXP_FILESYSTEM) -#include +# include namespace std_fs = std::experimental::filesystem; #endif From c9eea679f3cf550a1e1ae0ac3f3d636360cb0069 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 20 Sep 2024 14:11:38 +0000 Subject: [PATCH 19/53] link libs --- docs/snippets/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt index f853d07328373b..521c62660203c1 100644 --- a/docs/snippets/CMakeLists.txt +++ b/docs/snippets/CMakeLists.txt @@ -113,7 +113,7 @@ find_package(OpenVINO REQUIRED) add_executable(${TARGET_NAME} src/main.cpp) -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime) +target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::util stdc++fs) # [cmake:integration_example_cpp] From dd78713dc6f336e6e70edbd8b48b1a970eb799ca Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 20 Sep 2024 14:26:28 +0000 Subject: [PATCH 20/53] fix tests --- src/core/tests/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index f83c8dd55b5a2d..1ca63b532ec672 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -50,13 +50,13 @@ TEST(file_util, path_join) { string s1 = "/x1/x2/"; string s2 = "/"; - EXPECT_STREQ("/", ov::util::path_join({s1, s2}).c_str()); + EXPECT_STREQ("/x1/x2//", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2"; string s2 = "/test1/test2"; - EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); } { string s1 = "/x1/x2/"; From b95435ffca5bfcaa36fc7506d7adc2bc6d1f2ba7 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 20 Sep 2024 15:20:34 +0000 Subject: [PATCH 21/53] remove unnecessary dependency --- docs/snippets/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt index 521c62660203c1..491fa0236f93ec 100644 --- a/docs/snippets/CMakeLists.txt +++ b/docs/snippets/CMakeLists.txt @@ -113,7 +113,7 @@ find_package(OpenVINO REQUIRED) add_executable(${TARGET_NAME} src/main.cpp) -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime openvino::util stdc++fs) +target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime stdc++fs) # [cmake:integration_example_cpp] From fe43c6e840ae61e7cd3700d6a849188ee261da14 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Tue, 24 Sep 2024 15:41:34 +0000 Subject: [PATCH 22/53] just for CI test --- src/common/util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index b0fa46d2fab1c4..008b60aa08f2d0 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -64,7 +64,7 @@ elseif(${STD_FS_NO_LIB_NEEDED}) set(STD_FS_LIB "") else() message(WARNING "Unknown C++17 compiler - not passing -lstdc++fs") - set(STD_FS_LIB "") + set(STD_FS_LIB stdc++fs) endif() target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml ${STD_FS_LIB} ) From d89d6ab01374be541d89c1efe5e1f0690e6a8b66 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 25 Sep 2024 07:30:47 +0000 Subject: [PATCH 23/53] add cpp14 case for windows build --- .../include/openvino/util/ov_filesystem.hpp | 89 ++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 31b079bea37dea..91ac0e15530d22 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -40,7 +40,7 @@ # endif #elif defined(_MSC_VER) && defined(CPP_VER_17) # define HAS_FILESYSTEM 1 -#elif defined(_MSC_VER) && defined(CPP_VER_11) +#elif defined(_MSC_VER) && (defined(CPP_VER_11) || defined(CPP_VER_14)) # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM @@ -55,3 +55,90 @@ namespace std_fs = std::filesystem; # include namespace std_fs = std::experimental::filesystem; #endif + +// #if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) +// # if (__cplusplus <= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG <= 201703L) && (_MSC_VER <= 1913)) +// # if __has_include() +// # include +// # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +// # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM +// namespace std_fs = std::experimental::filesystem; +// # endif +// # elif __has_include() +// # include +// namespace std_fs = std::filesystem; +// # else +// # error "No std filesystem lib avaliable!" +// # endif +// #endif + +// // We haven't checked which filesystem to include yet +// #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL + +// // Check for feature test macro for +// # if defined(__cpp_lib_filesystem) +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 + +// // Check for feature test macro for +// # elif defined(__cpp_lib_experimental_filesystem) +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 + +// // We can't check if headers exist... +// // Let's assume experimental to be safe +// # elif !defined(__has_include) +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 + +// // Check if the header "" exists +// # elif __has_include() && ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L) && (_MSC_VER >= 1913))) + +// // If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental +// # ifdef _MSC_VER + +// // Check and include header that defines "_HAS_CXX17" +// # if __has_include() +// # include + +// // Check for enabled C++17 support +// # if defined(_HAS_CXX17) && _HAS_CXX17 +// // We're using C++17, so let's use the normal version +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 +// # endif +// # endif + +// // If the marco isn't defined yet, that means any of the other VS specific checks failed, so we need to use +// experimental # ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 +// # endif + +// // Not on Visual Studio. Let's use the normal version +// # else // #ifdef _MSC_VER +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 +// # endif + +// // Check if the header "" exists +// # elif __has_include() +// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 + +// // Fail if neither header is available with a nice error message +// # else +// # error Could not find system header "" or "" +// # endif + +// // We priously determined that we need the exprimental version +// # if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL +// // Include it +// # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +// # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM +// # include + +// // We need the alias from std::experimental::filesystem to std::filesystem +// namespace std_fs = std::experimental::filesystem; + +// // We have a decent compiler and can use the normal version +// # else +// // Include it +// # include +// namespace std_fs = std::filesystem; +// # endif + +// #endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL From 640065ac1a5c1028bce31ed515f7059f6657f05e Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 11:54:42 +0200 Subject: [PATCH 24/53] fix windows build --- src/common/util/CMakeLists.txt | 14 ++++++----- .../include/openvino/util/ov_filesystem.hpp | 24 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 008b60aa08f2d0..27af80c3a230ab 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -39,31 +39,33 @@ set_target_properties(${TARGET_NAME} PROPERTIES EXPORT_NAME util) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - "#include \nint main(int argc, char ** argv) {\n std::filesystem::path p(argv[0]);\n return p.string().length();\n}" + "#include \nint main(int argc, char ** argv) {\n std::experimental::filesystem::path p(argv[0]);\n return p.string().length();\n}" ) try_compile( STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - COMPILE_DEFINITIONS -std=c++17) + COMPILE_DEFINITIONS -std=c++11) try_compile( STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - COMPILE_DEFINITIONS -std=c++17 + COMPILE_DEFINITIONS -std=c++11 LINK_LIBRARIES stdc++fs) try_compile( STD_FS_NEEDS_CXXFS ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp - COMPILE_DEFINITIONS -std=c++17 + COMPILE_DEFINITIONS -std=c++11 LINK_LIBRARIES c++fs) -if(${STD_FS_NEEDS_STDCXXFS}) +if(MSVC) + set(STD_FS_LIB stdc++fs) +elseif(${STD_FS_NEEDS_STDCXXFS}) set(STD_FS_LIB stdc++fs) elseif(${STD_FS_NEEDS_CXXFS}) set(STD_FS_LIB c++fs) elseif(${STD_FS_NO_LIB_NEEDED}) set(STD_FS_LIB "") else() - message(WARNING "Unknown C++17 compiler - not passing -lstdc++fs") + message(WARNING "Unknown C++ compiler - not passing -lstdc++fs") set(STD_FS_LIB stdc++fs) endif() diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 91ac0e15530d22..b4b1181d88f984 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -22,7 +22,7 @@ # define CPP_VER_11 # if _MSVC_LANG >= 201402L # define CPP_VER_14 -# if _MSVC_LANG > 201402L +# if _MSVC_LANG >= 201703L # define CPP_VER_17 # if _MSVC_LANG >= 202002L # define CPP_VER_20 @@ -32,28 +32,28 @@ # endif #endif -#ifdef __has_include +#if defined(_MSC_VER) && defined(CPP_VER_17) +# define HAS_FILESYSTEM 1 +#elif defined(_MSC_VER) && defined(CPP_VER_11) +# define HAS_EXP_FILESYSTEM 1 +# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM +#elif defined(__has_include) # if defined(CPP_VER_17) && (__has_include()) && (!__has_include()) # define HAS_FILESYSTEM 1 # elif defined(CPP_VER_11) && (__has_include()) # define HAS_EXP_FILESYSTEM 1 # endif -#elif defined(_MSC_VER) && defined(CPP_VER_17) -# define HAS_FILESYSTEM 1 -#elif defined(_MSC_VER) && (defined(CPP_VER_11) || defined(CPP_VER_14)) -# define HAS_EXP_FILESYSTEM 1 -# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM #endif #if !defined(HAS_FILESYSTEM) && !defined(HAS_EXP_FILESYSTEM) # error "Neither #include nor #include is available." #elif defined(HAS_FILESYSTEM) -# include -namespace std_fs = std::filesystem; + #include + namespace std_fs = std::filesystem; #elif defined(HAS_EXP_FILESYSTEM) -# include -namespace std_fs = std::experimental::filesystem; + #include + namespace std_fs = std::experimental::filesystem; #endif // #if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) From c9806241feb5787d9c9c9d78baec8e8a5f3d5054 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 12:40:07 +0200 Subject: [PATCH 25/53] fix windows compilation errors --- src/common/util/CMakeLists.txt | 2 +- src/common/util/src/file_util.cpp | 22 +++++++++++----------- src/core/src/pass/visualize_tree.cpp | 2 +- src/frontends/common/src/manager.cpp | 2 +- src/frontends/common/src/plugin_loader.cpp | 2 +- src/inference/src/cpp/core.cpp | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 27af80c3a230ab..587d7fc93ac57f 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -57,7 +57,7 @@ file( LINK_LIBRARIES c++fs) if(MSVC) - set(STD_FS_LIB stdc++fs) + set(STD_FS_LIB "") elseif(${STD_FS_NEEDS_STDCXXFS}) set(STD_FS_LIB stdc++fs) elseif(${STD_FS_NEEDS_CXXFS}) diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index 9a214da9de5f7a..df3b740837de69 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -192,7 +192,7 @@ void ov::util::iterate_files(const ov::util::Path& path, std::vector dirs; #ifdef _WIN32 # ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - std::wstring pathw = string_to_wstring(path); + std::wstring pathw = path.native(); std::wstring file_match = path_join_w({pathw, L"*"}); WIN32_FIND_DATAW data; HANDLE hFind = FindFirstFileW(file_match.c_str(), &data); @@ -508,14 +508,14 @@ ov::util::FilePath ov::util::get_compiled_plugin_path(const std::string& plugin) str << "openvino-" << OpenVINO_VERSION; const auto sub_folder = str.str(); - std::string abs_file_path = ov::util::path_join({ov_library_path, sub_folder, plugin}); + ov::util::Path abs_file_path = ov::util::path_join({ov_library_path, sub_folder, plugin}); if (ov::util::file_exists(abs_file_path)) - return ov::util::to_file_path(abs_file_path); + return abs_file_path.native(); // 2. in the openvino.so location abs_file_path = ov::util::path_join({ov_library_path, plugin}); if (ov::util::file_exists(abs_file_path)) - return ov::util::to_file_path(abs_file_path); + return abs_file_path.native(); auto lib_name = plugin; // For 3rd case - convert to 4th case @@ -541,27 +541,27 @@ ov::util::FilePath ov::util::get_plugin_path(const std::string& plugin, const st if (ov::util::is_absolute_file_path(plugin)) return ov::util::to_file_path(plugin); - auto xml_path_ = xml_path; + ov::util::Path xml_path_ = xml_path; if (xml_path.find(ov::util::FileTraits::file_separator) == std::string::npos) xml_path_ = ov::util::path_join({std::string("."), xml_path}); // treat plugins.xml as CWD/plugins.xml // For 2nd case if (plugin.find(ov::util::FileTraits::file_separator) != std::string::npos) { auto path_ = ov::util::path_join({ov::util::get_directory(xml_path_), plugin}); - return ov::util::to_file_path(ov::util::get_absolute_file_path(path_)); // canonicalize path + return ov::util::to_file_path(ov::util::get_absolute_file_path(path_.string())); // canonicalize path } - auto lib_file_name = plugin; + ov::util::Path lib_file_name = plugin; // For 3rd case - convert to 4th case if (!ov::util::ends_with(plugin, ov::util::FileTraits::library_ext())) lib_file_name = ov::util::make_plugin_library_name({}, plugin); // For 4th case - auto lib_path = ov::util::path_join({ov::util::get_directory(xml_path_), lib_file_name}); - lib_path = ov::util::get_absolute_file_path(lib_path); // canonicalize path + ov::util::Path lib_path = ov::util::path_join({ov::util::get_directory(xml_path_), lib_file_name}); + lib_path = ov::util::get_absolute_file_path(lib_path.string()); // canonicalize path if (as_abs_only || ov::util::file_exists(lib_path)) - return ov::util::to_file_path(lib_path); - return ov::util::to_file_path(lib_file_name); + return ov::util::to_file_path(lib_path.string()); + return ov::util::to_file_path(lib_file_name.string()); } std::vector ov::util::load_binary(const std::string& path) { diff --git a/src/core/src/pass/visualize_tree.cpp b/src/core/src/pass/visualize_tree.cpp index cf7bb6e85bdf37..2ba4088fa4e4fc 100644 --- a/src/core/src/pass/visualize_tree.cpp +++ b/src/core/src/pass/visualize_tree.cpp @@ -676,7 +676,7 @@ std::string ov::pass::VisualizeTree::get_node_name(std::shared_ptr node) { } void ov::pass::VisualizeTree::render() const { - std::string ext = ov::util::get_file_ext(m_name); + std::string ext = ov::util::get_file_ext(m_name).string(); std::string output_format = ext.substr(1); std::string dot_file = m_name; if (ov::util::to_lower(ext) != ".dot") { diff --git a/src/frontends/common/src/manager.cpp b/src/frontends/common/src/manager.cpp index 0a31f9a2c426e9..980cdce2c534f8 100644 --- a/src/frontends/common/src/manager.cpp +++ b/src/frontends/common/src/manager.cpp @@ -172,7 +172,7 @@ class FrontEndManager::Impl { #endif } if (!model_path.empty()) { - auto ext = ov::util::get_file_ext(model_path); + auto ext = ov::util::get_file_ext(model_path).string(); auto it = priority_fe_extensions.find(ext); if (it != priority_fe_extensions.end()) { // Priority FE is found by file extension, try this first diff --git a/src/frontends/common/src/plugin_loader.cpp b/src/frontends/common/src/plugin_loader.cpp index 70b263344579c9..038afaa0ff29d0 100644 --- a/src/frontends/common/src/plugin_loader.cpp +++ b/src/frontends/common/src/plugin_loader.cpp @@ -157,7 +157,7 @@ bool PluginInfo::load_internal() { std::shared_ptr so; try { #ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT - so = ov::util::load_shared_object(ov::util::string_to_wstring(m_file_path).c_str()); + so = ov::util::load_shared_object(ov::util::string_to_wstring(m_file_path.string()).c_str()); #else so = ov::util::load_shared_object(m_file_path.c_str()); #endif diff --git a/src/inference/src/cpp/core.cpp b/src/inference/src/cpp/core.cpp index 2d6c204757bcf6..5a917925d0aaca 100644 --- a/src/inference/src/cpp/core.cpp +++ b/src/inference/src/cpp/core.cpp @@ -39,12 +39,12 @@ std::string find_plugins_xml(const std::string& xml_file) { // register plugins from default openvino-/plugins.xml config auto xmlConfigFileDefault = ov::util::path_join({ov_library_path, sub_folder, xml_file_name}); if (ov::util::file_exists(xmlConfigFileDefault)) - return xmlConfigFileDefault; + return xmlConfigFileDefault.string(); // 2. in folder with libopenvino.so xmlConfigFileDefault = ov::util::path_join({std::move(ov_library_path), std::move(xml_file_name)}); if (ov::util::file_exists(xmlConfigFileDefault)) - return xmlConfigFileDefault; + return xmlConfigFileDefault.string(); return xml_file; } From 84be5525f0315c4acfb054dde58e102c59e06b77 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 12:52:56 +0200 Subject: [PATCH 26/53] get_compiled_plugin_path return wstring --- src/common/util/src/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index df3b740837de69..22308935f360cf 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -510,12 +510,12 @@ ov::util::FilePath ov::util::get_compiled_plugin_path(const std::string& plugin) ov::util::Path abs_file_path = ov::util::path_join({ov_library_path, sub_folder, plugin}); if (ov::util::file_exists(abs_file_path)) - return abs_file_path.native(); + return abs_file_path.wstring(); // 2. in the openvino.so location abs_file_path = ov::util::path_join({ov_library_path, plugin}); if (ov::util::file_exists(abs_file_path)) - return abs_file_path.native(); + return abs_file_path.wstring(); auto lib_name = plugin; // For 3rd case - convert to 4th case From c8be1df6fb58c536e6b2597fd9b2fe0a402fd5a0 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 13:04:51 +0200 Subject: [PATCH 27/53] fix windows build errors --- .../onnx/frontend/src/utils/tensor_external_data.cpp | 4 ++-- src/frontends/tensorflow/src/checkpoint_v1_reader.cpp | 6 +++--- src/frontends/tensorflow/src/variables_index.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp index a3bbde3ef98624..0a0ef8a43239bf 100644 --- a/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp +++ b/src/frontends/onnx/frontend/src/utils/tensor_external_data.cpp @@ -36,7 +36,7 @@ TensorExternalData::TensorExternalData(const TensorProto& tensor) { Buffer TensorExternalData::load_external_mmap_data(const std::string& model_dir, MappedMemoryHandles cache) const { - const auto full_path = ov::util::get_absolute_file_path(ov::util::path_join({model_dir, m_data_location})); + const auto full_path = ov::util::get_absolute_file_path(ov::util::path_join({model_dir, m_data_location}).string()); const int64_t file_size = ov::util::file_size(full_path); if (file_size <= 0 || m_offset + m_data_length > static_cast(file_size)) { throw error::invalid_external_data{*this}; @@ -59,7 +59,7 @@ Buffer TensorExternalData::load_external_mmap_data(const std:: } Buffer TensorExternalData::load_external_data(const std::string& model_dir) const { - auto full_path = ov::util::get_absolute_file_path(ov::util::path_join({model_dir, m_data_location})); + auto full_path = ov::util::get_absolute_file_path(ov::util::path_join({model_dir, m_data_location}).string()); #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) ov::util::convert_path_win_style(full_path); std::ifstream external_data_stream(ov::util::string_to_wstring(full_path).c_str(), diff --git a/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp b/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp index fa5f8b2a2d78b6..3ccab830e7cebb 100644 --- a/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp +++ b/src/frontends/tensorflow/src/checkpoint_v1_reader.cpp @@ -56,12 +56,12 @@ void CheckpointV1Reader::initialize() { std::make_shared(checkpoint_path, std::ifstream::in | std::ifstream::binary); FRONT_END_GENERAL_CHECK( shard_stream && shard_stream->is_open(), - "[TensorFlow Frontend] incorrect model: checkpoint file " + checkpoint_path.native() + "does not exist"); + "[TensorFlow Frontend] incorrect model: checkpoint file " + checkpoint_path.string() + "does not exist"); const int32_t shard_ind = static_cast(m_shards.size()); m_shards.push_back(shard_stream); - m_shard_names.push_back(checkpoint_path); + m_shard_names.push_back(checkpoint_path.string()); std::string value; - find_entry(shard_stream, checkpoint_path, SAVED_TENSOR_SLICES_KEY, value); + find_entry(shard_stream, checkpoint_path.string(), SAVED_TENSOR_SLICES_KEY, value); // parse empty index block // This is only present at the first item of each checkpoint file and serves diff --git a/src/frontends/tensorflow/src/variables_index.cpp b/src/frontends/tensorflow/src/variables_index.cpp index 778f8b2f94bb7c..cb3f2faf29f84a 100644 --- a/src/frontends/tensorflow/src/variables_index.cpp +++ b/src/frontends/tensorflow/src/variables_index.cpp @@ -195,7 +195,7 @@ bool VariablesIndex::read_variables(std::ifstream& vi_stream, const std::string& std::snprintf(suffix.data(), suffix.size(), "data-%05d-of-%05d", shard, m_total_shards); std::string fullPath; if (is_saved_model) { - fullPath = ov::util::path_join({path, "variables", std::string("variables.") + suffix.data()}); + fullPath = ov::util::path_join({path, "variables", std::string("variables.") + suffix.data()}).string(); } else { fullPath = path + "." + suffix.data(); } From 05a581d9798eca8a095d83a20bd77c7ec95404b5 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 13:23:03 +0200 Subject: [PATCH 28/53] missing to string convertion --- src/tests/test_utils/common_test_utils/src/file_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/test_utils/common_test_utils/src/file_utils.cpp b/src/tests/test_utils/common_test_utils/src/file_utils.cpp index d0739710ab91ba..5359643b89c663 100644 --- a/src/tests/test_utils/common_test_utils/src/file_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/file_utils.cpp @@ -150,7 +150,7 @@ std::string getCurrentWorkingDir() { } std::string getModelFromTestModelZoo(const std::string& relModelPath) { - return ov::util::path_join({getExecutableDirectory(), relModelPath}); + return ov::util::path_join({getExecutableDirectory(), relModelPath}).string(); } std::string getRelativePath(const std::string& from, const std::string& to) { From 82fab71340524182176572234fdad9b9ac3d33ce Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 13:48:34 +0200 Subject: [PATCH 29/53] fix wondows op_conformance_utils --- .../op_conformance_utils/src/utils/file.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp b/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp index e45428ef650d02..ff46cf663eb59f 100644 --- a/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp +++ b/src/tests/functional/plugin/conformance/op_conformance_utils/src/utils/file.cpp @@ -16,7 +16,7 @@ get_filelist_recursive(const std::vector& dir_paths, std::vector result; for (auto&& dir_path : dir_paths) { if (!ov::util::directory_exists(dir_path)) { - std::string msg = "Input directory (" + dir_path.native() + ") doesn't not exist!"; + std::string msg = "Input directory (" + dir_path.string() + ") doesn't not exist!"; throw std::runtime_error(msg); } ov::util::iterate_files( @@ -24,7 +24,7 @@ get_filelist_recursive(const std::vector& dir_paths, [&result, &patterns](const ov::util::Path& file_path, bool is_dir) { if (ov::util::file_exists(file_path)) { for (const auto& pattern : patterns) { - if (std::regex_match(file_path.c_str(), pattern)) { + if (std::regex_match(file_path.string(), pattern)) { result.push_back(file_path); break; } @@ -43,7 +43,7 @@ read_lst_file(const std::vector& file_paths, std::vector res; for (const auto& file_path : file_paths) { if (!ov::util::file_exists(file_path)) { - std::string msg = "Input directory (" + file_path.native() + ") doesn't not exist!"; + std::string msg = "Input directory (" + file_path.string() + ") doesn't not exist!"; throw std::runtime_error(msg); } std::ifstream file(file_path); @@ -52,7 +52,7 @@ read_lst_file(const std::vector& file_paths, while (getline(file, buffer)) { if (buffer.find("#") == std::string::npos && !buffer.empty()) { for (const auto& pattern : patterns) { - if (std::regex_match(file_path.native(), pattern)) { + if (std::regex_match(file_path.string(), pattern)) { res.emplace_back(buffer); break; } @@ -60,7 +60,7 @@ read_lst_file(const std::vector& file_paths, } } } else { - std::string msg = "Error in opening file: " + file_path.native(); + std::string msg = "Error in opening file: " + file_path.string(); throw std::runtime_error(msg); } } From 5c4f8a960a7d425f8e55c83e9b844e75fe7ca47f Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 14:18:20 +0200 Subject: [PATCH 30/53] fix lib link for ov_integration_snippet --- docs/snippets/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt index 491fa0236f93ec..f853d07328373b 100644 --- a/docs/snippets/CMakeLists.txt +++ b/docs/snippets/CMakeLists.txt @@ -113,7 +113,7 @@ find_package(OpenVINO REQUIRED) add_executable(${TARGET_NAME} src/main.cpp) -target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime stdc++fs) +target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime) # [cmake:integration_example_cpp] From a240b5cf2216cb0fc5058826390c6ca3b87a90d0 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 15:02:47 +0200 Subject: [PATCH 31/53] fix windows ov_core_unit_tests build --- src/core/tests/check.cpp | 2 +- src/core/tests/file_util.cpp | 30 +++++++++---------- src/core/tests/frontend/frontend_manager.cpp | 2 +- .../pass/serialization/deterministicity.cpp | 12 ++++---- .../tests/pass/serialization/serialize.cpp | 4 +-- src/core/tests/pass/visualize_tree.cpp | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/core/tests/check.cpp b/src/core/tests/check.cpp index 2ef888cba49b66..5d56fd4743efd7 100644 --- a/src/core/tests/check.cpp +++ b/src/core/tests/check.cpp @@ -55,7 +55,7 @@ TEST(check, ov_throw_exception_check_relative_path_to_source) { } using namespace testing; const auto path = ov::util::path_join({"src", "core", "tests", "check.cpp"}); - const auto exp_native_slash = "Exception from " + path.native() + ":"; + const auto exp_native_slash = "Exception from " + path.string() + ":"; const auto exp_fwd_slash = "Exception from src/core/tests/check.cpp:"; OV_EXPECT_THROW(OPENVINO_THROW("Test message"), ov::Exception, diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 1ca63b532ec672..0c01df96783033 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -19,66 +19,66 @@ TEST(file_util, path_join) { string s1 = ""; string s2 = ""; - EXPECT_STREQ("", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{""}, ov::util::path_join({s1, s2})); } { string s1 = ""; string s2 = "/test1/test2"; - EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/test1/test2"}, ov::util::path_join({s1, s2})); } { string s1 = ""; string s2 = "/test1/test2/"; - EXPECT_STREQ("/test1/test2/", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/test1/test2/"}, ov::util::path_join({s1, s2})); } { string s1 = ""; string s2 = "test1/test2"; - EXPECT_STREQ("test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"test1/test2"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2"; string s2 = ""; - EXPECT_STREQ("/x1/x2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2/"; string s2 = "/"; - EXPECT_STREQ("/x1/x2//", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2//"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2"; string s2 = "/test1/test2"; - EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2/test1/test2"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2/"; string s2 = "test1/test2"; - EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2/test1/test2"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2"; string s2 = "test1/test2"; #ifndef _WIN32 - EXPECT_STREQ("/x1/x2/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2/test1/test2"}, ov::util::path_join({s1, s2})); #else - EXPECT_STREQ("/x1/x2\\test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/x1/x2\\test1/test2"}, ov::util::path_join({s1, s2})); #endif } { string s1 = "/"; string s2 = "test1/test2"; - EXPECT_STREQ("/test1/test2", ov::util::path_join({s1, s2}).c_str()); + EXPECT_EQ(ov::util::Path{"/test1/test2"}, ov::util::path_join({s1, s2})); } } @@ -125,14 +125,14 @@ TEST_F(TrimFileTest, relative_path_to_source) { const auto file_path = ov::util::path_join({"..", "..", "..", project_dir_name, "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); EXPECT_EQ(exp_path, str_ptr); } TEST_F(TrimFileTest, relative_path_to_source_but_no_project_dir) { const auto file_path = ov::util::path_join({"..", "..", "..", "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); EXPECT_EQ(file_path, str_ptr); } @@ -141,14 +141,14 @@ TEST_F(TrimFileTest, absolute_path_to_source) { const auto file_path = ov::util::path_join({"home", "user", project_dir_name, "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); EXPECT_EQ(exp_path, str_ptr); } TEST_F(TrimFileTest, absolute_path_to_source_but_no_project_dir) { const auto file_path = ov::util::path_join({"home", "user", "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); EXPECT_EQ(file_path, str_ptr); } diff --git a/src/core/tests/frontend/frontend_manager.cpp b/src/core/tests/frontend/frontend_manager.cpp index 1e42de563ddbc6..033e2490c45592 100644 --- a/src/core/tests/frontend/frontend_manager.cpp +++ b/src/core/tests/frontend/frontend_manager.cpp @@ -17,7 +17,7 @@ using namespace ov::frontend; static std::string mock_fe_path() { static auto lib_name = std::string(FRONTEND_LIB_PREFIX) + "mock1" + std::string(FRONTEND_LIB_SUFFIX); - return ov::util::path_join({ov::test::utils::getExecutableDirectory(), lib_name}); + return ov::util::path_join({ov::test::utils::getExecutableDirectory(), lib_name}).string(); } TEST(FrontEndManagerTest, testAvailableFrontEnds) { diff --git a/src/core/tests/pass/serialization/deterministicity.cpp b/src/core/tests/pass/serialization/deterministicity.cpp index 5bcfbf97b77890..250efa8669b311 100644 --- a/src/core/tests/pass/serialization/deterministicity.cpp +++ b/src/core/tests/pass/serialization/deterministicity.cpp @@ -72,7 +72,7 @@ class SerializationDeterministicityTest : public ov::test::TestsCommon, public D TEST_F(SerializationDeterministicityTest, BasicModel) { const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc.onnx"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc.onnx"}).string()); auto expected = ov::test::readModel(model, ""); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); @@ -89,7 +89,7 @@ TEST_F(SerializationDeterministicityTest, BasicModel) { TEST_F(SerializationDeterministicityTest, ModelWithMultipleLayers) { const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/addmul_abc.onnx"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/addmul_abc.onnx"}).string()); auto expected = ov::test::readModel(model, ""); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); @@ -108,9 +108,9 @@ TEST_F(SerializationDeterministicityTest, ModelWithMultipleLayers) { TEST_F(SerializationDeterministicityTest, ModelWithMultipleOutputs) { const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.xml"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.xml"}).string()); const std::string weights = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.bin"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.bin"}).string()); auto expected = ov::test::readModel(model, weights); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); @@ -127,9 +127,9 @@ TEST_F(SerializationDeterministicityTest, ModelWithMultipleOutputs) { TEST_F(SerializationDeterministicityTest, ModelWithConstants) { const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.xml"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.xml"}).string()); const std::string weights = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.bin"})); + ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.bin"}).string()); auto expected = ov::test::readModel(model, weights); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); diff --git a/src/core/tests/pass/serialization/serialize.cpp b/src/core/tests/pass/serialization/serialize.cpp index e45d5d1d1434ff..c9406d5b6f0157 100644 --- a/src/core/tests/pass/serialization/serialize.cpp +++ b/src/core/tests/pass/serialization/serialize.cpp @@ -39,10 +39,10 @@ class SerializationTest : public ov::test::TestsCommon, public testing::WithPara void SetUp() override { m_model_path = ov::test::utils::getModelFromTestModelZoo( - ov::util::path_join({SERIALIZED_ZOO, "ir/", std::get<0>(GetParam())})); + ov::util::path_join({SERIALIZED_ZOO, "ir/", std::get<0>(GetParam())}).string()); if (!std::get<1>(GetParam()).empty()) { m_binary_path = ov::test::utils::getModelFromTestModelZoo( - ov::util::path_join({SERIALIZED_ZOO, "ir/", std::get<1>(GetParam())})); + ov::util::path_join({SERIALIZED_ZOO, "ir/", std::get<1>(GetParam())}).string()); } std::string filePrefix = ov::test::utils::generateTestFilePrefix(); diff --git a/src/core/tests/pass/visualize_tree.cpp b/src/core/tests/pass/visualize_tree.cpp index 1b21f2b294e3db..dc168e06d96a94 100644 --- a/src/core/tests/pass/visualize_tree.cpp +++ b/src/core/tests/pass/visualize_tree.cpp @@ -39,7 +39,7 @@ class VisualizeTreeTest : public testing::Test { } const std::string vt_svg_file_path = - util::path_join({utils::getExecutableDirectory(), utils::generateTestFilePrefix() + "_tree.svg"}); + util::path_join({utils::getExecutableDirectory(), utils::generateTestFilePrefix() + "_tree.svg"}).string(); const std::string dot_file_path = vt_svg_file_path + ".dot"; }; From 8b4ab44d06f5f1167f69764d9ff3b82ff4632a76 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Wed, 25 Sep 2024 18:00:29 +0200 Subject: [PATCH 32/53] fix for openvino_onnx_frontend build --- src/common/util/include/openvino/util/ov_filesystem.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index b4b1181d88f984..5df9e68efe26d3 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -32,9 +32,7 @@ # endif #endif -#if defined(_MSC_VER) && defined(CPP_VER_17) -# define HAS_FILESYSTEM 1 -#elif defined(_MSC_VER) && defined(CPP_VER_11) +#if defined(_MSC_VER) && defined(CPP_VER_11) # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM From 86b4a74f8847f62680fea2bd7bd1d9635d4c8a3c Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 26 Sep 2024 10:53:45 +0200 Subject: [PATCH 33/53] add path to string casts --- src/frontends/onnx/tests/lib_close.cpp | 2 +- src/frontends/paddle/tests/lib_close.cpp | 2 +- src/frontends/paddle/tests/read_paddle_model_test.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontends/onnx/tests/lib_close.cpp b/src/frontends/onnx/tests/lib_close.cpp index 06641d0432ca48..c454298488ea76 100644 --- a/src/frontends/onnx/tests/lib_close.cpp +++ b/src/frontends/onnx/tests/lib_close.cpp @@ -15,6 +15,6 @@ INSTANTIATE_TEST_SUITE_P(ONNX, FrontendLibCloseTest, Values(std::make_tuple("onnx", path_join({std::string(TEST_ONNX_MODELS_DIRNAME), - std::string("external_data/external_data.onnx")}), + std::string("external_data/external_data.onnx")}).string(), "Y")), FrontendLibCloseTest::get_test_case_name); diff --git a/src/frontends/paddle/tests/lib_close.cpp b/src/frontends/paddle/tests/lib_close.cpp index f110f12fe3373e..b75df8eaef146b 100644 --- a/src/frontends/paddle/tests/lib_close.cpp +++ b/src/frontends/paddle/tests/lib_close.cpp @@ -14,6 +14,6 @@ INSTANTIATE_TEST_SUITE_P(Paddle, FrontendLibCloseTest, Values(std::make_tuple("paddle", path_join({std::string(TEST_PADDLE_MODELS_DIRNAME), - std::string("conv2d_relu/conv2d_relu.pdmodel")}), + std::string("conv2d_relu/conv2d_relu.pdmodel")}).string(), "conv2d_0.tmp_0")), FrontendLibCloseTest::get_test_case_name); diff --git a/src/frontends/paddle/tests/read_paddle_model_test.cpp b/src/frontends/paddle/tests/read_paddle_model_test.cpp index 830db6486b6d18..8e6cb03b6ea463 100644 --- a/src/frontends/paddle/tests/read_paddle_model_test.cpp +++ b/src/frontends/paddle/tests/read_paddle_model_test.cpp @@ -25,7 +25,7 @@ TEST(Paddle_Reader_Tests, LoadModelMemoryToCore) { ov::Core core; auto read_file = [&](const ov::util::Path& file_name, size_t& size) { - FILE* sFile = fopen(file_name.c_str(), "r"); + FILE* sFile = fopen(file_name.string().c_str(), "r"); fseek(sFile, 0, SEEK_END); size = ftell(sFile); uint8_t* ss = (uint8_t*)malloc(size); From ea0e39b70a07f72c1a5169661678042923160f40 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 26 Sep 2024 11:32:17 +0200 Subject: [PATCH 34/53] add path to string casts part2 --- .../onnx/tests/onnx_importer_test.cpp | 6 +++--- src/frontends/onnx/tests/onnx_utils.cpp | 2 +- src/frontends/onnx/tests/op_extension.cpp | 4 ++-- .../shared/gtest_main_manifest/main.cpp | 2 +- .../subgraphs_dumper/src/cache/cache.cpp | 10 +++++----- .../src/cache/graph_cache.cpp | 6 +++--- .../subgraphs_dumper/src/cache/op_cache.cpp | 2 +- .../conformance/subgraphs_dumper/src/main.cpp | 2 +- .../subgraphs_dumper/src/utils/cache.cpp | 4 ++-- .../subgraphs_dumper/tests/cache/cache.cpp | 4 ++-- .../tests/cache/graph_cache.cpp | 4 ++-- .../subgraphs_dumper/tests/cache/meta.cpp | 20 +++++++++---------- .../subgraphs_dumper/tests/cache/op_cache.cpp | 6 +++--- 13 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/frontends/onnx/tests/onnx_importer_test.cpp b/src/frontends/onnx/tests/onnx_importer_test.cpp index 5870c6cfb758fd..3a65333f46087a 100644 --- a/src/frontends/onnx/tests/onnx_importer_test.cpp +++ b/src/frontends/onnx/tests/onnx_importer_test.cpp @@ -114,7 +114,7 @@ TEST(ONNX_Importer_Tests, ImportModelWhenFileDoesNotExist) { TEST(ONNX_Importer_Tests, ImportModelFromStream) { auto model_file_path = - test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "addmul_abc.onnx"})); + test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "addmul_abc.onnx"}).string()); std::ifstream model_file_stream(model_file_path, std::ifstream::binary); ASSERT_TRUE(model_file_stream.is_open()); int count_adds = 0; @@ -136,14 +136,14 @@ TEST(ONNX_Importer_Tests, ImportModelFromStream) { TEST(ONNX_Importer_Tests, ImportModelWithoutMetadata) { Core core; auto model = core.read_model( - test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "priorbox_clustered.onnx"}))); + test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "priorbox_clustered.onnx"}).string())); ASSERT_FALSE(model->has_rt_info("framework")); } TEST(ONNX_Importer_Tests, ImportModelWithMetadata) { Core core; auto model = core.read_model( - test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "model_with_metadata.onnx"}))); + test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "model_with_metadata.onnx"}).string())); ASSERT_TRUE(model->has_rt_info("framework")); const auto rtinfo = model->get_rt_info(); diff --git a/src/frontends/onnx/tests/onnx_utils.cpp b/src/frontends/onnx/tests/onnx_utils.cpp index 376222cd1bab92..14e3ca23ca2c1b 100644 --- a/src/frontends/onnx/tests/onnx_utils.cpp +++ b/src/frontends/onnx/tests/onnx_utils.cpp @@ -134,7 +134,7 @@ InputModel::Ptr load_model(const wstring& model_path, FrontEnd::Ptr* return_fron } std::string onnx_backend_manifest(const std::string& manifest) { - return ov::util::path_join({ov::test::utils::getExecutableDirectory(), manifest}); + return ov::util::path_join({ov::test::utils::getExecutableDirectory(), manifest}).string(); } } // namespace tests diff --git a/src/frontends/onnx/tests/op_extension.cpp b/src/frontends/onnx/tests/op_extension.cpp index 6dc9be9c1298cd..15ada6c89099e2 100644 --- a/src/frontends/onnx/tests/op_extension.cpp +++ b/src/frontends/onnx/tests/op_extension.cpp @@ -155,7 +155,7 @@ TEST(ONNXOpExtensionViaCommonConstructor, onnx_op_extension_via_template_arg_wit fe->add_extension(ext); const auto input_model = fe->load(ov::test::utils::getModelFromTestModelZoo( - ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"}))); + ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"}).string())); std::shared_ptr model; EXPECT_NO_THROW(fe->convert(input_model)); @@ -169,7 +169,7 @@ TEST(ONNXOpExtensionViaCommonConstructor, onnx_op_extension_via_ov_type_name_wit fe->add_extension(ext); const auto input_model = fe->load(ov::test::utils::getModelFromTestModelZoo( - ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"}))); + ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"}).string())); std::shared_ptr model; EXPECT_NO_THROW(fe->convert(input_model)); diff --git a/src/frontends/tests/frontend/shared/gtest_main_manifest/main.cpp b/src/frontends/tests/frontend/shared/gtest_main_manifest/main.cpp index 1b26e05135b8c5..72729c1af1b2ab 100644 --- a/src/frontends/tests/frontend/shared/gtest_main_manifest/main.cpp +++ b/src/frontends/tests/frontend/shared/gtest_main_manifest/main.cpp @@ -12,7 +12,7 @@ static const std::string s_manifest{ #ifdef MANIFEST - ov::util::path_join({ov::test::utils::getExecutableDirectory(), MANIFEST}) + ov::util::path_join({ov::test::utils::getExecutableDirectory(), MANIFEST}).string() #endif }; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp index b592b5ba451f4f..424a4274dff821 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/cache.cpp @@ -21,10 +21,10 @@ bool ICache::serialize_model(const std::pair, ov::con ov::conformance::MetaInfo meta = graph_info.second; std::string model_name = model->get_friendly_name(); - std::string abs_searilization_dir = ov::util::path_join({ m_serialization_dir, rel_serialization_dir }); - std::string xml_path = ov::util::path_join({ abs_searilization_dir, model_name + ".xml" }); - std::string bin_path = ov::util::path_join({ abs_searilization_dir, model_name + ".bin" }); - std::string meta_path = ov::util::path_join({ abs_searilization_dir, model_name + ".meta" }); + std::string abs_searilization_dir = ov::util::path_join({ m_serialization_dir, rel_serialization_dir }).string(); + std::string xml_path = ov::util::path_join({ abs_searilization_dir, model_name + ".xml" }).string(); + std::string bin_path = ov::util::path_join({ abs_searilization_dir, model_name + ".bin" }).string(); + std::string meta_path = ov::util::path_join({ abs_searilization_dir, model_name + ".meta" }).string(); if (!ov::util::directory_exists(abs_searilization_dir)) { ov::util::create_directory_recursive(abs_searilization_dir); @@ -54,4 +54,4 @@ bool ICache::serialize_model(const std::pair, ov::con } // namespace subgraph_dumper } // namespace tools -} // namespace ov \ No newline at end of file +} // namespace ov diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp index b6ad5197f82137..b08fb3a6cbb882 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/graph_cache.cpp @@ -83,9 +83,9 @@ void GraphCache::update_cache(const std::shared_ptr& extracted_model, if (model_to_update == nullptr) { std::string serialized_model_path = ""; for (const auto& extractor : m_manager.get_extractors()) { - auto tmp_serialized_model_path = ov::util::path_join({ m_serialization_dir, m_cache_subdir, extractor.first, graph_name + ".xml" }); + const auto& tmp_serialized_model_path = ov::util::path_join({ m_serialization_dir, m_cache_subdir, extractor.first, graph_name + ".xml" }); if (ov::util::file_exists(tmp_serialized_model_path)) { - serialized_model_path = tmp_serialized_model_path; + serialized_model_path = tmp_serialized_model_path.string(); break; } } @@ -195,7 +195,7 @@ void GraphCache::serialize_cache() { auto rel_dir = ov::util::path_join({ m_cache_subdir, ov::util::get_model_type(cache_item->first), cache_item->second.get_any_extractor() }); - serialize_model(*cache_item, rel_dir); + serialize_model(*cache_item, rel_dir.string()); m_graph_cache.erase(cache_item); } } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp index 02c41529ab0499..b7f146bbe9b22e 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/cache/op_cache.cpp @@ -135,7 +135,7 @@ OpCache::serialize_op(const std::pair, ov::conformance std::string OpCache::get_rel_serilization_dir(const std::shared_ptr& node) { std::string op_folder_name = ov::util::get_node_version(node->get_type_info()); auto op_el_type = node->get_output_element_type(0).get_type_name(); - return ov::util::path_join({m_cache_subdir, ov::util::get_node_type(node), op_folder_name, op_el_type}); + return ov::util::path_join({m_cache_subdir, ov::util::get_node_type(node), op_folder_name, op_el_type}).string(); } } // namespace subgraph_dumper diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp index cf02c74f543f40..7e93886db5876e 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/main.cpp @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) { if (!FLAGS_local_cache.empty()) { std::vector tmp_paths; for (auto& dir : local_cache_dirs) { - tmp_paths.push_back(ov::util::path_join({dir, cache->m_cache_subdir})); + tmp_paths.push_back(ov::util::path_join({dir, cache->m_cache_subdir}).string()); } auto cached_ops = ov::util::find_models(tmp_paths, FLAGS_path_regex); auto this_cache_model_status = ov::util::cache_models(cache, cached_ops.first, FLAGS_extract_body, true); diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp index 93b4877860735e..1d3c35d9a01da4 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp @@ -15,12 +15,12 @@ namespace util { void save_model_status_to_file(const std::map>& caching_status, const std::string& output_dir) { - std::string cache_status_path = ov::util::path_join({output_dir, "model_caching_status"}); + std::string cache_status_path = ov::util::path_join({output_dir, "model_caching_status"}).string(); if (!ov::util::directory_exists(cache_status_path)) { ov::util::create_directory_recursive(cache_status_path); } for (const auto& status_info : caching_status) { - std::string output_file_path = ov::util::path_join({ cache_status_path, model_cache_status_to_str[status_info.first] + LST_EXTENSION}); + std::string output_file_path = ov::util::path_join({ cache_status_path, model_cache_status_to_str[status_info.first] + LST_EXTENSION}).string(); vector_to_file(status_info.second, output_file_path); } } diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/cache.cpp index ab3477718f224c..cff354f95b99c8 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/cache.cpp @@ -32,7 +32,7 @@ class ICacheUnitTest : public SubgraphsDumperBaseTest, SubgraphsDumperBaseTest::SetUp(); model_name = "test_model"; test_artifacts_dir = "test_artifacts"; - test_model_path = ov::util::path_join({ test_artifacts_dir, model_name + ".xml" }); + test_model_path = ov::util::path_join({ test_artifacts_dir, model_name + ".xml" }).string(); ov::util::create_directory_recursive(test_artifacts_dir); { auto params = ov::ParameterVector { @@ -112,4 +112,4 @@ TEST_F(ICacheUnitTest, is_model_large_to_store_const) { ASSERT_FALSE(this->is_model_large_to_store_const(test_model)); } -} // namespace \ No newline at end of file +} // namespace diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp index 295eda9654a713..c406bdf808decb 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/graph_cache.cpp @@ -32,8 +32,8 @@ class GraphCacheFuncTest : public SubgraphsDumperBaseTest { void SetUp() override { SubgraphsDumperBaseTest::SetUp(); test_model_name = "test_model_name"; - test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}); - test_model_path = ov::util::path_join({test_artifacts_dir, test_model_name + ".xml"}); + test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}).string(); + test_model_path = ov::util::path_join({test_artifacts_dir, test_model_name + ".xml"}).string(); ov::util::create_directory_recursive(test_artifacts_dir); { Model_0 test; diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp index 27eb5133935e62..f4ed6c2eefe5ee 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp @@ -86,7 +86,7 @@ class MetaInfoFuncTest : public SubgraphsDumperBaseTest { test_model_name = ov::util::replace_extension(test_model_path, ""); test_in_info = {{ "test_in_0", InputInfo({10}, DEFAULT_MIN_VALUE, 1, true) }}; test_model_info = {{ test_model_name, ModelInfo(test_model_path, 5) }}; - test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}); + test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}).string(); ov::util::create_directory_recursive(test_artifacts_dir); } @@ -129,7 +129,7 @@ TEST_F(MetaInfoFuncTest, update) { ASSERT_EQ(test_meta.get_input_info().at("test_in_0").max_shape, ov::PartialShape({10})); std::map test_input_info_1 = {{ "test_in_0", InputInfo({50}, 0, 1, true) }}; std::string test_model_1 = "test_model_1"; - std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}); + std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}).string(); ASSERT_ANY_THROW(test_meta.update(test_model_path_1, {})); ASSERT_ANY_THROW(test_meta.update(test_model_path_1, {{ "test_in_1", InputInfo({10}) }})); ASSERT_ANY_THROW(test_meta.update(test_model_path_1, {{ "test_in_0", InputInfo({10}, 0, 1, false) }})); @@ -143,7 +143,7 @@ TEST_F(MetaInfoFuncTest, update) { TEST_F(MetaInfoFuncTest, serialize) { auto test_meta = MetaInfo(test_model_name, test_in_info); - std::string seriliazation_path(ov::util::path_join({test_artifacts_dir, "test_meta.meta"})); + std::string seriliazation_path{ov::util::path_join({test_artifacts_dir, "test_meta.meta"}).string()}; test_meta.serialize(seriliazation_path); ASSERT_TRUE(ov::util::file_exists(seriliazation_path)); } @@ -161,7 +161,7 @@ class MetaInfoUnitTest : public MetaInfoFuncTest, }; TEST_F(MetaInfoUnitTest, serialize) { - std::string seriliazation_path(ov::util::path_join({test_artifacts_dir, "test_meta.meta"})); + std::string seriliazation_path{ov::util::path_join({test_artifacts_dir, "test_meta.meta"}).string()}; this->extractors = { "extractor_0", "extractor_1" }; this->serialize(seriliazation_path); ASSERT_TRUE(ov::util::file_exists(seriliazation_path)); @@ -173,7 +173,7 @@ TEST_F(MetaInfoUnitTest, serialize) { for (const auto model_xml : models_xml.children()) { auto model_name_xml = std::string(model_xml.attribute("name").value()); ASSERT_NE(model_info.find(model_name_xml), model_info.end()); - ASSERT_EQ(model_info[model_name_xml].this_op_cnt, model_xml.attribute("this_op_count").as_uint()); + ASSERT_EQ(model_info[model_name_xml].this_op_cnt, model_xml.attribute("this_op_count").as_uint()); ASSERT_EQ(model_info[model_name_xml].total_op_cnt, model_xml.attribute("total_op_count").as_uint()); auto paths = model_info[model_name_xml].model_paths; for (const auto& path_xml : model_xml.child("path")) { @@ -215,7 +215,7 @@ TEST_F(MetaInfoUnitTest, serialize) { } TEST_F(MetaInfoUnitTest, read_meta_from_file) { - std::string seriliazation_path(ov::util::path_join({test_artifacts_dir, "test_meta.meta"})); + std::string seriliazation_path{ov::util::path_join({test_artifacts_dir, "test_meta.meta"}).string()}; this->extractors = { "extractor_0", "extractor_1" }; this->serialize(seriliazation_path); auto new_meta = MetaInfo::read_meta_from_file(seriliazation_path); @@ -227,8 +227,8 @@ TEST_F(MetaInfoUnitTest, read_meta_from_file) { TEST_F(MetaInfoUnitTest, update) { auto test_meta = MetaInfo(test_model_name, test_in_info); std::map test_meta_1 = {{ "test_in_0", InputInfo({20}, 0, 1, true) }}; - std::string test_model_1 = "test_model_1"; - std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}); +std::string test_model_1 = "test_model_1"; + std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}).string(); OV_ASSERT_NO_THROW(this->update(test_model_path_1, test_meta_1)); ASSERT_NE(this->model_info.find(test_model_1), this->model_info.end()); ASSERT_EQ(*this->model_info[test_model_1].model_paths.begin(), test_model_path_1); @@ -240,7 +240,7 @@ TEST_F(MetaInfoUnitTest, update) { ASSERT_EQ(this->model_info[test_model_1].this_op_cnt, 2); ASSERT_EQ(this->input_info.begin()->second.min_shape, ov::PartialShape({10})); ASSERT_EQ(this->input_info.begin()->second.max_shape, ov::PartialShape({20})); - test_model_path_1 = ov::util::path_join({ "path", "to", "test", test_model_1 + ".xml"}); + test_model_path_1 = ov::util::path_join({ "path", "to", "test", test_model_1 + ".xml"}).string(); OV_ASSERT_NO_THROW(this->update(test_model_path_1, test_meta_1, 0, 1, "test_extractor")); ASSERT_EQ(this->model_info[test_model_1].model_paths.size(), 2); ASSERT_EQ(this->model_info[test_model_1].this_op_cnt, 3); @@ -268,4 +268,4 @@ TEST_F(MetaInfoUnitTest, get_any_extractor) { ASSERT_EQ(meta.get_any_extractor(), "test_extractor"); } -} // namespace \ No newline at end of file +} // namespace diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/op_cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/op_cache.cpp index 66ef666172f4c3..5101bfc5a8804c 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/op_cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/op_cache.cpp @@ -30,8 +30,8 @@ class OpCacheFuncTest : public SubgraphsDumperBaseTest { void SetUp() override { SubgraphsDumperBaseTest::SetUp(); test_model_name = "test_model_name"; - test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}); - test_model_path = ov::util::path_join({test_artifacts_dir, test_model_name + ".xml"}); + test_artifacts_dir = ov::util::path_join({ov::test::utils::getCurrentWorkingDir(), "test_artifacts"}).string(); + test_model_path = ov::util::path_join({test_artifacts_dir, test_model_name + ".xml"}).string(); ov::util::create_directory_recursive(test_artifacts_dir); { auto params = ov::ParameterVector { @@ -101,7 +101,7 @@ TEST_F(OpCacheUnitTest, update_cache_by_model) { this->update_cache(convert_node, test_model_path, 1); ASSERT_EQ(m_ops_cache.size(), 1); std::shared_ptr test_model_1; - std::string test_model_path_1 = ov::util::path_join({test_artifacts_dir, "model_1", test_model_name + ".xml"}); + std::string test_model_path_1 = ov::util::path_join({test_artifacts_dir, "model_1", test_model_name + ".xml"}).string(); { auto param = std::make_shared(ov::element::Type_t::f32, ov::PartialShape{1, 1, 1, 1}); param->set_friendly_name("in_0"); From 971b81e31a633ad505e10935a264725d91f6244f Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 26 Sep 2024 12:29:44 +0200 Subject: [PATCH 35/53] add path to string casts part3 --- .../conformance/subgraphs_dumper/src/utils/cache.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp index 1d3c35d9a01da4..46cfb9d559672c 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp @@ -28,9 +28,10 @@ void save_model_status_to_file(const std::map, std::pair>> find_models(const std::vector &dirs, const std::string& regexp) { - std::vector models, full_content, not_read_model; + std::vector models, not_read_model; + std::vector full_content{}; for (const auto& dir : dirs) { - std::vector dir_content; + std::vector dir_content{}; if (ov::util::directory_exists(dir)) { dir_content = ov::util::get_filelist_recursive({dir}, FROTEND_REGEXP); } else if (ov::util::file_exists(dir) && std::regex_match(dir, std::regex(".*" + std::string(LST_EXTENSION)))) { @@ -45,12 +46,12 @@ find_models(const std::vector &dirs, const std::string& regexp) { std::multimap models_sorted_by_size; auto in_regex = std::regex(regexp); for (const auto& model_file : full_content) { - if (std::regex_match(model_file, in_regex)) { + if (std::regex_match(model_file.string(), in_regex)) { try { // models.emplace_back(file); if (ov::util::file_exists(model_file)) { auto model_size = core->read_model(model_file)->get_graph_size(); - models_sorted_by_size.insert({ model_size, model_file}); + models_sorted_by_size.insert({ model_size, model_file.string()}); } else { continue; } From fa4363b0c6b0a7abaeecd4d4bc6f1876f8ac3eb7 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 26 Sep 2024 13:01:36 +0200 Subject: [PATCH 36/53] add path to string casts part4 --- .../plugin/conformance/subgraphs_dumper/src/utils/cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp index 46cfb9d559672c..2af8258efeb0da 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/src/utils/cache.cpp @@ -56,7 +56,7 @@ find_models(const std::vector &dirs, const std::string& regexp) { continue; } } catch (std::exception) { - not_read_model.emplace_back(model_file); + not_read_model.emplace_back(model_file.string()); // std::cout << "[ ERROR ] Impossible to read model: " << model_file << std::endl << "Exception: " << e.what(); } } From 00701963f43f3b13d3634fb637848bc5c3f20a45 Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Thu, 26 Sep 2024 13:38:18 +0200 Subject: [PATCH 37/53] add path to string casts part5 --- src/frontends/onnx/tests/onnx_import_convpool.in.cpp | 6 +++--- src/frontends/onnx/tests/onnx_import_quant.in.cpp | 4 ++-- .../op_conformance_runner/include/utils/models.hpp | 11 ++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp index ccc8be0359365b..ec028d3f2e5115 100644 --- a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp @@ -426,14 +426,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape) { test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/x.bin"})); + "files/convtranspose_output_shape/x.bin"}).string()); test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/w.bin"})); + "files/convtranspose_output_shape/w.bin"}).string()); test_case.add_expected_output_from_file({1, 2, 10, 8}, util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/y.bin"})); + "files/convtranspose_output_shape/y.bin"}).string()); test_case.run(); } diff --git a/src/frontends/onnx/tests/onnx_import_quant.in.cpp b/src/frontends/onnx/tests/onnx_import_quant.in.cpp index c2d48c292cb8c1..12627c3fe4f39b 100644 --- a/src/frontends/onnx/tests/onnx_import_quant.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_quant.in.cpp @@ -407,7 +407,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_quant_conv_linear_2d) { auto test_case = ov::test::TestCase(model, s_device); test_case.add_input_from_file( - util::path_join({ ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "files/qlinearconv2d/x.bin" })); + util::path_join({ ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "files/qlinearconv2d/x.bin" }).string()); test_case.add_input(std::vector{0.00369204697199166f}); // x_scale test_case.add_input(std::vector{132}); // x_zero_point test_case.add_input(std::vector{0}); // w @@ -417,7 +417,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_quant_conv_linear_2d) { test_case.add_input(std::vector{123}); // y_zero_point test_case.add_expected_output_from_file({ 1, 1, 7, 7 }, - util::path_join({ ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "files/qlinearconv2d/y.bin" })); + util::path_join({ ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "files/qlinearconv2d/y.bin" }).string()); test_case.run(); } diff --git a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp index 42f021987fa96b..daf7e94f61de6b 100644 --- a/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp +++ b/src/tests/functional/plugin/conformance/test_runner/op_conformance_runner/include/utils/models.hpp @@ -56,23 +56,20 @@ get_model_paths(const std::vector& conformance_ir_paths, for (auto& val : tmp_buf) { bool is_op = false; #ifdef _WIN32 - for (auto it = val.begin(); it != val.end(); ++it) { - if (*it == '/') - val.replace(it, it + 1, ov::test::utils::FileSeparator); - } + val.make_preferred(); #endif - for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val.native(), ov::test::utils::FileSeparator)) { + for (const auto& path_item : ov::test::utils::splitStringByDelimiter(val.string(), ov::test::utils::FileSeparator)) { auto pos = path_item.find('-'); auto tmp_path_item = pos == std::string::npos ? path_item : path_item.substr(0, pos); if (op_filelist.find(tmp_path_item) != op_filelist.end()) { - op_filelist[tmp_path_item].push_back({val, get_ref_path(val)}); + op_filelist[tmp_path_item].push_back({val.string(), get_ref_path(val.string())}); is_op = true; break; } } if (!is_op) { - op_filelist["undefined"].push_back({val, get_ref_path(val)}); + op_filelist["undefined"].push_back({val.string(), get_ref_path(val.string())}); } } } From e366b03fee1498e540b81bf87cafad20bf17e4ed Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 26 Sep 2024 12:23:54 +0000 Subject: [PATCH 38/53] use const + format --- .../plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp index f4ed6c2eefe5ee..007665e9caf083 100644 --- a/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp +++ b/src/tests/functional/plugin/conformance/subgraphs_dumper/tests/cache/meta.cpp @@ -227,7 +227,7 @@ TEST_F(MetaInfoUnitTest, read_meta_from_file) { TEST_F(MetaInfoUnitTest, update) { auto test_meta = MetaInfo(test_model_name, test_in_info); std::map test_meta_1 = {{ "test_in_0", InputInfo({20}, 0, 1, true) }}; -std::string test_model_1 = "test_model_1"; + const std::string test_model_1 = "test_model_1"; std::string test_model_path_1 = ov::util::path_join({ "path", "to", test_model_1 + ".xml"}).string(); OV_ASSERT_NO_THROW(this->update(test_model_path_1, test_meta_1)); ASSERT_NE(this->model_info.find(test_model_1), this->model_info.end()); From 57ece561cc7d8ed4a44b4abdceb99da17797fd22 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 26 Sep 2024 14:21:00 +0000 Subject: [PATCH 39/53] rewrite trim_file_name --- .../util/include/openvino/util/file_util.hpp | 2 +- src/common/util/src/file_util.cpp | 25 +++++++------------ src/core/tests/file_util.cpp | 12 ++++----- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/common/util/include/openvino/util/file_util.hpp b/src/common/util/include/openvino/util/file_util.hpp index a0298c8b1d3522..2155097d68fa48 100644 --- a/src/common/util/include/openvino/util/file_util.hpp +++ b/src/common/util/include/openvino/util/file_util.hpp @@ -395,7 +395,7 @@ void save_binary(const std::string& path, const char* binary, size_t bin_size); * @param fname Pointer to OpenVINO file name path. * @return Pointer to trimmed file name path. */ -const char* trim_file_name(const char* const fname); +ov::util::Path trim_file_name(const ov::util::Path& fname); template using enableIfSupportedChar = diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index 22308935f360cf..e30c8ce55794e6 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -616,21 +616,14 @@ void ov::util::save_binary(const std::string& path, const char* binary, size_t b } } -const char* ov::util::trim_file_name(const char* const fname) { - static const auto pattern_native_sep = - std::string(OV_NATIVE_PARENT_PROJECT_ROOT_DIR) + FileTraits::file_separator; - - const auto has_native_sep_pattern_ptr = std::strstr(fname, pattern_native_sep.c_str()); - auto fname_trim_ptr = has_native_sep_pattern_ptr ? has_native_sep_pattern_ptr + pattern_native_sep.size() : fname; - -#if defined(_WIN32) - // On windows check also forward slash as in some case the __FILE__ can have it instead native backward slash. - if (fname_trim_ptr == fname) { - static const auto pattern_fwd_sep = std::string(OV_NATIVE_PARENT_PROJECT_ROOT_DIR) + '/'; - if (const auto has_fwd_sep_pattern_ptr = std::strstr(fname, pattern_fwd_sep.c_str())) { - fname_trim_ptr = has_fwd_sep_pattern_ptr + pattern_fwd_sep.size(); - } +ov::util::Path ov::util::trim_file_name(const ov::util::Path& fname) { + // fs::relative, fs::proximate not avalieble in experimantal, upgrade on C++17. + + auto it = std::find(fname.begin(), fname.end(), ov::util::Path::string_type{OV_NATIVE_PARENT_PROJECT_ROOT_DIR}); + + if(it != fname.end()){ + return ov::util::path_join({++it, fname.end()}); + }else{ + return fname; } -#endif - return fname_trim_ptr; } diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index 0c01df96783033..c06ed293ee4cf3 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -125,14 +125,14 @@ TEST_F(TrimFileTest, relative_path_to_source) { const auto file_path = ov::util::path_join({"..", "..", "..", project_dir_name, "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(exp_path, str_ptr); } TEST_F(TrimFileTest, relative_path_to_source_but_no_project_dir) { const auto file_path = ov::util::path_join({"..", "..", "..", "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(file_path, str_ptr); } @@ -141,14 +141,14 @@ TEST_F(TrimFileTest, absolute_path_to_source) { const auto file_path = ov::util::path_join({"home", "user", project_dir_name, "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(exp_path, str_ptr); } TEST_F(TrimFileTest, absolute_path_to_source_but_no_project_dir) { const auto file_path = ov::util::path_join({"home", "user", "src", "test_src.cpp"}); - auto str_ptr = ov::util::trim_file_name(file_path.string().c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(file_path, str_ptr); } @@ -156,7 +156,7 @@ TEST_F(TrimFileTest, absolute_path_to_source_forward_slash_always_supported) { const auto exp_path = std::string("src/test_src.cpp"); const auto file_path = std::string("home/user/") + project_dir_name + "/src/test_src.cpp"; - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(exp_path, str_ptr); } @@ -164,6 +164,6 @@ TEST_F(TrimFileTest, relatice_path_to_source_forward_slash_always_supported) { const auto exp_path = std::string("src/test_src.cpp"); const auto file_path = std::string("../../") + project_dir_name + "/src/test_src.cpp"; - auto str_ptr = ov::util::trim_file_name(file_path.c_str()); + auto str_ptr = ov::util::trim_file_name(file_path); EXPECT_EQ(exp_path, str_ptr); } From 939c5a29ebf6ad323e466f1634af1c762b1f6fb3 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Thu, 26 Sep 2024 14:42:07 +0000 Subject: [PATCH 40/53] turn off filesystem warning --- .../include/openvino/util/ov_filesystem.hpp | 89 +------------------ 1 file changed, 2 insertions(+), 87 deletions(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 5df9e68efe26d3..f58812d933d9e0 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -40,6 +40,8 @@ # if defined(CPP_VER_17) && (__has_include()) && (!__has_include()) # define HAS_FILESYSTEM 1 # elif defined(CPP_VER_11) && (__has_include()) +# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM # define HAS_EXP_FILESYSTEM 1 # endif #endif @@ -53,90 +55,3 @@ #include namespace std_fs = std::experimental::filesystem; #endif - -// #if !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) -// # if (__cplusplus <= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG <= 201703L) && (_MSC_VER <= 1913)) -// # if __has_include() -// # include -// # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -// # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -// namespace std_fs = std::experimental::filesystem; -// # endif -// # elif __has_include() -// # include -// namespace std_fs = std::filesystem; -// # else -// # error "No std filesystem lib avaliable!" -// # endif -// #endif - -// // We haven't checked which filesystem to include yet -// #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL - -// // Check for feature test macro for -// # if defined(__cpp_lib_filesystem) -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 - -// // Check for feature test macro for -// # elif defined(__cpp_lib_experimental_filesystem) -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 - -// // We can't check if headers exist... -// // Let's assume experimental to be safe -// # elif !defined(__has_include) -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 - -// // Check if the header "" exists -// # elif __has_include() && ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L) && (_MSC_VER >= 1913))) - -// // If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental -// # ifdef _MSC_VER - -// // Check and include header that defines "_HAS_CXX17" -// # if __has_include() -// # include - -// // Check for enabled C++17 support -// # if defined(_HAS_CXX17) && _HAS_CXX17 -// // We're using C++17, so let's use the normal version -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 -// # endif -// # endif - -// // If the marco isn't defined yet, that means any of the other VS specific checks failed, so we need to use -// experimental # ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 -// # endif - -// // Not on Visual Studio. Let's use the normal version -// # else // #ifdef _MSC_VER -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 -// # endif - -// // Check if the header "" exists -// # elif __has_include() -// # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 - -// // Fail if neither header is available with a nice error message -// # else -// # error Could not find system header "" or "" -// # endif - -// // We priously determined that we need the exprimental version -// # if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL -// // Include it -// # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING -// # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -// # include - -// // We need the alias from std::experimental::filesystem to std::filesystem -// namespace std_fs = std::experimental::filesystem; - -// // We have a decent compiler and can use the normal version -// # else -// // Include it -// # include -// namespace std_fs = std::filesystem; -// # endif - -// #endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL From d73ba01dd620a129784ebb04d99cb72b70ca79d1 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 27 Sep 2024 08:27:21 +0000 Subject: [PATCH 41/53] avoid quoted paths at exception messages --- src/core/src/except.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/src/except.cpp b/src/core/src/except.cpp index 6ce0568e04e387..1ee40e378d4442 100644 --- a/src/core/src/except.cpp +++ b/src/core/src/except.cpp @@ -19,9 +19,9 @@ std::string ov::Exception::make_what(const char* file, const std::string& explanation) { std::stringstream ss; if (check_string) { - ss << "Check '" << check_string << "' failed at " << util::trim_file_name(file) << ":" << line; + ss << "Check '" << check_string << "' failed at " << util::trim_file_name(file).native() << ":" << line; } else { - ss << "Exception from " << util::trim_file_name(file) << ":" << line; + ss << "Exception from " << util::trim_file_name(file).native() << ":" << line; } if (!context_info.empty()) { ss << ":" << std::endl << context_info; From 6817ec6c7c48c8c8851271a4c5ff4c6342eb597f Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 27 Sep 2024 11:02:42 +0200 Subject: [PATCH 42/53] fix trim_file_name for windows build --- src/common/util/src/file_util.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index e30c8ce55794e6..d79ac997d99e0f 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -619,10 +619,10 @@ void ov::util::save_binary(const std::string& path, const char* binary, size_t b ov::util::Path ov::util::trim_file_name(const ov::util::Path& fname) { // fs::relative, fs::proximate not avalieble in experimantal, upgrade on C++17. - auto it = std::find(fname.begin(), fname.end(), ov::util::Path::string_type{OV_NATIVE_PARENT_PROJECT_ROOT_DIR}); + auto it = std::find(fname.begin(), fname.end(), ov::util::Path{OV_NATIVE_PARENT_PROJECT_ROOT_DIR}); if(it != fname.end()){ - return ov::util::path_join({++it, fname.end()}); + return ov::util::path_join(std::vector(++it, fname.end())); }else{ return fname; } From c1d5d3d7e15ac86484c8e7de2292c465fac9d6fe Mon Sep 17 00:00:00 2001 From: "Barnas, Michal" Date: Fri, 27 Sep 2024 12:20:45 +0200 Subject: [PATCH 43/53] cast trim_file_name to string on exception --- src/core/src/except.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/src/except.cpp b/src/core/src/except.cpp index 1ee40e378d4442..54e73b22c6d425 100644 --- a/src/core/src/except.cpp +++ b/src/core/src/except.cpp @@ -19,9 +19,9 @@ std::string ov::Exception::make_what(const char* file, const std::string& explanation) { std::stringstream ss; if (check_string) { - ss << "Check '" << check_string << "' failed at " << util::trim_file_name(file).native() << ":" << line; + ss << "Check '" << check_string << "' failed at " << util::trim_file_name(file).string() << ":" << line; } else { - ss << "Exception from " << util::trim_file_name(file).native() << ":" << line; + ss << "Exception from " << util::trim_file_name(file).string() << ":" << line; } if (!context_info.empty()) { ss << ":" << std::endl << context_info; From dadeb9315747d06e369e79327d3c1ddef2b19b3e Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Fri, 27 Sep 2024 14:14:06 +0000 Subject: [PATCH 44/53] revert test update, apply origin logic to new join_paths impl --- src/common/util/src/file_util.cpp | 10 +++++++++- src/core/tests/file_util.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index d79ac997d99e0f..f5e96c5a8b0647 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -105,7 +105,15 @@ std::wstring ov::util::get_directory(const std::wstring& s) { namespace { ov::util::Path join_paths(const ov::util::Path& s1, const ov::util::Path& s2) { - return s1 / s2; + if(s2.empty()){ + return s1; + } + else if(s1.empty() || *s2.begin() == ov::util::Path{"/"}){ + return s2; + } + else{ + return s1 / s2; + } } } // namespace diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp index c06ed293ee4cf3..306fe115e5412c 100644 --- a/src/core/tests/file_util.cpp +++ b/src/core/tests/file_util.cpp @@ -50,13 +50,13 @@ TEST(file_util, path_join) { string s1 = "/x1/x2/"; string s2 = "/"; - EXPECT_EQ(ov::util::Path{"/x1/x2//"}, ov::util::path_join({s1, s2})); + EXPECT_EQ(ov::util::Path{"/"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2"; string s2 = "/test1/test2"; - EXPECT_EQ(ov::util::Path{"/x1/x2/test1/test2"}, ov::util::path_join({s1, s2})); + EXPECT_EQ(ov::util::Path{"/test1/test2"}, ov::util::path_join({s1, s2})); } { string s1 = "/x1/x2/"; From 3e4aac425252398515ebda98b1516c943226a739 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 30 Sep 2024 08:08:41 +0000 Subject: [PATCH 45/53] clang code format --- .../util/include/openvino/util/ov_filesystem.hpp | 8 ++++---- src/common/util/src/file_util.cpp | 14 ++++++-------- .../pass/serialization/deterministicity.cpp | 16 ++++++++-------- src/frontends/onnx/tests/lib_close.cpp | 15 ++++++++------- .../onnx/tests/onnx_import_convpool.in.cpp | 9 ++++++--- src/frontends/onnx/tests/onnx_importer_test.cpp | 8 ++++---- src/frontends/paddle/tests/lib_close.cpp | 15 ++++++++------- 7 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index f58812d933d9e0..1895af45451435 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -49,9 +49,9 @@ #if !defined(HAS_FILESYSTEM) && !defined(HAS_EXP_FILESYSTEM) # error "Neither #include nor #include is available." #elif defined(HAS_FILESYSTEM) - #include - namespace std_fs = std::filesystem; +# include +namespace std_fs = std::filesystem; #elif defined(HAS_EXP_FILESYSTEM) - #include - namespace std_fs = std::experimental::filesystem; +# include +namespace std_fs = std::experimental::filesystem; #endif diff --git a/src/common/util/src/file_util.cpp b/src/common/util/src/file_util.cpp index f5e96c5a8b0647..59e064a0b385bd 100644 --- a/src/common/util/src/file_util.cpp +++ b/src/common/util/src/file_util.cpp @@ -3,7 +3,6 @@ // #include "openvino/util/file_util.hpp" -#include "openvino/util/file_path.hpp" #include @@ -14,6 +13,7 @@ #include #include "openvino/util/common_util.hpp" +#include "openvino/util/file_path.hpp" #ifdef _WIN32 # ifndef NOMINMAX @@ -105,13 +105,11 @@ std::wstring ov::util::get_directory(const std::wstring& s) { namespace { ov::util::Path join_paths(const ov::util::Path& s1, const ov::util::Path& s2) { - if(s2.empty()){ + if (s2.empty()) { return s1; - } - else if(s1.empty() || *s2.begin() == ov::util::Path{"/"}){ + } else if (s1.empty() || *s2.begin() == ov::util::Path{"/"}) { return s2; - } - else{ + } else { return s1 / s2; } } @@ -629,9 +627,9 @@ ov::util::Path ov::util::trim_file_name(const ov::util::Path& fname) { auto it = std::find(fname.begin(), fname.end(), ov::util::Path{OV_NATIVE_PARENT_PROJECT_ROOT_DIR}); - if(it != fname.end()){ + if (it != fname.end()) { return ov::util::path_join(std::vector(++it, fname.end())); - }else{ + } else { return fname; } } diff --git a/src/core/tests/pass/serialization/deterministicity.cpp b/src/core/tests/pass/serialization/deterministicity.cpp index 250efa8669b311..975bc85bb94e9a 100644 --- a/src/core/tests/pass/serialization/deterministicity.cpp +++ b/src/core/tests/pass/serialization/deterministicity.cpp @@ -107,10 +107,10 @@ TEST_F(SerializationDeterministicityTest, ModelWithMultipleLayers) { #endif TEST_F(SerializationDeterministicityTest, ModelWithMultipleOutputs) { - const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.xml"}).string()); - const std::string weights = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.bin"}).string()); + const std::string model = ov::test::utils::getModelFromTestModelZoo( + ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.xml"}).string()); + const std::string weights = ov::test::utils::getModelFromTestModelZoo( + ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.bin"}).string()); auto expected = ov::test::readModel(model, weights); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); @@ -126,10 +126,10 @@ TEST_F(SerializationDeterministicityTest, ModelWithMultipleOutputs) { } TEST_F(SerializationDeterministicityTest, ModelWithConstants) { - const std::string model = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.xml"}).string()); - const std::string weights = - ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.bin"}).string()); + const std::string model = ov::test::utils::getModelFromTestModelZoo( + ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.xml"}).string()); + const std::string weights = ov::test::utils::getModelFromTestModelZoo( + ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.bin"}).string()); auto expected = ov::test::readModel(model, weights); ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected); diff --git a/src/frontends/onnx/tests/lib_close.cpp b/src/frontends/onnx/tests/lib_close.cpp index c454298488ea76..fc687ec799da53 100644 --- a/src/frontends/onnx/tests/lib_close.cpp +++ b/src/frontends/onnx/tests/lib_close.cpp @@ -11,10 +11,11 @@ using namespace testing; using namespace ov::util; -INSTANTIATE_TEST_SUITE_P(ONNX, - FrontendLibCloseTest, - Values(std::make_tuple("onnx", - path_join({std::string(TEST_ONNX_MODELS_DIRNAME), - std::string("external_data/external_data.onnx")}).string(), - "Y")), - FrontendLibCloseTest::get_test_case_name); +INSTANTIATE_TEST_SUITE_P( + ONNX, + FrontendLibCloseTest, + Values(std::make_tuple( + "onnx", + path_join({std::string(TEST_ONNX_MODELS_DIRNAME), std::string("external_data/external_data.onnx")}).string(), + "Y")), + FrontendLibCloseTest::get_test_case_name); diff --git a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp index ec028d3f2e5115..6719086fb3ed50 100644 --- a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp @@ -426,14 +426,17 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape) { test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/x.bin"}).string()); + "files/convtranspose_output_shape/x.bin"}) + .string()); test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/w.bin"}).string()); + "files/convtranspose_output_shape/w.bin"}) + .string()); test_case.add_expected_output_from_file({1, 2, 10, 8}, util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, - "files/convtranspose_output_shape/y.bin"}).string()); + "files/convtranspose_output_shape/y.bin"}) + .string()); test_case.run(); } diff --git a/src/frontends/onnx/tests/onnx_importer_test.cpp b/src/frontends/onnx/tests/onnx_importer_test.cpp index 3a65333f46087a..a32873a7d3c8df 100644 --- a/src/frontends/onnx/tests/onnx_importer_test.cpp +++ b/src/frontends/onnx/tests/onnx_importer_test.cpp @@ -135,15 +135,15 @@ TEST(ONNX_Importer_Tests, ImportModelFromStream) { TEST(ONNX_Importer_Tests, ImportModelWithoutMetadata) { Core core; - auto model = core.read_model( - test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "priorbox_clustered.onnx"}).string())); + auto model = core.read_model(test::utils::getModelFromTestModelZoo( + util::path_join({TEST_ONNX_MODELS_DIRNAME, "priorbox_clustered.onnx"}).string())); ASSERT_FALSE(model->has_rt_info("framework")); } TEST(ONNX_Importer_Tests, ImportModelWithMetadata) { Core core; - auto model = core.read_model( - test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "model_with_metadata.onnx"}).string())); + auto model = core.read_model(test::utils::getModelFromTestModelZoo( + util::path_join({TEST_ONNX_MODELS_DIRNAME, "model_with_metadata.onnx"}).string())); ASSERT_TRUE(model->has_rt_info("framework")); const auto rtinfo = model->get_rt_info(); diff --git a/src/frontends/paddle/tests/lib_close.cpp b/src/frontends/paddle/tests/lib_close.cpp index b75df8eaef146b..812165a529a0d7 100644 --- a/src/frontends/paddle/tests/lib_close.cpp +++ b/src/frontends/paddle/tests/lib_close.cpp @@ -10,10 +10,11 @@ using namespace testing; using namespace ov::util; -INSTANTIATE_TEST_SUITE_P(Paddle, - FrontendLibCloseTest, - Values(std::make_tuple("paddle", - path_join({std::string(TEST_PADDLE_MODELS_DIRNAME), - std::string("conv2d_relu/conv2d_relu.pdmodel")}).string(), - "conv2d_0.tmp_0")), - FrontendLibCloseTest::get_test_case_name); +INSTANTIATE_TEST_SUITE_P( + Paddle, + FrontendLibCloseTest, + Values(std::make_tuple( + "paddle", + path_join({std::string(TEST_PADDLE_MODELS_DIRNAME), std::string("conv2d_relu/conv2d_relu.pdmodel")}).string(), + "conv2d_0.tmp_0")), + FrontendLibCloseTest::get_test_case_name); From 9ad7dade1b8eb8574a90ddb968967b12585f83ec Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Mon, 30 Sep 2024 08:16:36 +0000 Subject: [PATCH 46/53] unnecessary include --- src/common/util/include/openvino/util/file_path.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp index 2b050a09200b79..b24917989737cc 100644 --- a/src/common/util/include/openvino/util/file_path.hpp +++ b/src/common/util/include/openvino/util/file_path.hpp @@ -4,7 +4,6 @@ #pragma once -#include #include #include "openvino/util/ov_filesystem.hpp" From 7069710a6bc12bd228e2cc0d55da3a79b1b1580e Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 14:14:35 +0000 Subject: [PATCH 47/53] fix android experimental filesystem include --- src/common/util/include/openvino/util/ov_filesystem.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 1895af45451435..38898f8f4d4938 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -36,13 +36,17 @@ # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM +#elif defined(ANDROID) || defined(__ANDROID__) +# define HAS_EXP_FILESYSTEM 1 +# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING +# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM #elif defined(__has_include) # if defined(CPP_VER_17) && (__has_include()) && (!__has_include()) # define HAS_FILESYSTEM 1 # elif defined(CPP_VER_11) && (__has_include()) +# define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -# define HAS_EXP_FILESYSTEM 1 # endif #endif From 8d6fd9011cdd43da4e513f4defb819ae5afd5142 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 14:31:09 +0000 Subject: [PATCH 48/53] fix android experimental filesystem include2 --- src/common/util/include/openvino/util/ov_filesystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 38898f8f4d4938..27e4af99b35a62 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -36,7 +36,7 @@ # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -#elif defined(ANDROID) || defined(__ANDROID__) +#elif defined(ANDROID) || defined(__ANDROID__) || defined(__clang__) || defined(__INTEL_CLANG_COMPILER) || defined(__INTEL_LLVM_COMPILER) # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM From 71108d3cda7bc89ec9d2977fa06e1b30eb3e8405 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 15:10:51 +0000 Subject: [PATCH 49/53] link stdc++fs for STD_FS_NO_LIB_NEEDED --- src/common/util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 587d7fc93ac57f..c8a4441b5402c4 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -63,7 +63,7 @@ elseif(${STD_FS_NEEDS_STDCXXFS}) elseif(${STD_FS_NEEDS_CXXFS}) set(STD_FS_LIB c++fs) elseif(${STD_FS_NO_LIB_NEEDED}) - set(STD_FS_LIB "") + set(STD_FS_LIB stdc++fs) else() message(WARNING "Unknown C++ compiler - not passing -lstdc++fs") set(STD_FS_LIB stdc++fs) From b820345f08c99b7e8e86193fb485486849fe4906 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 15:21:38 +0000 Subject: [PATCH 50/53] revert: link stdc++fs for STD_FS_NO_LIB_NEEDED --- src/common/util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index c8a4441b5402c4..587d7fc93ac57f 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -63,7 +63,7 @@ elseif(${STD_FS_NEEDS_STDCXXFS}) elseif(${STD_FS_NEEDS_CXXFS}) set(STD_FS_LIB c++fs) elseif(${STD_FS_NO_LIB_NEEDED}) - set(STD_FS_LIB stdc++fs) + set(STD_FS_LIB "") else() message(WARNING "Unknown C++ compiler - not passing -lstdc++fs") set(STD_FS_LIB stdc++fs) From a4d5a385c7180f7abdab5555b5a1d4f276e73576 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 15:29:42 +0000 Subject: [PATCH 51/53] remove unnecessary checks --- src/common/util/include/openvino/util/ov_filesystem.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/include/openvino/util/ov_filesystem.hpp b/src/common/util/include/openvino/util/ov_filesystem.hpp index 27e4af99b35a62..38898f8f4d4938 100644 --- a/src/common/util/include/openvino/util/ov_filesystem.hpp +++ b/src/common/util/include/openvino/util/ov_filesystem.hpp @@ -36,7 +36,7 @@ # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM -#elif defined(ANDROID) || defined(__ANDROID__) || defined(__clang__) || defined(__INTEL_CLANG_COMPILER) || defined(__INTEL_LLVM_COMPILER) +#elif defined(ANDROID) || defined(__ANDROID__) # define HAS_EXP_FILESYSTEM 1 # define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING # define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM From 6162145c70cfe1b3d870af8fc0e5eb211a185408 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Wed, 2 Oct 2024 15:44:42 +0000 Subject: [PATCH 52/53] add cmake fs debug message --- src/common/util/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index 587d7fc93ac57f..ab0ecbe92c00d4 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -57,12 +57,16 @@ file( LINK_LIBRARIES c++fs) if(MSVC) + message(INFO "MSVC - no fs linking") set(STD_FS_LIB "") elseif(${STD_FS_NEEDS_STDCXXFS}) + message(INFO "STD_FS_NEEDS_STDCXXFS - stdc++fs linking") set(STD_FS_LIB stdc++fs) elseif(${STD_FS_NEEDS_CXXFS}) + message(INFO "STD_FS_NEEDS_CXXFS - c++fs linking") set(STD_FS_LIB c++fs) elseif(${STD_FS_NO_LIB_NEEDED}) + message(INFO "STD_FS_NO_LIB_NEEDED - no fs linking") set(STD_FS_LIB "") else() message(WARNING "Unknown C++ compiler - not passing -lstdc++fs") From 8905ff3429220ca489993669a1dc6804f7123d23 Mon Sep 17 00:00:00 2001 From: Michal Barnas Date: Tue, 8 Oct 2024 07:52:41 +0000 Subject: [PATCH 53/53] fix android linker error --- src/common/util/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/CMakeLists.txt b/src/common/util/CMakeLists.txt index ab0ecbe92c00d4..3ac0b984f66588 100644 --- a/src/common/util/CMakeLists.txt +++ b/src/common/util/CMakeLists.txt @@ -70,7 +70,7 @@ elseif(${STD_FS_NO_LIB_NEEDED}) set(STD_FS_LIB "") else() message(WARNING "Unknown C++ compiler - not passing -lstdc++fs") - set(STD_FS_LIB stdc++fs) + set(STD_FS_LIB "") endif() target_link_libraries(${TARGET_NAME} PRIVATE ${CMAKE_DL_LIBS} PUBLIC openvino::pugixml ${STD_FS_LIB} )