[neurun] Replace IObject with ITensor in OperandContext (#9335)
authorSergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics <s.barannikov@samsung.com>
Tue, 3 Dec 2019 03:52:50 +0000 (06:52 +0300)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Tue, 3 Dec 2019 03:52:50 +0000 (12:52 +0900)
Replace uses of `IObject` with `ITensor` in `OperandContext`.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
runtime/neurun/core/src/compiler/ExecutorFactory.cc
runtime/neurun/core/src/compiler/OperandContext.cc
runtime/neurun/core/src/compiler/OperandContext.h
runtime/neurun/core/src/exec/ExecutorBase.h

index 06f3d76..2b6dbb5 100644 (file)
@@ -181,7 +181,7 @@ exec::IExecutor *ExecutorFactory::createLinearExecutor(graph::Graph &graph)
   for (auto &tensor_builder : tensor_builders)
   {
     tensor_builder->iterate([&](const model::OperandIndex &index) {
-      auto object = tensor_builder->wrapTensor(index);
+      auto object = tensor_builder->tensorAt(index);
       operand_context->set(index, object);
     });
   }
@@ -342,7 +342,7 @@ exec::IExecutor *ExecutorFactory::createDataflowExecutor(graph::Graph &graph, bo
   for (auto &tensor_builder : tensor_builders)
   {
     tensor_builder->iterate([&](const model::OperandIndex &index) {
-      auto object = tensor_builder->wrapTensor(index);
+      auto object = tensor_builder->tensorAt(index);
       operand_context->set(index, object);
     });
   }
index 77adc55..3fc3816 100644 (file)
@@ -24,18 +24,18 @@ namespace compiler
 {
 
 OperandContext &OperandContext::set(const model::OperandIndex &id,
-                                    const std::shared_ptr<backend::operand::IObject> &object)
+                                    const std::shared_ptr<backend::operand::ITensor> &tensor)
 {
-  // Only one object for an id
-  assert(_objects.find(id) == _objects.end());
-  _objects[id] = object;
+  // Only one tensor for an id
+  assert(_tensors.find(id) == _tensors.end());
+  _tensors[id] = tensor;
   return (*this);
 }
 
 void OperandContext::iterate(
-    const std::function<void(const model::OperandIndex &, backend::operand::IObject &)> &fn)
+    const std::function<void(const model::OperandIndex &, backend::operand::ITensor &)> &fn)
 {
-  for (auto &e : _objects)
+  for (auto &e : _tensors)
   {
     fn(e.first, *e.second);
   }
index 1691225..0b7dc52 100644 (file)
@@ -17,7 +17,7 @@
 #ifndef __NEURUN_COMPILER_OPERAND_CONTEXT_H__
 #define __NEURUN_COMPILER_OPERAND_CONTEXT_H__
 
-#include "backend/operand/IObject.h"
+#include "backend/operand/ITensor.h"
 #include "model/OperandIndexMap.h"
 #include <unordered_map>
 #include <memory>
@@ -31,30 +31,30 @@ class OperandContext
 {
 public:
   OperandContext &set(const model::OperandIndex &ind,
-                      const std::shared_ptr<backend::operand::IObject> &object);
+                      const std::shared_ptr<backend::operand::ITensor> &tensor);
 
 public:
   bool exist(const ::neurun::model::OperandIndex &ind) const
   {
-    return _objects.find(ind) != _objects.end();
+    return _tensors.find(ind) != _tensors.end();
   }
 
 public:
-  std::shared_ptr<backend::operand::IObject> at(const model::OperandIndex &ind) const
+  std::shared_ptr<backend::operand::ITensor> at(const model::OperandIndex &ind) const
   {
-    return _objects.at(ind);
+    return _tensors.at(ind);
   }
 
-  std::shared_ptr<backend::operand::IObject> &at(const model::OperandIndex &ind)
+  std::shared_ptr<backend::operand::ITensor> &at(const model::OperandIndex &ind)
   {
-    return _objects.at(ind);
+    return _tensors.at(ind);
   }
 
   void
-  iterate(const std::function<void(const model::OperandIndex &, backend::operand::IObject &)> &fn);
+  iterate(const std::function<void(const model::OperandIndex &, backend::operand::ITensor &)> &fn);
 
 private:
-  model::OperandIndexMap<std::shared_ptr<backend::operand::IObject>> _objects;
+  model::OperandIndexMap<std::shared_ptr<backend::operand::ITensor>> _tensors;
 };
 
 } // namespace compiler
index 00f1f34..f94320c 100644 (file)
@@ -75,7 +75,7 @@ private:
     const auto operand_index = _graph.getInputs().at(index);
     const auto &operand = _graph.operands().at(operand_index);
 
-    const auto tensor = _operand_context->at(operand_index)->ptr();
+    const auto tensor = _operand_context->at(operand_index);
     const auto tensor_layout = tensor->layout();
 
     if (((io_layout == model::Layout::NHWC) && (tensor_layout == model::Layout::NCHW)) ||
@@ -97,7 +97,7 @@ private:
   {
     const auto operand_index = _graph.getOutputs().at(index);
     const auto &operand = _graph.operands().at(operand_index);
-    const auto tensor = _operand_context->at(operand_index)->ptr();
+    const auto tensor = _operand_context->at(operand_index);
     const auto tensor_layout = tensor->layout();
 
     if (((tensor_layout == model::Layout::NCHW) && (io_layout == model::Layout::NHWC)) ||