From 1662a6ccecf60648012d9afeebf782f2d62794bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=83=81=EA=B7=9C/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 22 Mar 2019 16:31:05 +0900 Subject: [PATCH] [neurun] Replace uint32_t with Index in Set (#4816) 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 --- runtimes/neurun/core/include/graph/Index.h | 7 +++++++ runtimes/neurun/core/include/model/operand/Set.h | 2 +- runtimes/neurun/core/include/model/operation/Set.h | 2 +- runtimes/neurun/core/src/model/operand/Set.cc | 4 ++-- runtimes/neurun/core/src/model/operation/Set.cc | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/runtimes/neurun/core/include/graph/Index.h b/runtimes/neurun/core/include/graph/Index.h index cd84533..f257212 100644 --- a/runtimes/neurun/core/include/graph/Index.h +++ b/runtimes/neurun/core/include/graph/Index.h @@ -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; } diff --git a/runtimes/neurun/core/include/model/operand/Set.h b/runtimes/neurun/core/include/model/operand/Set.h index 9dff7ec..dff8495 100644 --- a/runtimes/neurun/core/include/model/operand/Set.h +++ b/runtimes/neurun/core/include/model/operand/Set.h @@ -51,7 +51,7 @@ private: private: std::unordered_map> _objects; - uint32_t _index_count; + Index _index_count; }; } // namespace operand diff --git a/runtimes/neurun/core/include/model/operation/Set.h b/runtimes/neurun/core/include/model/operation/Set.h index eebf91e..8a22315 100644 --- a/runtimes/neurun/core/include/model/operation/Set.h +++ b/runtimes/neurun/core/include/model/operation/Set.h @@ -53,7 +53,7 @@ private: private: std::unordered_map> _nodes; - uint32_t _index_count; + Index _index_count; }; } // namespace operation diff --git a/runtimes/neurun/core/src/model/operand/Set.cc b/runtimes/neurun/core/src/model/operand/Set.cc index cdbc5f5..ed64a27 100644 --- a/runtimes/neurun/core/src/model/operand/Set.cc +++ b/runtimes/neurun/core/src/model/operand/Set.cc @@ -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) diff --git a/runtimes/neurun/core/src/model/operation/Set.cc b/runtimes/neurun/core/src/model/operation/Set.cc index 5b42284..4d374f8 100644 --- a/runtimes/neurun/core/src/model/operation/Set.cc +++ b/runtimes/neurun/core/src/model/operation/Set.cc @@ -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) -- 2.7.4