Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
nshchego committed Oct 17, 2024
1 parent fc8c636 commit 76c1773
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 12 deletions.
2 changes: 2 additions & 0 deletions samples/cpp/benchmark_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void collect_name_collisions_map(const std::shared_ptr<ov::Model>& 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<ov::op::util::MultiSubGraphOp>(node)) {
if (auto msn = ov::as_type<ov::op::util::MultiSubGraphOp>(node.get())) {
for (const auto& body : msn->get_functions()) {
collect_name_collisions_map(body, name_collisions_map);
}
Expand Down
8 changes: 8 additions & 0 deletions src/core/include/openvino/core/attribute_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ class OPENVINO_API AttributeVisitor {

/// The generic visitor. There must be a definition of AttributeAdapter<T> that can convert
/// to a ValueAccessor<U> for one of the on_adpater methods.
//template <typename AT>
//void on_attribute(const char* name, AT& value) {
// AttributeAdapter<AT> adapter(value);
// start_structure(name);
// on_adapter(get_name_with_context(), adapter);
// finish_structure();
//}
template <typename AT>
void on_attribute(const std::string& name, AT& value) {
AttributeAdapter<AT> adapter(value);
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/core/src/attribute_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ std::vector<shared_ptr<ov::Node>> 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);
Expand Down
24 changes: 13 additions & 11 deletions src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ class XmlSerializer : public ov::AttributeVisitor {

void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override {
using BodyTargetNames = std::tuple<std::string, std::string, std::vector<std::string>>;

const std::vector<BodyTargetNames> 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) {
Expand All @@ -448,27 +448,29 @@ 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;
}
if (is_body_target) {
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;
}
Expand Down

0 comments on commit 76c1773

Please sign in to comment.