Skip to content

Commit

Permalink
Validate model before serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
t-jankowski committed Aug 22, 2024
1 parent 486fd0b commit 8d50dba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,8 @@ namespace ov {
bool pass::Serialize::run_on_model(const std::shared_ptr<ov::Model>& model) {
RUN_ON_FUNCTION_SCOPE(Serialize);

model->validate_nodes_and_infer_types();

// TODO xxx-105807: if rt_info is set in python api as a string ['precise_0'] = '',
// we need to convert value to a class in order to have rt_info in the IR. The code below will convert
// ['precise_0'] = '' into => rt_info['precise_0'] = DisableFP16Compression{}
Expand Down
9 changes: 9 additions & 0 deletions src/core/tests/pass/serialization/cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ TEST_F(SerializationCleanupTest, SerializationShouldWorkWithDynamicFunction) {
ASSERT_TRUE(std::ifstream(m_out_xml_path, std::ios::in).good());
ASSERT_TRUE(std::ifstream(m_out_bin_path, std::ios::in).good());
}

TEST_F(SerializationCleanupTest, SerializationShouldNotWorkWithMissingParameter) {
const auto model = create_test_model("RemovedParameter", ov::PartialShape{2});
model->remove_parameter(model->get_parameters()[0]);

ASSERT_ANY_THROW(ov::pass::Serialize(m_out_xml_path, m_out_bin_path).run_on_model(model));
EXPECT_FALSE(std::ifstream(m_out_xml_path, std::ios::in).good());
EXPECT_FALSE(std::ifstream(m_out_bin_path, std::ios::in).good());
}

0 comments on commit 8d50dba

Please sign in to comment.