[neurun] Remove linear namespace (#6407)
author이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Fri, 9 Aug 2019 01:50:58 +0000 (10:50 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 9 Aug 2019 01:50:58 +0000 (10:50 +0900)
As `namespace` linear has only few classes this commit moves those to
namespace `compiler`.

`compiler::Element` will be renamed to `compiler::LinearElement`.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/core/include/graph/Graph.h
runtimes/neurun/core/src/compiler/Compiler.cc
runtimes/neurun/core/src/compiler/Element.h [moved from runtimes/neurun/core/src/linear/Element.h with 82% similarity]
runtimes/neurun/core/src/compiler/ExecutorFactory.cc
runtimes/neurun/core/src/compiler/Linear.cc [moved from runtimes/neurun/core/src/linear/Linear.cc with 99% similarity]
runtimes/neurun/core/src/compiler/Linear.h [moved from runtimes/neurun/core/src/linear/Linear.h with 94% similarity]
runtimes/neurun/core/src/exec/LinearExecutor.h
runtimes/neurun/core/src/graph/Graph.cc

index 9f4182f..13b29b9 100644 (file)
@@ -38,7 +38,7 @@ class LowerInfo;
 
 namespace neurun
 {
-namespace linear
+namespace compiler
 {
 class Linear;
 } // namespace linear
@@ -122,7 +122,7 @@ public:
   void finishBuilding(void);
   void lower(void);
   void removeOperand(const model::OperandIndex &ind) { _model->operands.remove(ind); }
-  std::unique_ptr<linear::Linear> linearize(void);
+  std::unique_ptr<compiler::Linear> linearize(void);
   bool isBuildingPhase(void) const { return _phase == Phase::BUILDING; }
   std::shared_ptr<const model::Model> shareModel() { return _model; }
   std::unique_ptr<graph::LowerInfoMap> releaseLowerInfo() { return std::move(_lower_info_map); }
index b8d3170..90b078e 100644 (file)
@@ -26,7 +26,7 @@
 #include "backend/ExecTime.h"
 #include "graph/operation/LowerInfo.h"
 #include "dumper/dot/DotDumper.h"
-#include "linear/Linear.h"
+#include "compiler/Linear.h"
 #include "exec/interp/ExecManager.h"
 #include "backend/ExecTime.h"
 #include "util/ConfigSource.h"
similarity index 82%
rename from runtimes/neurun/core/src/linear/Element.h
rename to runtimes/neurun/core/src/compiler/Element.h
index 03a6999..098c0f8 100644 (file)
  * limitations under the License.
  */
 
-#ifndef __NEURUN_LINEAR_ELEMENT_H__
-#define __NEURUN_LINEAR_ELEMENT_H__
+#ifndef __NEURUN_COMPILER_ELEMENT_H__
+#define __NEURUN_COMPILER_ELEMENT_H__
 
 #include "model/Subgraph.h"
 #include "graph/LowerInfoMap.h"
 
+// TODO Put this in class Linear (as an inner class)
 namespace neurun
 {
-namespace linear
+namespace compiler
 {
 
 struct Element
@@ -37,7 +38,7 @@ struct Element
   }
 };
 
-} // namespace linear
+} // namespace compiler
 } // namespace neurun
 
-#endif // __NEURUN_LINEAR_ELEMENT_H__
+#endif // __NEURUN_COMPILER_ELEMENT_H__
index 33e1680..728c80f 100644 (file)
@@ -23,7 +23,7 @@
 #include "exec/ParallelExecutor.h"
 #include "compiler/BackendResolver.h"
 #include "backend/ExecTime.h"
-#include "linear/Linear.h"
+#include "compiler/Linear.h"
 #include "graph/dumper/Dumper.h"
 #include "OperationValidator.h"
 #include "SubTensorAnalyzer.h"
@@ -96,7 +96,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph)
    ***********************/
 
   // Fix shapes
