[neurun] Sequance replaced with FunctionSequance in linear executor (#5653)
authorIvan Vagin/AI Tools Lab /SRR/Engineer/삼성전자 <ivan.vagin@samsung.com>
Tue, 16 Jul 2019 03:39:02 +0000 (06:39 +0300)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Tue, 16 Jul 2019 03:39:02 +0000 (12:39 +0900)
* [neurun] Sequance replaced with FunctionSequance

* Sequance replaced with FunctionSequance in linear executor

Signed-off-by: Ivan Vagin <ivan.vagin@samsung.com>
* Fixed formatting

Signed-off-by: Ivan Vagin <ivan.vagin@samsung.com>
runtimes/neurun/core/src/compiler/ExecutorFactory.cc
runtimes/neurun/core/src/compiler/Plan.h
runtimes/neurun/core/src/compiler/PlanBuilder.cc
runtimes/neurun/core/src/compiler/PlanBuilder.h
runtimes/neurun/core/src/compiler/operation/Sequence.cc [deleted file]
runtimes/neurun/core/src/compiler/operation/Sequence.h [deleted file]
runtimes/neurun/core/src/exec/LinearExecutor.cc

index 5c4bdb9..68086ea 100644 (file)
@@ -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<operation::Sequence>();
+  auto function_sequence = std::make_shared<exec::FunctionSequence>();
 
   // 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<Plan>(operation_sequence);
+  auto plan = std::make_shared<Plan>(function_sequence);
   return new exec::LinearExecutor{graph.shareModel(),
                                   linear->releaseSubgraphContext(),
                                   operand_context,
index ccda8d9..7d393ca 100644 (file)
@@ -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<operation::Sequence> &ops) : _ops{ops}
+  Plan(std::shared_ptr<exec::FunctionSequence> &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<operation::Sequence> _ops{nullptr};
+  std::shared_ptr<exec::FunctionSequence> _ops{nullptr};
 };
 
 } // namespace compiler
index b4ac0de..e3958c7 100644 (file)
@@ -42,7 +42,7 @@ void PlanBuilder::finalize(const linear::Linear *linear,
   }
 
   // Generate kernels
-  auto execution_builder = nnfw::cpp14::make_unique<ExecutionBuilder>(_operations);
+  auto execution_builder = nnfw::cpp14::make_unique<ExecutionBuilder>(_functions);
   linear->iterate([&](const linear::Element &element) {
     auto backend = element.lower_info->backend();
     auto kernel_gen = backend->kernel_gen();
index ac2b079..c3bc097 100644 (file)
@@ -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 (file)
index 3160e04..0000000
+++ /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 (file)
index c3ced26..0000000
+++ /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 <stdint.h>
-#include "exec/IFunction.h"
-#include <memory>
-#include <vector>
-
-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<std::unique_ptr<::neurun::exec::IFunction>> _functions;
-};
-
-} // namespace operation
-} // namespace compiler
-} // namespace neurun
-
-#endif // __NEURUN_COMPILER_OPERATION_SEQUENCE_H__
index a1d3932..8c387e0 100644 (file)
@@ -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