summaryrefslogtreecommitdiff
path: root/runtimes
diff options
context:
space:
mode:
author이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>2019-04-16 11:28:08 +0900
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>2019-04-16 11:28:08 +0900
commit26595a5da4ccb025348751f9eafabbfb2ba3a97d (patch)
treea090c5531099183e2cb389532b0455ee1e3e7456 /runtimes
parent60a3e226cade5676616649b07231ab48bb9960e4 (diff)
downloadnnfw-26595a5da4ccb025348751f9eafabbfb2ba3a97d.tar.gz
nnfw-26595a5da4ccb025348751f9eafabbfb2ba3a97d.tar.bz2
nnfw-26595a5da4ccb025348751f9eafabbfb2ba3a97d.zip
[neurun] Rename operation::Index as OperationIndex (#5002)
This is for reducing namespace operation. Part of #4985 Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
Diffstat (limited to 'runtimes')
-rw-r--r--runtimes/neurun/core/include/graph/Graph.h8
-rw-r--r--runtimes/neurun/core/include/graph/LowerInfoMap.h4
-rw-r--r--runtimes/neurun/core/include/model/OperationIndex.h (renamed from runtimes/neurun/core/include/model/operation/Index.h)5
-rw-r--r--runtimes/neurun/core/include/model/operand/Object.h8
-rw-r--r--runtimes/neurun/core/include/model/operation/IndexList.h14
-rw-r--r--runtimes/neurun/core/include/model/operation/Set.h22
-rw-r--r--runtimes/neurun/core/include/model/operation/Subgraph.h8
-rw-r--r--runtimes/neurun/core/src/compiler/Compiler.cc8
-rw-r--r--runtimes/neurun/core/src/compiler/ParamChecker.cc2
-rw-r--r--runtimes/neurun/core/src/dumper/dot/DotBuilder.h2
-rw-r--r--runtimes/neurun/core/src/dumper/dot/DotDumper.cc2
-rw-r--r--runtimes/neurun/core/src/dumper/dot/DotNodeInfo.cc2
-rw-r--r--runtimes/neurun/core/src/dumper/dot/DotNodeInfo.h6
-rw-r--r--runtimes/neurun/core/src/exec/DataflowExecutor.cc2
-rw-r--r--runtimes/neurun/core/src/exec/DataflowExecutor.h4
-rw-r--r--runtimes/neurun/core/src/exec/Job.cc4
-rw-r--r--runtimes/neurun/core/src/exec/Job.h8
-rw-r--r--runtimes/neurun/core/src/graph/Graph.cc30
-rw-r--r--runtimes/neurun/core/src/graph/pass/OperationPass.cc2
-rw-r--r--runtimes/neurun/core/src/graph/pass/OperationPass.h4
-rw-r--r--runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc6
-rw-r--r--runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.h8
-rw-r--r--runtimes/neurun/core/src/graph/verifier/Verifier.cc12
-rw-r--r--runtimes/neurun/core/src/linear/Linear.cc2
-rw-r--r--runtimes/neurun/core/src/linear/Linear.h2
-rw-r--r--runtimes/neurun/core/src/model/operand/Object.cc8
-rw-r--r--runtimes/neurun/core/src/model/operation/IndexList.cc4
-rw-r--r--runtimes/neurun/core/src/model/operation/Set.cc14
-rw-r--r--runtimes/neurun/frontend/nnapi/wrapper/model.cc2
-rw-r--r--runtimes/neurun/test/graph/operation/Set.cc4
30 files changed, 102 insertions, 105 deletions
diff --git a/runtimes/neurun/core/include/graph/Graph.h b/runtimes/neurun/core/include/graph/Graph.h
index 909bba9e5..cbf1eca1a 100644
--- a/runtimes/neurun/core/include/graph/Graph.h
+++ b/runtimes/neurun/core/include/graph/Graph.h
@@ -70,7 +70,7 @@ public:
{
public:
using GraphRef = typename std::conditional<is_const, const Graph &, Graph &>::type;
- using IndexRef = const model::operation::Index &;
+ using IndexRef = const model::OperationIndex &;
using NodeRef = typename std::conditional<is_const, const model::operation::Node &,
model::operation::Node &>::type;
using IterFn = std::function<void(IndexRef, NodeRef)>;
@@ -115,7 +115,7 @@ public:
public:
model::operand::Index addOperand(const model::operand::Shape &shape,
const model::operand::TypeInfo &type);
- model::operation::Index addOperation(std::unique_ptr<model::operation::Node> &&node);
+ model::OperationIndex addOperation(std::unique_ptr<model::operation::Node> &&node);
void setOperandValue(const model::operand::Index &ind,
std::unique_ptr<model::operand::Data> &&data);
void addInput(const model::operand::Index &ind);
@@ -158,8 +158,8 @@ private:
// For LOWERED phase
public:
- const operation::LowerInfo *getLowerInfo(const model::operation::Index &index) const;
- void setLowerInfo(const model::operation::Index &index,
+ const operation::LowerInfo *getLowerInfo(const model::OperationIndex &index) const;
+ void setLowerInfo(const model::OperationIndex &index,
std::unique_ptr<operation::LowerInfo> &&lower_info);
const operand::LowerInfo *getLowerInfo(const model::operand::Index &index) const;
operand::LowerInfo *getLowerInfo(const model::operand::Index &index);
diff --git a/runtimes/neurun/core/include/graph/LowerInfoMap.h b/runtimes/neurun/core/include/graph/LowerInfoMap.h
index 2b293227a..831b0ead5 100644
--- a/runtimes/neurun/core/include/graph/LowerInfoMap.h
+++ b/runtimes/neurun/core/include/graph/LowerInfoMap.h
@@ -23,7 +23,7 @@
#include "graph/operand/LowerInfo.h"
#include "graph/operation/LowerInfo.h"
#include "model/operand/IndexMap.h"
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
namespace neurun
{
@@ -32,7 +32,7 @@ namespace graph
struct LowerInfoMap
{
- std::unordered_map<model::operation::Index, std::unique_ptr<operation::LowerInfo>> operation;
+ std::unordered_map<model::OperationIndex, std::unique_ptr<operation::LowerInfo>> operation;
model::operand::IndexMap<std::unique_ptr<operand::LowerInfo>> operand;
};
diff --git a/runtimes/neurun/core/include/model/operation/Index.h b/runtimes/neurun/core/include/model/OperationIndex.h
index 5e0952ac3..0eada5317 100644
--- a/runtimes/neurun/core/include/model/operation/Index.h
+++ b/runtimes/neurun/core/include/model/OperationIndex.h
@@ -23,13 +23,10 @@ namespace neurun
{
namespace model
{
-namespace operation
-{
struct IndexTag;
-using Index = ::neurun::graph::Index<uint32_t, IndexTag>;
+using OperationIndex = ::neurun::graph::Index<uint32_t, IndexTag>;
-} // namespace operation
} // namespace model
} // namespace neurun
diff --git a/runtimes/neurun/core/include/model/operand/Object.h b/runtimes/neurun/core/include/model/operand/Object.h
index 4581ad82a..151d11218 100644
--- a/runtimes/neurun/core/include/model/operand/Object.h
+++ b/runtimes/neurun/core/include/model/operand/Object.h
@@ -65,10 +65,10 @@ public:
const operation::IndexList &getUses() const { return _uses; }
const operation::IndexList &getDef() const { return _def; }
- void appendUse(const operation::Index &idx);
- void removeUse(const operation::Index &idx);
- void appendDef(const operation::Index &idx);
- void removeDef(const operation::Index &idx);
+ void appendUse(const OperationIndex &idx);
+ void removeUse(const OperationIndex &idx);
+ void appendDef(const OperationIndex &idx);
+ void removeDef(const OperationIndex &idx);
public:
void type(const DataType &type) { _info.type(type); };
diff --git a/runtimes/neurun/core/include/model/operation/IndexList.h b/runtimes/neurun/core/include/model/operation/IndexList.h
index c0af29829..4a5e420fd 100644
--- a/runtimes/neurun/core/include/model/operation/IndexList.h
+++ b/runtimes/neurun/core/include/model/operation/IndexList.h
@@ -20,7 +20,7 @@
#include <initializer_list>
#include <list>
-#include "Index.h"
+#include "model/OperationIndex.h"
namespace neurun
{
@@ -33,19 +33,19 @@ class IndexList
{
public:
IndexList(void) = default;
- IndexList(std::initializer_list<Index> list);
+ IndexList(std::initializer_list<OperationIndex> list);
public:
- void append(const Index &index) { _list.push_back(index); }
- void remove(const Index &index) { _list.remove(index); }
+ void append(const OperationIndex &index) { _list.push_back(index); }
+ void remove(const OperationIndex &index) { _list.remove(index); }
public:
uint32_t size() const { return static_cast<uint32_t>(_list.size()); }
- const std::list<Index> &list() const { return _list; }
- bool contains(const Index &index) const;
+ const std::list<OperationIndex> &list() const { return _list; }
+ bool contains(const OperationIndex &index) const;
private:
- std::list<Index> _list;
+ std::list<OperationIndex> _list;
};
} // namespace operation
diff --git a/runtimes/neurun/core/include/model/operation/Set.h b/runtimes/neurun/core/include/model/operation/Set.h
index 8a2231572..ce8839d5b 100644
--- a/runtimes/neurun/core/include/model/operation/Set.h
+++ b/runtimes/neurun/core/include/model/operation/Set.h
@@ -19,7 +19,7 @@
#include <memory>
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
#include "Node.h"
#include <unordered_map>
@@ -37,23 +37,23 @@ public:
Set() : _index_count(0) {}
public:
- Index append(std::unique_ptr<Node> &&node);
- void remove(const Index &index) { _nodes.erase(index); };
+ OperationIndex append(std::unique_ptr<Node> &&node);
+ void remove(const OperationIndex &index) { _nodes.erase(index); };
public:
- const Node &at(const Index &) const;
- Node &at(const Index &);
- bool exist(const Index &) const;
+ const Node &at(const OperationIndex &) const;
+ Node &at(const OperationIndex &);
+ bool exist(const OperationIndex &) const;
uint32_t size() const { return _nodes.size(); }
- void iterate(const std::function<void(const Index &, const Node &)> &fn) const;
- void iterate(const std::function<void(const Index &, Node &)> &fn);
+ void iterate(const std::function<void(const OperationIndex &, const Node &)> &fn) const;
+ void iterate(const std::function<void(const OperationIndex &, Node &)> &fn);
private:
- const Index generateIndex();
+ const OperationIndex generateIndex();
private:
- std::unordered_map<Index, std::unique_ptr<Node>> _nodes;
- Index _index_count;
+ std::unordered_map<OperationIndex, std::unique_ptr<Node>> _nodes;
+ OperationIndex _index_count;
};
} // namespace operation
diff --git a/runtimes/neurun/core/include/model/operation/Subgraph.h b/runtimes/neurun/core/include/model/operation/Subgraph.h
index a9fe6b751..15aff961a 100644
--- a/runtimes/neurun/core/include/model/operation/Subgraph.h
+++ b/runtimes/neurun/core/include/model/operation/Subgraph.h
@@ -21,7 +21,7 @@
#include <string>
#include <memory>
-#include "Index.h"
+#include "model/OperationIndex.h"
#include "Node.h"
namespace neurun
@@ -36,10 +36,10 @@ namespace operation
// support Swappable)
struct Element
{
- Index index;
+ OperationIndex index;
const Node *node;
- Element(const Index *i, const Node *n) : index{*i}, node{n}
+ Element(const OperationIndex *i, const Node *n) : index{*i}, node{n}
{
// DO NOTHING
}
@@ -57,7 +57,7 @@ public:
virtual std::string getName(void) const override { return "Subgraph"; }
public:
- void appendOperation(const Index &index, const Node &node)
+ void appendOperation(const OperationIndex &index, const Node &node)
{
_operations.emplace_back(&index, &node);
}
diff --git a/runtimes/neurun/core/src/compiler/Compiler.cc b/runtimes/neurun/core/src/compiler/Compiler.cc
index 5d9a68758..6ab5672f0 100644
--- a/runtimes/neurun/core/src/compiler/Compiler.cc
+++ b/runtimes/neurun/core/src/compiler/Compiler.cc
@@ -149,10 +149,10 @@ std::shared_ptr<exec::IExecutor> Compiler::createLinearExecutor(graph::Graph &mo
std::shared_ptr<exec::IExecutor> Compiler::createDataflowExecutor(graph::Graph &model)
{
auto operand_context = std::make_shared<OperandContext>();
- std::unordered_map<model::operation::Index, std::unique_ptr<backend::IStage>> stages;
+ std::unordered_map<model::OperationIndex, std::unique_ptr<backend::IStage>> stages;
model.operations().iterate(
- [&](const model::operation::Index &index, const model::operation::Node &node) {
+ [&](const model::OperationIndex &index, const model::operation::Node &node) {
auto backend = model.getLowerInfo(index)->backend();
// Generate Stage
@@ -203,12 +203,12 @@ std::shared_ptr<exec::IExecutor> Compiler::createDataflowExecutor(graph::Graph &
};
// TODO Remove this method and make `append` to get index value as an argument
- void setNextIndex(const model::operation::Index next_index) { _next_index = next_index; }
+ void setNextIndex(const model::OperationIndex next_index) { _next_index = next_index; }
exec::DataflowExecutor::CodeMap &&releaseCodeMap() { return std::move(_code_map); }
private:
- model::operation::Index _next_index;
+ model::OperationIndex _next_index;
exec::DataflowExecutor::CodeMap _code_map;
};
diff --git a/runtimes/neurun/core/src/compiler/ParamChecker.cc b/runtimes/neurun/core/src/compiler/ParamChecker.cc
index f0f6b4a8e..b17d35b5f 100644
--- a/runtimes/neurun/core/src/compiler/ParamChecker.cc
+++ b/runtimes/neurun/core/src/compiler/ParamChecker.cc
@@ -28,7 +28,7 @@ using Usage = neurun::model::operand::Usage;
void ParamChecker::operator()()
{
_model->operations().iterate(
- [&](const model::operation::Index &, const model::operation::Node &node) {
+ [&](const model::OperationIndex &, const model::operation::Node &node) {
node.accept(std::move(*this));
});
}
diff --git a/runtimes/neurun/core/src/dumper/dot/DotBuilder.h b/runtimes/neurun/core/src/dumper/dot/DotBuilder.h
index 783e92b80..01781bd94 100644
--- a/runtimes/neurun/core/src/dumper/dot/DotBuilder.h
+++ b/runtimes/neurun/core/src/dumper/dot/DotBuilder.h
@@ -19,7 +19,7 @@
#include <sstream>
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
#include "model/operand/Index.h"
#include "model/operation/Node.h"
diff --git a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
index cb64f3953..d97027d74 100644
--- a/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
+++ b/runtimes/neurun/core/src/dumper/dot/DotDumper.cc
@@ -39,7 +39,7 @@ void DotDumper::dumpIfNeeded(const std::string &tag)
auto &operations = _graph.operations();
auto &operands = _graph.operands();
- operations.iterate([&](const model::operation::Index &index, const model::operation::Node &node) {
+ operations.iterate([&](const model::OperationIndex &index, const model::operation::Node &node) {
neurun::dumper::dot::DotNodeInfo node_info(_graph, index, node);
for (auto output : node.getOutputs())
diff --git a/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.cc b/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.cc
index 169c76978..39ad83b7e 100644
--- a/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.cc
+++ b/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.cc
@@ -35,7 +35,7 @@ const std::string DotNodeInfo::BG_COLOR_SCHEME = "pastel18";
const std::string DotNodeInfo::BG_COLORS[8] = {"1", "2", "5", "6", "3", "4", "7", "8"};
DotNodeInfo::DotNodeInfo(const neurun::graph::Graph &graph,
- const neurun::model::operation::Index &index,
+ const neurun::model::OperationIndex &index,
const neurun::model::operation::Node &node)
: _index(index), _node(node), _lower_info(graph.getLowerInfo(index))
{
diff --git a/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.h b/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.h
index 19d88d6c1..c187088ae 100644
--- a/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.h
+++ b/runtimes/neurun/core/src/dumper/dot/DotNodeInfo.h
@@ -19,7 +19,7 @@
#include "IDotInfo.h"
#include "model/operation/Node.h"
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
namespace neurun
{
@@ -44,7 +44,7 @@ public:
static const std::string BG_COLORS[8];
public:
- DotNodeInfo(const neurun::graph::Graph &graph, const neurun::model::operation::Index &index,
+ DotNodeInfo(const neurun::graph::Graph &graph, const neurun::model::OperationIndex &index,
const neurun::model::operation::Node &node);
public:
@@ -58,7 +58,7 @@ private:
void addBackendLabel();
private:
- neurun::model::operation::Index _index;
+ neurun::model::OperationIndex _index;
const neurun::model::operation::Node &_node;
const neurun::graph::operation::LowerInfo *_lower_info;
std::vector<std::string> _labels;
diff --git a/runtimes/neurun/core/src/exec/DataflowExecutor.cc b/runtimes/neurun/core/src/exec/DataflowExecutor.cc
index 609279dda..6ec365316 100644
--- a/runtimes/neurun/core/src/exec/DataflowExecutor.cc
+++ b/runtimes/neurun/core/src/exec/DataflowExecutor.cc
@@ -56,7 +56,7 @@ DataflowExecutor::DataflowExecutor(const std::shared_ptr<const model::Model> &mo
VERBOSE(DataflowExecutor) << "Constructing Dataflow Executor" << std::endl;
// Create jobs
- _model->operations.iterate([&](const model::operation::Index &index,
+ _model->operations.iterate([&](const model::OperationIndex &index,
const model::operation::Node &node) {
VERBOSE(DataflowExecutor) << "Add a job #" << index.value() << std::endl;
_finished_jobs.emplace_back(nnfw::cpp14::make_unique<Job>(index, _code_map.at(index).get(),
diff --git a/runtimes/neurun/core/src/exec/DataflowExecutor.h b/runtimes/neurun/core/src/exec/DataflowExecutor.h
index 4ea6fe645..e9530b70c 100644
--- a/runtimes/neurun/core/src/exec/DataflowExecutor.h
+++ b/runtimes/neurun/core/src/exec/DataflowExecutor.h
@@ -24,7 +24,7 @@
#include "FunctionSequence.h"
#include "Job.h"
#include "model/operand/IndexSet.h"
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
#include "model/Model.h"
#include "cpp14/memory.h"
#include "exec/ExecutorBase.h"
@@ -37,7 +37,7 @@ namespace exec
class DataflowExecutor : public ExecutorBase
{
public:
- using CodeMap = std::unordered_map<model::operation::Index, std::unique_ptr<FunctionSequence>>;
+ using CodeMap = std::unordered_map<model::OperationIndex, std::unique_ptr<FunctionSequence>>;
private:
void notify(const model::operand::IndexSet &operands);
diff --git a/runtimes/neurun/core/src/exec/Job.cc b/runtimes/neurun/core/src/exec/Job.cc
index 3fabafa4b..c09d0672b 100644
--- a/runtimes/neurun/core/src/exec/Job.cc
+++ b/runtimes/neurun/core/src/exec/Job.cc
@@ -23,8 +23,8 @@ namespace neurun
namespace exec
{
-Job::Job(const model::operation::Index &index, IFunction *fn,
- const model::operand::IndexSet &inputs, const model::operand::IndexSet &outputs)
+Job::Job(const model::OperationIndex &index, IFunction *fn, const model::operand::IndexSet &inputs,
+ const model::operand::IndexSet &outputs)
: _index{index}, _fn{fn}, _outputs{outputs}
{
for (auto input : inputs)
diff --git a/runtimes/neurun/core/src/exec/Job.h b/runtimes/neurun/core/src/exec/Job.h
index 85178dd94..df401b0ab 100644
--- a/runtimes/neurun/core/src/exec/Job.h
+++ b/runtimes/neurun/core/src/exec/Job.h
@@ -20,7 +20,7 @@
#include <unordered_set>
#include "exec/IFunction.h"
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
#include "model/operand/IndexSet.h"
namespace neurun
@@ -39,7 +39,7 @@ public:
* @param inputs Input operand list
* @param outputs Output operand list
*/
- Job(const model::operation::Index &index, IFunction *fn, const model::operand::IndexSet &inputs,
+ Job(const model::OperationIndex &index, IFunction *fn, const model::operand::IndexSet &inputs,
const model::operand::IndexSet &outputs);
/**
* @brief Remove the given operand from blocking input list
@@ -68,7 +68,7 @@ public:
*
* @return Operation index
*/
- model::operation::Index index() const { return _index; }
+ model::OperationIndex index() const { return _index; }
/**
* @brief Return output indices
*
@@ -77,7 +77,7 @@ public:
const model::operand::IndexSet &outputs() const { return _outputs; }
private:
- model::operation::Index _index;
+ model::OperationIndex _index;
IFunction *_fn;
std::unordered_set<model::operand::Index> _blocking_inputs;
const model::operand::IndexSet _outputs;
diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc
index 64f586709..6c491ad11 100644
--- a/runtimes/neurun/core/src/graph/Graph.cc
+++ b/runtimes/neurun/core/src/graph/Graph.cc
@@ -49,7 +49,7 @@ model::operand::Index Graph::addOperand(const model::operand::Shape &shape,
return _model->operands.append(shape, type);
}
-model::operation::Index Graph::addOperation(std::unique_ptr<model::operation::Node> &&node)
+model::OperationIndex Graph::addOperation(std::unique_ptr<model::operation::Node> &&node)
{
assert(isBuildingPhase());
return _model->operations.append(std::move(node));
@@ -111,7 +111,7 @@ void Graph::lower(void)
_lower_info_map = nnfw::cpp14::make_unique<LowerInfoMap>();
_model->operations.iterate(
- [&](const model::operation::Index &index, model::operation::Node &node) {
+ [&](const model::OperationIndex &index, model::operation::Node &node) {
auto backend = _backend_resolver->getBackend(typeid(node));
// Operation LowerInfo
@@ -149,7 +149,7 @@ void Graph::lower(void)
// Add DefBackend constants same as UseBackend
// NOTE This assumes a constant operand is used by only one operation
- _model->operations.iterate([&](const model::operation::Index &, model::operation::Node &node) {
+ _model->operations.iterate([&](const model::OperationIndex &, model::operation::Node &node) {
// LowerInfo for input operands
for (auto operand : node.getInputs())
{
@@ -259,7 +259,7 @@ std::unique_ptr<linear::Linear> Graph::linearize(void)
void Graph::initializeUseDef()
{
operations().iterate(
- [&](const model::operation::Index &index, const model::operation::Node &node) -> void {
+ [&](const model::OperationIndex &index, const model::operation::Node &node) -> void {
auto outputs = node.getOutputs();
for (auto output : outputs)
{
@@ -274,7 +274,7 @@ void Graph::initializeUseDef()
});
}
-const operation::LowerInfo *Graph::getLowerInfo(const model::operation::Index &index) const
+const operation::LowerInfo *Graph::getLowerInfo(const model::OperationIndex &index) const
{
if (!_lower_info_map)
return nullptr;
@@ -284,7 +284,7 @@ const operation::LowerInfo *Graph::getLowerInfo(const model::operation::Index &i
return itr->second.get();
}
-void Graph::setLowerInfo(const model::operation::Index &index,
+void Graph::setLowerInfo(const model::OperationIndex &index,
std::unique_ptr<operation::LowerInfo> &&lower_info)
{
assert(_lower_info_map);
@@ -355,7 +355,7 @@ void Graph::partition()
{
std::unique_ptr<model::operation::Subgraph> subg = nullptr;
Graph::PostDfsConstIterator().iterate(
- *this, [&](const model::operation::Index &index, const model::operation::Node &node) {
+ *this, [&](const model::OperationIndex &index, const model::operation::Node &node) {
if (!subg)
subg = nnfw::cpp14::make_unique<model::operation::Subgraph>();
@@ -435,7 +435,7 @@ template <bool is_const>
void Graph::DefaultIterator<is_const>::iterate(GraphRef graph, const IterFn &fn) const
{
graph.operations().iterate(
- [&](const model::operation::Index &index, NodeRef node) -> void { fn(index, node); });
+ [&](const model::OperationIndex &index, NodeRef node) -> void { fn(index, node); });
}
//
@@ -447,12 +447,12 @@ void Graph::PostDfsIterator<is_const>::iterate(GraphRef graph, const IterFn &fn)
{
assert(!graph.isBuildingPhase()); // Restrict iteration condition
- std::unordered_map<model::operation::Index, bool> visited;
+ std::unordered_map<model::OperationIndex, bool> visited;
graph.operations().iterate(
- [&](const model::operation::Index &index, NodeRef) { visited[index] = false; });
+ [&](const model::OperationIndex &index, NodeRef) { visited[index] = false; });
- std::function<void(const model::operation::Index &, NodeRef)> dfs_recursive =
- [&](const model::operation::Index &index, NodeRef node) -> void {
+ std::function<void(const model::OperationIndex &, NodeRef)> dfs_recursive =
+ [&](const model::OperationIndex &index, NodeRef node) -> void {
if (visited[index])
return;
visited[index] = true;
@@ -472,9 +472,9 @@ void Graph::PostDfsIterator<is_const>::iterate(GraphRef graph, const IterFn &fn)
graph.operations().iterate(dfs_recursive);
// All of the operations(nodes) must have been visited.
- assert(std::all_of(
- visited.begin(), visited.end(),
- [](const std::pair<const model::operation::Index, bool> &v) { return v.second; }));
+ assert(
+ std::all_of(visited.begin(), visited.end(),
+ [](const std::pair<const model::OperationIndex, bool> &v) { return v.second; }));
}
} // namespace graph
diff --git a/runtimes/neurun/core/src/graph/pass/OperationPass.cc b/runtimes/neurun/core/src/graph/pass/OperationPass.cc
index e71f79188..4f8336221 100644
--- a/runtimes/neurun/core/src/graph/pass/OperationPass.cc
+++ b/runtimes/neurun/core/src/graph/pass/OperationPass.cc
@@ -27,7 +27,7 @@ namespace pass
void OperationPass::run()
{
- _graph.operations().iterate([&](const model::operation::Index &index,
+ _graph.operations().iterate([&](const model::OperationIndex &index,
model::operation::Node &node) { callback(index, node); });
}
diff --git a/runtimes/neurun/core/src/graph/pass/OperationPass.h b/runtimes/neurun/core/src/graph/pass/OperationPass.h
index 38f8303b1..7bce9326e 100644
--- a/runtimes/neurun/core/src/graph/pass/OperationPass.h
+++ b/runtimes/neurun/core/src/graph/pass/OperationPass.h
@@ -24,7 +24,7 @@
#include "Pass.h"
-#include "model/operation/Index.h"
+#include "model/OperationIndex.h"
#include "model/operation/Node.h"
namespace neurun
@@ -61,7 +61,7 @@ public:
* @param i[in] Index of the operation node
* @param n[in] The operation node
*/
- virtual void callback(const model::operation::Index &i, model::operation::Node &n) = 0;
+ virtual void callback(const model::OperationIndex &i, model::operation::Node &n) = 0;
};
} // namespace pass
diff --git a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc
index d1ba0b877..25f4a28a8 100644
--- a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc
+++ b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.cc
@@ -50,7 +50,7 @@ void PermutationInsertionPass::callback(const model::operand::Index &index,
return;
}
- std::list<model::operation::Index> permute_indexes;
+ std::list<model::OperationIndex> permute_indexes;
// Build a map for all necessary type of operands
std::unordered_map<const backend::Backend *, model::operand::Index> backend_to_index;
@@ -76,7 +76,7 @@ void PermutationInsertionPass::callback(const model::operand::Index &index,
// Update operations' input that uses this operand
{
- std::list<model::operation::Index> remove_list;
+ std::list<model::OperationIndex> remove_list;
auto uses = object.getUses();
for (auto use : uses.list())
@@ -113,7 +113,7 @@ void PermutationInsertionPass::callback(const model::operand::Index &index,
}
}
-model::operation::Index
+model::OperationIndex
PermutationInsertionPass::insertPermute(const model::operand::Index &operand_index,
const backend::Backend *backend)
{
diff --git a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.h b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.h
index c1f84c7b4..f2cac4e01 100644
--- a/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.h
+++ b/runtimes/neurun/core/src/graph/pass/PermutationInsertionPass.h
@@ -18,7 +18,7 @@
#define __NEURUN_GRAPH_PASS_PERMUTATION_INSERTION_PASS_H__
#include "OperandPass.h"
-#include "model/operand/Object.h" //for model::operation::Index
+#include "model/operand/Object.h" //for model::OperationIndex
#include "backend/BackendManager.h"
namespace neurun
@@ -43,10 +43,10 @@ public:
* @param operand_index is the target operand index for the insertion
* @param backend is the output operand's backend type
*
- * @return model::operation::Index
+ * @return model::OperationIndex
*/
- model::operation::Index insertPermute(const model::operand::Index &operand_index,
- const backend::Backend *backend);
+ model::OperationIndex insertPermute(const model::operand::Index &operand_index,
+ const backend::Backend *backend);
private:
};
diff --git a/runtimes/neurun/core/src/graph/verifier/Verifier.cc b/runtimes/neurun/core/src/graph/verifier/Verifier.cc
index a5b53af85..e0d05d711 100644
--- a/runtimes/neurun/core/src/graph/verifier/Verifier.cc
+++ b/runtimes/neurun/core/src/graph/verifier/Verifier.cc
@@ -36,15 +36,15 @@ bool DAGChecker::verify(const Graph &graph) const
auto &operations = graph.operations();
bool cyclic = false;
- std::unordered_map<model::operation::Index, bool> visited;
- operations.iterate([&](const model::operation::Index &index, const model::operation::Node &) {
+ std::unordered_map<model::OperationIndex, bool> visited;
+ operations.iterate([&](const model::OperationIndex &index, const model::operation::Node &) {
visited[index] = false;
});
- std::unordered_map<model::operation::Index, bool> on_stack = visited; // Copy from visited
+ std::unordered_map<model::OperationIndex, bool> on_stack = visited; // Copy from visited
- std::function<void(const model::operation::Index &index, const model::operation::Node &)>
+ std::function<void(const model::OperationIndex &index, const model::operation::Node &)>
dfs_recursive =
- [&](const model::operation::Index &index, const model::operation::Node &node) -> void {
+ [&](const model::OperationIndex &index, const model::operation::Node &node) -> void {
if (on_stack[index])
cyclic = true;
if (visited[index])
@@ -77,7 +77,7 @@ bool EdgeConsistencyChecker::verify(const Graph &graph) const
{
auto &operations = graph.operations();
uint32_t mismatches = 0;
- operations.iterate([&](const model::operation::Index &index, const model::operation::Node &node) {
+ operations.iterate([&](const model::OperationIndex &index, const model::operation::Node &node) {
for (auto operand_index : node.getInputs())
{
auto &operand = graph.operands().at(operand_index);
diff --git a/runtimes/neurun/core/src/linear/Linear.cc b/runtimes/neurun/core/src/linear/Linear.cc
index a573b5dd2..dcf17c263 100644
--- a/runtimes/neurun/core/src/linear/Linear.cc
+++ b/runtimes/neurun/core/src/linear/Linear.cc
@@ -197,7 +197,7 @@ void Linear::iterate(const std::function<void(const Element &element)> &fn) cons
}
}
-const graph::operation::LowerInfo *Linear::getLowerInfo(const model::operation::Index &index) const
+const graph::operation::LowerInfo *Linear::getLowerInfo(const model::OperationIndex &index) const
{
if (!_lower_info_map)
return nullptr;
diff --git a/runtimes/neurun/core/src/linear/Linear.h b/runtimes/neurun/core/src/linear/Linear.h
index 1720be2a4..a682a6f49 100644
--- a/runtimes/neurun/core/src/linear/Linear.h
+++ b/runtimes/neurun/core/src/linear/Linear.h
@@ -82,7 +82,7 @@ public:
private:
// TODO Replace these getLowerInfo methods with ones of LowerInfoMap in the future
- const graph::operation::LowerInfo *getLowerInfo(const model::operation::Index &index) const;
+ const graph::operation::LowerInfo *getLowerInfo(const model::OperationIndex &index) const;
const graph::operand::LowerInfo *getLowerInfo(const model::operand::Index &index) const;
private:
diff --git a/runtimes/neurun/core/src/model/operand/Object.cc b/runtimes/neurun/core/src/model/operand/Object.cc
index 524b85f8b..8d0d000b7 100644
--- a/runtimes/neurun/core/src/model/operand/Object.cc
+++ b/runtimes/neurun/core/src/model/operand/Object.cc
@@ -53,7 +53,7 @@ bool Object::usage(const Usage usage)
return true;
}
-void Object::appendUse(const ::neurun::model::operation::Index &idx)
+void Object::appendUse(const ::neurun::model::OperationIndex &idx)
{
assert(_usage != Usage::NOT_DEFINED);
assert(!_uses.contains(idx));
@@ -61,7 +61,7 @@ void Object::appendUse(const ::neurun::model::operation::Index &idx)
_uses.append(idx);
}
-void Object::removeUse(const ::neurun::model::operation::Index &idx)
+void Object::removeUse(const ::neurun::model::OperationIndex &idx)
{
assert(_usage != Usage::NOT_DEFINED);
assert(_uses.contains(idx));
@@ -69,7 +69,7 @@ void Object::removeUse(const ::neurun::model::operation::Index &idx)
_uses.remove(idx);
}
-void Object::appendDef(const ::neurun::model::operation::Index &idx)
+void Object::appendDef(const ::neurun::model::OperationIndex &idx)
{
assert(_usage != Usage::NOT_DEFINED && _usage != Usage::CONSTANT);
assert(_def.size() == 0);
@@ -77,7 +77,7 @@ void Object::appendDef(const ::neurun::model::operation::Index &idx)
_def.append(idx);
}
-void Object::removeDef(const ::neurun::model::operation::Index &idx)
+void Object::removeDef(const ::neurun::model::OperationIndex &idx)
{
assert(_usage != Usage::NOT_DEFINED);
assert(_def.contains(idx));
diff --git a/runtimes/neurun/core/src/model/operation/IndexList.cc b/runtimes/neurun/core/src/model/operation/IndexList.cc
index b1fc89bb3..75e845c95 100644
--- a/runtimes/neurun/core/src/model/operation/IndexList.cc
+++ b/runtimes/neurun/core/src/model/operation/IndexList.cc
@@ -25,12 +25,12 @@ namespace model
namespace operation
{
-IndexList::IndexList(std::initializer_list<Index> list) : _list(list)
+IndexList::IndexList(std::initializer_list<OperationIndex> list) : _list(list)
{
// DO NOTHING
}
-bool IndexList::contains(const ::neurun::model::operation::Index &index) const
+bool IndexList::contains(const ::neurun::model::OperationIndex &index) const
{
return std::find(_list.begin(), _list.end(), index) != _list.end();
}
diff --git a/runtimes/neurun/core/src/model/operation/Set.cc b/runtimes/neurun/core/src/model/operation/Set.cc
index 4d374f86f..84f4e3b84 100644
--- a/runtimes/neurun/core/src/model/operation/Set.cc
+++ b/runtimes/neurun/core/src/model/operation/Set.cc
@@ -25,14 +25,14 @@ namespace model
namespace operation
{
-const Index Set::generateIndex()
+const OperationIndex Set::generateIndex()
{
assert(_index_count.valid());
return _index_count++;
}
-Index Set::append(std::unique_ptr<Node> &&node)
+OperationIndex Set::append(std::unique_ptr<Node> &&node)
{
auto index = generateIndex();
@@ -40,13 +40,13 @@ Index Set::append(std::unique_ptr<Node> &&node)
return index;
}
-const Node &Set::at(const Index &index) const { return *(_nodes.at(index)); }
+const Node &Set::at(const OperationIndex &index) const { return *(_nodes.at(index)); }
-Node &Set::at(const Index &index) { return *(_nodes.at(index)); }
+Node &Set::at(const OperationIndex &index) { return *(_nodes.at(index)); }
-bool Set::exist(const Index &index) const { return _nodes.find(index) != _nodes.end(); }
+bool Set::exist(const OperationIndex &index) const { return _nodes.find(index) != _nodes.end(); }
-void Set::iterate(const std::function<void(const Index &, const Node &)> &fn) const
+void Set::iterate(const std::function<void(const OperationIndex &, const Node &)> &fn) const
{
for (auto it = _nodes.begin(); it != _nodes.end(); ++it)
{
@@ -54,7 +54,7 @@ void Set::iterate(const std::function<void(const Index &, const Node &)> &fn) co
}
}
-void Set::iterate(const std::function<void(const Index &, Node &)> &fn)
+void Set::iterate(const std::function<void(const OperationIndex &, Node &)> &fn)
{
for (auto it = _nodes.begin(); it != _nodes.end(); ++it)
{
diff --git a/runtimes/neurun/frontend/nnapi/wrapper/model.cc b/runtimes/neurun/frontend/nnapi/wrapper/model.cc
index a7ed51a01..8d0276922 100644
--- a/runtimes/neurun/frontend/nnapi/wrapper/model.cc
+++ b/runtimes/neurun/frontend/nnapi/wrapper/model.cc
@@ -234,7 +234,7 @@ void ANeuralNetworksModel::setOptionalOperand(const neurun::model::operand::Inde
void ANeuralNetworksModel::fillOptionalOperand(void)
{
_model->operations.iterate(
- [&](const ::neurun::model::operation::Index &, ::neurun::model::operation::Node &node) {
+ [&](const ::neurun::model::OperationIndex &, ::neurun::model::operation::Node &node) {
for (auto input : node.getInputs())
{
// TODO fill default value for optional operands
diff --git a/runtimes/neurun/test/graph/operation/Set.cc b/runtimes/neurun/test/graph/operation/Set.cc
index 3560482ee..cc4e1fb06 100644
--- a/runtimes/neurun/test/graph/operation/Set.cc
+++ b/runtimes/neurun/test/graph/operation/Set.cc
@@ -21,14 +21,14 @@
using neurun::model::operation::Set;
using neurun::model::operation::Node;
-using neurun::model::operation::Index;
+using neurun::model::OperationIndex;
TEST(graph_operation_Set, operation_test)
{
Set set;
set.append(
std::unique_ptr<Node>(new neurun_test::graph::SimpleMockNode({1, 2, 3, 4}, {5, 6, 7})));
- Index idx{0u};
+ OperationIndex idx{0u};
ASSERT_EQ(set.at(idx).getInputs().size(), 4);
ASSERT_EQ(set.at(idx).getOutputs().size(), 3);
}