Use Coordinates in SubTensorInfo (#5395)
author오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 14 Jun 2019 00:46:38 +0000 (09:46 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 14 Jun 2019 00:46:38 +0000 (09:46 +0900)
Use Coordinates instead of Coordinate4D in SubTensorAnalyzer and SubTensorInfo

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/backend/acl_common/TemplTensorBuilder.h
runtimes/neurun/core/include/compiler/SubTensorInfo.h
runtimes/neurun/core/include/graph/operand/ParentInfo.h
runtimes/neurun/core/src/compiler/SubTensorAnalyzer.cc

index 71278cd..decc5ae 100644 (file)
@@ -225,13 +225,13 @@ void TemplTensorBuilder<T_ITensor, T_Tensor, T_SubTensor, T_Object>::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<T_SubTensor>(parent_tensor.get(), shape, coordinates, true);
       _subtensors[current] = tensor;
       stack.pop();
index 2698e61..92b2759 100644 (file)
@@ -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
index adf7053..024925d 100644 (file)
@@ -26,7 +26,7 @@
 #include <stdint.h>
 
 #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
index 3f707f8..5859adc 100644 (file)
@@ -60,7 +60,7 @@ void SubTensorAnalyzer::visit(const model::operation::ConcatNode &node)
     auto input_shape = _ctx.at(input_index).shape();
     std::vector<int32_t> 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<graph::operand::ParentInfo> parentInfo =
         nnfw::cpp14::make_unique<graph::operand::ParentInfo>(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);
   }
 }