summaryrefslogtreecommitdiff
path: root/compiler/moco/lang
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/moco/lang')
-rw-r--r--compiler/moco/lang/CMakeLists.txt21
-rw-r--r--compiler/moco/lang/README.md3
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFAdd.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFAvgPool.h101
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFBiasAdd.h68
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFConcatV2.h90
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFConst.h94
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFConv2D.h55
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFConv2DBackpropInput.h102
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFDepthwiseConv2dNative.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h54
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFFusedBatchNorm.h55
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFIdentity.h52
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFMaxPool.h101
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFMaximum.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFMean.h71
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFMul.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFPack.h86
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFPad.h61
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFPlaceholder.h90
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFPush.h84
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFRealDiv.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFRelu.h52
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFRelu6.h50
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFReshape.h54
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFRsqrt.h52
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFShape.h60
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFSoftmax.h37
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFSqrt.h52
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFSquaredDifference.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFSqueeze.h71
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFStopGradient.h52
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFStridedSlice.h123
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFSub.h56
-rw-r--r--compiler/moco/lang/include/moco/IR/Nodes/TFTanh.h37
-rw-r--r--compiler/moco/lang/include/moco/IR/TFDataLayout.h29
-rw-r--r--compiler/moco/lang/include/moco/IR/TFDialect.h43
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNode.h23
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodeDecl.h104
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodeImpl.h68
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodeVisitor.forward.h30
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodeVisitor.h83
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodes.h55
-rw-r--r--compiler/moco/lang/include/moco/IR/TFNodes.lst48
-rw-r--r--compiler/moco/lang/include/moco/IR/TFOpcode.h35
-rw-r--r--compiler/moco/lang/include/moco/IR/TFPadding.h29
-rw-r--r--compiler/moco/lang/include/moco/IR/VariadicArityNode.h77
-rw-r--r--compiler/moco/lang/include/moco/Names.h96
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp32
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFConst.cpp113
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp95
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp35
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp35
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp32
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp34
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp46
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp38
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp31
-rw-r--r--compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp30
-rw-r--r--compiler/moco/lang/src/IR/TFDialect.cpp91
-rw-r--r--compiler/moco/lang/src/IR/TFDialect.test.cpp29
-rw-r--r--compiler/moco/lang/src/IR/TFNode.cpp137
-rw-r--r--compiler/moco/lang/src/IR/TFNode.test.cpp44
-rw-r--r--compiler/moco/lang/src/IR/VariadicArityNode.test.cpp55
86 files changed, 4510 insertions, 0 deletions
diff --git a/compiler/moco/lang/CMakeLists.txt b/compiler/moco/lang/CMakeLists.txt
new file mode 100644
index 000000000..a64fdf92a
--- /dev/null
+++ b/compiler/moco/lang/CMakeLists.txt
@@ -0,0 +1,21 @@
+file(GLOB_RECURSE SOURCES "src/*.cpp")
+file(GLOB_RECURSE TESTS "src/*.test.cpp")
+list(REMOVE_ITEM SOURCES ${TESTS})
+
+add_library(moco_lang SHARED ${SOURCES})
+target_include_directories(moco_lang PRIVATE src)
+target_include_directories(moco_lang PUBLIC include)
+target_link_libraries(moco_lang PUBLIC loco)
+target_link_libraries(moco_lang PRIVATE nncc_common)
+target_link_libraries(moco_lang PRIVATE stdex)
+install(TARGETS moco_lang DESTINATION lib) # moco_tf_frontend requires moco_lang
+
+if(NOT ENABLE_TEST)
+ return()
+endif(NOT ENABLE_TEST)
+
+nnas_find_package(GTest REQUIRED)
+
+GTest_AddTest(moco_lang_test ${TESTS})
+target_include_directories(moco_lang_test PRIVATE src)
+target_link_libraries(moco_lang_test moco_lang)
diff --git a/compiler/moco/lang/README.md b/compiler/moco/lang/README.md
new file mode 100644
index 000000000..6ee3fc660
--- /dev/null
+++ b/compiler/moco/lang/README.md
@@ -0,0 +1,3 @@
+# lang
+
+`lang` provides TensorFlow Dialect IR
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFAdd.h b/compiler/moco/lang/include/moco/IR/Nodes/TFAdd.h
new file mode 100644
index 000000000..13b064fba
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFAdd.h
@@ -0,0 +1,56 @@
+/*
+ * 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__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFAvgPool.h b/compiler/moco/lang/include/moco/IR/Nodes/TFAvgPool.h
new file mode 100644
index 000000000..74c91b5fb
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFAvgPool.h
@@ -0,0 +1,101 @@
+/*
+ * 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 *value(void) const { return at(0)->node(); }
+ void value(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__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFBiasAdd.h b/compiler/moco/lang/include/moco/IR/Nodes/TFBiasAdd.h
new file mode 100644
index 000000000..11e309caa
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFBiasAdd.h
@@ -0,0 +1,68 @@
+/*
+ * 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__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFConcatV2.h b/compiler/moco/lang/include/moco/IR/Nodes/TFConcatV2.h
new file mode 100644
index 000000000..7f0d32697
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFConcatV2.h
@@ -0,0 +1,90 @@
+/*
+ * 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_TFCONCATV2_H__
+#define __MOCO_IR_TFCONCATV2_H__
+
+#include "moco/IR/TFNodeDecl.h"
+#include "moco/IR/VariadicArityNode.h"
+
+namespace moco
+{
+
+/// @note TFConcatV2 corresponds to the following GraphDef
+/*
+node {
+ name: "Concat"
+ op: "ConcatV2"
+ input: "Input01"
+ input: "Input02"
+ input: "Axis"
+ attr {
+ key: "N"
+ value {
+ i: 2
+ }
+ }
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "Tidx"
+ value {
+ type: DT_INT32
+ }
+ }
+}
+*/
+
+class TFConcatV2 final : public VariadicArityNode<TFNodeImpl<TFOpcode::ConcatV2>>
+{
+public:
+ TFConcatV2(uint32_t arity) : VariadicArityNode<TFNodeImpl<TFOpcode::ConcatV2>>(arity + 1)
+ {
+ // we add +1 for axis of VariadicArityNode ctor
+ // at least one value is required
+ assert(arity >= 1);
+ }
+
+public:
+ uint32_t num_values(void) const
+ {
+ // last one is for axis
+ return arity() - 1;
+ }
+
+public:
+ Node *values(uint32_t index) const
+ {
+ assert(index < num_values());
+ return at(index)->node();
+ }
+ void values(uint32_t index, Node *node)
+ {
+ assert(index < num_values());
+ at(index)->node(node);
+ }
+
+ Node *axis(void) const { return at(num_values())->node(); }
+ void axis(Node *node) { at(num_values())->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFCONCATV2_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFConst.h b/compiler/moco/lang/include/moco/IR/Nodes/TFConst.h
new file mode 100644
index 000000000..7c2595fcb
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFConst.h
@@ -0,0 +1,94 @@
+/*
+ * 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_TFCONSTANT_H__
+#define __MOCO_IR_TFCONSTANT_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <loco/IR/DataTypeTraits.h>
+#include <loco/IR/NodeMixins.h>
+#include <loco/IR/TensorShape.h>
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFConst corresponds to the following GraphDef
+/*
+node {
+ name: "val"
+ op: "Const"
+ attr {
+ key: "dtype"
+ value { type: DT_FLOAT }
+ }
+ attr {
+ key: "value"
+ value {
+ tensor {
+ dtype: DT_FLOAT
+ tensor_shape {
+ dim { size: 1 }
+ dim { size: 3 }
+ dim { size: 4 }
+ dim { size: 4 }
+ }
+ float_val: 2.1
+ }
+ }
+ }
+}
+*/
+
+/**
+ * @brief IR for tf.constant
+ *
+ * @note Implementation for this class came from Canonical ConstGen
+ * Read comments in loco::ConstGen for details
+ */
+class TFConst final : public FixedArityNode<0, TFNodeImpl<TFOpcode::Const>>,
+ public loco::NodeMixin<loco::NodeTrait::DataType>,
+ public loco::NodeMixin<loco::NodeTrait::TensorShape>
+{
+public:
+ TFConst() = default;
+
+public:
+ template <loco::DataType DT> uint32_t size(void) const;
+ template <loco::DataType DT> void size(uint32_t size);
+
+ template <loco::DataType DT> const typename loco::DataTypeImpl<DT>::Type &at(uint32_t n) const;
+ template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &at(uint32_t n);
+
+private:
+ std::vector<uint8_t> _data;
+};
+
+} // namespace moco
+
+namespace moco
+{
+
+loco::TensorShape tensor_shape(const TFConst *node);
+
+uint32_t num_elements(const TFConst *tfconst);
+bool same_shape(const TFConst *lhs, const TFConst *rhs);
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFCONSTANT_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFConv2D.h b/compiler/moco/lang/include/moco/IR/Nodes/TFConv2D.h
new file mode 100644
index 000000000..0d5a17879
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFConv2D.h
@@ -0,0 +1,55 @@
+/*
+ * 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_TFCONV2D_H__
+#define __MOCO_IR_TFCONV2D_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+class TFConv2D final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Conv2D>>
+{
+public:
+ loco::Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+ loco::Node *filter(void) const { return at(1)->node(); }
+ void filter(Node *node) { at(1)->node(node); }
+
+public:
+ const TFPadding &padding(void) const { return _padding; }
+ void padding(const TFPadding &padding) { _padding = padding; }
+
+ const TFDataLayout &data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+ const std::vector<int64_t> &strides(void) const { return _strides; }
+ void strides(const std::vector<int64_t> &strides) { _strides = strides; }
+
+private:
+ TFPadding _padding;
+ TFDataLayout _data_layout;
+ std::vector<int64_t> _strides;
+ // TODO Support "Dilation"
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFCONV2D_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFConv2DBackpropInput.h b/compiler/moco/lang/include/moco/IR/Nodes/TFConv2DBackpropInput.h
new file mode 100644
index 000000000..43e620d24
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFConv2DBackpropInput.h
@@ -0,0 +1,102 @@
+/*
+ * 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_TFCONV2DBACKPROPINPUT_H__
+#define __MOCO_IR_TFCONV2DBACKPROPINPUT_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFConv2DBackpropInput corresponds to the following GraphDef
+/*
+node {
+ name: "conv2d_backprop_input"
+ op: "Conv2DBackpropInput"
+ input: "input_sizes"
+ input: "filter"
+ input: "out_backprop"
+ attr {
+ key: "T"
+ value { type: DT_FLOAT }
+ }
+ attr {
+ key: "data_format"
+ value { s: "NHWC" }
+ }
+ attr {
+ key: "dilations"
+ value {
+ list { i: 1 i: 1 i: 1 i: 1 }
+ }
+ }
+ attr {
+ key: "padding"
+ value { s: "SAME" }
+ }
+ attr {
+ key: "strides"
+ value {
+ list { i: 1 i: 2 i: 2 i: 1 }
+ }
+ }
+}
+*/
+
+/**
+ * @note For Tensorflow Conv2DBackpropInput, 'input' refers actual output of the
+ * node, and 'input' refers actual input. The reasone of this is, as name
+ * suggests, because it is inspired from backpropagation of convolution.
+ * For example, 'out_backprop' of Conv2DBackpropInput is its actual input
+ * feature map, and 'input_sizes' means desired output node's size.
+ * Note that this convention is against loco canonical's convention.
+ */
+class TFConv2DBackpropInput final
+ : public FixedArityNode<3, TFNodeImpl<TFOpcode::Conv2DBackpropInput>>
+{
+public:
+ loco::Node *input_sizes(void) const { return at(0)->node(); }
+ void input_sizes(Node *node) { at(0)->node(node); }
+
+ loco::Node *filter(void) const { return at(1)->node(); }
+ void filter(Node *node) { at(1)->node(node); }
+
+ loco::Node *out_backprop(void) const { return at(2)->node(); }
+ void out_backprop(Node *node) { at(2)->node(node); }
+
+public:
+ const TFPadding &padding(void) const { return _padding; }
+ void padding(const TFPadding &padding) { _padding = padding; }
+
+ const TFDataLayout &data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+ const std::vector<int64_t> &strides(void) const { return _strides; }
+ void strides(const std::vector<int64_t> &strides) { _strides = strides; }
+
+private:
+ TFPadding _padding;
+ TFDataLayout _data_layout;
+ std::vector<int64_t> _strides;
+ // TODO Support "Dilation"
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFCONV2DBACKPROPINPUT_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFDepthwiseConv2dNative.h b/compiler/moco/lang/include/moco/IR/Nodes/TFDepthwiseConv2dNative.h
new file mode 100644
index 000000000..aefc0b5d9
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFDepthwiseConv2dNative.h
@@ -0,0 +1,56 @@
+/*
+ * 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_TFDEPTHWISECONV2DNATIVE_H__
+#define __MOCO_IR_TFDEPTHWISECONV2DNATIVE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+class TFDepthwiseConv2dNative final
+ : public FixedArityNode<2, TFNodeImpl<TFOpcode::DepthwiseConv2dNative>>
+{
+public:
+ loco::Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+ loco::Node *filter(void) const { return at(1)->node(); }
+ void filter(Node *node) { at(1)->node(node); }
+
+public:
+ const TFPadding &padding(void) const { return _padding; }
+ void padding(const TFPadding &padding) { _padding = padding; }
+
+ const TFDataLayout &data_layout(void) const { return _data_layout; }
+ void data_layout(const TFDataLayout &data_layout) { _data_layout = data_layout; }
+
+ const std::vector<int64_t> &strides(void) const { return _strides; }
+ void strides(const std::vector<int64_t> &strides) { _strides = strides; }
+
+private:
+ TFPadding _padding;
+ TFDataLayout _data_layout;
+ std::vector<int64_t> _strides;
+ // TODO Support "Dilation"
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFDEPTHWISECONV2DNATIVE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h b/compiler/moco/lang/include/moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h
new file mode 100644
index 000000000..ec54da596
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h
@@ -0,0 +1,54 @@
+/*
+ * 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_TFFAKEQUANTWITHMINMAXVARS_H__
+#define __MOCO_IR_TFFAKEQUANTWITHMINMAXVARS_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+class TFFakeQuantWithMinMaxVars final
+ : public FixedArityNode<3, TFNodeImpl<TFOpcode::FakeQuantWithMinMaxVars>>
+{
+public:
+ loco::Node *inputs(void) const { return at(0)->node(); }
+ void inputs(Node *node) { at(0)->node(node); }
+
+ loco::Node *min(void) const { return at(1)->node(); }
+ void min(Node *node) { at(1)->node(node); }
+
+ loco::Node *max(void) const { return at(2)->node(); }
+ void max(Node *node) { at(2)->node(node); }
+
+public:
+ const int64_t &num_bits(void) const { return _num_bits; }
+ void num_bits(const int64_t &num_bits) { _num_bits = num_bits; }
+
+ const bool &narrow_range(void) const { return _narrow_range; }
+ void narrow_range(const bool &narrow_range) { _narrow_range = narrow_range; }
+
+private:
+ int64_t _num_bits{8};
+ bool _narrow_range{false};
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFFAKEQUANTWITHMINMAXVARS_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFFusedBatchNorm.h b/compiler/moco/lang/include/moco/IR/Nodes/TFFusedBatchNorm.h
new file mode 100644
index 000000000..5b980e3b2
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFFusedBatchNorm.h
@@ -0,0 +1,55 @@
+/*
+ * 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_TFFUSEDBATCHNORM_H__
+#define __MOCO_IR_TFFUSEDBATCHNORM_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+class TFFusedBatchNorm final : public FixedArityNode<5, TFNodeImpl<TFOpcode::FusedBatchNorm>>
+{
+public:
+ TFFusedBatchNorm() = default;
+
+public:
+ Node *x(void) const { return at(0)->node(); }
+ void x(Node *node) { at(0)->node(node); }
+
+ Node *scale(void) const { return at(1)->node(); } // gamma
+ void scale(Node *node) { at(1)->node(node); }
+
+ Node *offset(void) const { return at(2)->node(); } // beta
+ void offset(Node *node) { at(2)->node(node); }
+
+ Node *mean(void) const { return at(3)->node(); }
+ void mean(Node *node) { at(3)->node(node); }
+
+ Node *variance(void) const { return at(4)->node(); }
+ void variance(Node *node) { at(4)->node(node); }
+
+ float epsilon(void) const { return _epsilon; }
+ void epsilon(float epsilon) { _epsilon = epsilon; }
+
+private:
+ float _epsilon = 0.001f;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFFUSEDBATCHNORM_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFIdentity.h b/compiler/moco/lang/include/moco/IR/Nodes/TFIdentity.h
new file mode 100644
index 000000000..26a1a36bf
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFIdentity.h
@@ -0,0 +1,52 @@
+/*
+ * 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_TFIDENTITY_H__
+#define __MOCO_IR_TFIDENTITY_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFIdentity corresponds to the following GraphDef
+/*
+node {
+ name: "identity"
+ op: "Identity"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFIdentity final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Identity>>
+{
+public:
+ TFIdentity() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFIDENTITY_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFMaxPool.h b/compiler/moco/lang/include/moco/IR/Nodes/TFMaxPool.h
new file mode 100644
index 000000000..a66b4044e
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFMaxPool.h
@@ -0,0 +1,101 @@
+/*
+ * 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_TFMAXPOOL_H__
+#define __MOCO_IR_TFMAXPOOL_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFMaxPool corresponds to the following GraphDef
+/*
+node {
+ name: "maxpool2d"
+ op: "MaxPool"
+ input: "placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "data_format"
+ value {
+ s: "NHWC"
+ }
+ }
+ attr {
+ key: "ksize"
+ value {
+ list {
+ i: 1 i: 2 i: 2 i: 1
+ }
+ }
+ }
+ attr {
+ key: "padding"
+ value {
+ s: "VALID"
+ }
+ }
+ attr {
+ key: "strides"
+ value {
+ list {
+ i: 1 i: 1 i: 1 i: 1
+ }
+ }
+ }
+}
+*/
+
+class TFMaxPool final : public FixedArityNode<1, TFNodeImpl<TFOpcode::MaxPool>>
+{
+public:
+ TFMaxPool() = 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_TFMAXPOOL_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFMaximum.h b/compiler/moco/lang/include/moco/IR/Nodes/TFMaximum.h
new file mode 100644
index 000000000..346dbebe8
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFMaximum.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2020 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_TFMAXIMUM_H__
+#define __MOCO_IR_TFMAXIMUM_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFMaximum corresponds to the following GraphDef
+/*
+node {
+ name: "maximum"
+ op: "Maximum"
+ input: "x"
+ input: "y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFMaximum final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Maximum>>
+{
+public:
+ TFMaximum() = 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_TFMAXIMUM_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFMean.h b/compiler/moco/lang/include/moco/IR/Nodes/TFMean.h
new file mode 100644
index 000000000..abcd21c49
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFMean.h
@@ -0,0 +1,71 @@
+/*
+ * 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_TFMEAN_H__
+#define __MOCO_IR_TFMEAN_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFMean corresponds to the following GraphDef
+/*
+node {
+ name: "Mean"
+ op: "Mean"
+ input: "Placeholder"
+ input: "Mean/reduction_indices"
+ attr {
+ key: "T"
+ value { type: DT_FLOAT }
+ }
+ attr {
+ key: "Tidx"
+ value { type: DT_INT32 }
+ }
+ attr {
+ key: "keep_dims"
+ value { b: true }
+ }
+}
+*/
+
+class TFMean final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Mean>>
+{
+public:
+ TFMean() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+ Node *reduction_indices(void) const { return at(1)->node(); }
+ void reduction_indices(Node *node) { at(1)->node(node); }
+
+public:
+ bool keep_dims(void) const { return _keep_dims; }
+ void keep_dims(bool keep_dims) { _keep_dims = keep_dims; }
+
+private:
+ bool _keep_dims = false;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFMEAN_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFMul.h b/compiler/moco/lang/include/moco/IR/Nodes/TFMul.h
new file mode 100644
index 000000000..4692838cb
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFMul.h
@@ -0,0 +1,56 @@
+/*
+ * 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_TFMUL_H__
+#define __MOCO_IR_TFMUL_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFMul corresponds to the following GraphDef
+/*
+node {
+ name: "mul"
+ op: "Mul"
+ input: "x"
+ input: "y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFMul final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Mul>>
+{
+public:
+ TFMul() = 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_TFMUL_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFPack.h b/compiler/moco/lang/include/moco/IR/Nodes/TFPack.h
new file mode 100644
index 000000000..1046a18ed
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFPack.h
@@ -0,0 +1,86 @@
+/*
+ * 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_TFPACK_H__
+#define __MOCO_IR_TFPACK_H__
+
+#include "moco/IR/TFNodeDecl.h"
+#include "moco/IR/VariadicArityNode.h"
+
+namespace moco
+{
+/// @note TFPack corresponds to the following GraphDef
+/*
+node {
+ name: "Pack"
+ op: "Pack"
+ input: "input_1"
+ input: "input_2"
+ attr {
+ key: "N"
+ value {
+ i: 2
+ }
+ }
+ attr {
+ key: "T"
+ value {
+ type: DT_INT32
+ }
+ }
+ attr {
+ key: "axis"
+ value {
+ i: 0
+ }
+ }
+}
+*/
+
+class TFPack final : public VariadicArityNode<TFNodeImpl<TFOpcode::Pack>>
+{
+public:
+ TFPack(uint32_t arity) : VariadicArityNode<TFNodeImpl<TFOpcode::Pack>>(arity)
+ {
+ // at least one item should exist
+ assert(arity >= 1);
+ }
+
+public:
+ Node *values(uint32_t index) const
+ {
+ assert(index < arity());
+ return at(index)->node();
+ }
+ void values(uint32_t index, Node *node)
+ {
+ assert(index < arity());
+ at(index)->node(node);
+ }
+
+public:
+ uint32_t N(void) const { return arity(); }
+
+ int32_t axis(void) const { return _axis; }
+ void axis(int32_t axis) { _axis = axis; }
+
+private:
+ int32_t _axis{0};
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFPACK_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFPad.h b/compiler/moco/lang/include/moco/IR/Nodes/TFPad.h
new file mode 100644
index 000000000..dae4741d6
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFPad.h
@@ -0,0 +1,61 @@
+/*
+ * 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_TFPAD_H__
+#define __MOCO_IR_TFPAD_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+/// @note TFPad corresponds to the following GraphDef
+/*
+node {
+ name: "Pad"
+ op: "Pad"
+ input: "Const_tensor"
+ input: "Const_paddings"
+ attr {
+ key: "T"
+ value {
+ type: DT_INT32
+ }
+ }
+ attr {
+ key: "Tpaddings"
+ value {
+ type: DT_INT32
+ }
+ }
+}
+*/
+
+class TFPad final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Pad>>
+{
+public:
+ TFPad() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+ Node *paddings(void) const { return at(1)->node(); }
+ void paddings(Node *node) { at(1)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFPAD_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFPlaceholder.h b/compiler/moco/lang/include/moco/IR/Nodes/TFPlaceholder.h
new file mode 100644
index 000000000..65a78e665
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFPlaceholder.h
@@ -0,0 +1,90 @@
+/*
+ * 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_TFPLACEHOLDER_H__
+#define __MOCO_IR_TFPLACEHOLDER_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <loco/IR/DataTypeTraits.h>
+#include <loco/IR/NodeMixins.h>
+#include <loco/IR/GraphInputIndex.h>
+#include <loco/IR/TensorShape.h>
+
+namespace moco
+{
+
+/// @note TFPlaceholder corresponds to the following GraphDef
+/*
+node {
+ name: "placeholder"
+ op: "Placeholder"
+ attr {
+ key: "dtype"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "shape"
+ value {
+ shape {
+ dim {
+ size: 1
+ }
+ dim {
+ size: 3
+ }
+ dim {
+ size: 3
+ }
+ dim {
+ size: 1
+ }
+ }
+ }
+ }
+}
+*/
+
+/**
+ * @brief IR for tf.placeholder
+ */
+class TFPlaceholder final : public FixedArityNode<0, TFNodeImpl<TFOpcode::Placeholder>>,
+ public loco::NodeMixin<loco::NodeTrait::DataType>,
+ public loco::NodeMixin<loco::NodeTrait::TensorShape>
+{
+public:
+ TFPlaceholder() = default;
+
+ // TODO Update unkown shape information. tensorflow::NodeDef may not have "shape" attr.
+};
+
+} // namespace moco
+
+namespace moco
+{
+
+bool indexed(const TFPlaceholder *node);
+loco::GraphInputIndex index(const TFPlaceholder *node);
+void index(TFPlaceholder *node, const loco::GraphInputIndex index);
+loco::TensorShape tensor_shape(const TFPlaceholder *node);
+
+TFPlaceholder *placeholder_node(loco::Graph *g, const loco::GraphInputIndex &idx);
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFPLACEHOLDER_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFPush.h b/compiler/moco/lang/include/moco/IR/Nodes/TFPush.h
new file mode 100644
index 000000000..e45804252
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFPush.h
@@ -0,0 +1,84 @@
+/*
+ * 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_TFPUSH_H__
+#define __MOCO_IR_TFPUSH_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <loco.h>
+
+namespace moco
+{
+
+/**
+ * @brief Make a value visible to user
+ *
+ * @note TFPush is a virtual node that does not corresponds to real TensorFlow node
+ * Why this node is introduced:
+ * - Any TensorFlow Nodes can be an output.
+ * - So let any TFNode type can provide OutputIndex using Annotation.
+ * - Problem comes when in transformation, output node can be replaced.
+ * - This causes that OutputIndex Annotation should be copied to new node.
+ * - This makes every transformation in any Dialect code change.
+ * - And even worse, this makes every new transformation follow this rule.
+ * - Which is not good.
+ * - Thus, like loco Canonical does, follow loco::Push.
+ */
+class TFPush /* to user */ final : public FixedArityNode<1, TFNodeImpl<TFOpcode::TFPush>>
+{
+public:
+ TFPush() = default;
+
+public:
+ loco::Node *from(void) const { return at(0)->node(); }
+ void from(loco::Node *node) { at(0)->node(node); }
+
+public:
+ void index(const loco::GraphOutputIndex &index);
+
+ /**
+ * @brief Get associated output index
+ *
+ * The behavior of this method is undefined when "index" is not set before.
+ *
+ * NOTE This method intentionally returns "GraphOutputIndex" instead of "const GraphOutputIndex &"
+ * not to expose the internal implementation details.
+ */
+ loco::GraphOutputIndex index(void) const;
+
+ /**
+ * @brief Check whether index is initialized
+ *
+ * NOTE "indexed" method does not validate whether index is in a valid range
+ */
+ bool indexed(void) const { return _index != -1; }
+
+ /**
+ * @brief Reset output index
+ */
+ void index_reset(void) { _index = -1; }
+
+private:
+ int64_t _index = -1; // Uninitialized
+};
+
+/// @brief Find a TFPush node with a given output index
+TFPush *push_node(loco::Graph *g, const loco::GraphOutputIndex &index);
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFPUSH_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFRealDiv.h b/compiler/moco/lang/include/moco/IR/Nodes/TFRealDiv.h
new file mode 100644
index 000000000..8d61b3d13
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFRealDiv.h
@@ -0,0 +1,56 @@
+/*
+ * 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_TFREALDIV_H__
+#define __MOCO_IR_TFREALDIV_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFRealDiv corresponds to the following GraphDef
+/*
+node {
+ name: "div"
+ op: "RealDiv"
+ input: "x"
+ input: "y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFRealDiv final : public FixedArityNode<2, TFNodeImpl<TFOpcode::RealDiv>>
+{
+public:
+ TFRealDiv() = 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_TFREALDIV_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFRelu.h b/compiler/moco/lang/include/moco/IR/Nodes/TFRelu.h
new file mode 100644
index 000000000..90e121e5e
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFRelu.h
@@ -0,0 +1,52 @@
+/*
+ * 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_TFRELU_H__
+#define __MOCO_IR_TFRELU_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFRelu corresponds to the following GraphDef
+/*
+node {
+ name: "output/relu"
+ op: "Relu"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFRelu final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Relu>>
+{
+public:
+ TFRelu() = default;
+
+public:
+ Node *features(void) const { return at(0)->node(); }
+ void features(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFRELU_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFRelu6.h b/compiler/moco/lang/include/moco/IR/Nodes/TFRelu6.h
new file mode 100644
index 000000000..bb705b782
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFRelu6.h
@@ -0,0 +1,50 @@
+/*
+ * 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_TFRELU6_H__
+#define __MOCO_IR_TFRELU6_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFRelu6 corresponds to the following GraphDef
+/*
+node {
+ name: "Relu6"
+ op: "Relu6"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value { type: DT_FLOAT }
+ }
+}
+*/
+
+class TFRelu6 final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Relu6>>
+{
+public:
+ TFRelu6() = default;
+
+public:
+ Node *features(void) const { return at(0)->node(); }
+ void features(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFRELU6_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFReshape.h b/compiler/moco/lang/include/moco/IR/Nodes/TFReshape.h
new file mode 100644
index 000000000..1f743565d
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFReshape.h
@@ -0,0 +1,54 @@
+/*
+ * 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_TFRESHAPE_H__
+#define __MOCO_IR_TFRESHAPE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFReshape corresponds to the following GraphDef
+/*
+node {
+ name: "reshape"
+ op: "Reshape"
+ input: "tensor"
+ input: "shape"
+ attr {
+ key: "T"
+ value { type: DT_FLOAT }
+ }
+}
+*/
+
+class TFReshape final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Reshape>>
+{
+public:
+ TFReshape() = default;
+
+public:
+ Node *tensor(void) const { return at(0)->node(); }
+ void tensor(Node *node) { at(0)->node(node); }
+
+ Node *shape(void) const { return at(1)->node(); }
+ void shape(Node *node) { at(1)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFRESHAPE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFRsqrt.h b/compiler/moco/lang/include/moco/IR/Nodes/TFRsqrt.h
new file mode 100644
index 000000000..c71a5b98c
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFRsqrt.h
@@ -0,0 +1,52 @@
+/*
+ * 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_TFRSQRT_H__
+#define __MOCO_IR_TFRSQRT_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFRsqrt corresponds to the following GraphDef
+/*
+node {
+ name: "Rsqrt"
+ op: "Rsqrt"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFRsqrt final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Rsqrt>>
+{
+public:
+ TFRsqrt() = default;
+
+public:
+ Node *x(void) const { return at(0)->node(); }
+ void x(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFRSQRT_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFShape.h b/compiler/moco/lang/include/moco/IR/Nodes/TFShape.h
new file mode 100644
index 000000000..36f0f1e69
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFShape.h
@@ -0,0 +1,60 @@
+/*
+ * 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_TFSHAPE_H__
+#define __MOCO_IR_TFSHAPE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <loco/IR/NodeMixins.h>
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFShape corresponds to the following GraphDef
+/*
+node {
+ name: "Shape"
+ op: "Shape"
+ input: "some_input"
+ attr {
+ key: "T"
+ value { type: DT_FLOAT }
+ }
+ attr {
+ key: "out_type"
+ value { type: DT_INT32 }
+ }
+}
+*/
+
+/// @note Mixed in dtype() is for 'out_type' attribute
+class TFShape final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Shape>>,
+ public loco::NodeMixin<loco::NodeTrait::DataType>
+{
+public:
+ TFShape() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSHAPE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFSoftmax.h b/compiler/moco/lang/include/moco/IR/Nodes/TFSoftmax.h
new file mode 100644
index 000000000..c98df1d82
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFSoftmax.h
@@ -0,0 +1,37 @@
+/*
+ * 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_TFSOFTMAX_H__
+#define __MOCO_IR_TFSOFTMAX_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+class TFSoftmax final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Softmax>>
+{
+public:
+ TFSoftmax() = default;
+
+public:
+ Node *logits(void) const { return at(0)->node(); }
+ void logits(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSOFTMAX_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFSqrt.h b/compiler/moco/lang/include/moco/IR/Nodes/TFSqrt.h
new file mode 100644
index 000000000..273b5d49b
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFSqrt.h
@@ -0,0 +1,52 @@
+/*
+ * 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_TFSQRT_H__
+#define __MOCO_IR_TFSQRT_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFSqrt corresponds to the following GraphDef
+/*
+node {
+ name: "Sqrt"
+ op: "Sqrt"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFSqrt final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Sqrt>>
+{
+public:
+ TFSqrt() = default;
+
+public:
+ Node *x(void) const { return at(0)->node(); }
+ void x(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSQRT_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFSquaredDifference.h b/compiler/moco/lang/include/moco/IR/Nodes/TFSquaredDifference.h
new file mode 100644
index 000000000..4e0a929d3
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFSquaredDifference.h
@@ -0,0 +1,56 @@
+/*
+ * 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_TFSQUAREDDIFFERENCE_H__
+#define __MOCO_IR_TFSQUAREDDIFFERENCE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFSquaredDifference corresponds to the following GraphDef
+/*
+node {
+ name: "SquaredDifference"
+ op: "SquaredDifference"
+ input: "input_x"
+ input: "input_y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFSquaredDifference final : public FixedArityNode<2, TFNodeImpl<TFOpcode::SquaredDifference>>
+{
+public:
+ TFSquaredDifference() = 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_TFSQUAREDDIFFERENCE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFSqueeze.h b/compiler/moco/lang/include/moco/IR/Nodes/TFSqueeze.h
new file mode 100644
index 000000000..612497ee7
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFSqueeze.h
@@ -0,0 +1,71 @@
+/*
+ * 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_TFSQUEEZE_H__
+#define __MOCO_IR_TFSQUEEZE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+#include <vector>
+
+namespace moco
+{
+
+/// @note TFSqueeze corresponds to the following GraphDef
+/*
+node {
+ name: "squeeze"
+ op: "Squeeze"
+ input: "x"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+ attr {
+ key: "squeeze_dims"
+ value {
+ list {
+ i: a
+ i: b
+ ..
+ }
+ }
+ }
+}
+*/
+
+class TFSqueeze final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Squeeze>>
+{
+public:
+ TFSqueeze() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+public:
+ const std::vector<int64_t> &squeeze_dims(void) const { return _squeeze_dims; }
+ void squeeze_dims(const std::vector<int64_t> &squeeze_dims) { _squeeze_dims = squeeze_dims; }
+
+private:
+ std::vector<int64_t> _squeeze_dims;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSQUEEZE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFStopGradient.h b/compiler/moco/lang/include/moco/IR/Nodes/TFStopGradient.h
new file mode 100644
index 000000000..cfebd92a9
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFStopGradient.h
@@ -0,0 +1,52 @@
+/*
+ * 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_TFSTOPGRADIENT_H__
+#define __MOCO_IR_TFSTOPGRADIENT_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFStopGradient corresponds to the following GraphDef
+/*
+node {
+ name: "StopGradient"
+ op: "StopGradient"
+ input: "Placeholder"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFStopGradient final : public FixedArityNode<1, TFNodeImpl<TFOpcode::StopGradient>>
+{
+public:
+ TFStopGradient() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSTOPGRADIENT_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFStridedSlice.h b/compiler/moco/lang/include/moco/IR/Nodes/TFStridedSlice.h
new file mode 100644
index 000000000..75012b219
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFStridedSlice.h
@@ -0,0 +1,123 @@
+/*
+ * 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_TFSTRIDEDSLICE_H__
+#define __MOCO_IR_TFSTRIDEDSLICE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFStridedSlice corresponds to the following GraphDef
+/*
+node {
+ name: "StridedSlice"
+ op: "StridedSlice"
+ input: "input"
+ input: "begin"
+ input: "end"
+ input: "stride"
+ attr {
+ key: "Index"
+ value {
+ type: DT_INT32
+ }
+ }
+ attr {
+ key: "T"
+ value {
+ type: DT_INT32
+ }
+ }
+ attr {
+ key: "begin_mask"
+ value {
+ i: 0
+ }
+ }
+ attr {
+ key: "ellipsis_mask"
+ value {
+ i: 0
+ }
+ }
+ attr {
+ key: "end_mask"
+ value {
+ i: 0
+ }
+ }
+ attr {
+ key: "new_axis_mask"
+ value {
+ i: 0
+ }
+ }
+ attr {
+ key: "shrink_axis_mask"
+ value {
+ i: 0
+ }
+ }
+}
+*/
+
+class TFStridedSlice final : public FixedArityNode<4, TFNodeImpl<TFOpcode::StridedSlice>>
+{
+public:
+ TFStridedSlice() = default;
+
+public:
+ Node *input(void) const { return at(0)->node(); }
+ void input(Node *node) { at(0)->node(node); }
+
+ Node *begin(void) const { return at(1)->node(); }
+ void begin(Node *node) { at(1)->node(node); }
+
+ Node *end(void) const { return at(2)->node(); }
+ void end(Node *node) { at(2)->node(node); }
+
+ Node *strides(void) const { return at(3)->node(); }
+ void strides(Node *node) { at(3)->node(node); }
+
+public:
+ int32_t begin_mask(void) const { return _begin_mask; }
+ void begin_mask(int32_t begin_mask) { _begin_mask = begin_mask; }
+
+ int32_t end_mask(void) const { return _end_mask; }
+ void end_mask(int32_t end_mask) { _end_mask = end_mask; }
+
+ int32_t ellipsis_mask(void) const { return _ellipsis_mask; }
+ void ellipsis_mask(int32_t ellipsis_mask) { _ellipsis_mask = ellipsis_mask; }
+
+ int32_t new_axis_mask(void) const { return _new_axis_mask; }
+ void new_axis_mask(int32_t new_axis_mask) { _new_axis_mask = new_axis_mask; }
+
+ int32_t shrink_axis_mask(void) const { return _shrink_axis_mask; }
+ void shrink_axis_mask(int32_t shrink_axis_mask) { _shrink_axis_mask = shrink_axis_mask; }
+
+private:
+ int32_t _begin_mask{0};
+ int32_t _end_mask{0};
+ int32_t _ellipsis_mask{0};
+ int32_t _new_axis_mask{0};
+ int32_t _shrink_axis_mask{0};
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFSTRIDEDSLICE_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFSub.h b/compiler/moco/lang/include/moco/IR/Nodes/TFSub.h
new file mode 100644
index 000000000..27905cbdb
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFSub.h
@@ -0,0 +1,56 @@
+/*
+ * 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_TFSUB_H__
+#define __MOCO_IR_TFSUB_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+/// @note TFSub corresponds to the following GraphDef
+/*
+node {
+ name: "sub"
+ op: "Sub"
+ input: "x"
+ input: "y"
+ attr {
+ key: "T"
+ value {
+ type: DT_FLOAT
+ }
+ }
+}
+*/
+
+class TFSub final : public FixedArityNode<2, TFNodeImpl<TFOpcode::Sub>>
+{
+public:
+ TFSub() = 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_TFSUB_H__
diff --git a/compiler/moco/lang/include/moco/IR/Nodes/TFTanh.h b/compiler/moco/lang/include/moco/IR/Nodes/TFTanh.h
new file mode 100644
index 000000000..4543c62f3
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/Nodes/TFTanh.h
@@ -0,0 +1,37 @@
+/*
+ * 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_TFTANH_H__
+#define __MOCO_IR_TFTANH_H__
+
+#include "moco/IR/TFNodeDecl.h"
+
+namespace moco
+{
+
+class TFTanh final : public FixedArityNode<1, TFNodeImpl<TFOpcode::Tanh>>
+{
+public:
+ TFTanh() = default;
+
+public:
+ Node *x(void) const { return at(0)->node(); }
+ void x(Node *node) { at(0)->node(node); }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFTANH_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFDataLayout.h b/compiler/moco/lang/include/moco/IR/TFDataLayout.h
new file mode 100644
index 000000000..f0edfacd5
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFDataLayout.h
@@ -0,0 +1,29 @@
+/*
+ * 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_TFDATALAYOUT_H__
+#define __MOCO_IR_TFDATALAYOUT_H__
+
+#include <string>
+
+namespace moco
+{
+
+using TFDataLayout = std::string;
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFDATALAYOUT_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFDialect.h b/compiler/moco/lang/include/moco/IR/TFDialect.h
new file mode 100644
index 000000000..847bc527f
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFDialect.h
@@ -0,0 +1,43 @@
+/*
+ * 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_TFDIALECT_H__
+#define __MOCO_IR_TFDIALECT_H__
+
+#include <loco/IR/Dialect.h>
+
+namespace moco
+{
+
+/**
+ * @brief A singleton for TensorFlow Dialect
+ */
+class TFDialect final : public loco::Dialect
+{
+private:
+ TFDialect();
+
+public:
+ TFDialect(const TFDialect &) = delete;
+ TFDialect(TFDialect &&) = delete;
+
+public:
+ static loco::Dialect *get(void);
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFDIALECT_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNode.h b/compiler/moco/lang/include/moco/IR/TFNode.h
new file mode 100644
index 000000000..e3d900ba3
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNode.h
@@ -0,0 +1,23 @@
+/*
+ * 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_TFNODE_H__
+#define __MOCO_IR_TFNODE_H__
+
+#include "moco/IR/TFNodeDecl.h"
+#include "moco/IR/TFNodeImpl.h"
+
+#endif // __MOCO_IR_TFNODE_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodeDecl.h b/compiler/moco/lang/include/moco/IR/TFNodeDecl.h
new file mode 100644
index 000000000..68d7161b6
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodeDecl.h
@@ -0,0 +1,104 @@
+/*
+ * 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_TFNODE_DECL_H__
+#define __MOCO_IR_TFNODE_DECL_H__
+
+#include <loco/IR/Node.h>
+#include <loco/IR/Dialect.h>
+
+#include "moco/IR/TFOpcode.h"
+#include "moco/IR/TFNodeVisitor.forward.h"
+
+#include "moco/IR/TFDataLayout.h"
+#include "moco/IR/TFPadding.h"
+
+#include <array>
+#include <string>
+
+namespace moco
+{
+
+/**
+ * @note NodeName is string name of the Node without ':#' prefix like ':0' or ':1'
+ */
+using NodeName = std::string;
+
+struct TFNode : public loco::Node
+{
+ virtual ~TFNode() = default;
+
+ const loco::Dialect *dialect(void) const final;
+ virtual TFOpcode opcode(void) const = 0;
+
+ template <typename T> T accept(TFNodeVisitorBase<T> *) const;
+ template <typename T> T accept(TFNodeMutableVisitorBase<T> *);
+
+ NodeName name(void) const { return _name; }
+ void name(const NodeName &name) { _name = name; }
+
+private:
+ NodeName _name;
+};
+
+template <TFOpcode Code> struct TFNodeImpl : public TFNode
+{
+ virtual ~TFNodeImpl() = default;
+
+ uint32_t opnum(void) const final { return static_cast<uint32_t>(Code); }
+ TFOpcode opcode(void) const final { return Code; }
+};
+
+/**
+ * @brief Nodes with the fixed number of inputs
+ */
+template <unsigned N, typename Base> class FixedArityNode : public Base
+{
+public:
+ FixedArityNode()
+ {
+ for (uint32_t n = 0; n < N; ++n)
+ {
+ _args[n] = std::unique_ptr<loco::Use>{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<std::unique_ptr<loco::Use>, N> _args{};
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFNODE_DECL_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodeImpl.h b/compiler/moco/lang/include/moco/IR/TFNodeImpl.h
new file mode 100644
index 000000000..afc306031
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodeImpl.h
@@ -0,0 +1,68 @@
+/*
+ * 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_TFNODE_IMPL_H__
+#define __MOCO_IR_TFNODE_IMPL_H__
+
+#include "moco/IR/TFNodes.h"
+#include "moco/IR/TFNodeVisitor.h"
+
+#include <stdexcept>
+
+namespace moco
+{
+
+template <typename T> T TFNode::accept(TFNodeVisitorBase<T> *v) const
+{
+ switch (this->opcode())
+ {
+#define TENSORFLOW_NODE(OPCODE, CLASS) \
+ case TFOpcode::OPCODE: \
+ return v->visit(dynamic_cast<const CLASS *>(this));
+
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+ default:
+ break;
+ }
+
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ throw std::runtime_error{"Unsupported Node"};
+}
+
+template <typename T> T TFNode::accept(TFNodeMutableVisitorBase<T> *v)
+{
+ switch (this->opcode())
+ {
+#define TENSORFLOW_NODE(OPCODE, CLASS) \
+ case TFOpcode::OPCODE: \
+ return v->visit(dynamic_cast<CLASS *>(this));
+
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+ default:
+ break;
+ }
+
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ throw std::runtime_error{"Unsupported Node"};
+}
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFNODE_IMPL_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodeVisitor.forward.h b/compiler/moco/lang/include/moco/IR/TFNodeVisitor.forward.h
new file mode 100644
index 000000000..1eb86871c
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodeVisitor.forward.h
@@ -0,0 +1,30 @@
+/*
+ * 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_TFNODE_VISITOR_FORWARD_H__
+#define __MOCO_IR_TFNODE_VISITOR_FORWARD_H__
+
+namespace moco
+{
+
+// NOTE These forward declarations SHOULD BE aligned with Node delcarations in
+// "TFNodeVisitor.h"
+template <typename T> struct TFNodeVisitorBase;
+template <typename T> struct TFNodeMutableVisitorBase;
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFNODE_VISITOR_FORWARD_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodeVisitor.h b/compiler/moco/lang/include/moco/IR/TFNodeVisitor.h
new file mode 100644
index 000000000..8d23e447d
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodeVisitor.h
@@ -0,0 +1,83 @@
+/*
+ * 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_TFNODE_VISITOR_H__
+#define __MOCO_IR_TFNODE_VISITOR_H__
+
+#include "moco/IR/TFNodes.h"
+
+#include <stdexcept>
+
+namespace moco
+{
+
+/**
+ * DO NOT use this class. Use TFNodeVisitor instead.
+ */
+template <typename T> struct TFNodeVisitorBase
+{
+ virtual ~TFNodeVisitorBase() = default;
+
+#define TENSORFLOW_NODE(OPCODE, CLASS) virtual T visit(const CLASS *) = 0;
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+};
+
+template <typename T> struct TFNodeVisitor : public TFNodeVisitorBase<T>
+{
+ virtual ~TFNodeVisitor() = default;
+
+#define TENSORFLOW_NODE(OPCODE, CLASS) \
+ virtual T visit(const CLASS *node) { return visit(static_cast<const TFNode *>(node)); }
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ /// @brief Default fallback
+ virtual T visit(const TFNode *) { throw std::runtime_error{"Unsupported Node"}; }
+};
+
+/**
+ * DO NOT use this class. Use TFNodeMutableVisitor instead.
+ */
+template <typename T> struct TFNodeMutableVisitorBase
+{
+ virtual ~TFNodeMutableVisitorBase() = default;
+
+#define TENSORFLOW_NODE(OPCODE, CLASS) virtual T visit(CLASS *) = 0;
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+};
+
+template <typename T> struct TFNodeMutableVisitor : public TFNodeMutableVisitorBase<T>
+{
+ virtual ~TFNodeMutableVisitor() = default;
+
+#define TENSORFLOW_NODE(OPCODE, CLASS) \
+ virtual T visit(CLASS *node) { return visit(static_cast<TFNode *>(node)); }
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ /// @brief Default fallback
+ virtual T visit(TFNode *) { throw std::runtime_error{"Unsupported Node"}; }
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFNODE_VISITOR_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodes.h b/compiler/moco/lang/include/moco/IR/TFNodes.h
new file mode 100644
index 000000000..ad54dfdf3
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodes.h
@@ -0,0 +1,55 @@
+/*
+ * 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_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/TFConcatV2.h"
+#include "moco/IR/Nodes/TFConst.h"
+#include "moco/IR/Nodes/TFConv2D.h"
+#include "moco/IR/Nodes/TFConv2DBackpropInput.h"
+#include "moco/IR/Nodes/TFDepthwiseConv2dNative.h"
+#include "moco/IR/Nodes/TFFakeQuantWithMinMaxVars.h"
+#include "moco/IR/Nodes/TFFusedBatchNorm.h"
+#include "moco/IR/Nodes/TFIdentity.h"
+#include "moco/IR/Nodes/TFMaximum.h"
+#include "moco/IR/Nodes/TFMaxPool.h"
+#include "moco/IR/Nodes/TFMean.h"
+#include "moco/IR/Nodes/TFMul.h"
+#include "moco/IR/Nodes/TFPack.h"
+#include "moco/IR/Nodes/TFPad.h"
+#include "moco/IR/Nodes/TFPlaceholder.h"
+#include "moco/IR/Nodes/TFRealDiv.h"
+#include "moco/IR/Nodes/TFRelu.h"
+#include "moco/IR/Nodes/TFRelu6.h"
+#include "moco/IR/Nodes/TFReshape.h"
+#include "moco/IR/Nodes/TFRsqrt.h"
+#include "moco/IR/Nodes/TFShape.h"
+#include "moco/IR/Nodes/TFSoftmax.h"
+#include "moco/IR/Nodes/TFSqrt.h"
+#include "moco/IR/Nodes/TFSquaredDifference.h"
+#include "moco/IR/Nodes/TFSqueeze.h"
+#include "moco/IR/Nodes/TFStopGradient.h"
+#include "moco/IR/Nodes/TFStridedSlice.h"
+#include "moco/IR/Nodes/TFSub.h"
+#include "moco/IR/Nodes/TFTanh.h"
+// For virtual node(s)
+#include "moco/IR/Nodes/TFPush.h"
+
+#endif // __MOCO_IR_TFNODES_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFNodes.lst b/compiler/moco/lang/include/moco/IR/TFNodes.lst
new file mode 100644
index 000000000..8373d2b8d
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFNodes.lst
@@ -0,0 +1,48 @@
+#ifndef TENSORFLOW_NODE
+#error "Define TENSORFLOW_NODE"
+#endif // TENSORFLOW_NODE
+
+//
+// PLEASE SORT NODE DECLS IN ALPHABETICAL ORDER
+//
+// Naming rule: Follow names in TensorFlow C++ source
+// ex) for AvgPool, tensorflow/core/ops/nn_ops.cc
+// REGISTER_OP("AvgPool") <-- OPCODE: AvgPool. Prefix `TF` for CLASS name
+// .Input("value: T") <-- Input name is 'value'
+//
+
+// TENSORFLOW_NODE(OPCODE, CLASS)
+TENSORFLOW_NODE(Add, TFAdd)
+TENSORFLOW_NODE(AvgPool, TFAvgPool)
+TENSORFLOW_NODE(BiasAdd, TFBiasAdd)
+TENSORFLOW_NODE(ConcatV2, TFConcatV2)
+TENSORFLOW_NODE(Const, TFConst)
+TENSORFLOW_NODE(Conv2D, TFConv2D)
+TENSORFLOW_NODE(Conv2DBackpropInput, TFConv2DBackpropInput)
+TENSORFLOW_NODE(DepthwiseConv2dNative, TFDepthwiseConv2dNative)
+TENSORFLOW_NODE(FakeQuantWithMinMaxVars, TFFakeQuantWithMinMaxVars)
+TENSORFLOW_NODE(FusedBatchNorm, TFFusedBatchNorm)
+TENSORFLOW_NODE(Identity, TFIdentity)
+TENSORFLOW_NODE(Maximum, TFMaximum)
+TENSORFLOW_NODE(MaxPool, TFMaxPool)
+TENSORFLOW_NODE(Mean, TFMean)
+TENSORFLOW_NODE(Mul, TFMul)
+TENSORFLOW_NODE(Pack, TFPack)
+TENSORFLOW_NODE(Pad, TFPad)
+TENSORFLOW_NODE(Placeholder, TFPlaceholder)
+TENSORFLOW_NODE(RealDiv, TFRealDiv)
+TENSORFLOW_NODE(Relu, TFRelu)
+TENSORFLOW_NODE(Relu6, TFRelu6)
+TENSORFLOW_NODE(Reshape, TFReshape)
+TENSORFLOW_NODE(Rsqrt, TFRsqrt)
+TENSORFLOW_NODE(Shape, TFShape)
+TENSORFLOW_NODE(Softmax, TFSoftmax)
+TENSORFLOW_NODE(Sqrt, TFSqrt)
+TENSORFLOW_NODE(SquaredDifference, TFSquaredDifference)
+TENSORFLOW_NODE(Squeeze, TFSqueeze)
+TENSORFLOW_NODE(StopGradient, TFStopGradient)
+TENSORFLOW_NODE(StridedSlice, TFStridedSlice)
+TENSORFLOW_NODE(Sub, TFSub)
+TENSORFLOW_NODE(Tanh, TFTanh)
+// For virtual node(s)
+TENSORFLOW_NODE(TFPush, TFPush)
diff --git a/compiler/moco/lang/include/moco/IR/TFOpcode.h b/compiler/moco/lang/include/moco/IR/TFOpcode.h
new file mode 100644
index 000000000..7524dcce4
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFOpcode.h
@@ -0,0 +1,35 @@
+/*
+ * 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_TFOPCODE_H__
+#define __MOCO_IR_TFOPCODE_H__
+
+namespace moco
+{
+
+/**
+ * @brief TensorFlow Node Opcode
+ */
+enum class TFOpcode
+{
+#define TENSORFLOW_NODE(OPCODE, CLASS) OPCODE,
+#include "TFNodes.lst"
+#undef TENSORFLOW_NODE
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFOPCODE_H__
diff --git a/compiler/moco/lang/include/moco/IR/TFPadding.h b/compiler/moco/lang/include/moco/IR/TFPadding.h
new file mode 100644
index 000000000..c75b3f2ce
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/TFPadding.h
@@ -0,0 +1,29 @@
+/*
+ * 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_TFPADDING_H__
+#define __MOCO_IR_TFPADDING_H__
+
+#include <string>
+
+namespace moco
+{
+
+using TFPadding = std::string;
+
+} // namespace moco
+
+#endif // __MOCO_IR_TFPADDING_H__
diff --git a/compiler/moco/lang/include/moco/IR/VariadicArityNode.h b/compiler/moco/lang/include/moco/IR/VariadicArityNode.h
new file mode 100644
index 000000000..7df0f7dec
--- /dev/null
+++ b/compiler/moco/lang/include/moco/IR/VariadicArityNode.h
@@ -0,0 +1,77 @@
+/*
+ * 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_VARIADIC_ARITY_NODE_H__
+#define __MOCO_IR_VARIADIC_ARITY_NODE_H__
+
+#include <loco/IR/Node.h>
+#include <loco/IR/Use.h>
+
+#include <vector>
+#include <memory>
+#include <cassert>
+
+namespace moco
+{
+
+/**
+ * @brief Nodes with the variadic inputs
+ */
+template <typename Base> class VariadicArityNode : public Base
+{
+public:
+ VariadicArityNode(uint32_t arity)
+ {
+ for (uint32_t n = 0; n < arity; ++n)
+ {
+ _args.emplace_back(std::move(std::unique_ptr<loco::Use>{new loco::Use{this}}));
+ }
+ };
+
+ virtual ~VariadicArityNode() = default;
+
+public:
+ uint32_t arity(void) const final { return _args.size(); }
+
+ loco::Node *arg(uint32_t n) const final
+ {
+ assert(n < _args.size());
+ return _args.at(n)->node();
+ }
+
+ void drop(void) final
+ {
+ for (uint32_t n = 0; n < _args.size(); ++n)
+ {
+ _args.at(n)->node(nullptr);
+ }
+ }
+
+protected:
+ // This API allows inherited classes to access "_args" field.
+ loco::Use *at(uint32_t n) const
+ {
+ assert(n < _args.size());
+ return _args.at(n).get();
+ }
+
+private:
+ std::vector<std::unique_ptr<loco::Use>> _args;
+};
+
+} // namespace moco
+
+#endif // __MOCO_IR_VARIADIC_ARITY_NODE_H__
diff --git a/compiler/moco/lang/include/moco/Names.h b/compiler/moco/lang/include/moco/Names.h
new file mode 100644
index 000000000..1addc812b
--- /dev/null
+++ b/compiler/moco/lang/include/moco/Names.h
@@ -0,0 +1,96 @@
+/*
+ * 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_NAMES_H__
+#define __MOCO_NAMES_H__
+
+#include <string>
+#include <stdexcept>
+
+namespace moco
+{
+
+struct TensorName final
+{
+public:
+ /**
+ * @brief Constructor
+ *
+ * @note If tensor_name does not have ":index", this constructor adds ":0" by default
+ */
+ explicit TensorName(const std::string &tensor_name)
+ {
+ if (tensor_name.find(":") != std::string::npos) // tensor_name is a form of letter:0
+ {
+ _name.assign(tensor_name);
+ }
+ else
+ {
+ _name.assign(tensor_name + ":0"); // if it does not have ":index", adds ":0" by default
+ }
+ }
+
+ explicit TensorName(const std::string &node_name, const int tensor_index)
+ {
+ if (node_name.find(":") != std::string::npos) // tensor_name is already a form of name:0
+ {
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ throw std::runtime_error("Error: Node name has already tensor index:" + node_name);
+ }
+ else
+ {
+ _name.assign(node_name + ":" + std::to_string(tensor_index));
+ }
+ }
+
+ const std::string &name() const { return _name; }
+
+ /**
+ * @brief Returns node name from tensor name by removing, e.g., ":0"
+ */
+ const std::string nodeName() const
+ {
+ auto index = _name.find(":");
+
+ if (index != std::string::npos)
+ return _name.substr(0, index);
+ else
+ {
+ // TODO including oops will make oops dependent to modules that include this
+ // postpone decision to this or not
+ throw std::runtime_error{"Error: Tensor name should be a 'name:number' format: " + _name};
+ }
+ };
+
+private:
+ std::string _name;
+};
+
+/**
+ * @brief To use TensorName as a key in std::map, this struct defines how to compare two TensorNames
+ */
+struct TensorNameCompare
+{
+ bool operator()(const TensorName &lhs, const TensorName &rhs) const
+ {
+ return lhs.name() < rhs.name();
+ }
+};
+
+} // namespace moco
+
+#endif // __MOCO_NAMES_H__
diff --git a/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp
new file mode 100644
index 000000000..d2cfb6ac4
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFAdd.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp
new file mode 100644
index 000000000..32a27ffa0
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFAvgPool.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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.value(), 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>({}));
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp
new file mode 100644
index 000000000..4a15a4981
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFBiasAdd.test.cpp
@@ -0,0 +1,32 @@
+/*
+ * 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(), "");
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp
new file mode 100644
index 000000000..8f7df92d0
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFConcatV2.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFConcatV2.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFConcatV2Test, constructor)
+{
+ moco::TFConcatV2 concatv2_node(3); // num of values
+
+ ASSERT_EQ(concatv2_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(concatv2_node.opcode(), moco::TFOpcode::ConcatV2);
+
+ ASSERT_EQ(concatv2_node.num_values(), 3);
+ ASSERT_EQ(concatv2_node.values(0), nullptr);
+ ASSERT_EQ(concatv2_node.values(1), nullptr);
+ ASSERT_EQ(concatv2_node.values(2), nullptr);
+ ASSERT_EQ(concatv2_node.axis(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFConst.cpp b/compiler/moco/lang/src/IR/Nodes/TFConst.cpp
new file mode 100644
index 000000000..5c8c08ec0
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFConst.cpp
@@ -0,0 +1,113 @@
+/*
+ * 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/TFConst.h"
+
+#include <cassert>
+
+namespace moco
+{
+
+template <loco::DataType DT> uint32_t TFConst::size(void) const
+{
+ assert(dtype() == DT);
+ assert(_data.size() % sizeof(typename loco::DataTypeImpl<DT>::Type) == 0);
+ return _data.size() / sizeof(typename loco::DataTypeImpl<DT>::Type);
+}
+
+template <loco::DataType DT> void TFConst::size(uint32_t l)
+{
+ assert(dtype() == DT);
+ _data.resize(l * sizeof(typename loco::DataTypeImpl<DT>::Type));
+}
+
+template <loco::DataType DT>
+const typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n) const
+{
+ assert(dtype() == DT);
+ assert(n < size<DT>());
+ return *(reinterpret_cast<const typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
+}
+
+template <loco::DataType DT> typename loco::DataTypeImpl<DT>::Type &TFConst::at(uint32_t n)
+{
+ assert(dtype() == DT);
+ assert(n < size<DT>());
+ return *(reinterpret_cast<typename loco::DataTypeImpl<DT>::Type *>(_data.data()) + n);
+}
+
+#define INSTANTIATE(DT) \
+ template uint32_t TFConst::size<DT>(void) const; \
+ template void TFConst::size<DT>(uint32_t); \
+ template const typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t) const; \
+ template typename loco::DataTypeImpl<DT>::Type &TFConst::at<DT>(uint32_t);
+
+INSTANTIATE(loco::DataType::S8);
+INSTANTIATE(loco::DataType::S32);
+INSTANTIATE(loco::DataType::FLOAT32);
+
+#undef INSTANTIATE
+
+loco::TensorShape tensor_shape(const TFConst *node)
+{
+ assert(node != nullptr);
+
+ loco::TensorShape shape;
+
+ uint32_t rank = node->rank();
+ shape.rank(rank);
+ for (uint32_t index = 0; index < rank; ++index)
+ {
+ assert(node->dim(index).known());
+ shape.dim(index) = node->dim(index).value();
+ }
+
+ return shape;
+}
+
+uint32_t num_elements(const TFConst *tfconst)
+{
+ assert(tfconst != nullptr);
+
+ uint32_t num_elements = 1;
+ for (uint32_t index = 0; index < tfconst->rank(); ++index)
+ {
+ assert(tfconst->dim(index).known());
+ uint32_t dim = tfconst->dim(index).value();
+ num_elements = num_elements * dim;
+ }
+ return num_elements;
+}
+
+bool same_shape(const TFConst *lhs, const TFConst *rhs)
+{
+ assert(lhs != nullptr);
+ assert(rhs != nullptr);
+
+ if (lhs->rank() != rhs->rank())
+ return false;
+
+ for (uint32_t index = 0; index < lhs->rank(); ++index)
+ {
+ assert(lhs->dim(index).known());
+ assert(rhs->dim(index).known());
+ if (lhs->dim(index).value() != rhs->dim(index).value())
+ return false;
+ }
+ return true;
+}
+
+} // namespace moco
diff --git a/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp
new file mode 100644
index 000000000..259966e33
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFConst.test.cpp
@@ -0,0 +1,95 @@
+/*
+ * 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/TFConst.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFConstantTest, constructor)
+{
+ moco::TFConst constant;
+
+ ASSERT_EQ(constant.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(constant.opcode(), moco::TFOpcode::Const);
+
+ ASSERT_EQ(constant.dtype(), loco::DataType::Unknown);
+ ASSERT_EQ(constant.rank(), 0);
+
+ constant.dtype(loco::DataType::FLOAT32);
+ ASSERT_EQ(constant.dtype(), loco::DataType::FLOAT32);
+
+ constant.rank(2);
+ ASSERT_EQ(constant.rank(), 2);
+
+ constant.dim(0) = 2;
+ constant.dim(1) = 3;
+
+ ASSERT_TRUE(constant.dim(0).known());
+ ASSERT_TRUE(constant.dim(1).known());
+
+ ASSERT_EQ(constant.dim(0), 2);
+ ASSERT_EQ(constant.dim(1), 3);
+
+ constant.size<loco::DataType::FLOAT32>(6);
+
+ ASSERT_EQ(constant.size<loco::DataType::FLOAT32>(), 6);
+
+ constant.at<loco::DataType::FLOAT32>(0) = 0.0f; // Set 0,0
+ constant.at<loco::DataType::FLOAT32>(1) = 1.0f; // Set 0,1
+ constant.at<loco::DataType::FLOAT32>(2) = 2.0f; // Set 0,2
+ constant.at<loco::DataType::FLOAT32>(3) = 3.0f; // Set 1,0
+ constant.at<loco::DataType::FLOAT32>(4) = 4.0f; // Set 1,1
+ constant.at<loco::DataType::FLOAT32>(5) = 5.0f; // Set 1,2
+
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(0), 0.0f);
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(1), 1.0f);
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(2), 2.0f);
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(3), 3.0f);
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(4), 4.0f);
+ ASSERT_EQ(constant.at<loco::DataType::FLOAT32>(5), 5.0f);
+}
+
+TEST(TFConstantTest, datatype_s8)
+{
+ moco::TFConst constant;
+
+ ASSERT_EQ(constant.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(constant.opcode(), moco::TFOpcode::Const);
+
+ ASSERT_EQ(constant.dtype(), loco::DataType::Unknown);
+ ASSERT_EQ(constant.rank(), 0);
+
+ constant.dtype(loco::DataType::S8);
+ ASSERT_EQ(constant.dtype(), loco::DataType::S8);
+
+ constant.rank(1);
+ ASSERT_EQ(constant.rank(), 1);
+
+ constant.dim(0) = 3;
+ ASSERT_TRUE(constant.dim(0).known());
+ ASSERT_EQ(constant.dim(0), 3);
+ constant.size<loco::DataType::S8>(3);
+ ASSERT_EQ(constant.size<loco::DataType::S8>(), 3);
+
+ constant.at<loco::DataType::S8>(0) = -1;
+ constant.at<loco::DataType::S8>(1) = 1;
+ constant.at<loco::DataType::S8>(2) = 0;
+
+ ASSERT_EQ(constant.at<loco::DataType::S8>(0), -1);
+ ASSERT_EQ(constant.at<loco::DataType::S8>(1), 1);
+ ASSERT_EQ(constant.at<loco::DataType::S8>(2), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp
new file mode 100644
index 000000000..3e3453db0
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFConv2D.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFConv2D.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFConv2DTest, constructor)
+{
+ moco::TFConv2D conv2d_node;
+
+ ASSERT_EQ(conv2d_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(conv2d_node.opcode(), moco::TFOpcode::Conv2D);
+
+ ASSERT_EQ(conv2d_node.input(), nullptr);
+ ASSERT_EQ(conv2d_node.filter(), nullptr);
+ ASSERT_EQ(conv2d_node.padding(), "");
+ ASSERT_EQ(conv2d_node.data_layout(), "");
+ ASSERT_EQ(conv2d_node.strides().size(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp
new file mode 100644
index 000000000..f7ad4ce67
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFConv2DBackpropInput.test.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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/TFConv2DBackpropInput.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFConv2DBackpropInputTest, constructor)
+{
+ moco::TFConv2DBackpropInput conv2dbi_node;
+
+ ASSERT_EQ(conv2dbi_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(conv2dbi_node.opcode(), moco::TFOpcode::Conv2DBackpropInput);
+
+ ASSERT_EQ(conv2dbi_node.input_sizes(), nullptr);
+ ASSERT_EQ(conv2dbi_node.filter(), nullptr);
+ ASSERT_EQ(conv2dbi_node.out_backprop(), nullptr);
+ ASSERT_EQ(conv2dbi_node.padding(), "");
+ ASSERT_EQ(conv2dbi_node.data_layout(), "");
+ ASSERT_EQ(conv2dbi_node.strides().size(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp
new file mode 100644
index 000000000..2562997c2
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFDepthwiseConv2dNative.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFDepthwiseConv2dNative.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFDepthwiseConv2dNativeTest, constructor)
+{
+ moco::TFDepthwiseConv2dNative depthwiseConv2dnative_node;
+
+ ASSERT_EQ(depthwiseConv2dnative_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(depthwiseConv2dnative_node.opcode(), moco::TFOpcode::DepthwiseConv2dNative);
+
+ ASSERT_EQ(depthwiseConv2dnative_node.input(), nullptr);
+ ASSERT_EQ(depthwiseConv2dnative_node.filter(), nullptr);
+ ASSERT_EQ(depthwiseConv2dnative_node.padding(), "");
+ ASSERT_EQ(depthwiseConv2dnative_node.data_layout(), "");
+ ASSERT_EQ(depthwiseConv2dnative_node.strides().size(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp
new file mode 100644
index 000000000..be8fc3a70
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFFakeQuantWithMinMaxVars.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFFakeQuantWithMinMaxVars.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFFakeQuantWithMinMaxVarsTest, constructor)
+{
+ moco::TFFakeQuantWithMinMaxVars fakequant_node;
+
+ ASSERT_EQ(fakequant_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(fakequant_node.opcode(), moco::TFOpcode::FakeQuantWithMinMaxVars);
+
+ ASSERT_EQ(fakequant_node.inputs(), nullptr);
+ ASSERT_EQ(fakequant_node.min(), nullptr);
+ ASSERT_EQ(fakequant_node.max(), nullptr);
+ ASSERT_EQ(fakequant_node.num_bits(), 8);
+ ASSERT_EQ(fakequant_node.narrow_range(), false);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp
new file mode 100644
index 000000000..265f8f9a4
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFFusedBatchNorm.test.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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/TFFusedBatchNorm.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFFusedBatchNormTest, constructor)
+{
+ moco::TFFusedBatchNorm fbn_node;
+
+ ASSERT_EQ(fbn_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(fbn_node.opcode(), moco::TFOpcode::FusedBatchNorm);
+
+ ASSERT_EQ(fbn_node.x(), nullptr);
+ ASSERT_EQ(fbn_node.scale(), nullptr);
+ ASSERT_EQ(fbn_node.offset(), nullptr);
+ ASSERT_EQ(fbn_node.mean(), nullptr);
+ ASSERT_EQ(fbn_node.variance(), nullptr);
+ ASSERT_NE(fbn_node.epsilon(), 0.0f);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp
new file mode 100644
index 000000000..deb17d502
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFIdentity.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFIdentity.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFIdentituTest, constructor)
+{
+ moco::TFIdentity identity_node;
+
+ ASSERT_EQ(identity_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(identity_node.opcode(), moco::TFOpcode::Identity);
+
+ ASSERT_EQ(identity_node.input(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp
new file mode 100644
index 000000000..482ad889d
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFMaxPool.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFMaxPool.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFMaxPoolTest, constructor)
+{
+ moco::TFMaxPool maxpool;
+
+ ASSERT_EQ(maxpool.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(maxpool.opcode(), moco::TFOpcode::MaxPool);
+
+ ASSERT_EQ(maxpool.input(), nullptr);
+ ASSERT_EQ(maxpool.data_layout(), "");
+ ASSERT_EQ(maxpool.padding(), "");
+ ASSERT_EQ(maxpool.ksize(), std::vector<int64_t>({}));
+ ASSERT_EQ(maxpool.strides(), std::vector<int64_t>({}));
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp
new file mode 100644
index 000000000..568bd7038
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFMaximum.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2020 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/TFMaximum.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFMaximumTest, constructor)
+{
+ moco::TFMaximum max_node;
+
+ ASSERT_EQ(max_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(max_node.opcode(), moco::TFOpcode::Maximum);
+
+ ASSERT_EQ(max_node.x(), nullptr);
+ ASSERT_EQ(max_node.y(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp
new file mode 100644
index 000000000..126b31783
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFMean.test.cpp
@@ -0,0 +1,32 @@
+/*
+ * 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/TFMean.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFMeanTest, constructor)
+{
+ moco::TFMean mean_node;
+
+ ASSERT_EQ(mean_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(mean_node.opcode(), moco::TFOpcode::Mean);
+
+ ASSERT_EQ(mean_node.input(), nullptr);
+ ASSERT_EQ(mean_node.reduction_indices(), nullptr);
+ ASSERT_EQ(mean_node.keep_dims(), false);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp
new file mode 100644
index 000000000..a4a1ecfd7
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFMul.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFMul.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFMulTest, constructor)
+{
+ moco::TFMul mul_node;
+
+ ASSERT_EQ(mul_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(mul_node.opcode(), moco::TFOpcode::Mul);
+
+ ASSERT_EQ(mul_node.x(), nullptr);
+ ASSERT_EQ(mul_node.y(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp
new file mode 100644
index 000000000..a62b39f3d
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFPack.test.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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/TFPack.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFPackTest, constructor)
+{
+ moco::TFPack pack_node(3); // num of values
+
+ ASSERT_EQ(pack_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(pack_node.opcode(), moco::TFOpcode::Pack);
+
+ ASSERT_EQ(pack_node.N(), 3);
+ ASSERT_EQ(pack_node.values(0), nullptr);
+ ASSERT_EQ(pack_node.values(1), nullptr);
+ ASSERT_EQ(pack_node.values(2), nullptr);
+ ASSERT_EQ(pack_node.axis(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp
new file mode 100644
index 000000000..f3f3dcc8c
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFPad.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFPad.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFPadTest, constructor)
+{
+ moco::TFPad pad;
+
+ ASSERT_EQ(pad.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(pad.opcode(), moco::TFOpcode::Pad);
+
+ ASSERT_EQ(pad.input(), nullptr);
+ ASSERT_EQ(pad.paddings(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp
new file mode 100644
index 000000000..e082f0c3e
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFPlaceholder.test.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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/TFPlaceholder.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFPlaceholderTest, constructor)
+{
+ moco::TFPlaceholder placeholder;
+
+ ASSERT_EQ(placeholder.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(placeholder.opcode(), moco::TFOpcode::Placeholder);
+
+ ASSERT_EQ(placeholder.dtype(), loco::DataType::Unknown);
+ ASSERT_EQ(placeholder.rank(), 0);
+
+ placeholder.dtype(loco::DataType::FLOAT32);
+ ASSERT_EQ(placeholder.dtype(), loco::DataType::FLOAT32);
+
+ placeholder.rank(2);
+ ASSERT_EQ(placeholder.rank(), 2);
+
+ placeholder.dim(0) = 2;
+ placeholder.dim(1) = 3;
+
+ ASSERT_TRUE(placeholder.dim(0).known());
+ ASSERT_TRUE(placeholder.dim(1).known());
+
+ ASSERT_EQ(placeholder.dim(0), 2);
+ ASSERT_EQ(placeholder.dim(1), 3);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp
new file mode 100644
index 000000000..bfb8154a6
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFRealDiv.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFRealDiv.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFRealDivTest, constructor)
+{
+ moco::TFRealDiv div_node;
+
+ ASSERT_EQ(div_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(div_node.opcode(), moco::TFOpcode::RealDiv);
+
+ ASSERT_EQ(div_node.x(), nullptr);
+ ASSERT_EQ(div_node.y(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp
new file mode 100644
index 000000000..650e2550d
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFRelu.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFRelu.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFReluTest, constructor)
+{
+ moco::TFRelu relu_node;
+
+ ASSERT_EQ(relu_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(relu_node.opcode(), moco::TFOpcode::Relu);
+
+ ASSERT_EQ(relu_node.features(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp
new file mode 100644
index 000000000..9cce83df3
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFRelu6.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFRelu6.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFRelu6Test, constructor)
+{
+ moco::TFRelu6 relu6_node;
+
+ ASSERT_EQ(relu6_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(relu6_node.opcode(), moco::TFOpcode::Relu6);
+
+ ASSERT_EQ(relu6_node.features(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp
new file mode 100644
index 000000000..514c691e9
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFReshape.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFReshape.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFReshapeTest, constructor)
+{
+ moco::TFReshape reshape_node;
+
+ ASSERT_EQ(reshape_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(reshape_node.opcode(), moco::TFOpcode::Reshape);
+
+ ASSERT_EQ(reshape_node.tensor(), nullptr);
+ ASSERT_EQ(reshape_node.shape(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp
new file mode 100644
index 000000000..e94336dfe
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFRsqrt.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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//TFRsqrt.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFRsqrtTest, constructor)
+{
+ moco::TFRsqrt rsqrt_node;
+
+ ASSERT_EQ(rsqrt_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(rsqrt_node.opcode(), moco::TFOpcode::Rsqrt);
+
+ ASSERT_EQ(rsqrt_node.x(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp
new file mode 100644
index 000000000..28110d790
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFShape.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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//TFShape.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFShapeTest, constructor)
+{
+ moco::TFShape shape_node;
+
+ ASSERT_EQ(shape_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(shape_node.opcode(), moco::TFOpcode::Shape);
+
+ ASSERT_EQ(shape_node.input(), nullptr);
+ ASSERT_EQ(shape_node.dtype(), loco::DataType::Unknown);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp
new file mode 100644
index 000000000..67449feac
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFSoftmax.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFSoftmax.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFSoftmaxTest, constructor)
+{
+ moco::TFSoftmax softmax_node;
+
+ ASSERT_EQ(softmax_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(softmax_node.opcode(), moco::TFOpcode::Softmax);
+
+ ASSERT_EQ(softmax_node.logits(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp
new file mode 100644
index 000000000..942769f6c
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFSqrt.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFSqrt.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFSqrtTest, constructor)
+{
+ moco::TFSqrt sqrt_node;
+
+ ASSERT_EQ(sqrt_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(sqrt_node.opcode(), moco::TFOpcode::Sqrt);
+
+ ASSERT_EQ(sqrt_node.x(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp
new file mode 100644
index 000000000..c3ece9b70
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFSquaredDifference.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFSquaredDifference.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFSquaredDifferenceTest, constructor)
+{
+ moco::TFSquaredDifference sd_node;
+
+ ASSERT_EQ(sd_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(sd_node.opcode(), moco::TFOpcode::SquaredDifference);
+
+ ASSERT_EQ(sd_node.x(), nullptr);
+ ASSERT_EQ(sd_node.y(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp
new file mode 100644
index 000000000..034ca70b2
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFSqueeze.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFSqueeze.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFSqueezeTest, constructor)
+{
+ moco::TFSqueeze squeeze_node;
+
+ ASSERT_EQ(squeeze_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(squeeze_node.opcode(), moco::TFOpcode::Squeeze);
+
+ ASSERT_EQ(squeeze_node.input(), nullptr);
+ ASSERT_EQ(squeeze_node.squeeze_dims().size(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp
new file mode 100644
index 000000000..054ccda41
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFStopGradient.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFStopGradient.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFStopGradientTest, constructor)
+{
+ moco::TFStopGradient node;
+
+ ASSERT_EQ(node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(node.opcode(), moco::TFOpcode::StopGradient);
+
+ ASSERT_EQ(node.input(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp
new file mode 100644
index 000000000..9e7e45543
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFStridedSlice.test.cpp
@@ -0,0 +1,38 @@
+/*
+ * 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/TFStridedSlice.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFStridedSliceTest, constructor)
+{
+ moco::TFStridedSlice node;
+
+ ASSERT_EQ(node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(node.opcode(), moco::TFOpcode::StridedSlice);
+
+ ASSERT_EQ(node.input(), nullptr);
+ ASSERT_EQ(node.begin(), nullptr);
+ ASSERT_EQ(node.end(), nullptr);
+ ASSERT_EQ(node.strides(), nullptr);
+ ASSERT_EQ(node.begin_mask(), 0);
+ ASSERT_EQ(node.end_mask(), 0);
+ ASSERT_EQ(node.ellipsis_mask(), 0);
+ ASSERT_EQ(node.new_axis_mask(), 0);
+ ASSERT_EQ(node.shrink_axis_mask(), 0);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp
new file mode 100644
index 000000000..4b80713bd
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFSub.test.cpp
@@ -0,0 +1,31 @@
+/*
+ * 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/TFSub.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFSubTest, constructor)
+{
+ moco::TFSub sub_node;
+
+ ASSERT_EQ(sub_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(sub_node.opcode(), moco::TFOpcode::Sub);
+
+ ASSERT_EQ(sub_node.x(), nullptr);
+ ASSERT_EQ(sub_node.y(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp b/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp
new file mode 100644
index 000000000..38458a694
--- /dev/null
+++ b/compiler/moco/lang/src/IR/Nodes/TFTanh.test.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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/TFTanh.h"
+#include "moco/IR/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFTanhTest, constructor)
+{
+ moco::TFTanh tanh_node;
+
+ ASSERT_EQ(tanh_node.dialect(), moco::TFDialect::get());
+ ASSERT_EQ(tanh_node.opcode(), moco::TFOpcode::Tanh);
+
+ ASSERT_EQ(tanh_node.x(), nullptr);
+}
diff --git a/compiler/moco/lang/src/IR/TFDialect.cpp b/compiler/moco/lang/src/IR/TFDialect.cpp
new file mode 100644
index 000000000..35bbcc2c9
--- /dev/null
+++ b/compiler/moco/lang/src/IR/TFDialect.cpp
@@ -0,0 +1,91 @@
+/*
+ * 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/TFDialect.h"
+#include "moco/IR/TFNode.h"
+
+#include <loco/IR/Graph.h>
+#include <loco/IR/GraphInputIndex.h>
+#include <loco/IR/GraphOutputIndex.h>
+
+#include <stdex/Memory.h>
+
+#include <cassert>
+#include <stdexcept>
+
+namespace
+{
+
+struct GiiQueryServiceImpl final : public loco::GraphInputIndexQueryService
+{
+ bool associated(const loco::Node *node) const final
+ {
+ if (auto tfplaceholder = dynamic_cast<const moco::TFPlaceholder *>(node))
+ {
+ return moco::indexed(tfplaceholder);
+ }
+ return false;
+ }
+
+ loco::GraphOutputIndex index(const loco::Node *node) const final
+ {
+ assert(associated(node));
+ auto tfplaceholder = dynamic_cast<const moco::TFPlaceholder *>(node);
+ assert(tfplaceholder != nullptr);
+ return moco::index(tfplaceholder);
+ }
+};
+
+struct GoiQueryServiceImpl final : public loco::GraphOutputIndexQueryService
+{
+ bool associated(const loco::Node *node) const final
+ {
+ if (auto tfpush = dynamic_cast<const moco::TFPush *>(node))
+ {
+ return tfpush->indexed();
+ }
+ return false;
+ }
+
+ loco::GraphOutputIndex index(const loco::Node *node) const final
+ {
+ assert(associated(node));
+ if (auto tfpush = dynamic_cast<const moco::TFPush *>(node))
+ {
+ return tfpush->index();
+ }
+ throw std::invalid_argument("node");
+ }
+};
+
+} // namespace
+
+namespace moco
+{
+
+TFDialect::TFDialect()
+{
+ service<loco::GraphInputIndexQueryService>(stdex::make_unique<GiiQueryServiceImpl>());
+ service<loco::GraphOutputIndexQueryService>(stdex::make_unique<GoiQueryServiceImpl>());
+}
+
+loco::Dialect *TFDialect::get(void)
+{
+ static TFDialect d;
+ return &d;
+}
+
+} // namespace moco
diff --git a/compiler/moco/lang/src/IR/TFDialect.test.cpp b/compiler/moco/lang/src/IR/TFDialect.test.cpp
new file mode 100644
index 000000000..3c8b1a16b
--- /dev/null
+++ b/compiler/moco/lang/src/IR/TFDialect.test.cpp
@@ -0,0 +1,29 @@
+/*
+ * 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/TFDialect.h"
+
+#include <gtest/gtest.h>
+
+TEST(TFDialectTest, get)
+{
+ auto d = moco::TFDialect::get();
+
+ // get() SHOULD return a valid(non-null) pointer
+ ASSERT_NE(d, nullptr);
+ // The return value SHOULD be stable across multiple invocations
+ ASSERT_EQ(d, moco::TFDialect::get());
+}
diff --git a/compiler/moco/lang/src/IR/TFNode.cpp b/compiler/moco/lang/src/IR/TFNode.cpp
new file mode 100644
index 000000000..ab9356196
--- /dev/null
+++ b/compiler/moco/lang/src/IR/TFNode.cpp
@@ -0,0 +1,137 @@
+/*
+ * 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/TFNode.h"
+#include "moco/IR/TFDialect.h"
+
+#include <cassert>
+
+namespace moco
+{
+
+const loco::Dialect *TFNode::dialect(void) const { return TFDialect::get(); }
+
+} // namespace moco
+
+// TODO move this to appropriate place
+#include <stdex/Memory.h>
+
+namespace moco
+{
+
+struct GraphInputIndexAnnotation : public loco::NodeAnnotation
+{
+public:
+ GraphInputIndexAnnotation(const loco::GraphInputIndex &index) : _index{index}
+ {
+ // DO NOTHING
+ }
+
+public:
+ const loco::GraphInputIndex &index(void) const { return _index; }
+
+private:
+ loco::GraphInputIndex _index;
+};
+
+bool indexed(const TFPlaceholder *node)
+{
+ return (node->annot<GraphInputIndexAnnotation>() != nullptr);
+}
+
+loco::GraphInputIndex index(const TFPlaceholder *node)
+{
+ assert(indexed(node));
+ return node->annot<GraphInputIndexAnnotation>()->index();
+}
+
+void index(TFPlaceholder *node, const loco::GraphInputIndex index)
+{
+ node->annot(stdex::make_unique<GraphInputIndexAnnotation>(index));
+}
+
+loco::TensorShape tensor_shape(const TFPlaceholder *node)
+{
+ assert(node != nullptr);
+
+ loco::TensorShape shape;
+
+ uint32_t rank = node->rank();
+ shape.rank(rank);
+ for (uint32_t index = 0; index < rank; ++index)
+ {
+ if (node->dim(index).known())
+ shape.dim(index) = node->dim(index).value();
+ else
+ shape.dim(index).unset();
+ }
+
+ return shape;
+}
+
+TFPlaceholder *placeholder_node(loco::Graph *g, const loco::GraphInputIndex &idx)
+{
+ for (uint32_t n = 0; n < g->nodes()->size(); ++n)
+ {
+ if (auto tfplaceholder = dynamic_cast<TFPlaceholder *>(g->nodes()->at(n)))
+ {
+ if (indexed(tfplaceholder) && index(tfplaceholder) == idx)
+ {
+ return tfplaceholder;
+ }
+ }
+ }
+ return nullptr;
+}
+
+} // namespace moco
+
+namespace moco
+{
+
+/**
+ * TFPush
+ */
+
+void TFPush::index(const loco::GraphOutputIndex &index)
+{
+ // Push internally stores "GraphOutputIndex" as int64_t
+ _index = static_cast<int64_t>(index);
+}
+
+loco::GraphOutputIndex TFPush::index(void) const
+{
+ assert(_index >= std::numeric_limits<loco::GraphOutputIndex>::min());
+ assert(_index <= std::numeric_limits<loco::GraphOutputIndex>::max());
+ return static_cast<loco::GraphOutputIndex>(_index);
+}
+
+TFPush *push_node(loco::Graph *g, const loco::GraphOutputIndex &index)
+{
+ for (uint32_t n = 0; n < g->nodes()->size(); ++n)
+ {
+ if (auto tfpush = dynamic_cast<TFPush *>(g->nodes()->at(n)))
+ {
+ if (tfpush->indexed() && tfpush->index() == index)
+ {
+ return tfpush;
+ }
+ }
+ }
+ return nullptr;
+}
+
+} // namespace moco
diff --git a/compiler/moco/lang/src/IR/TFNode.test.cpp b/compiler/moco/lang/src/IR/TFNode.test.cpp
new file mode 100644
index 000000000..4df1211db
--- /dev/null
+++ b/compiler/moco/lang/src/IR/TFNode.test.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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/TFPlaceholder.h"
+
+#include <loco.h>
+
+#include <gtest/gtest.h>
+
+TEST(TFNodeTest_Placeholder, index)
+{
+ loco::Graph graph;
+
+ auto test_node = graph.nodes()->create<moco::TFPlaceholder>();
+
+ loco::GraphInputIndex index_set{100};
+ moco::index(test_node, index_set);
+
+ auto index_get = moco::index(test_node);
+ ASSERT_EQ(index_get, index_set);
+}
+
+TEST(TFNodeTest_Placeholder, name)
+{
+ loco::Graph graph;
+
+ auto test_node = graph.nodes()->create<moco::TFPlaceholder>();
+
+ test_node->name("PlaceholderName");
+ ASSERT_EQ(test_node->name(), "PlaceholderName");
+}
diff --git a/compiler/moco/lang/src/IR/VariadicArityNode.test.cpp b/compiler/moco/lang/src/IR/VariadicArityNode.test.cpp
new file mode 100644
index 000000000..57361af98
--- /dev/null
+++ b/compiler/moco/lang/src/IR/VariadicArityNode.test.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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/VariadicArityNode.h"
+
+#include <loco/IR/Nodes.h>
+
+#include <gtest/gtest.h>
+
+namespace
+{
+
+using namespace moco;
+
+class ArbitraryInputNode : public VariadicArityNode<loco::Node>
+{
+public:
+ ArbitraryInputNode(uint32_t arity) : VariadicArityNode<loco::Node>(arity) {}
+
+ void input(uint32_t idx, loco::Node *node) { at(idx)->node(node); }
+ loco::Node *input(uint32_t idx) const { return at(idx)->node(); }
+
+ const loco::Dialect *dialect(void) const { return nullptr; } // this won't be called for testing
+ uint32_t opnum(void) const { return -1; } // this won't be called for testing
+};
+
+} // namespace
+
+TEST(CustomOpTest, VariadicArityNode_arity_n)
+{
+ loco::ConstGen cg0, cg1, cg2;
+
+ ArbitraryInputNode a_node(3);
+ a_node.input(0, &cg0);
+ a_node.input(1, &cg1);
+ a_node.input(2, &cg2);
+
+ ASSERT_EQ(a_node.arity(), 3);
+ ASSERT_EQ(a_node.input(0), &cg0);
+ ASSERT_EQ(a_node.input(1), &cg1);
+ ASSERT_EQ(a_node.input(2), &cg2);
+}