[neurun] Replace uint32_t with Index in Set (#4816)
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Fri, 22 Mar 2019 07:31:05 +0000 (16:31 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Fri, 22 Mar 2019 07:31:05 +0000 (16:31 +0900)
operand::Set and operation::Set have hardcoded uint32_t and assertion,
which is based on wrong assumption that Index is always uint32_t.
This patch replaces uint32_t with Index.

Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
runtimes/neurun/core/include/graph/Index.h
runtimes/neurun/core/include/model/operand/Set.h
runtimes/neurun/core/include/model/operation/Set.h
runtimes/neurun/core/src/model/operand/Set.cc
runtimes/neurun/core/src/model/operation/Set.cc

index cd84533..f257212 100644 (file)
@@ -53,6 +53,13 @@ public:
   bool operator!=(T o) const { return !(*this == o); }
   bool operator!=(const Index &o) const { return !(*this == o); }
 
+  Index operator++(int)
+  {
+    Index temp = *this;
+    _index++;
+    return temp;
+  }
+
   bool valid() const { return _index != UNDEFINED; }
   T value() const { return _index; }
 
index 9dff7ec..dff8495 100644 (file)
@@ -51,7 +51,7 @@ private:
 
 private:
   std::unordered_map<Index, std::unique_ptr<Object>> _objects;
-  uint32_t _index_count;
+  Index _index_count;
 };
 
 } // namespace operand
index eebf91e..8a22315 100644 (file)
@@ -53,7 +53,7 @@ private:
 
 private:
   std::unordered_map<Index, std::unique_ptr<Node>> _nodes;
-  uint32_t _index_count;
+  Index _index_count;
 };
 
 } // namespace operation
index cdbc5f5..ed64a27 100644 (file)
@@ -27,9 +27,9 @@ namespace operand
 
 const Index Set::generateIndex()
 {
-  assert((_index_count) <= 0x7fffffff);
+  assert(_index_count.valid());
 
-  return Index{_index_count++};
+  return _index_count++;
 }
 
 Index Set::append(const Shape &shape, const TypeInfo &type)
index 5b42284..4d374f8 100644 (file)
@@ -27,9 +27,9 @@ namespace operation
 
 const Index Set::generateIndex()
 {
-  assert((_index_count) <= 0x7fffffff);
+  assert(_index_count.valid());
 
-  return Index{_index_count++};
+  return _index_count++;
 }
 
 Index Set::append(std::unique_ptr<Node> &&node)