From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 18 Jul 2018 04:03:57 +0000 (+0900) Subject: [nest] Add 'Domain' class (#697) X-Git-Tag: nncc_backup~2393 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=102881692e7078cbbc48a6cdc2a3dfb02c661b86;p=platform%2Fcore%2Fml%2Fnnfw.git [nest] Add 'Domain' class (#697) This commit adds 'Domain' class which allows users to easily build dereference expression with pre-allocated domain. Signed-off-by: Jonghyun Park --- diff --git a/contrib/nest/include/nest/Domain.h b/contrib/nest/include/nest/Domain.h new file mode 100644 index 0000000..5f2ddd5 --- /dev/null +++ b/contrib/nest/include/nest/Domain.h @@ -0,0 +1,38 @@ +#ifndef __NEST_DOMAIN_H__ +#define __NEST_DOMAIN_H__ + +#include "nest/Closure.h" + +namespace nest +{ + +class Domain +{ +public: + Domain() = default; + +public: + Domain(const DomainID &id) : _id{id} + { + // DO NOTHING + } + +public: + Domain(const Domain &) = default; + +public: + template Closure operator()(Args &&... indices) + { + return Closure{_id, std::forward(indices)...}; + } + +public: + const DomainID &id(void) const { return _id; } + +private: + DomainID const _id; +}; + +} // namespace nest + +#endif // __NEST_DOMAIN_H__ diff --git a/contrib/nest/include/nest/expr/Subscript.h b/contrib/nest/include/nest/expr/Subscript.h index ba073d3..5e5a4c8 100644 --- a/contrib/nest/include/nest/expr/Subscript.h +++ b/contrib/nest/include/nest/expr/Subscript.h @@ -4,6 +4,7 @@ #include "nest/expr/Node.h" #include +#include #include @@ -15,8 +16,7 @@ namespace expr class Subscript { public: - template - Subscript(Args &&... indicies) : _indices{std::forward(indicies)...} + Subscript(std::initializer_list> indices) : _indices{indices} { // DO NOTHING } diff --git a/contrib/nest/src/Domain.test.cpp b/contrib/nest/src/Domain.test.cpp new file mode 100644 index 0000000..1b85360 --- /dev/null +++ b/contrib/nest/src/Domain.test.cpp @@ -0,0 +1,25 @@ +#include "nest/Domain.h" + +#include + +namespace +{ +namespace expr +{ +struct DummyNode final : public nest::expr::Node +{ +}; +} // namespace expr +} // namespace + +// NOTE Build failed when DOMAIN is used instead of _DOMAIN +TEST(_DOMAIN, base_usecase) +{ + nest::DomainID dom_id{0}; + nest::Domain dom{dom_id}; + + nest::Closure clo = dom(std::make_shared<::expr::DummyNode>()); + + ASSERT_EQ(clo.id(), dom_id); + ASSERT_EQ(clo.sub().rank(), 1); +}