From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 19 Jul 2018 10:12:03 +0000 (+0900) Subject: [coco] Add 'Bag' class (#726) X-Git-Tag: nncc_backup~2375 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db228dcbb9e6fa6b9ff8261fde6ce06fb2b9e5d8;p=platform%2Fcore%2Fml%2Fnnfw.git [coco] Add 'Bag' class (#726) This commit adds 'Bag' class which serves as memory allocation in coco IR. Signed-off-by: Jonghyun Park --- diff --git a/contrib/coco/core/include/coco/IR/Bag.h b/contrib/coco/core/include/coco/IR/Bag.h new file mode 100644 index 0000000..9ca7d01 --- /dev/null +++ b/contrib/coco/core/include/coco/IR/Bag.h @@ -0,0 +1,37 @@ +#ifndef __COCO_IR_BAG_H__ +#define __COCO_IR_BAG_H__ + +#include + +namespace coco +{ + +/*** + * @brief A collection of (abstracted) elements of the same type + * + * When there are N elements in a bag, we refer to N as the size of this bag, and every + * element in a bag has a unique numeric ID whose range is [0, N). + * + * NOTE 'Bag' is not a container (such as std::vector). 'Bag' just assures that there are + * N elements. It does not state about its value. + * + * NOTE coco IR treats Bag as virtual memory allocation + */ +class Bag +{ +public: + Bag(uint32_t size) : _size{size} + { + // DO NOTHING + } + +public: + uint32_t size(void) const { return _size; } + +private: + uint32_t const _size; +}; + +} // namespace coco + +#endif // __COCO_IR_BAG_H__ diff --git a/contrib/coco/core/src/IR/Bag.test.cpp b/contrib/coco/core/src/IR/Bag.test.cpp new file mode 100644 index 0000000..1a98d64 --- /dev/null +++ b/contrib/coco/core/src/IR/Bag.test.cpp @@ -0,0 +1,10 @@ +#include "coco/IR/Bag.h" + +#include + +TEST(IR_BAG, ctor_should_set_size) +{ + coco::Bag b{3}; + + ASSERT_EQ(b.size(), 3); +}