Skip to content

Commit

Permalink
Use real world test case
Browse files Browse the repository at this point in the history
  • Loading branch information
t-jankowski committed Sep 23, 2024
1 parent be5358b commit 8360e8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/frontends/ir/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,18 @@ size_t get_ir_version(std::istream& model) {
pugi::xml_document doc;

// For dominant number of IRs `load_buffer' in this case returns parsing-error as 512 is not enough for the whole
// root tag. Basing on Pugi manual "If parsing failed because the source data was not a valid XML, the resulting
// root node. Basing on Pugi manual "If parsing failed because the source data was not a valid XML, the resulting
// tree is not destroyed - despite the fact that load function returns error, you can use the part of the tree that
// was successfully parsed." root tag is processed as typically it's enough to read model version. However if IR is
// small enough to fit 512 bytes ok-status is returned. Thus ignoring returned value.
// was successfully parsed." root node is processed because it should be enough to read model version. However if IR
// is small enough to fit 512 bytes ok-status is returned. Thus ignoring returned value.
std::ignore =
doc.load_buffer(header.data(), header.size(), pugi::parse_default | pugi::parse_fragment, pugi::encoding_utf8);

auto ir_version = get_ir_version(doc);

// In case attribute name is very long and placed before version attribute the latter is not accesible within first
// 512 bytes, so read the whole stream and try to obtain version value.
// In case attribute name is very long and placed before version attribute of root node or there is long comment
// node before root node then version attribute of root node is not accesible within first 512 bytes, so read the
// whole stream and try to obtain version value.
if (ir_version == 0) {
if (doc.load(model))
ir_version = get_ir_version(doc);
Expand Down
5 changes: 3 additions & 2 deletions src/frontends/ir/tests/frontend_test_basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,10 +1524,11 @@ TEST_F(IRFrontendTests, load_model_weights_not_exist_at_path) {
std::remove(model_file_path.c_str());
}

TEST_F(IRFrontendTests, VeryLongModelName) {
TEST_F(IRFrontendTests, LongComment) {
std::string testModel = R"V0G0N(
<?xml version="1.0"?>
<net name="VeryLongModelName....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................." version="11">
<!-- Long comment ............................................................................................................................................................................................................................................................................................................................................................................................................................................................ -->
<net name="IR with long comment" version="11">
<layers>
<layer id="0" name="Parameter_1" type="Parameter" version="opset1">
<data shape="2" element_type="f16" />
Expand Down

0 comments on commit 8360e8d

Please sign in to comment.