From 4e20e75bdcce3c208aae733bbec9800357415f5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=88=98=EC=A7=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 18 Oct 2018 20:22:38 +0900 Subject: [PATCH] [neurun] Make DotDumper to show backend info for operands (#3240) Related : #3236 This commit makes `DotDumper` to show backend info for operands. Signed-off-by: sjsujinkim --- runtimes/neurun/src/dumper/dot/DotOperandInfo.cc | 53 +++++++++++++++++++++++- runtimes/neurun/src/dumper/dot/DotOperandInfo.h | 6 +++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc b/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc index 7c30181..d7dc443 100644 --- a/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc +++ b/runtimes/neurun/src/dumper/dot/DotOperandInfo.cc @@ -17,6 +17,9 @@ #include #include "DotOperandInfo.h" +#include "graph/operand/LowerInfo.h" +#include "backend/interface/IConfig.h" +#include "backend/BackendManager.h" namespace neurun { @@ -27,12 +30,19 @@ namespace dot const std::string DotOperandInfo::INPUT_SHAPE = "Mdiamond"; const std::string DotOperandInfo::OPERAND_SHAPE = "ellipse"; +// TODO : Change brewer color schemes (8 colors) +const std::string DotOperandInfo::BG_COLOR1 = "pink"; +const std::string DotOperandInfo::BG_COLOR2 = "lightblue1"; DotOperandInfo::DotOperandInfo(const neurun::graph::operand::Index &index, const neurun::graph::operand::Object &object) : _index(index), _object(object) { - // DO NOTHING + const auto &lower_info = object.lower_info(); + if (lower_info) + { + addBackendLabel(); + } } std::string DotOperandInfo::index_str() const @@ -46,7 +56,7 @@ std::string DotOperandInfo::index_str() const std::string DotOperandInfo::label() const { std::stringstream ss; - ss << _index.value(); + ss << _index.value() << std::endl; for (auto label : _labels) { ss << label << std::endl; @@ -65,6 +75,45 @@ std::string DotOperandInfo::dot_shape() const return OPERAND_SHAPE; } +std::string DotOperandInfo::bg_color() const +{ + const auto &lower_info = _object.lower_info(); + if (!lower_info) + return DEFAULT_BG_COLOR; + assert(lower_info != nullptr); + const auto &def_backends = lower_info->def_backends(); + assert(def_backends.size() == 1); + + std::string backend_id = def_backends.getOnlyElement()->config()->id(); + // TODO : This is just workaround it can be made more efficient. + if (backend_id == "acl_cl") + { + return BG_COLOR1; + } + else if (backend_id == "cpu") + { + return BG_COLOR2; + } + else + { + return DEFAULT_BG_COLOR; + } +} + +void DotOperandInfo::addBackendLabel() +{ + std::string label; + const auto &lower_info = _object.lower_info(); + assert(lower_info != nullptr); + const auto &def_backends = lower_info->def_backends(); + assert(def_backends.size() == 1); + + label += "["; + label += def_backends.getOnlyElement()->config()->id(); + label += "]"; + _labels.emplace_back(label); +} + } // namespace dot } // namespace dumper } // namespace neurun diff --git a/runtimes/neurun/src/dumper/dot/DotOperandInfo.h b/runtimes/neurun/src/dumper/dot/DotOperandInfo.h index a5ebe2e..39fe5d5 100644 --- a/runtimes/neurun/src/dumper/dot/DotOperandInfo.h +++ b/runtimes/neurun/src/dumper/dot/DotOperandInfo.h @@ -35,6 +35,8 @@ class DotOperandInfo : public IDotInfo public: static const std::string INPUT_SHAPE; static const std::string OPERAND_SHAPE; + static const std::string BG_COLOR1; + static const std::string BG_COLOR2; public: DotOperandInfo(const neurun::graph::operand::Index &index, @@ -44,6 +46,10 @@ public: virtual std::string index_str() const override; virtual std::string label() const override; virtual std::string dot_shape() const override; + virtual std::string bg_color() const override; + +private: + void addBackendLabel(); private: const neurun::graph::operand::Index &_index; -- 2.7.4