summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>2019-04-17 01:10:19 (GMT)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2019-04-17 01:10:19 (GMT)
commit1db63a49d107e595e324744e2de01fe8c51a1b86 (patch)
tree4b6cefe2a322b8780c856ec05f9802b0190b24fc
parent23be4330f239bca3b56670b4cfc3f029acb90a1a (diff)
downloadnnfw-1db63a49d107e595e324744e2de01fe8c51a1b86.zip
nnfw-1db63a49d107e595e324744e2de01fe8c51a1b86.tar.gz
nnfw-1db63a49d107e595e324744e2de01fe8c51a1b86.tar.bz2
Fix OperationIndex build break from Subgraph (#5012)
It fixes build-break caused by Subgraph's use of model::operation::Index, which is renamed to model::OperationIndex. Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
-rw-r--r--runtimes/neurun/core/include/model/operation/SubgraphContext.h35
-rw-r--r--runtimes/neurun/core/src/model/operation/SubgraphContext.cc33
2 files changed, 40 insertions, 28 deletions
diff --git a/runtimes/neurun/core/include/model/operation/SubgraphContext.h b/runtimes/neurun/core/include/model/operation/SubgraphContext.h
index 100f7b2..4a0e0e2 100644
--- a/runtimes/neurun/core/include/model/operation/SubgraphContext.h
+++ b/runtimes/neurun/core/include/model/operation/SubgraphContext.h
@@ -23,6 +23,8 @@
#include <unordered_map>
+using neurun::model::OperationIndex;
+
namespace neurun
{
namespace model
@@ -36,24 +38,27 @@ public:
SubgraphContext() : _index_count(0) {}
public:
- Index append(std::unique_ptr<Subgraph> &&subg);
- Index append(const Index &index, const Node &node);
- void remove(const Index &index) { _subgs.erase(index); };
+ OperationIndex append(std::unique_ptr<Subgraph> &&subg);
+ OperationIndex append(const OperationIndex &index, const Node &node);
+ void remove(const OperationIndex &index) { _subgs.erase(index); };
public:
- const Subgraph &at(const Index &) const;
- Subgraph &at(const Index &);
- std::unique_ptr<Subgraph> releaseAt(const Index &index) { return std::move(_subgs.at(index)); }
- Subgraph *getAt(const Index &index) { return _subgs.at(index).get(); }
- bool exist(const Index &) const;
-
- bool hasNode(const Index &node_index) const;
- Index findNode(const Index &node_index) const;
+ const Subgraph &at(const OperationIndex &) const;
+ Subgraph &at(const OperationIndex &);
+ std::unique_ptr<Subgraph> releaseAt(const OperationIndex &index)
+ {
+ return std::move(_subgs.at(index));
+ }
+ Subgraph *getAt(const OperationIndex &index) { return _subgs.at(index).get(); }
+ bool exist(const OperationIndex &) const;
+
+ bool hasNode(const OperationIndex &node_index) const;
+ OperationIndex findNode(const OperationIndex &node_index) const;
uint32_t size() const { return _subgs.size(); }
- void iterate(const std::function<void(const Index &, const Subgraph &)> &fn) const;
- void iterate(const std::function<void(const Index &, Subgraph &)> &fn);
+ void iterate(const std::function<void(const OperationIndex &, const Subgraph &)> &fn) const;
+ void iterate(const std::function<void(const OperationIndex &, Subgraph &)> &fn);
// TODO: Extract this into external helper function
void dump(const std::string &msg) const;
@@ -61,10 +66,10 @@ public:
void clear() { _subgs.clear(); }
private:
- Index generateIndex();
+ OperationIndex generateIndex();
private:
- std::unordered_map<Index, std::unique_ptr<Subgraph>> _subgs;
+ std::unordered_map<OperationIndex, std::unique_ptr<Subgraph>> _subgs;
uint32_t _index_count;
};
diff --git a/runtimes/neurun/core/src/model/operation/SubgraphContext.cc b/runtimes/neurun/core/src/model/operation/SubgraphContext.cc
index 367fbdf..20a82e1 100644
--- a/runtimes/neurun/core/src/model/operation/SubgraphContext.cc
+++ b/runtimes/neurun/core/src/model/operation/SubgraphContext.cc
@@ -29,34 +29,40 @@ namespace model
namespace operation
{
-Index SubgraphContext::generateIndex()
+OperationIndex SubgraphContext::generateIndex()
{
assert((_index_count) <= UINT32_MAX);
- return Index{_index_count++};
+ return OperationIndex{_index_count++};
}
-Index SubgraphContext::append(std::unique_ptr<Subgraph> &&subgraph)
+OperationIndex SubgraphContext::append(std::unique_ptr<Subgraph> &&subgraph)
{
auto index = generateIndex();
_subgs[index] = std::move(subgraph);
return index;
}
-Index SubgraphContext::append(const Index &index, const Node &node)
+OperationIndex SubgraphContext::append(const OperationIndex &index, const Node &node)
{
std::unique_ptr<Subgraph> subg = nnfw::cpp14::make_unique<model::operation::Subgraph>();
subg->appendOperation(index, node);
return append(std::move(subg));
}
-const Subgraph &SubgraphContext::at(const Index &index) const { return *(_subgs.at(index)); }
+const Subgraph &SubgraphContext::at(const OperationIndex &index) const
+{
+ return *(_subgs.at(index));
+}
-Subgraph &SubgraphContext::at(const Index &index) { return *(_subgs.at(index)); }
+Subgraph &SubgraphContext::at(const OperationIndex &index) { return *(_subgs.at(index)); }
-bool SubgraphContext::exist(const Index &index) const { return _subgs.find(index) != _subgs.end(); }
+bool SubgraphContext::exist(const OperationIndex &index) const
+{
+ return _subgs.find(index) != _subgs.end();
+}
-bool SubgraphContext::hasNode(const Index &node_index) const
+bool SubgraphContext::hasNode(const OperationIndex &node_index) const
{
for (auto it = _subgs.begin(); it != _subgs.end(); ++it)
{
@@ -71,7 +77,7 @@ bool SubgraphContext::hasNode(const Index &node_index) const
return false;
}
-Index SubgraphContext::findNode(const Index &node_index) const
+OperationIndex SubgraphContext::findNode(const OperationIndex &node_index) const
{
for (auto it = _subgs.begin(); it != _subgs.end(); ++it)
{
@@ -87,10 +93,11 @@ Index SubgraphContext::findNode(const Index &node_index) const
}
assert(true && "DO NOT ENTER HERE");
- return Index(UINT32_MAX); // CAN'T ENTER HERE
+ return OperationIndex(UINT32_MAX); // CAN'T ENTER HERE
}
-void SubgraphContext::iterate(const std::function<void(const Index &, const Subgraph &)> &fn) const
+void SubgraphContext::iterate(
+ const std::function<void(const OperationIndex &, const Subgraph &)> &fn) const
{
for (auto it = _subgs.begin(); it != _subgs.end(); ++it)
{
@@ -98,7 +105,7 @@ void SubgraphContext::iterate(const std::function<void(const Index &, const Subg
}
}
-void SubgraphContext::iterate(const std::function<void(const Index &, Subgraph &)> &fn)
+void SubgraphContext::iterate(const std::function<void(const OperationIndex &, Subgraph &)> &fn)
{
for (auto it = _subgs.begin(); it != _subgs.end(); ++it)
{
@@ -110,7 +117,7 @@ void SubgraphContext::iterate(const std::function<void(const Index &, Subgraph &
void SubgraphContext::dump(const std::string &msg) const
{
VERBOSE(SubgraphContext) << "SubgraphContext(" << msg << ")" << std::endl;
- iterate([&](const model::operation::Index &idx, const model::operation::Subgraph &subg) {
+ iterate([&](const OperationIndex &idx, const model::operation::Subgraph &subg) {
VERBOSE(SubgraphContext) << idx.value() << "] " << subg.getStr() << std::endl;
});
}