Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/common/util/include/openvino/util/file_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ inline bool file_exists(const Path& path) noexcept {
std::filesystem::path get_directory(const std::filesystem::path& path);

std::filesystem::path path_join(std::initializer_list<std::filesystem::path>&& paths);
std::wstring path_join_w(std::initializer_list<std::wstring>&& paths);

Comment thread
almilosz marked this conversation as resolved.
/**
* @brief Iterates over files in given directory and applies provided function to each file found.
Expand Down
5 changes: 0 additions & 5 deletions src/common/util/src/file_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,10 @@ std::filesystem::path path_join(Container&& paths) {
return joined_path;
}

// TODO: Remove string() / wstring() casts on function call site
std::filesystem::path ov::util::path_join(std::initializer_list<std::filesystem::path>&& paths) {
return ::path_join<>(std::move(paths));
}

std::wstring ov::util::path_join_w(std::initializer_list<std::wstring>&& paths) {
return ::path_join<>(std::move(paths)).wstring();
}

namespace {
void process_dir_entry(const std::filesystem::directory_entry& dir_entry,
const std::function<void(const std::filesystem::path& file)>& func) {
Expand Down
14 changes: 7 additions & 7 deletions src/core/tests/pass/serialization/deterministicity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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"}).string());
ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir", "add_abc.onnx"}));

auto expected = ov::test::readModel(model, "");
ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected);
Expand All @@ -93,7 +93,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"}).string());
ov::test::utils::getModelFromTestModelZoo(ov::util::path_join({SERIALIZED_ZOO, "ir", "addmul_abc.onnx"}));

auto expected = ov::test::readModel(model, "");
ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected);
Expand All @@ -112,9 +112,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"}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", "split_equal_parts_2d.xml"}));
const std::string weights = ov::test::utils::getModelFromTestModelZoo(
ov::util::path_join({SERIALIZED_ZOO, "ir/split_equal_parts_2d.bin"}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", "split_equal_parts_2d.bin"}));

auto expected = ov::test::readModel(model, weights);
ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected);
Expand All @@ -131,9 +131,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"}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", "add_abc_initializers.xml"}));
const std::string weights = ov::test::utils::getModelFromTestModelZoo(
ov::util::path_join({SERIALIZED_ZOO, "ir/add_abc_initializers.bin"}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", "add_abc_initializers.bin"}));

auto expected = ov::test::readModel(model, weights);
ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected);
Expand All @@ -150,7 +150,7 @@ TEST_F(SerializationDeterministicityTest, ModelWithConstants) {

TEST_F(SerializationDeterministicityTest, ModelWithVariable) {
const auto model = ov::test::utils::getModelFromTestModelZoo(
ov::util::path_join({SERIALIZED_ZOO, "ir/dynamic_variable.xml"}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", "dynamic_variable.xml"}));

auto expected = ov::test::readModel(model, "");
ov::pass::Serialize(m_out_xml_path_1, m_out_bin_path_1).run_on_model(expected);
Expand Down
4 changes: 2 additions & 2 deletions src/core/tests/pass/serialization/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,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())}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", std::get<0>(GetParam())}));
if (!std::get<1>(GetParam()).empty()) {
m_binary_path = ov::test::utils::getModelFromTestModelZoo(
ov::util::path_join({SERIALIZED_ZOO, "ir/", std::get<1>(GetParam())}).string());
ov::util::path_join({SERIALIZED_ZOO, "ir", std::get<1>(GetParam())}));
}

std::string filePrefix = ov::test::utils::generateTestFilePrefix();
Expand Down
13 changes: 5 additions & 8 deletions src/frontends/onnx/tests/load_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ static LoadFromFEParam getTestData() {
}

TEST_P(FrontEndLoadFromTest, testLoadFromStreamAndPassPath) {
const auto path =
ov::util::path_join(
{ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "external_data/external_data.onnx"})
.string();
const auto path = ov::util::path_join(
{ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "external_data/external_data.onnx"});
std::ifstream ifs(path, std::ios::in | std::ios::binary);
ASSERT_TRUE(ifs.is_open()) << "Could not open an ifstream for the model path: " << path;
std::istream* is = &ifs;
Expand Down Expand Up @@ -67,8 +65,7 @@ TEST_P(FrontEndLoadFromTest, load_model_not_exists_at_path) {

TEST_P(FrontEndLoadFromTest, load_model_and_apply_ppp) {
auto model_file_path =
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, m_param.m_stream})
.string();
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, m_param.m_stream});

m_frontEnd = m_fem.load_by_model(model_file_path);
const auto fe_model = m_frontEnd->load(model_file_path);
Expand Down Expand Up @@ -102,7 +99,7 @@ using ::ONNX_NAMESPACE::Version;

TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoUint64) {
const auto path =
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "abs.onnx"}).string();
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "abs.onnx"});
std::ifstream ifs(path, std::ios::in | std::ios::binary);
ASSERT_TRUE(ifs.is_open()) << "Could not open an ifstream for the model path: " << path;
std::vector<std::string> frontends;
Expand Down Expand Up @@ -130,7 +127,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoUint64) {

TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoUint64_Negative) {
const auto path =
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "abs.onnx"}).string();
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "abs.onnx"});
std::ifstream ifs(path, std::ios::in | std::ios::binary);
ASSERT_TRUE(ifs.is_open()) << "Could not open an ifstream for the model path: " << path;
std::vector<std::string> frontends;
Expand Down
10 changes: 5 additions & 5 deletions src/frontends/onnx/tests/onnx_importer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}).string());
test::utils::getModelFromTestModelZoo(util::path_join({TEST_ONNX_MODELS_DIRNAME, "addmul_abc.onnx"}));
std::ifstream model_file_stream(model_file_path, std::ifstream::binary);
ASSERT_TRUE(model_file_stream.is_open());
int count_adds = 0;
Expand All @@ -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"})));
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"})));
ASSERT_TRUE(model->has_rt_info("framework"));

const auto rtinfo = model->get_rt_info();
Expand Down
4 changes: 2 additions & 2 deletions src/frontends/onnx/tests/op_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}).string()));
ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"})));

std::shared_ptr<ov::Model> model;
EXPECT_NO_THROW(fe->convert(input_model));
Expand All @@ -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"}).string()));
ov::util::path_join({TEST_ONNX_MODELS_DIRNAME, "relu_custom_domain.onnx"})));

std::shared_ptr<ov::Model> model;
EXPECT_NO_THROW(fe->convert(input_model));
Expand Down
4 changes: 4 additions & 0 deletions src/tests/test_utils/common_test_utils/src/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ std::string getModelFromTestModelZoo(const std::string& relModelPath) {
return ov::util::path_join({getExecutableDirectory(), relModelPath}).string();
}

std::string getModelFromTestModelZoo(const std::filesystem::path& relModelPath) {
return ov::util::path_to_string(std::filesystem::path(getExecutableDirectory()) / relModelPath);
}
Comment thread
almilosz marked this conversation as resolved.
Comment on lines +177 to +179
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our existing tests operate on the assumption that getExecutableDirectory() does not contain Unicode characters. It's okay to use ov::util::make_path here and follow the convention in OpenVINO, but the paths in tests just do not contain Unicode characters.


std::string getRelativePath(const std::string& from, const std::string& to) {
auto split_path = [](const std::string& path) -> std::vector<std::string> {
std::string sep{FileTraits<char>::file_separator};
Expand Down
Loading