From 5345b55e6db6d805d4e4f009126806699c6f3429 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 9 Aug 2019 14:04:57 +0900 Subject: [PATCH] [neurun] Rename compiler::Element (#6430) Move `compiler::Element` to `compiler::Linear::Element`. This removes `Element.h` and make it to be an inner class of `Linear`. Signed-off-by: Hanjoung Lee --- runtimes/neurun/core/src/compiler/Element.h | 44 ---------------------- .../neurun/core/src/compiler/ExecutorFactory.cc | 4 +- runtimes/neurun/core/src/compiler/Linear.cc | 2 +- runtimes/neurun/core/src/compiler/Linear.h | 14 ++++++- runtimes/neurun/core/src/exec/LinearExecutor.h | 6 +-- 5 files changed, 19 insertions(+), 51 deletions(-) delete mode 100644 runtimes/neurun/core/src/compiler/Element.h diff --git a/runtimes/neurun/core/src/compiler/Element.h b/runtimes/neurun/core/src/compiler/Element.h deleted file mode 100644 index 098c0f8..0000000 --- a/runtimes/neurun/core/src/compiler/Element.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#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 compiler -{ - -struct Element -{ - const model::Subgraph *subgraph; - const graph::operation::LowerInfo *lower_info; - - Element(const model::Subgraph *subgraph, const graph::operation::LowerInfo *lower_info) - : subgraph{subgraph}, lower_info{lower_info} - { - // DO NOTHING - } -}; - -} // namespace compiler -} // namespace neurun - -#endif // __NEURUN_COMPILER_ELEMENT_H__ diff --git a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc index 728c80f..e34a03d 100644 --- a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc +++ b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc @@ -96,7 +96,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph) ***********************/ // Fix shapes - linear->iterate([&](const compiler::Element &element) { + linear->iterate([&](const compiler::Linear::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 compiler::Element &element) { + linear->iterate([&](const compiler::Linear::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/compiler/Linear.cc b/runtimes/neurun/core/src/compiler/Linear.cc index a4fca3d..83efb96 100644 --- a/runtimes/neurun/core/src/compiler/Linear.cc +++ b/runtimes/neurun/core/src/compiler/Linear.cc @@ -322,7 +322,7 @@ void Linear::iterate(const std::function &fn) cons void Linear::generateConstantInitializers(void) const { - iterate([&](const compiler::Element &element) { + iterate([&](const compiler::Linear::Element &element) { auto backend = element.lower_info->backend(); auto constant_initializer = _backend_resolver->getBackendContext(backend)->constant_initializer; diff --git a/runtimes/neurun/core/src/compiler/Linear.h b/runtimes/neurun/core/src/compiler/Linear.h index 28869db..5f87aae 100644 --- a/runtimes/neurun/core/src/compiler/Linear.h +++ b/runtimes/neurun/core/src/compiler/Linear.h @@ -20,7 +20,6 @@ #include #include -#include "Element.h" #include "model/Model.h" #include "model/Subgraphs.h" #include "backend/ITensorBuilder.h" @@ -46,6 +45,19 @@ namespace compiler class Linear { public: + struct Element + { + const model::Subgraph *subgraph; + const graph::operation::LowerInfo *lower_info; + + Element(const model::Subgraph *subgraph, const graph::operation::LowerInfo *lower_info) + : subgraph{subgraph}, lower_info{lower_info} + { + // DO NOTHING + } + }; + +public: Linear(const std::shared_ptr &model, std::unique_ptr subgraphs, std::unique_ptr lower_info_map, diff --git a/runtimes/neurun/core/src/exec/LinearExecutor.h b/runtimes/neurun/core/src/exec/LinearExecutor.h index 9be1f12..42cbad4 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 "compiler/Element.h" +#include "compiler/Linear.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 -- 2.7.4