{
auto index = generateIndex();
- _objects[index.asInt()] = nnfw::make_unique<Object>(shape, type);
+ _objects[index] = nnfw::make_unique<Object>(shape, type);
return index;
}
-const Object &Set::at(const Index &index) const { return *(_objects.at(index.asInt())); }
+const Object &Set::at(const Index &index) const { return *(_objects.at(index)); }
-Object &Set::at(const Index &index) { return *(_objects.at(index.asInt())); }
+Object &Set::at(const Index &index) { return *(_objects.at(index)); }
bool Set::exist(const Index &index) const { return index.value() < _objects.size(); }
#define __NEURUN_GRAPH_OPERAND_SET_H__
#include <memory>
-#include <map>
+#include <unordered_map>
#include "Object.h"
#include "Index.h"
const Index generateIndex();
private:
- std::map<uint32_t, std::unique_ptr<Object>> _objects;
+ std::unordered_map<Index, std::unique_ptr<Object>> _objects;
uint32_t _index_count;
};
{
auto index = generateIndex();
- _nodes[index.value()] = std::move(node);
+ _nodes[index] = std::move(node);
return index;
}
-const Node &Set::at(const Index &index) const { return *(_nodes.at(index.value())); }
+const Node &Set::at(const Index &index) const { return *(_nodes.at(index)); }
-Node &Set::at(const Index &index) { return *(_nodes.at(index.value())); }
+Node &Set::at(const Index &index) { return *(_nodes.at(index)); }
-bool Set::exist(const Index &index) const { return _nodes.find(index.value()) != _nodes.end(); }
+bool Set::exist(const Index &index) const { return _nodes.find(index) != _nodes.end(); }
void Set::iterate(const std::function<void(const Index &, const Node &)> &fn) const
{
for (auto it = _nodes.begin(); it != _nodes.end(); ++it)
{
- fn(Index{it->first}, *it->second);
+ fn(it->first, *it->second);
}
}
{
for (auto it = _nodes.begin(); it != _nodes.end(); ++it)
{
- fn(Index{it->first}, *it->second);
+ fn(it->first, *it->second);
}
}
#include "graph/operation/Index.h"
#include "Node.h"
-#include <map>
+#include <unordered_map>
namespace neurun
{
const Index generateIndex();
private:
- std::map<uint32_t, std::unique_ptr<Node>> _nodes;
+ std::unordered_map<Index, std::unique_ptr<Node>> _nodes;
uint32_t _index_count;
};
#define __INTERNAL_BACKEND_MANAGER_H__
#include <memory>
+#include <map>
#include "graph/operand/Set.h"