-  linear->iterate([&](const linear::Element &element) {
+  linear->iterate([&](const compiler::Element &element) {
     auto backend = element.lower_info->backend();
     auto shape_fixer = linear->getBackendContext(backend)->shape_fixer;
     shape_fixer->fix(*element.subgraph);
@@ -140,7 +140,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph)
   auto execution_builder = nnfw::cpp14::make_unique<ExecutionBuilder>(*function_sequence);
 
   // Generate kernels
-  linear->iterate([&](const linear::Element &element) {
+  linear->iterate([&](const compiler::Element &element) {
     auto backend = element.lower_info->backend();
     auto kernel_gen = linear->getBackendContext(backend)->kernel_gen;
     kernel_gen->generate(*element.subgraph, execution_builder.get());
similarity index 99%
rename from runtimes/neurun/core/src/linear/Linear.cc
rename to runtimes/neurun/core/src/compiler/Linear.cc
index 5cd9c8d..a4fca3d 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace neurun
 {
-namespace linear
+namespace compiler
 {
 
 Linear::Linear(const std::shared_ptr<const model::Model> &model,
@@ -322,7 +322,7 @@ void Linear::iterate(const std::function<void(const Element &element)> &fn) cons
 
 void Linear::generateConstantInitializers(void) const
 {
-  iterate([&](const linear::Element &element) {
+  iterate([&](const compiler::Element &element) {
     auto backend = element.lower_info->backend();
 
     auto constant_initializer = _backend_resolver->getBackendContext(backend)->constant_initializer;
@@ -350,5 +350,5 @@ const graph::operand::LowerInfo *Linear::getLowerInfo(const model::OperandIndex
   return itr->second.get();
 }
 
-} // namespace linear
+} // namespace compiler
 } // namespace neurun
similarity index 94%
rename from runtimes/neurun/core/src/linear/Linear.h
rename to runtimes/neurun/core/src/compiler/Linear.h
index 2f37036..28869db 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef __NEURUN_LINEAR_LINEAR_H__
-#define __NEURUN_LINEAR_LINEAR_H__
+#ifndef __NEURUN_COMPILER_LINEAR_H__
+#define __NEURUN_COMPILER_LINEAR_H__
 
 #include <vector>
 #include <memory>
@@ -40,7 +40,7 @@ struct OperationVisitor;
 
 namespace neurun
 {
-namespace linear
+namespace compiler
 {
 
 class Linear
@@ -89,7 +89,7 @@ private:
   std::unique_ptr<compiler::BackendResolver> _backend_resolver;
 };
 
-} // namespace linear
+} // namespace compiler
 } // namespace neurun
 
-#endif // __NEURUN_LINEAR_LINEAR_H__
+#endif // __NEURUN_COMPILER_LINEAR_H__
index 403a426..9be1f12 100644 (file)
@@ -24,7 +24,7 @@
 
 #include "ExecutorBase.h"
 #include "compiler/Plan.h"
-#include "linear/Element.h"
+#include "compiler/Element.h"
 
 namespace neurun
 {
@@ -47,7 +47,7 @@ public:
                  const std::shared_ptr<compiler::OperandContext> &operand_context,
                  std::unique_ptr<graph::LowerInfoMap> lower_info,
                  std::unique_ptr<backend::MemoryManagerSet> mem_mgrs,
-                 std::unique_ptr<std::vector<linear::Element>> elements,
+                 std::unique_ptr<std::vector<compiler::Element>> elements,
                  const std::shared_ptr<const neurun::compiler::Plan> &plan)
       : ExecutorBase{model, std::move(subgraphs), operand_context, std::move(lower_info),
                      std::move(mem_mgrs)},
@@ -60,7 +60,7 @@ public:
 
 private:
   std::shared_ptr<const compiler::Plan> _plan;
-  std::unique_ptr<std::vector<linear::Element>> _elements;
+  std::unique_ptr<std::vector<compiler::Element>> _elements;
 };
 
 } // namespace exec
index 207b909..4264b1a 100644 (file)
@@ -22,7 +22,7 @@
 #include "util/logging.h"
 #include "verifier/Verifier.h"
 #include "cpp14/memory.h"
-#include "linear/Linear.h"
+#include "compiler/Linear.h"
 #include "graph/operation/LowerInfo.h"
 #include "graph/operand/LowerInfo.h"
 #include "graph/operand/PermuteFactor.h"
@@ -436,11 +436,11 @@ void Graph::lower(void)
   }
 }
 
-std::unique_ptr<linear::Linear> Graph::linearize(void)
+std::unique_ptr<compiler::Linear> Graph::linearize(void)
 {
   assert(_phase == Phase::MODEL);
 
-  auto linear = nnfw::cpp14::make_unique<linear::Linear>(
+  auto linear = nnfw::cpp14::make_unique<compiler::Linear>(
       shareModel(), releaseSubgraphs(), releaseLowerInfo(), releaseBackendResolver());
 
   // TODO Move the operations and operands to linear object