From: 윤현식/On-Device Lab(SR)/Principal Engineer/삼성전자 Date: Mon, 26 Aug 2019 08:19:46 +0000 (+0900) Subject: [exo-tflite] Adding FixedArityNode (#6917) X-Git-Tag: accepted/tizen/unified/20190903.052428~132 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8a19e35ba3de3edf4e3b48e200638d1baefa17ce;p=platform%2Fcore%2Fml%2Fnnfw.git [exo-tflite] Adding FixedArityNode (#6917) FixedArityNode is copied from loco since loco::FixedArityNode's destiny is doomed. Signed-off-by: Hyun Sik Yoon --- diff --git a/compiler/exo-tflite/src/Dialect/IR/TFLNodes.h b/compiler/exo-tflite/src/Dialect/IR/TFLNodes.h index 5feee48..4b648ac 100644 --- a/compiler/exo-tflite/src/Dialect/IR/TFLNodes.h +++ b/compiler/exo-tflite/src/Dialect/IR/TFLNodes.h @@ -23,9 +23,48 @@ #include #include +#include + namespace locoex { +/** + * @brief Nodes with the fixed number of inputs + */ +template class FixedArityNode : public Base +{ +public: + FixedArityNode() + { + for (uint32_t n = 0; n < N; ++n) + { + _args[n] = std::unique_ptr(new loco::Use{this}); + } + } + + virtual ~FixedArityNode() = default; + +public: + unsigned arity(void) const final { return N; } + + loco::Node *arg(uint32_t n) const final { return _args.at(n)->node(); } + + void drop(void) final + { + for (uint32_t n = 0; n < N; ++n) + { + _args.at(n)->node(nullptr); + } + } + +protected: + // This API allows inherited classes to access "_args" field. + loco::Use *at(unsigned n) const { return _args.at(n).get(); } + +private: + std::array, N> _args; +}; + class TFLRelu final : public loco::FixedArityNode<1, TFLNodeImpl> { public: