From 494091e01241f7536991c493e33ab694f3ccbb5a Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Fri, 27 Aug 2021 09:56:56 +0300 Subject: [PATCH] Try to fix Serialize --- .../src/transformations/serialize.cpp | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/inference-engine/src/transformations/src/transformations/serialize.cpp b/inference-engine/src/transformations/src/transformations/serialize.cpp index 3fbb1463f088bf..b10c5da24fa38c 100644 --- a/inference-engine/src/transformations/src/transformations/serialize.cpp +++ b/inference-engine/src/transformations/src/transformations/serialize.cpp @@ -811,8 +811,34 @@ void ngfunction_2_irv10(pugi::xml_node& netXml, f.validate_nodes_and_infer_types(); } } + +std::string valid_xml_path(const std::string &path) { + NGRAPH_CHECK(path.length() > 4, "Path for xml file is to short: \"" + path + "\""); + + const char *const extension = ".xml"; + const bool has_xml_extension = path.rfind(extension) == path.size() - std::strlen(extension); + NGRAPH_CHECK(has_xml_extension, + "Path for xml file doesn't contains file name with 'xml' extension: \"" + + path + "\""); + return path; +} + +std::string provide_bin_path(const std::string &xmlPath, const std::string &binPath) { + if (!binPath.empty()) { + return binPath; + } + assert(xmlPath.size() > 4); // should be check by valid_xml_path + std::string bestPath = xmlPath; + const char *const extension = "bin"; + const auto ext_size = std::strlen(extension); + bestPath.replace(bestPath.size() - ext_size, ext_size, extension); + return bestPath; +} + } // namespace +namespace ngraph { + // ! [function_pass:serialize_cpp] // serialize.cpp bool pass::Serialize::run_on_function(std::shared_ptr f) { @@ -868,33 +894,6 @@ bool pass::Serialize::run_on_function(std::shared_ptr f) { return false; } -namespace { - -std::string valid_xml_path(const std::string &path) { - NGRAPH_CHECK(path.length() > 4, "Path for xml file is to short: \"" + path + "\""); - - const char *const extension = ".xml"; - const bool has_xml_extension = path.rfind(extension) == path.size() - std::strlen(extension); - NGRAPH_CHECK(has_xml_extension, - "Path for xml file doesn't contains file name with 'xml' extension: \"" + - path + "\""); - return path; -} - -std::string provide_bin_path(const std::string &xmlPath, const std::string &binPath) { - if (!binPath.empty()) { - return binPath; - } - assert(xmlPath.size() > 4); // should be check by valid_xml_path - std::string bestPath = xmlPath; - const char *const extension = "bin"; - const auto ext_size = std::strlen(extension); - bestPath.replace(bestPath.size() - ext_size, ext_size, extension); - return bestPath; -} - -} // namespace - pass::Serialize::Serialize(std::ostream& xmlFile, std::ostream& binFile, pass::Serialize::Version version, @@ -921,3 +920,4 @@ pass::Serialize::Serialize(const std::string& xmlPath, { } // ! [function_pass:serialize_cpp] +} // namespace ngraph