--- /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.
+ */
+
+#ifndef __MOCO_IR_TFADD_H__
+#define __MOCO_IR_TFADD_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFAdd corresponds to the following GraphDef
+/*
+node {
+ name: "add"
+ op: "Add"
+ input: "x"
+ input: "y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFAdd final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Add>>
+{
+public:
+ TFAdd() = default;
+
+public:
+ Node *x(void) const { return at(0)->node(); }
+ void x(Node *node) { at(0)->node(node); }
+
+ Node *y(void) const { return at(1)->node(); }
+ void y(Node *node) { at(1)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFADD_H__
--- /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.
+ */
+
+#ifndef __MOCO_IR_TFAVGPOOL_H__
+#define __MOCO_IR_TFAVGPOOL_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFAvgPool corresponds to the following GraphDef
+/*
+node {
+ name: "avgpool"
+ op: "AvgPool"
+ input: "placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "data_format"
+ value {
+ s: "NHWC"
+ }
+ }
+ attr {
+ key: "ksize"
+ value {
+ list {
+ i: 1 i: 3 i: 3 i: 1
+ }
+ }
+ }
+ attr {
+ key: "padding"
+ value {
+ s: "SAME"
+ }
+ }
+ attr {
+ key: "strides"
+ value {
+ list {
+ i: 1 i: 1 i: 1 i: 1
+ }
+ }
+ }
+}
+*/
+
+class TFAvgPool final : public FixedArityNode<1, TFNodeImpl<TFOpcode::AvgPool>>
+{
+public:
+ TFAvgPool() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { return at(0)->node(node); }
+
+public:
+ const TFDataLayout &data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+ const TFPadding &padding(void) const { return _padding; }
+ void padding(const TFPadding &padding) { _padding = padding; }
+
+ const std::vector<int64_t> &ksize(void) const { return _ksize; }
+ void ksize(const std::vector<int64_t> &ksize) { _ksize = ksize; }
+
+ const std::vector<int64_t> &strides(void) const { return _strides; }
+ void strides(const std::vector<int64_t> &strides) { _strides = strides; }
+
+private:
+ TFDataLayout _data_layout;
+ TFPadding _padding;
+ std::vector<int64_t> _ksize;
+ std::vector<int64_t> _strides;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFAVGPOOL_H__
--- /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.
+ */
+
+#ifndef __MOCO_IR_TFBIASADD_H__
+#define __MOCO_IR_TFBIASADD_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFBiasAdd corresponds to the following GraphDef
+/*
+node {
+ name: "bias_add_01"
+ op: "BiasAdd"
+ input: "input_01"
+ input: "bias_add_01/bias"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "data_format"
+ value {
+ s: "NHWC"
+ }
+ }
+}
+*/
+
+class TFBiasAdd final : public FixedArityNode<2, TFNodeImpl<TFOpcode::BiasAdd>>
+{
+public:
+ TFBiasAdd() = default;
+
+public:
+ Node *value(void) const { return at(0)->node(); }
+ void value(Node *node) { return at(0)->node(node); }
+
+ Node *bias(void) const { return at(1)->node(); }
+ void bias(Node *node) { return at(1)->node(node); }
+
+ const TFDataLayout data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+private:
+ TFDataLayout _data_layout;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFBIASADD_H__
#ifndef __MOCO_IR_TFNODES_H__
#define __MOCO_IR_TFNODES_H__
-//#include "moco/IR/Nodes/TFAdd.h"
-//#include "moco/IR/Nodes/TFAvgPool.h"
-//#include "moco/IR/Nodes/TFBiasAdd.h"
+#include "moco/IR/Nodes/TFAdd.h"
+#include "moco/IR/Nodes/TFAvgPool.h"
+#include "moco/IR/Nodes/TFBiasAdd.h"
//#include "moco/IR/Nodes/TFConcatV2.h"
//#include "moco/IR/Nodes/TFConst.h"
//#include "moco/IR/Nodes/TFConv2D.h"
//
// TENSORFLOW_NODE(OPCODE, CLASS)
-//TENSORFLOW_NODE(Add, TFAdd)
-//TENSORFLOW_NODE(AvgPool, TFAvgPool)
-//TENSORFLOW_NODE(BiasAdd, TFBiasAdd)
+TENSORFLOW_NODE(Add, TFAdd)
+TENSORFLOW_NODE(AvgPool, TFAvgPool)
+TENSORFLOW_NODE(BiasAdd, TFBiasAdd)
//TENSORFLOW_NODE(ConcatV2, TFConcatV2)
//TENSORFLOW_NODE(Const, TFConst)
//TENSORFLOW_NODE(Conv2D, TFConv2D)
--- /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 "moco/IR/Nodes/TFAdd.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFAddTest, constructor)
+{
+ moco::TFAdd add_node;
+
+ ASSERT_EQ(add_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(add_node.opcode(), moco::TFOpcode::Add);
+
+ ASSERT_EQ(add_node.x(), nullptr);
+ ASSERT_EQ(add_node.y(), nullptr);
+}
--- /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 "moco/IR/Nodes/TFAvgPool.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFAvgPoolTest, constructor)
+{
+ moco::TFAvgPool avgpool;
+
+ ASSERT_EQ(avgpool.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(avgpool.opcode(), moco::TFOpcode::AvgPool);
+
+ ASSERT_EQ(avgpool.input(), nullptr);
+ ASSERT_EQ(avgpool.data_layout(), "");
+ ASSERT_EQ(avgpool.padding(), "");
+ ASSERT_EQ(avgpool.ksize(), std::vector<int64_t>({}));
+ ASSERT_EQ(avgpool.strides(), std::vector<int64_t>({}));
+}
--- /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 "moco/IR/Nodes/TFBiasAdd.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFBiasAddTest, constructor)
+{
+ moco::TFBiasAdd bias_add;
+
+ ASSERT_EQ(bias_add.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(bias_add.opcode(), moco::TFOpcode::BiasAdd);
+
+ ASSERT_EQ(bias_add.value(), nullptr);
+ ASSERT_EQ(bias_add.bias(), nullptr);
+ ASSERT_EQ(bias_add.data_layout(), "");
+}