Skip to content

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

[core] Migrate frontends/ir/src/ to std::filesystem::path (#34925)

Alicja Miloszewskac9178de3cfb0
diff --git a/src/frontends/ir/src/frontend.cpp b/src/frontends/ir/src/frontend.cpp
index 37199930ff2..5337bed0210 100644
--- a/src/frontends/ir/src/frontend.cpp
+++ b/src/frontends/ir/src/frontend.cpp
@@ -163,7 +163,7 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
return exts;
};
- auto create_input_model = [&](std::string weights_path) -> std::shared_ptr<InputModel> {
+ auto create_input_model = [&](std::filesystem::path weights_path) -> std::shared_ptr<InputModel> {
if (provided_model_stream) {
return std::make_shared<InputModel>(*provided_model_stream,
weights,
@@ -243,7 +243,7 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
}
}
- return create_input_model(ov::util::path_to_string(weights_path));
+ return create_input_model(std::move(weights_path));
}
std::shared_ptr<ov::Model> FrontEnd::convert(const InputModel::Ptr& model) const {
diff --git a/src/frontends/ir/src/input_model.cpp b/src/frontends/ir/src/input_model.cpp
index 3794880df41..ac05973fa15 100644
--- a/src/frontends/ir/src/input_model.cpp
+++ b/src/frontends/ir/src/input_model.cpp
@@ -208,13 +208,13 @@ class InputModel::InputModelIRImpl {
std::unordered_map<std::string, ov::OpSet> m_opsets;
pugi::xml_node m_root;
pugi::xml_document m_xml_doc;
- std::string m_weights_path;
+ std::filesystem::path m_weights_path;
public:
InputModelIRImpl(std::istream& model,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path)
+ std::filesystem::path weights_path)
: m_weights(weights),
m_extensions(extensions),
m_weights_path(std::move(weights_path)) {
@@ -226,7 +226,7 @@ public:
InputModelIRImpl(const std::shared_ptr<ov::AlignedBuffer>& model,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path)
+ std::filesystem::path weights_path)
: m_weights(weights),
m_extensions(extensions),
m_weights_path(std::move(weights_path)) {
@@ -249,14 +249,14 @@ private:
InputModel::InputModel(std::istream& model,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path) {
+ std::filesystem::path weights_path) {
_impl = std::make_shared<InputModelIRImpl>(model, weights, extensions, std::move(weights_path));
}
InputModel::InputModel(const std::shared_ptr<ov::AlignedBuffer>& model,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path) {
+ std::filesystem::path weights_path) {
_impl = std::make_shared<InputModelIRImpl>(model, weights, extensions, std::move(weights_path));
}
@@ -274,7 +274,7 @@ std::shared_ptr<ov::Model> InputModel::InputModelIRImpl::convert() {
visitor.on_attribute("net", model);
model->get_rt_info()["version"] = int64_t(version);
if (!m_weights_path.empty())
- model->get_rt_info()["__weights_path"] = m_weights_path;
+ model->get_rt_info()["__weights_path"] = ov::util::path_to_string(m_weights_path);
parse_pre_process(m_root, m_weights, model);
return model;
diff --git a/src/frontends/ir/src/input_model.hpp b/src/frontends/ir/src/input_model.hpp
index 98e3a0f4dfd..790c577a743 100644
--- a/src/frontends/ir/src/input_model.hpp
+++ b/src/frontends/ir/src/input_model.hpp
@@ -4,8 +4,10 @@
#pragma once
+#include <filesystem>
#include <istream>
#include <memory>
+#include <unordered_map>
#include "openvino/frontend/manager.hpp"
#include "openvino/frontend/visibility.hpp"
@@ -23,12 +25,12 @@ public:
InputModel(std::istream& stream,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path = {});
+ std::filesystem::path weights_path = {});
InputModel(const std::shared_ptr<ov::AlignedBuffer>& model_buf,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
- std::string weights_path = {});
+ std::filesystem::path weights_path = {});
std::shared_ptr<Model> convert();
};