Introduce operation::LowerInfo (#2389)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Wed, 22 Aug 2018 01:38:09 +0000 (10:38 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Wed, 22 Aug 2018 01:38:09 +0000 (10:38 +0900)
Introduce `operation::LowerInfo` which contains backend id as string.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/src/graph/Graph.cc
runtimes/neurun/src/graph/operation/LowerInfo.cc [new file with mode: 0644]
runtimes/neurun/src/graph/operation/LowerInfo.h [new file with mode: 0644]
runtimes/neurun/src/graph/operation/Node.h

index 6be8a67..d14fe6c 100644 (file)
@@ -7,6 +7,7 @@
 #include "verifier/IVerifier.h"
 #include "nnfw/std/memory.h"
 #include "linear/Linear.h"
+#include "operation/LowerInfo.h"
 
 namespace neurun
 {
@@ -60,13 +61,22 @@ void Graph::finishBuilding(void)
 void Graph::lower(void)
 {
   assert(_phase == Phase::MODEL);
-  _phase = Phase::LOWERED;
 
-  // Call graph verifications for the LOWERED phase
+  // Lower
+  {
+    _operations.iterate([&](const operation::Index &, operation::Node &node) {
+      // TODO Update backend id accordingly. Currently "acl_cl" by default
+      node.lower_info(nnfw::make_unique<operation::LowerInfo>(std::string("acl_cl")));
+    });
+  }
+
+  // Graph verifications for the LOWERED phase
   {
     verifier::DAGChecker dag_checker;
     dag_checker.verify(*this);
   }
+
+  _phase = Phase::LOWERED;
 }
 
 std::unique_ptr<linear::Linear> Graph::linearize(void)
diff --git a/runtimes/neurun/src/graph/operation/LowerInfo.cc b/runtimes/neurun/src/graph/operation/LowerInfo.cc
new file mode 100644 (file)
index 0000000..c59bd1c
--- /dev/null
@@ -0,0 +1,17 @@
+#include "LowerInfo.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+LowerInfo::LowerInfo(const std::string &backend_id) : _backend_id(backend_id)
+{
+  // DO NOTHING
+}
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
diff --git a/runtimes/neurun/src/graph/operation/LowerInfo.h b/runtimes/neurun/src/graph/operation/LowerInfo.h
new file mode 100644 (file)
index 0000000..c524b00
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
+#define __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
+
+#include <string>
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+class LowerInfo
+{
+public:
+  LowerInfo(const std::string &backend_id);
+  const std::string &backend_id() const { return _backend_id; }
+
+private:
+  const std::string _backend_id;
+};
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
+
+#endif // __NEURUN_GRAPH_OPERATION_LOWER_INFO_H__
index 586516c..a00466b 100644 (file)
@@ -1,8 +1,11 @@
 #ifndef __NEURUN_GRAPH_OPERATION_NODE_H__
 #define __NEURUN_GRAPH_OPERATION_NODE_H__
 
+#include <memory>
+
 #include "graph/operand/IndexSet.h"
 #include "internal/op/Node.h"
+#include "LowerInfo.h"
 
 namespace neurun
 {
@@ -11,7 +14,9 @@ namespace graph
 namespace operation
 {
 
-struct Node
+class LowerInfo;
+
+class Node
 {
 public:
   virtual ~Node() = default;
@@ -20,6 +25,13 @@ public:
   virtual operand::IndexSet inputs() const = 0;
   virtual operand::IndexSet outputs() const = 0;
   virtual const ::internal::tflite::op::Node *op() const = 0;
+
+public:
+  void lower_info(std::unique_ptr<LowerInfo> &&lower_info) { _lower_info = std::move(lower_info); }
+  const LowerInfo *lower_info() const { return _lower_info.get(); }
+
+private:
+  std::unique_ptr<LowerInfo> _lower_info;
 };
 
 } // namespace operation