From a6ce84f9e34d21e13f130ce3cb2475a55994ead9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ivan=20Vagin/AI=20Tools=20Lab=20/SRR/Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 16 Jul 2019 06:39:02 +0300 Subject: [PATCH] [neurun] Sequance replaced with FunctionSequance in linear executor (#5653) * [neurun] Sequance replaced with FunctionSequance * Sequance replaced with FunctionSequance in linear executor Signed-off-by: Ivan Vagin * Fixed formatting Signed-off-by: Ivan Vagin --- .../neurun/core/src/compiler/ExecutorFactory.cc | 6 +-- runtimes/neurun/core/src/compiler/Plan.h | 8 ++-- runtimes/neurun/core/src/compiler/PlanBuilder.cc | 2 +- runtimes/neurun/core/src/compiler/PlanBuilder.h | 14 +++--- .../neurun/core/src/compiler/operation/Sequence.cc | 30 ------------ .../neurun/core/src/compiler/operation/Sequence.h | 54 ---------------------- runtimes/neurun/core/src/exec/LinearExecutor.cc | 9 +--- 7 files changed, 16 insertions(+), 107 deletions(-) delete mode 100644 runtimes/neurun/core/src/compiler/operation/Sequence.cc delete mode 100644 runtimes/neurun/core/src/compiler/operation/Sequence.h diff --git a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc index 5c4bdb9..68086ea 100644 --- a/runtimes/neurun/core/src/compiler/ExecutorFactory.cc +++ b/runtimes/neurun/core/src/compiler/ExecutorFactory.cc @@ -62,7 +62,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph) const auto &operands = graph.operands(); // Compilation result will be filled in operand_context and operation_sequence - auto operation_sequence = std::make_shared(); + auto function_sequence = std::make_shared(); // linearize auto linear = graph.linearize(); @@ -93,7 +93,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph) * Code generation phase ***********************/ - PlanBuilder plan_builder{*operand_context, *operation_sequence}; + PlanBuilder plan_builder{*operand_context, *function_sequence}; // Fix shapes linear->iterate([&](const linear::Element &element) { @@ -116,7 +116,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph) mem_mgrs->insert(std::move(tensor_builder->releaseMemoryManager())); } - auto plan = std::make_shared(operation_sequence); + auto plan = std::make_shared(function_sequence); return new exec::LinearExecutor{graph.shareModel(), linear->releaseSubgraphContext(), operand_context, diff --git a/runtimes/neurun/core/src/compiler/Plan.h b/runtimes/neurun/core/src/compiler/Plan.h index ccda8d9..7d393ca 100644 --- a/runtimes/neurun/core/src/compiler/Plan.h +++ b/runtimes/neurun/core/src/compiler/Plan.h @@ -18,8 +18,8 @@ #define __NEURUN_CODEGEN_PLAN_H__ #include "graph/Graph.h" +#include "exec/FunctionSequence.h" #include "compiler/OperandContext.h" -#include "compiler/operation/Sequence.h" namespace neurun { @@ -38,16 +38,16 @@ public: * @param[in] operands Compiled operand context * @param[in] ops Compiled operation sequence */ - Plan(std::shared_ptr &ops) : _ops{ops} + Plan(std::shared_ptr &ops) : _ops{ops} { // DO NOTHING } public: - const operation::Sequence &operations(void) const { return *_ops; } + exec::FunctionSequence &functions(void) const { return *_ops; } private: - std::shared_ptr _ops{nullptr}; + std::shared_ptr _ops{nullptr}; }; } // namespace compiler diff --git a/runtimes/neurun/core/src/compiler/PlanBuilder.cc b/runtimes/neurun/core/src/compiler/PlanBuilder.cc index b4ac0de..e3958c7 100644 --- a/runtimes/neurun/core/src/compiler/PlanBuilder.cc +++ b/runtimes/neurun/core/src/compiler/PlanBuilder.cc @@ -42,7 +42,7 @@ void PlanBuilder::finalize(const linear::Linear *linear, } // Generate kernels - auto execution_builder = nnfw::cpp14::make_unique(_operations); + auto execution_builder = nnfw::cpp14::make_unique(_functions); linear->iterate([&](const linear::Element &element) { auto backend = element.lower_info->backend(); auto kernel_gen = backend->kernel_gen(); diff --git a/runtimes/neurun/core/src/compiler/PlanBuilder.h b/runtimes/neurun/core/src/compiler/PlanBuilder.h index ac2b079..c3bc097 100644 --- a/runtimes/neurun/core/src/compiler/PlanBuilder.h +++ b/runtimes/neurun/core/src/compiler/PlanBuilder.h @@ -17,8 +17,8 @@ #ifndef __NEURUN_COMPILER_PLAN_BUILDER_H__ #define __NEURUN_COMPILER_PLAN_BUILDER_H__ +#include "exec/FunctionSequence.h" #include "compiler/OperandContext.h" -#include "compiler/operation/Sequence.h" #include "compiler/IExecutionBuilder.h" #include "backend/IShapeFixer.h" #include "backend/ITensorBuilder.h" @@ -32,7 +32,7 @@ namespace compiler class ExecutionBuilder final : public IExecutionBuilder { public: - ExecutionBuilder(operation::Sequence &operations) : _operations{operations} + ExecutionBuilder(exec::FunctionSequence &functions) : _functions{functions} { // DO NOTHING } @@ -40,18 +40,18 @@ public: public: void append(std::unique_ptr<::neurun::exec::IFunction> &&f) override { - _operations.append(std::move(f)); + _functions.append(std::move(f)); } private: - operation::Sequence &_operations; + exec::FunctionSequence &_functions; }; class PlanBuilder { public: - PlanBuilder(OperandContext &operands, operation::Sequence &operations) - : _operands{operands}, _operations{operations} + PlanBuilder(OperandContext &operands, exec::FunctionSequence &functions) + : _operands{operands}, _functions{functions} { // DO NOTHING } @@ -62,7 +62,7 @@ public: private: OperandContext &_operands; - operation::Sequence &_operations; + exec::FunctionSequence &_functions; }; } // namepsace compiler diff --git a/runtimes/neurun/core/src/compiler/operation/Sequence.cc b/runtimes/neurun/core/src/compiler/operation/Sequence.cc deleted file mode 100644 index 3160e04..0000000 --- a/runtimes/neurun/core/src/compiler/operation/Sequence.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ - -#include "Sequence.h" - -namespace neurun -{ -namespace compiler -{ -namespace operation -{ - -// NO IMPLEMENTATION YET - -} // namespace operation -} // namespace compiler -} // namespace neurun diff --git a/runtimes/neurun/core/src/compiler/operation/Sequence.h b/runtimes/neurun/core/src/compiler/operation/Sequence.h deleted file mode 100644 index c3ced26..0000000 --- a/runtimes/neurun/core/src/compiler/operation/Sequence.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018 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_OPERATION_SEQUENCE_H__ -#define __NEURUN_COMPILER_OPERATION_SEQUENCE_H__ -#include -#include "exec/IFunction.h" -#include -#include - -namespace neurun -{ -namespace compiler -{ -namespace operation -{ - -class Sequence -{ -public: - uint32_t size(void) const { return _functions.size(); } - -public: - Sequence &append(std::unique_ptr<::neurun::exec::IFunction> &&func) - { - _functions.emplace_back(std::move(func)); - return (*this); - } - -public: - ::neurun::exec::IFunction &at(uint32_t n) const { return *(_functions.at(n)); } - -private: - std::vector> _functions; -}; - -} // namespace operation -} // namespace compiler -} // namespace neurun - -#endif // __NEURUN_COMPILER_OPERATION_SEQUENCE_H__ diff --git a/runtimes/neurun/core/src/exec/LinearExecutor.cc b/runtimes/neurun/core/src/exec/LinearExecutor.cc index a1d3932..8c387e0 100644 --- a/runtimes/neurun/core/src/exec/LinearExecutor.cc +++ b/runtimes/neurun/core/src/exec/LinearExecutor.cc @@ -21,14 +21,7 @@ namespace neurun namespace exec { -void LinearExecutor::executeImpl() -{ - const auto &operations = _plan->operations(); - for (uint32_t n = 0; n < operations.size(); ++n) - { - operations.at(n).run(); - } -} +void LinearExecutor::executeImpl() { _plan->functions().run(); } } // namespace exec } // namespace neurun -- 2.7.4