From: Ivan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 Date: Tue, 16 Jul 2019 03:39:02 +0000 (+0300) Subject: [neurun] Sequance replaced with FunctionSequance in linear executor (#5653) X-Git-Tag: submit/tizen/20190809.050447~541 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6ce84f9e34d21e13f130ce3cb2475a55994ead9;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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