From 6509d3d41b6233eb3e25f4f31b2d0644ccf2d820 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 19 Jul 2019 16:52:14 +0900 Subject: [PATCH] [dotdump] Show Backend ID for each Subgraph (#5716) This commit makes it to show Backend ID for each Subgraph. `fillcolor` member is introduced but not used yet. Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/src/dumper/dot/DotBuilder.cc | 4 ++-- runtimes/neurun/core/src/dumper/dot/DotDumper.cc | 10 ++++++++-- runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.cc | 8 -------- runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.h | 8 +++++++- runtimes/neurun/core/src/dumper/dot/Node.cc | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/runtimes/neurun/core/src/dumper/dot/DotBuilder.cc b/runtimes/neurun/core/src/dumper/dot/DotBuilder.cc index 143c810..8563b4c 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotBuilder.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotBuilder.cc @@ -37,8 +37,8 @@ void DotBuilder::update(const Node &node_info) void DotBuilder::addSubgraph(const DotSubgraphInfo &subgraph_info) { - _dot << "subgraph cluster_" << subgraph_info.index_str() << " {\n"; - _dot << " label=\"" << subgraph_info.index_str() << "\";\n"; + _dot << "subgraph cluster_" << subgraph_info.index().value() << " {\n"; + _dot << " label=\"" << subgraph_info.label() << "\";\n"; _dot << " style=filled;\n"; _dot << " color=lightgrey;\n"; _dot << " "; diff --git a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc index 338d2f8..2c522cd 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc @@ -141,17 +141,23 @@ void DotDumper::dumpIfNeeded(const std::string &tag) if (subgraphs) { subgraphs->iterate([&](const model::SubgraphIndex &index, const model::Subgraph &subgraph) { + const auto lower_info = _graph.getLowerInfo(index); + auto fillcolor = backend_to_fillcolor(lower_info->backend()); + std::string label = + std::to_string(index.value()) + " [" + lower_info->backend()->config()->id() + "]"; DotSubgraphInfo subgraph_info{index, subgraph, shown_operand_set}; + subgraph_info.label(label); + subgraph_info.fillcolor(fillcolor); dot_builder.addSubgraph(subgraph_info); + // Set fillcolor of all operations in the subgraph - const auto lower_info = _graph.getLowerInfo(index); for (const auto &op : subgraph.operations()) { auto found = operation_nodes.find(op.index); if (found != operation_nodes.end()) { auto &&op = found->second; - op->setAttribute("fillcolor", backend_to_fillcolor(lower_info->backend())); + op->setAttribute("fillcolor", fillcolor); } } }); diff --git a/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.cc b/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.cc index 13cee04..1ea681b 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.cc @@ -51,14 +51,6 @@ DotSubgraphInfo::DotSubgraphInfo(const model::SubgraphIndex &index, const model: } } -std::string DotSubgraphInfo::index_str() const -{ - std::stringstream ss; - ss << _index.value(); - - return ss.str(); -} - } // namespace dot } // namespace dumper } // namespace neurun diff --git a/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.h b/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.h index 659290f..771c555 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.h +++ b/runtimes/neurun/core/src/dumper/dot/DotSubgraphInfo.h @@ -36,12 +36,18 @@ public: DotSubgraphInfo(const model::SubgraphIndex &index, const model::Subgraph &subgraph, const util::Set &shown_operands); - std::string index_str() const; + model::SubgraphIndex index() const { return _index; } + std::string label() const { return _label; } + void label(const std::string &val) { _label = val; } + std::string fillcolor() const { return _fillcolor; } + void fillcolor(const std::string &val) { _fillcolor = val; } const std::unordered_set &operations() const { return _operations; } const std::unordered_set &operands() const { return _operands; } private: model::SubgraphIndex _index; + std::string _label; + std::string _fillcolor; std::unordered_set _operations; std::unordered_set _operands; }; diff --git a/runtimes/neurun/core/src/dumper/dot/Node.cc b/runtimes/neurun/core/src/dumper/dot/Node.cc index e4e43da..166f0f4 100644 --- a/runtimes/neurun/core/src/dumper/dot/Node.cc +++ b/runtimes/neurun/core/src/dumper/dot/Node.cc @@ -25,7 +25,7 @@ namespace dot const std::string Node::DEFAULT_COLORSCHEME = "x11"; const std::string Node::DEFAULT_FILLCOLOR = "white"; -// RED BLUE ORANGE YELLOW GREEN PUPLE CYAN PINK +// RED, BLUE, GREEN, PURPLE, ORANGE, YELLOW, BROWN, PINK const std::string Node::BG_COLORS[8] = {"1", "2", "3", "4", "5", "6", "7", "8"}; Node::Node(const std::string &id) : _id{id} -- 2.7.4