[neurun] Extract Coordinate4D from ParentInfo (#3806)
author김수진/동작제어Lab(SR)/Engineer/삼성전자 <sjsujin.kim@samsung.com>
Mon, 3 Dec 2018 07:37:18 +0000 (16:37 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 3 Dec 2018 07:37:18 +0000 (16:37 +0900)
This commit extracts `Coordinate4D` class from `ParentInfo` to use in other classes generally.

Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
runtimes/neurun/src/compiler/SubTensorAnalyzer.cc
runtimes/neurun/src/compiler/SubTensorInfo.h
runtimes/neurun/src/graph/operand/ParentInfo.h
runtimes/neurun/src/util/feature/Coordinate4D.h [new file with mode: 0644]

index f75d61b..9c88d39 100644 (file)
@@ -61,8 +61,7 @@ void SubTensorAnalyzer::visit(const graph::operation::ConcatNode &node)
     auto input_shape_4D = _ctx.at(input_index).lower_info()->shape();
     std::vector<int32_t> offset = {0, 0, 0, 0};
     offset[axis] = axis_point;
-    graph::operand::ParentInfo::Coordinate4D coordinate_info(offset[0], offset[1], offset[2],
-                                                             offset[3]);
+    neurun::util::feature::Coordinate4D coordinate_info(offset[0], offset[1], offset[2], offset[3]);
     std::unique_ptr<graph::operand::ParentInfo> parentInfo =
         nnfw::make_unique<graph::operand::ParentInfo>(output_index, coordinate_info);
 
index 66d790b..2d943af 100644 (file)
@@ -23,6 +23,7 @@
 #define __NEURUN_COMPILER_SUBTENSOR_INFO_H__
 
 #include "graph/operand/Object.h"
+#include "util/feature/Coordinate4D.h"
 
 namespace neurun
 {
@@ -68,13 +69,13 @@ public:
    * @brief   Return tensor's offset in parent tensor
    * @return  Tensor offset
    */
-  const graph::operand::ParentInfo::Coordinate4D offset(void) const { return _offset; }
+  const neurun::util::feature::Coordinate4D offset(void) const { return _offset; }
 
 private:
   const graph::operand::Index _parent;
   const graph::operand::Shape _shape;
   const graph::operand::TypeInfo _type;
-  const graph::operand::ParentInfo::Coordinate4D _offset;
+  const neurun::util::feature::Coordinate4D _offset;
 };
 
 } // compiler
index 74bfe11..929040b 100644 (file)
@@ -26,6 +26,7 @@
 #include <stdint.h>
 
 #include "Index.h"
+#include "util/feature/Coordinate4D.h"
 
 namespace neurun
 {
@@ -34,6 +35,8 @@ namespace graph
 namespace operand
 {
 
+using neurun::util::feature::Coordinate4D;
+
 /**
  * @brief      Class to represent parent operand in child operand
  */
@@ -41,63 +44,6 @@ class ParentInfo
 {
 public:
   /**
-   * @brief    Class to represent position(offset) of subtensor.\n
-   *        Assume that parent and child are already lowered (can get Shape4D).
-   */
-  class Coordinate4D
-  {
-  public:
-    /**
-     * @brief Construct a new Coordinate4D object
-     */
-    Coordinate4D(void) : _n{0}, _h{0}, _w{0}, _c{0}
-    {
-      // DO NOTHING
-    }
-    /**
-     * @brief     Construct a new Coordinate4D object
-     * @param[in] n Batch offset
-     * @param[in] h Height offset
-     * @param[in] w Width offset
-     * @param[in] c Channel offset
-     * @return
-     */
-    Coordinate4D(int32_t n, int32_t h, int32_t w, int32_t c) : _n{n}, _h{h}, _w{w}, _c{c}
-    {
-      // DO NOTHING
-    }
-
-  public:
-    /**
-     * @brief   Return batch offset
-     * @return  Batch offset
-     */
-    int32_t n(void) const { return _n; }
-    /**
-     * @brief   Return height offset
-     * @return  Height offset
-     */
-    int32_t h(void) const { return _h; }
-    /**
-     * @brief   Return width offset
-     * @return  Width offset
-     */
-    int32_t w(void) const { return _w; }
-    /**
-     * @brief   Return channel offset
-     * @return  Channel offset
-     */
-    int32_t c(void) const { return _c; }
-
-  private:
-    int32_t _n;
-    int32_t _h;
-    int32_t _w;
-    int32_t _c;
-  };
-
-public:
-  /**
    * @brief     Construct a new ParentInfo object
    * @param[in] parent      Index of parent operand
    * @param[in] coordinate  Offset of child operand in parent operand
diff --git a/runtimes/neurun/src/util/feature/Coordinate4D.h b/runtimes/neurun/src/util/feature/Coordinate4D.h
new file mode 100644 (file)
index 0000000..27d6f7b
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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_UTIL_FEATURE_COORDINATE_4D_H__
+#define __NEURUN_UTIL_FEATURE_COORDINATE_4D_H__
+
+#include <stdint.h>
+
+namespace neurun
+{
+namespace util
+{
+namespace feature
+{
+
+/**
+ * @brief Class to represent position(offset) of subtensor.\n
+ *        Assume that parent and child are already lowered (can get Shape4D).
+ */
+class Coordinate4D
+{
+public:
+  /**
+   * @brief Construct a new Coordinate4D object
+   */
+  Coordinate4D(void) : _n{0}, _h{0}, _w{0}, _c{0}
+  {
+    // DO NOTHING
+  }
+  /**
+   * @brief     Construct a new Coordinate4D object
+   * @param[in] n Batch offset
+   * @param[in] h Height offset
+   * @param[in] w Width offset
+   * @param[in] c Channel offset
+   * @return
+   */
+  Coordinate4D(int32_t n, int32_t h, int32_t w, int32_t c) : _n{n}, _h{h}, _w{w}, _c{c}
+  {
+    // DO NOTHING
+  }
+
+public:
+  /**
+   * @brief   Return batch offset
+   * @return  Batch offset
+   */
+  int32_t n(void) const { return _n; }
+  /**
+   * @brief   Return height offset
+   * @return  Height offset
+   */
+  int32_t h(void) const { return _h; }
+  /**
+   * @brief   Return width offset
+   * @return  Width offset
+   */
+  int32_t w(void) const { return _w; }
+  /**
+   * @brief   Return channel offset
+   * @return  Channel offset
+   */
+  int32_t c(void) const { return _c; }
+
+private:
+  int32_t _n;
+  int32_t _h;
+  int32_t _w;
+  int32_t _c;
+};
+
+} // namespace feature
+} // namespace util
+} // namespace neurun
+
+#endif // __NEURUN_UTIL_FEATURE_COORDINATE_4D_H__