Skip to content

Commit

Permalink
Propagate weights_path as std::string unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrupa-intel committed Sep 2, 2024
1 parent 4e23a62 commit 6aef555
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 54 deletions.
8 changes: 4 additions & 4 deletions src/frontends/ir/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
return exts;
};

#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
auto create_input_model = [&](std::wstring& weights_path) -> std::shared_ptr<InputModel> {
#else
auto create_input_model = [&](std::string& weights_path) -> std::shared_ptr<InputModel> {
#endif
if (provided_model_stream) {
return std::make_shared<InputModel>(*provided_model_stream, weights, create_extensions_map(), weights_path);
} else if (local_model_stream.is_open()) {
Expand Down Expand Up @@ -241,7 +237,11 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
}
}

#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
return create_input_model(ov::util::wstring_to_string(weights_path));
#else
return create_input_model(weights_path);
#endif
}

std::shared_ptr<ov::Model> FrontEnd::convert(const InputModel::Ptr& model) const {
Expand Down
16 changes: 2 additions & 14 deletions src/frontends/ir/src/input_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,16 @@ class InputModel::InputModelIRImpl {
std::unordered_map<std::string, ov::OpSet> m_opsets;
pugi::xml_node m_root;
pugi::xml_document m_xml_doc;
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring m_weights_path;
#else
std::string m_weights_path;
#endif

public:
InputModelIRImpl(std::istream& stream,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring& m_weights_path)
#else
std::string& m_weights_path)
#endif
std::string& weights_path)
: m_weights(weights),
m_extensions(extensions),
m_weights_path(m_weights_path) {
m_weights_path(weights_path) {
pugi::xml_parse_result res = m_xml_doc.load(stream);
if (res.status != pugi::status_ok) {
OPENVINO_THROW(res.description(), " at offset ", res.offset);
Expand All @@ -239,11 +231,7 @@ class InputModel::InputModelIRImpl {
InputModel::InputModel(std::istream& stream,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path) {
#else
std::string weights_path) {
#endif
_impl = std::make_shared<InputModelIRImpl>(stream, weights, extensions, weights_path);
}

Expand Down
4 changes: 0 additions & 4 deletions src/frontends/ir/src/input_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ class InputModel : public ov::frontend::InputModel {
InputModel(std::istream& stream,
const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path = L"");
#else
std::string weights_path = "");
#endif

std::shared_ptr<Model> convert();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ class CompiledModel : public ov::ICompiledModel {
std::vector<ov::Output<const ov::Node>> m_outputs;
std::vector<std::shared_ptr<Graph>> m_graphs;
bool m_loaded_from_cache;
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring m_weights_path;
#else
std::string m_weights_path;
#endif
};

} // namespace intel_gpu
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ struct data : public primitive_base<data> {

size_t original_size = SIZE_MAX;
size_t bin_offset = SIZE_MAX;
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path = L"";
#else
std::string weights_path = "";
#endif

size_t hash() const override {
size_t seed = primitive::hash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ static constexpr Property<size_t, PropertyMutability::RW> max_dynamic_batch{"DYN
static constexpr Property<bool, PropertyMutability::RW> nv12_two_inputs{"GPU_NV12_TWO_INPUTS"};
static constexpr Property<float, PropertyMutability::RW> buffers_preallocation_ratio{"GPU_BUFFERS_PREALLOCATION_RATIO"};
static constexpr Property<size_t, PropertyMutability::RW> max_kernels_per_batch{"GPU_MAX_KERNELS_PER_BATCH"};
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
static constexpr Property<std::wstring, PropertyMutability::RW> weights_path{"GPU_WEIGHTS_PATH"};
#else
static constexpr Property<std::string, PropertyMutability::RW> weights_path{"GPU_WEIGHTS_PATH"};
#endif

} // namespace intel_gpu
} // namespace ov
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/intel_gpu/src/graph/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,11 +1723,7 @@ void program::cancel_compilation_context() {
}

void program::save(cldnn::BinaryOutputBuffer& ob) const {
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path;
#else
std::string weights_path;
#endif
weights_path = _config.get_property(ov::intel_gpu::weights_path);
ob << weights_path;

Expand Down Expand Up @@ -1846,11 +1842,7 @@ void program::save(cldnn::BinaryOutputBuffer& ob) const {
void program::load(cldnn::BinaryInputBuffer& ib) {
init_program();

#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::wstring weights_path;
#else
std::string weights_path;
#endif
ib >> weights_path;
ov::AnyMap weights_path_property{{"GPU_WEIGHTS_PATH", weights_path}};
_config.set_property(weights_path_property);
Expand Down
14 changes: 6 additions & 8 deletions src/plugins/intel_gpu/src/plugin/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ CompiledModel::CompiledModel(std::shared_ptr<ov::Model> model,
m_model_name(model->get_friendly_name()),
m_inputs(ov::ICompiledModel::inputs()),
m_outputs(ov::ICompiledModel::outputs()),
m_loaded_from_cache(false)
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
,
m_weights_path(model->get_rt_info()["weights_path"].as<std::wstring>()) {
#else
,
m_weights_path(model->get_rt_info()["weights_path"].as<std::string>()) {
#endif
m_loaded_from_cache(false) {
auto model_rt_info = model->get_rt_info();
auto weights_path = model_rt_info.find("weights_path");
if (weights_path != model_rt_info.end()) {
m_weights_path = weights_path->second.as<std::string>();
}
auto graph_base = std::make_shared<Graph>(model, m_context, m_config, 0);
for (uint16_t n = 0; n < m_config.get_property(ov::num_streams); n++) {
auto graph = n == 0 ? graph_base : std::make_shared<Graph>(graph_base, n);
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/intel_gpu/src/runtime/execution_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ void ExecutionConfig::set_default() {
std::make_tuple(ov::intel_gpu::use_only_static_kernels_for_dynamic_shape, false),
std::make_tuple(ov::intel_gpu::buffers_preallocation_ratio, 1.1f),
std::make_tuple(ov::intel_gpu::max_kernels_per_batch, 8),
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
std::make_tuple(ov::intel_gpu::weights_path, L""));
#else
std::make_tuple(ov::intel_gpu::weights_path, ""));
#endif
}

void ExecutionConfig::register_property_impl(const std::pair<std::string, ov::Any>& property, PropertyVisibility visibility, BaseValidator::Ptr validator) {
Expand Down

0 comments on commit 6aef555

Please sign in to comment.