Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ov::serialize(model) does not report when file writing fails #23281

Closed
wants to merge 39 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5b75352
adding error msg issue #23190
mishra-18 Mar 5, 2024
e36b073
Merge branch 'master' into master
mishra-18 Mar 6, 2024
abca81b
Droped catch block for ofstream
mishra-18 Mar 6, 2024
b30d556
Merge branch 'master' into master
mishra-18 Mar 6, 2024
488404f
Merge branch 'openvinotoolkit:master' into master
mishra-18 Mar 18, 2024
1b79745
made changes in serialize.cpp, added test
mishra-18 Mar 20, 2024
53ba3e1
made changes added test
mishra-18 Mar 20, 2024
6ccab12
Merge branch 'openvinotoolkit:master' into master
mishra-18 Mar 20, 2024
24dfc7c
updated serialize.cpp
mishra-18 Mar 20, 2024
592a914
made review changes
mishra-18 Mar 20, 2024
ff2ea21
Merge branch 'master' into master
mishra-18 Apr 11, 2024
6a20ee1
Merge branch 'master' into master
mlukasze May 20, 2024
735f41b
Update src/core/tests/pass/serialization/serialize.cpp
mishra-18 Jun 8, 2024
d86d8e3
Update src/core/tests/pass/serialization/serialize.cpp
mishra-18 Jun 8, 2024
22c16f6
Update src/core/tests/pass/serialization/serialize.cpp
mishra-18 Jun 8, 2024
b85f4b1
Merge branch 'master' into master
mishra-18 Jun 9, 2024
6b8f83b
Updated TEST in serialize.cpp
mishra-18 Jun 10, 2024
7be4be5
Update serialize.cpp
mishra-18 Jun 11, 2024
a248220
Merge branch 'master' into master
mishra-18 Jun 11, 2024
8af61f8
Merge branch 'master' into master
mlukasze Jun 18, 2024
e4214a6
Merge branch 'master' into master
mishra-18 Jul 8, 2024
1768525
ran through clang-format
mishra-18 Jul 8, 2024
41f6ab9
Merge branch 'master' into master
mishra-18 Jul 8, 2024
e8a0589
Merge branch 'master' into master
mishra-18 Jul 14, 2024
2b99598
Merge branch 'master' into master
mlukasze Jul 25, 2024
3792a68
Merge branch 'master' into master
mlukasze Jul 29, 2024
8787f5f
Merge branch 'master' into master
mlukasze Jul 30, 2024
c0d2571
Merge branch 'master' into master
p-durandin Aug 7, 2024
6cdd132
Merge branch 'master' into master
p-durandin Sep 2, 2024
adb2b4a
Merge branch 'master' into master
mlukasze Sep 17, 2024
b0a3a7f
Merge branch 'master' into master
mlukasze Sep 18, 2024
cf85bb1
Merge branch 'master' into master
mlukasze Sep 18, 2024
01a91c3
Merge branch 'master' into master
mishra-18 Oct 7, 2024
bcc6b9f
Merge branch 'master' into master
mishra-18 Oct 7, 2024
3eba490
Merge branch 'master' into master
mlukasze Nov 4, 2024
b8ac5ce
Merge branch 'master' into master
mlukasze Nov 6, 2024
91dd6b3
Merge branch 'master' into master
mlukasze Nov 21, 2024
6b67b12
Merge branch 'master' into master
praasz Nov 21, 2024
b5c9b02
Merge branch 'master' into master
mlukasze Dec 5, 2024
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
32 changes: 19 additions & 13 deletions src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,21 +1229,27 @@ bool pass::Serialize::run_on_model(const std::shared_ptr<ov::Model>& model) {
if (xmlDir != m_xmlPath)
ov::util::create_directory_recursive(xmlDir);

std::ofstream bin_file(m_binPath, std::ios::out | std::ios::binary);
OPENVINO_ASSERT(bin_file, "Can't open bin file: \"" + m_binPath + "\"");

// create xml file
std::ofstream xml_file(m_xmlPath, std::ios::out);
OPENVINO_ASSERT(xml_file, "Can't open xml file: \"" + m_xmlPath + "\"");

try {
// create bin file
std::ofstream bin_file(m_binPath, std::ios::out | std::ios::binary);
bin_file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
OPENVINO_ASSERT(bin_file, "Can't open bin file: \"" + m_binPath + "\"");

// create xml file
std::ofstream xml_file(m_xmlPath, std::ios::out);
xml_file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
OPENVINO_ASSERT(xml_file, "Can't open xml file: \"" + m_xmlPath + "\"");
mishra-18 marked this conversation as resolved.
Show resolved Hide resolved

serializeFunc(xml_file, bin_file, model, m_version);
} catch (const ov::AssertFailure&) {
// optimization decision was made to create .bin file upfront and
// write to it directly instead of buffering its content in memory,
// hence we need to delete it here in case of failure
xml_file.close();
bin_file.close();
} catch (const std::ofstream::failure& e) {
mlukasze marked this conversation as resolved.
Show resolved Hide resolved
// Handle file stream errors
std::cerr << "Exception opening/writing file. Not Enough Space in disk: " << e.what() << '\n';
mlukasze marked this conversation as resolved.
Show resolved Hide resolved
std::remove(m_xmlPath.c_str());
std::remove(m_binPath.c_str());
ilya-lavrenov marked this conversation as resolved.
Show resolved Hide resolved
throw;
} catch (const ov::AssertFailure& e) {
vurusovs marked this conversation as resolved.
Show resolved Hide resolved
// Handle other any exceptions
std::cerr << "OpenVINO assertion failed: " << e.what() << '\n';
std::remove(m_xmlPath.c_str());
std::remove(m_binPath.c_str());
throw;
Expand Down
Loading