From: 이한종/On-Device Lab(SR)/Engineer/삼성전자 Date: Fri, 9 Aug 2019 01:50:58 +0000 (+0900) Subject: [neurun] Remove linear namespace (#6407) X-Git-Tag: submit/tizen/20190809.050447~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d59ca8e4dc6109feea286f7e66b1178a1b62198d;p=platform%2Fcore%2Fml%2Fnnfw.git [neurun] Remove linear namespace (#6407) 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 --- diff --git a/runtimes/neurun/core/include/graph/Graph.h b/runtimes/neurun/core/include/graph/Graph.h index 9f4182f..13b29b9 100644 --- a/runtimes/neurun/core/include/graph/Graph.h +++ b/runtimes/neurun/core/include/graph/Graph.h @@ -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 linearize(void); + std::unique_ptr linearize(void); bool isBuildingPhase(void) const { return _phase == Phase::BUILDING; } std::shared_ptr shareModel() { return _model; } std::unique_ptr releaseLowerInfo() { return std::move(_lower_info_map); } diff --git a/runtimes/neurun/core/src/compiler/Compiler.cc b/runtimes/neurun/core/src/compiler/Compiler.cc index b8d3170..90b078e 100644 --- a/runtimes/neurun/core/src/compiler/Compiler.cc +++ b/runtimes/neurun/core/src/compiler/Compiler.cc @@ -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" diff --git a/runtimes/neurun/core/src/linear/Element.h b/runtimes/neurun/core/src/compiler/Element.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 --- a/runtimes/neurun/core/src/linear/Element.h +++ b/runtimes/neurun/core/src/compiler/Element.h @@ -14,15 +14,16 @@ * 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__ diff --git a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc index 33e1680..728c80f 100644 --- a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc +++ b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc @@ -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(*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()); diff --git a/runtimes/neurun/core/src/linear/Linear.cc b/runtimes/neurun/core/src/compiler/Linear.cc 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 --- a/runtimes/neurun/core/src/linear/Linear.cc +++ b/runtimes/neurun/core/src/compiler/Linear.cc @@ -32,7 +32,7 @@ namespace neurun { -namespace linear +namespace compiler { Linear::Linear(const std::shared_ptr &model, @@ -322,7 +322,7 @@ void Linear::iterate(const std::function &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 diff --git a/runtimes/neurun/core/src/linear/Linear.h b/runtimes/neurun/core/src/compiler/Linear.h 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 --- a/runtimes/neurun/core/src/linear/Linear.h +++ b/runtimes/neurun/core/src/compiler/Linear.h @@ -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 #include @@ -40,7 +40,7 @@ struct OperationVisitor; namespace neurun { -namespace linear +namespace compiler { class Linear @@ -89,7 +89,7 @@ private: std::unique_ptr _backend_resolver; }; -} // namespace linear +} // namespace compiler } // namespace neurun -#endif // __NEURUN_LINEAR_LINEAR_H__ +#endif // __NEURUN_COMPILER_LINEAR_H__ diff --git a/runtimes/neurun/core/src/exec/LinearExecutor.h b/runtimes/neurun/core/src/exec/LinearExecutor.h index 403a426..9be1f12 100644 --- a/runtimes/neurun/core/src/exec/LinearExecutor.h +++ b/runtimes/neurun/core/src/exec/LinearExecutor.h @@ -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 &operand_context, std::unique_ptr lower_info, std::unique_ptr mem_mgrs, - std::unique_ptr> elements, + std::unique_ptr> elements, const std::shared_ptr &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 _plan; - std::unique_ptr> _elements; + std::unique_ptr> _elements; }; } // namespace exec diff --git a/runtimes/neurun/core/src/graph/Graph.cc b/runtimes/neurun/core/src/graph/Graph.cc index 207b909..4264b1a 100644 --- a/runtimes/neurun/core/src/graph/Graph.cc +++ b/runtimes/neurun/core/src/graph/Graph.cc @@ -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 Graph::linearize(void) +std::unique_ptr Graph::linearize(void) { assert(_phase == Phase::MODEL); - auto linear = nnfw::cpp14::make_unique( + auto linear = nnfw::cpp14::make_unique( shareModel(), releaseSubgraphs(), releaseLowerInfo(), releaseBackendResolver()); // TODO Move the operations and operands to linear object