From 76c177384f18bf77be58da531db0117f9ef20eb8 Mon Sep 17 00:00:00 2001 From: Nikolay Shchegolev Date: Thu, 17 Oct 2024 12:57:16 +0400 Subject: [PATCH] 2 --- samples/cpp/benchmark_app/main.cpp | 2 ++ .../resolve_names_collisions.cpp | 2 +- .../openvino/core/attribute_visitor.hpp | 8 +++++++ src/core/src/attribute_visitor.cpp | 4 ++++ src/core/src/model.cpp | 1 + src/core/src/pass/serialize.cpp | 24 ++++++++++--------- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 2cfd15b77afb6e..c5640dba3aa6c4 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -568,6 +568,7 @@ int main(int argc, char* argv[]) { auto duration_ms = get_duration_ms_till_now(startTime); slog::info << "Compile model took " << double_to_string(duration_ms) << " ms" << slog::endl; slog::info << "Original model I/O parameters:" << slog::endl; +return 0; printInputAndOutputsInfoShort(compiledModel); if (statistics) @@ -746,6 +747,7 @@ int main(int argc, char* argv[]) { compiledModel = core.compile_model(model, device_name, device_config); duration_ms = get_duration_ms_till_now(startTime); slog::info << "Compile model took " << double_to_string(duration_ms) << " ms" << slog::endl; +return 0; if (statistics) statistics->add_parameters( StatisticsReport::Category::EXECUTION_RESULTS, diff --git a/src/common/transformations/src/transformations/resolve_names_collisions.cpp b/src/common/transformations/src/transformations/resolve_names_collisions.cpp index f6472dbc2aedcd..7a09ca13f1c7f8 100644 --- a/src/common/transformations/src/transformations/resolve_names_collisions.cpp +++ b/src/common/transformations/src/transformations/resolve_names_collisions.cpp @@ -18,7 +18,7 @@ void collect_name_collisions_map(const std::shared_ptr& model, // Collect a names collision map for all nodes in the graph const auto& friendly_name = node->get_friendly_name(); name_collisions_map[friendly_name].emplace_back(node.get()); - if (auto msn = ov::as_type_ptr(node)) { + if (auto msn = ov::as_type(node.get())) { for (const auto& body : msn->get_functions()) { collect_name_collisions_map(body, name_collisions_map); } diff --git a/src/core/include/openvino/core/attribute_visitor.hpp b/src/core/include/openvino/core/attribute_visitor.hpp index a2c6ebdd985980..71b4d8e0123a7e 100644 --- a/src/core/include/openvino/core/attribute_visitor.hpp +++ b/src/core/include/openvino/core/attribute_visitor.hpp @@ -99,6 +99,13 @@ class OPENVINO_API AttributeVisitor { /// The generic visitor. There must be a definition of AttributeAdapter that can convert /// to a ValueAccessor for one of the on_adpater methods. + //template + //void on_attribute(const char* name, AT& value) { + // AttributeAdapter adapter(value); + // start_structure(name); + // on_adapter(get_name_with_context(), adapter); + // finish_structure(); + //} template void on_attribute(const std::string& name, AT& value) { AttributeAdapter adapter(value); @@ -114,6 +121,7 @@ class OPENVINO_API AttributeVisitor { virtual std::string get_name_with_context(); /// \brief Start visiting a nested structure virtual void start_structure(const std::string& name); + //virtual void start_structure(const char* name); /// \brief Finish visiting a nested structure virtual std::string finish_structure(); using node_id_t = std::string; diff --git a/src/core/src/attribute_visitor.cpp b/src/core/src/attribute_visitor.cpp index ed2c86d8476722..d366e75d2f8f18 100644 --- a/src/core/src/attribute_visitor.cpp +++ b/src/core/src/attribute_visitor.cpp @@ -14,6 +14,10 @@ void ov::AttributeVisitor::start_structure(const string& name) { m_context.push_back(name); } +//void ov::AttributeVisitor::start_structure(const char* name) { +// m_context.push_back(name); +//} + string ov::AttributeVisitor::finish_structure() { string result = m_context.back(); m_context.pop_back(); diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index 1493d950cd78ef..df0751af23ba13 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -305,6 +305,7 @@ std::vector> ov::Model::get_ordered_ops() const { NodeVector nodes; if (m_shared_rt_info->get_use_topological_cache()) { + nodes.reserve(m_cached_ordered_ops.size()); for (const auto& node : m_cached_ordered_ops) { if (auto locked_node = node.lock()) { nodes.emplace_back(locked_node); diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp index 929eed2bf2cd3f..79ce9961fb25dc 100644 --- a/src/core/src/pass/serialize.cpp +++ b/src/core/src/pass/serialize.cpp @@ -429,11 +429,11 @@ class XmlSerializer : public ov::AttributeVisitor { void on_adapter(const std::string& name, ov::ValueAccessor& adapter) override { using BodyTargetNames = std::tuple>; - - const std::vector body_names = { + static const BodyTargetNames body_names[3] = { BodyTargetNames{"body", "port_map", {"input_descriptions", "output_descriptions", "special_body_ports"}}, BodyTargetNames{"then_body", "then_port_map", {"then_inputs", "then_outputs"}}, - BodyTargetNames{"else_body", "else_port_map", {"else_inputs", "else_outputs"}}}; + BodyTargetNames{"else_body", "else_port_map", {"else_inputs", "else_outputs"}} + }; BodyTargetNames bnames; bool is_body_target = false; for (const auto& _body_target : body_names) { @@ -448,18 +448,21 @@ class XmlSerializer : public ov::AttributeVisitor { } } if (!is_body_target) { - std::string id = "input_descriptions"; - std::string od = "output_descriptions"; - const auto& id_pos = name.find("input_descriptions"); - const auto& od_pos = name.find("output_descriptions"); + static const char* id = "input_descriptions"; + static const char* od = "output_descriptions"; + static const size_t id_len = strlen(id); + static const size_t od_len = strlen(id); + + const auto& id_pos = name.find(id); + const auto& od_pos = name.find(od); auto id_str = name; size_t body_id; if (id_pos != std::string::npos) { - id_str.erase(id_pos, id.length()); + id_str.erase(id_pos, id_len); (void)std::stoi(id_str, &body_id); is_body_target = true; } else if (od_pos != std::string::npos) { - id_str.erase(od_pos, od.length()); + id_str.erase(od_pos, od_len); (void)std::stoi(id_str, &body_id); is_body_target = true; } @@ -467,8 +470,7 @@ class XmlSerializer : public ov::AttributeVisitor { auto body_name = "body" + id_str; if (m_xml_node.parent().child(body_name.c_str())) { bnames = BodyTargetNames{body_name, - "port_map" + id_str, - {"input_descriptions" + id_str, "output_descriptions" + id_str}}; + "port_map" + id_str, {id + id_str, od + id_str}}; } else { is_body_target = false; }