From 8c4f2bf2050df9740f33b8c3166af507bcac40ad Mon Sep 17 00:00:00 2001 From: Sergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics Date: Tue, 3 Dec 2019 06:52:50 +0300 Subject: [PATCH] [neurun] Replace IObject with ITensor in OperandContext (#9335) Replace uses of `IObject` with `ITensor` in `OperandContext`. Signed-off-by: Sergei Barannikov --- runtime/neurun/core/src/compiler/ExecutorFactory.cc | 4 ++-- runtime/neurun/core/src/compiler/OperandContext.cc | 12 ++++++------ runtime/neurun/core/src/compiler/OperandContext.h | 18 +++++++++--------- runtime/neurun/core/src/exec/ExecutorBase.h | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/runtime/neurun/core/src/compiler/ExecutorFactory.cc b/runtime/neurun/core/src/compiler/ExecutorFactory.cc index 06f3d76..2b6dbb5 100644 --- a/runtime/neurun/core/src/compiler/ExecutorFactory.cc +++ b/runtime/neurun/core/src/compiler/ExecutorFactory.cc @@ -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); }); } diff --git a/runtime/neurun/core/src/compiler/OperandContext.cc b/runtime/neurun/core/src/compiler/OperandContext.cc index 77adc55..3fc3816 100644 --- a/runtime/neurun/core/src/compiler/OperandContext.cc +++ b/runtime/neurun/core/src/compiler/OperandContext.cc @@ -24,18 +24,18 @@ namespace compiler { OperandContext &OperandContext::set(const model::OperandIndex &id, - const std::shared_ptr &object) + const std::shared_ptr &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 &fn) + const std::function &fn) { - for (auto &e : _objects) + for (auto &e : _tensors) { fn(e.first, *e.second); } diff --git a/runtime/neurun/core/src/compiler/OperandContext.h b/runtime/neurun/core/src/compiler/OperandContext.h index 1691225..0b7dc52 100644 --- a/runtime/neurun/core/src/compiler/OperandContext.h +++ b/runtime/neurun/core/src/compiler/OperandContext.h @@ -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 #include @@ -31,30 +31,30 @@ class OperandContext { public: OperandContext &set(const model::OperandIndex &ind, - const std::shared_ptr &object); + const std::shared_ptr &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 at(const model::OperandIndex &ind) const + std::shared_ptr at(const model::OperandIndex &ind) const { - return _objects.at(ind); + return _tensors.at(ind); } - std::shared_ptr &at(const model::OperandIndex &ind) + std::shared_ptr &at(const model::OperandIndex &ind) { - return _objects.at(ind); + return _tensors.at(ind); } void - iterate(const std::function &fn); + iterate(const std::function &fn); private: - model::OperandIndexMap> _objects; + model::OperandIndexMap> _tensors; }; } // namespace compiler diff --git a/runtime/neurun/core/src/exec/ExecutorBase.h b/runtime/neurun/core/src/exec/ExecutorBase.h index 00f1f34..f94320c 100644 --- a/runtime/neurun/core/src/exec/ExecutorBase.h +++ b/runtime/neurun/core/src/exec/ExecutorBase.h @@ -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)) || -- 2.7.4