From 92365ce6468173c1c355b93e183db470966ff2af 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: Thu, 8 Aug 2019 11:27:18 +0900 Subject: [PATCH] [neurun] Enhance DotDumper backend color assign (#6368) Enhance DotDumper backend color assignment. Each Backend will have its unique color up to 8 of them. Before it was assigned based on hard-coded Backend ID. Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/src/dumper/dot/DotDumper.cc | 27 +++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc index f20713d..bf147b7 100644 --- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc +++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc @@ -23,6 +23,7 @@ #include "model/Subgraph.h" #include "model/OperationIndexMap.h" #include "backend/Backend.h" +#include "backend/BackendManager.h" #include "backend/IConfig.h" namespace neurun @@ -62,20 +63,26 @@ void DotDumper::dump(const std::string &tag) operation_nodes.emplace(index, std::move(node)); }); - auto backend_to_fillcolor = [](const neurun::backend::Backend *backend) { - std::string backend_id = backend->config()->id(); - // TODO : This is just workaround it can be made more efficient. - if (backend_id == "acl_cl") - { - return OperandNode::BG_COLORS[BLUE]; - } - else if (backend_id == "cpu") + auto backend_to_fillcolor = [](const backend::Backend *backend) { + static const auto map = []() { + std::unordered_map ret; + uint32_t index = 1; // Start from 1 to avoid 0(red) which is too dark :( + for (const auto backend : backend::BackendManager::instance().getAll()) + { + ret.emplace(backend, OperandNode::BG_COLORS[index]); + index = (index + 1) % (sizeof(Node::BG_COLORS) / sizeof(Node::BG_COLORS[0])); + } + return ret; + }(); + + auto itr = map.find(backend); + if (itr == map.end()) { - return OperandNode::BG_COLORS[GREEN]; + return Node::DEFAULT_FILLCOLOR; } else { - return Node::DEFAULT_FILLCOLOR; + return itr->second; } }; -- 2.7.4