namespace locoex
{
-// TODO define TFLNodes here
+class TFLRelu final : public loco::FixedArityNode<1, TFLNodeImpl<TFLOpcode::RELU>>
+{
+public:
+ TFLRelu() = default;
+
+public:
+ loco::Node *input(void) const { return at(0)->node(); }
+ void input(loco::Node *node) { at(0)->node(node); }
+};
+
+// TODO define more children of TFLNode
} // namespace locoex
//
// PLEASE SORT NODE DECLS IN ALPHABETICAL ORDER
//
-// Example)
-// TFL_NODE(Relu, locoex::TFLRelu)
+TFL_NODE(RELU, locoex::TFLRelu)
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "TFLNodes.h"
+
+#include "TFLDialect.h"
+#include "TFLOpcode.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFLReluTest, constructor)
+{
+ locoex::TFLRelu relu_node;
+
+ ASSERT_EQ(relu_node.dialect(), locoex::TFLDialect::get());
+ ASSERT_EQ(relu_node.opcode(), locoex::TFLOpcode::RELU);
+
+ ASSERT_EQ(relu_node.input(), nullptr);
+}
bool build(const loco::Node *, locop::NodeSummary &s) const final;
protected:
-#define TFL_NODE(OPCODE, CLASS) \
- virtual bool summary(const CLASS *node, locop::NodeSummary &s) const \
- { \
- s.opname("NYI " #CLASS); \
- s.state(locop::NodeSummary::State::PartiallyKnown); \
- return true; \
+#define TFL_NODE(OPCODE, CLASS) \
+ virtual bool summary(const CLASS *, locop::NodeSummary &s) const \
+ { \
+ s.opname("NYI " #CLASS); \
+ s.state(locop::NodeSummary::State::PartiallyKnown); \
+ return true; \
}
#include "Dialect/IR/TFLNodes.lst"
#undef TFL_NODE
return false;
}
+bool TFLNodeSummaryBuilder::summary(const locoex::TFLRelu *node, locop::NodeSummary &s) const
+{
+ s.opname("TFL.RELU");
+ s.args().append("input", tbl()->lookup(node->input()));
+ s.state(locop::NodeSummary::State::Complete);
+ return true;
+}
+
} // namespace
namespace exo