From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Thu, 19 Jul 2018 05:41:49 +0000 (+0900) Subject: [nest] Support 'push' statement construction (#716) X-Git-Tag: nncc_backup~2381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=beaafe8eef3c6dea961c7575c6468e8a8291d53e;p=platform%2Fcore%2Fml%2Fnnfw.git [nest] Support 'push' statement construction (#716) This commit allows users to construct 'push' statement through 'module'. Signed-off-by: Jonghyun Park --- diff --git a/contrib/nest/include/nest/Module.h b/contrib/nest/include/nest/Module.h index 59cd634..e8af83b 100644 --- a/contrib/nest/include/nest/Module.h +++ b/contrib/nest/include/nest/Module.h @@ -3,6 +3,7 @@ #include "nest/VarContext.h" #include "nest/DomainContext.h" +#include "nest/Block.h" namespace nest { @@ -29,6 +30,15 @@ private: public: DomainContext &domain(void) { return _domain_ctx; } const DomainContext &domain(void) const { return _domain_ctx; } + +private: + Block _block; + +public: + const Block &block(void) const { return _block; } + +public: + void push(const Expr &expr); }; } // namespace nest diff --git a/contrib/nest/src/Module.cpp b/contrib/nest/src/Module.cpp new file mode 100644 index 0000000..18c953b --- /dev/null +++ b/contrib/nest/src/Module.cpp @@ -0,0 +1,12 @@ +#include "nest/Module.h" + +namespace nest +{ + +void Module::push(const Expr &expr) +{ + auto stmt = std::make_shared(expr); + _block.append(stmt); +} + +} // namespace nest diff --git a/contrib/nest/src/Module.test.cpp b/contrib/nest/src/Module.test.cpp index 119c3f1..5def2c7 100644 --- a/contrib/nest/src/Module.test.cpp +++ b/contrib/nest/src/Module.test.cpp @@ -37,3 +37,19 @@ TEST(MODULE, create_domain) create(m, {1, 3, 3}); check(m); } + +TEST(MODULE, push) +{ + nest::Module m; + + auto ifm = m.domain().make({1, 3, 3}); + + auto var_ch = m.var().make(); + auto var_row = m.var().make(); + auto var_col = m.var().make(); + + m.push(ifm(var_ch, var_row, var_col)); + + ASSERT_EQ(m.block().size(), 1); + ASSERT_NE(m.block().at(0)->asPush(), nullptr); +}