OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[core] Fix for nullptr bin_path in read_model() (#34658)
Alicja Miloszewska7e5c0d9a4673
diff --git a/src/inference/include/openvino/runtime/core.hpp b/src/inference/include/openvino/runtime/core.hppindex 6c61c99005d..d9d2dfe390a 100644--- a/src/inference/include/openvino/runtime/core.hpp+++ b/src/inference/include/openvino/runtime/core.hpp@@ -120,7 +120,17 @@ public:std::shared_ptr<ov::Model> read_model(const Path& model_path,const Path& bin_path = {},const ov::AnyMap& properties = {}) const {- if constexpr (std::is_constructible_v<std::string, Path>) {+ if constexpr (std::is_pointer_v<Path>) {+ if constexpr (std::is_constructible_v<std::string, Path>) {+ return read_model(std::string(model_path),+ bin_path ? std::string(bin_path) : std::string{},+ properties);+ } else {+ return read_model(std::wstring(model_path),+ bin_path ? std::wstring(bin_path) : std::wstring{},+ properties);+ }+ } else if constexpr (std::is_constructible_v<std::string, Path>) {return read_model(std::string(model_path), std::string(bin_path), properties);} else if constexpr (std::is_constructible_v<std::wstring, Path>) {return read_model(std::wstring(model_path), std::wstring(bin_path), properties);diff --git a/src/inference/tests/functional/ov_core_test.cpp b/src/inference/tests/functional/ov_core_test.cppindex 9ac072a9051..1cb429fb0b6 100644--- a/src/inference/tests/functional/ov_core_test.cpp+++ b/src/inference/tests/functional/ov_core_test.cpp@@ -187,7 +187,27 @@ TEST_F(CoreBaseTest, read_model_with_std_fs_path_unicode) {}}}++TEST_F(CoreBaseTest, read_model_with_const_wchar_path) {+ generate_test_model_files("test-model");++ ov::Core core;+ const std::wstring model_path_w = ov::util::string_to_wstring(model_file_name);+ const wchar_t* model_path = model_path_w.c_str();+ const auto model = core.read_model(model_path);+ EXPECT_NE(model, nullptr);+}#endif++TEST_F(CoreBaseTest, read_model_with_const_char_path) {+ generate_test_model_files("test-model");++ ov::Core core;+ const char* model_path = model_file_name.c_str();+ const auto model = core.read_model(model_path);+ EXPECT_NE(model, nullptr);+}+namespace ov::test {TEST_F(CoreBaseTest, read_model_with_std_fs_path) {generate_test_model_files("test-model");