From 66a2b106a5745e14d868442e43e2a28a206c75ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 14 Jun 2019 09:46:38 +0900 Subject: [PATCH] Use Coordinates in SubTensorInfo (#5395) Use Coordinates instead of Coordinate4D in SubTensorAnalyzer and SubTensorInfo Signed-off-by: Hyeongseok Oh --- runtimes/neurun/backend/acl_common/TemplTensorBuilder.h | 8 ++++---- runtimes/neurun/core/include/compiler/SubTensorInfo.h | 5 ++--- runtimes/neurun/core/include/graph/operand/ParentInfo.h | 10 +++++----- runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc | 5 ++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/runtimes/neurun/backend/acl_common/TemplTensorBuilder.h b/runtimes/neurun/backend/acl_common/TemplTensorBuilder.h index 71278cd..decc5ae 100644 --- a/runtimes/neurun/backend/acl_common/TemplTensorBuilder.h +++ b/runtimes/neurun/backend/acl_common/TemplTensorBuilder.h @@ -225,13 +225,13 @@ void TemplTensorBuilder::prepare(voi // Only support axis: 3 (channel) ::arm_compute::Coordinates coordinates; coordinates.set_num_dimensions(4); - assert(info.offset().h() == 0); - assert(info.offset().n() == 0); - assert(info.offset().w() == 0); + assert(info.offset()[0] == 0); + assert(info.offset()[1] == 0); + assert(info.offset()[2] == 0); // TODO Change to set data_layout for each front-end auto channel_index = get_data_layout_dimension_index( parent_tensor->info()->data_layout(), ::arm_compute::DataLayoutDimension::CHANNEL); - coordinates[channel_index] = info.offset().c(); + coordinates[channel_index] = info.offset()[3]; auto tensor = std::make_shared(parent_tensor.get(), shape, coordinates, true); _subtensors[current] = tensor; stack.pop(); diff --git a/runtimes/neurun/core/include/compiler/SubTensorInfo.h b/runtimes/neurun/core/include/compiler/SubTensorInfo.h index 2698e61..92b2759 100644 --- a/runtimes/neurun/core/include/compiler/SubTensorInfo.h +++ b/runtimes/neurun/core/include/compiler/SubTensorInfo.h @@ -23,7 +23,6 @@ #define __NEURUN_COMPILER_SUBTENSOR_INFO_H__ #include "model/Operand.h" -#include "util/feature/Coordinate4D.h" namespace neurun { @@ -69,13 +68,13 @@ public: * @brief Return tensor's offset in parent tensor * @return Tensor offset */ - const neurun::util::feature::Coordinate4D offset(void) const { return _offset; } + const neurun::util::Coordinates offset(void) const { return _offset; } private: const model::OperandIndex _parent; const model::Shape _shape; const model::TypeInfo _type; - const neurun::util::feature::Coordinate4D _offset; + const neurun::util::Coordinates _offset; }; } // compiler diff --git a/runtimes/neurun/core/include/graph/operand/ParentInfo.h b/runtimes/neurun/core/include/graph/operand/ParentInfo.h index adf7053..024925d 100644 --- a/runtimes/neurun/core/include/graph/operand/ParentInfo.h +++ b/runtimes/neurun/core/include/graph/operand/ParentInfo.h @@ -26,7 +26,7 @@ #include #include "model/Index.h" -#include "util/feature/Coordinate4D.h" +#include "util/Coordinates.h" namespace neurun { @@ -35,7 +35,7 @@ namespace graph namespace operand { -using neurun::util::feature::Coordinate4D; +using neurun::util::Coordinates; /** * @brief Class to represent parent operand in child operand @@ -49,7 +49,7 @@ public: * @param[in] coordinate Offset of child operand in parent operand * @return */ - ParentInfo(const model::OperandIndex parent, const Coordinate4D &coordinate) + ParentInfo(const model::OperandIndex parent, const Coordinates &coordinate) : _parent{parent}, _coordinate{coordinate} { // DO NOTHING @@ -65,11 +65,11 @@ public: * @brief Retern offset in parent * @return Offset */ - Coordinate4D offset(void) const { return _coordinate; } + Coordinates offset(void) const { return _coordinate; } private: model::OperandIndex _parent; - Coordinate4D _coordinate; + Coordinates _coordinate; }; } // namespace operand diff --git a/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc b/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc index 3f707f8..5859adc 100644 --- a/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc +++ b/runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc @@ -60,7 +60,7 @@ void SubTensorAnalyzer::visit(const model::operation::ConcatNode &node) auto input_shape = _ctx.at(input_index).shape(); std::vector offset = {0, 0, 0, 0}; offset[axis] = axis_point; - neurun::util::feature::Coordinate4D coordinate_info(offset[0], offset[1], offset[2], offset[3]); + neurun::util::Coordinates coordinate_info({offset[0], offset[1], offset[2], offset[3]}); std::unique_ptr parentInfo = nnfw::cpp14::make_unique(output_index, coordinate_info); @@ -68,8 +68,7 @@ void SubTensorAnalyzer::visit(const model::operation::ConcatNode &node) assert(_ctx.at(input_index).parent_info() == nullptr); _ctx.at(input_index).parent_info(std::move(parentInfo)); - // NOTE Only support when axis is 3(channel) - axis_point += input_shape.dim(3); + axis_point += input_shape.dim(axis); } } -- 2.7.4