From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 6 Sep 2018 10:54:46 +0000 (+0900) Subject: [coco] Support partial shuffling (#1382) X-Git-Tag: nncc_backup~1894 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f46fc2033a468f496916f7a07402f423202e97ba;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Support partial shuffling (#1382) Shuffle instruction now uses 'map' instead of 'vector' to store element transfers between two bags. This change allows users to encode partial shuffling in coco IR. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/Shuffle.h b/contrib/coco/core/include/coco/IR/Shuffle.h index 00908c0..759ced7 100644 --- a/contrib/coco/core/include/coco/IR/Shuffle.h +++ b/contrib/coco/core/include/coco/IR/Shuffle.h @@ -9,7 +9,7 @@ #include "coco/ADT/PtrLink.h" -#include +#include namespace coco { @@ -46,7 +46,13 @@ public: void into(Bag *); public: - const ElemID &at(uint32_t n) const { return _content.at(n); } + /** + * Let M be the return of at(N). This means that N-th element in the destination + * bag will be filled with the value of M-th element in the source bag. + * + * NOTE at(n) may be undefined on partial shuffle + */ + const ElemID &at(uint32_t n) const { return _content.at(ElemID{n}); } public: void insert(const ElemID &from, const ElemID &into); @@ -59,7 +65,7 @@ private: UpdateSlot _into; private: - std::vector _content; + std::map _content; }; } // namespace coco diff --git a/contrib/coco/core/src/IR/Shuffle.cpp b/contrib/coco/core/src/IR/Shuffle.cpp index 08926cb..afa1926 100644 --- a/contrib/coco/core/src/IR/Shuffle.cpp +++ b/contrib/coco/core/src/IR/Shuffle.cpp @@ -15,7 +15,7 @@ std::set &operator+=(std::set &res, coco::Bag *b) namespace coco { -void Shuffle::insert(const ElemID &from, const ElemID &into) { _content.at(into.value()) = from; } +void Shuffle::insert(const ElemID &from, const ElemID &into) { _content[into] = from; } std::set Shuffle::reads(void) const { @@ -36,11 +36,6 @@ std::set Shuffle::updates(void) const } void Shuffle::from(Bag *b) { _from.value(b); } - -void Shuffle::into(Bag *b) -{ - _into.value(b); - _content.resize((b == nullptr) ? 0 : b->size()); -} +void Shuffle::into(Bag *b) { _into.value(b); } } // namespace coco