#include <sstream>
#include "DotOperandInfo.h"
+#include "graph/operand/LowerInfo.h"
+#include "backend/interface/IConfig.h"
+#include "backend/BackendManager.h"
namespace neurun
{
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
std::string DotOperandInfo::label() const
{
std::stringstream ss;
- ss << _index.value();
+ ss << _index.value() << std::endl;
for (auto label : _labels)
{
ss << label << std::endl;
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
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,
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;