#include "model/Subgraph.h"
#include "model/OperationIndexMap.h"
#include "backend/Backend.h"
+#include "backend/BackendManager.h"
#include "backend/IConfig.h"
namespace neurun
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<const backend::Backend *, std::string> 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;
}
};