From: 박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 Date: Wed, 29 May 2019 08:30:30 +0000 (+0900) Subject: [loco] Introduce FilterEncode (#3625) X-Git-Tag: nncc_backup~503 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f4c080abc0faeac15c6e76bae57c8b6647bb16b0;p=platform%2Fcore%2Fml%2Fnnfw.git [loco] Introduce FilterEncode (#3625) This commit introduces FilterEncode node which expresses Tenser-to-Filter conversion. Signed-off-by: Jonghyun Park --- diff --git a/contrib/loco/include/loco/IR/Nodes.h b/contrib/loco/include/loco/IR/Nodes.h index c8e9c61..81e2ec3 100644 --- a/contrib/loco/include/loco/IR/Nodes.h +++ b/contrib/loco/include/loco/IR/Nodes.h @@ -25,6 +25,7 @@ #include "loco/IR/Window.h" #include "loco/IR/Stride.h" #include "loco/IR/FeatureCodec.h" +#include "loco/IR/FilterCodec.h" #include "loco/IR/NodeMixins.h" namespace loco @@ -258,6 +259,26 @@ private: std::unique_ptr _dec{nullptr}; }; +/** + * @brief Create a filter from a tensor + */ +class FilterEncode final : public FixedArityNode<1> +{ +public: + Node *input(void) const { return at(0)->node(); } + void input(Node *node) { at(0)->node(node); } + +public: + FilterEncoder *encoder(void) const { return _enc.get(); } + void encoder(std::unique_ptr &&enc) { _enc = std::move(enc); } + +private: + /// @note "encoder" is mandatory + std::unique_ptr _enc{nullptr}; +}; + +// TODO Introduce FilterDecode (if required) + enum class ReshapeType { Fixed, // shape is known at compile time diff --git a/contrib/loco/src/IR/Nodes.test.cpp b/contrib/loco/src/IR/Nodes.test.cpp index edd1ed8..eff02e3 100644 --- a/contrib/loco/src/IR/Nodes.test.cpp +++ b/contrib/loco/src/IR/Nodes.test.cpp @@ -163,3 +163,11 @@ TEST(Reshape_Fixed_Test, shape) ASSERT_EQ(reshape.dim(0), 2); ASSERT_EQ(reshape.dim(1), 3); } + +TEST(FilterEncodeTest, constructor) +{ + loco::FilterEncode filter_encode; + + ASSERT_EQ(filter_encode.input(), nullptr); + ASSERT_EQ(filter_encode.encoder(), nullptr); +}