From: 이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Fri, 22 Mar 2019 07:31:05 +0000 (+0900) Subject: [neurun] Replace uint32_t with Index in Set (#4816) X-Git-Tag: submit/tizen/20190325.013700~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1662a6ccecf60648012d9afeebf782f2d62794bd;p=platform%2Fcore%2Fml%2Fnnfw.git [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 --- 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)