summaryrefslogtreecommitdiff
path: root/compiler/luci/import
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/luci/import')
-rw-r--r--compiler/luci/import/CMakeLists.txt1
-rw-r--r--compiler/luci/import/include/luci/Import/CircleReader.h13
-rw-r--r--compiler/luci/import/include/luci/Import/GraphBuilder.h18
-rw-r--r--compiler/luci/import/include/luci/Import/GraphBuilderBase.h48
-rw-r--r--compiler/luci/import/include/luci/Import/GraphBuilderContext.h23
-rw-r--r--compiler/luci/import/include/luci/Import/GraphBuilderRegistry.h12
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes.h80
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleAddN.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleArgMin.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleBCQFullyConnected.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleBCQGather.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleBatchMatMul.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleCast.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleCeil.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleCustom.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleDepthToSpace.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleElu.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleExpandDims.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleFill.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleFloor.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleFloorDiv.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleFloorMod.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleGather.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleGatherNd.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleGreater.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleGreaterEqual.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleIf.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleInstanceNorm.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleL2Normalize.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleL2Pool2D.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLeakyRelu.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLess.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLessEqual.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLocalResponseNormalization.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLog.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLogSoftmax.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLogicalAnd.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleLogistic.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleMatrixDiag.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleMatrixSetDiag.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleMaximum.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleMinimum.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleMirrorPad.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleNeg.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleNotEqual.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleOneHot.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CirclePRelu.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CirclePow.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleRange.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleRank.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReduceAny.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReduceMax.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReduceMin.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReduceProd.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleRelu6.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReluN1To1.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleResizeBilinear.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleResizeNearestNeighbor.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReverseSequence.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleReverseV2.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleRound.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleScatterNd.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSegmentSum.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSelect.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSelectV2.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleShape.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSin.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSlice.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToBatchND.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToDepth.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSparseToDense.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSplit.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSplitV.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSqrt.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSquare.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSquaredDifference.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSqueeze.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleStridedSlice.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleSum.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleTanh.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleTile.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleTopKV2.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleTransposeConv.h37
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleUnpack.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleWhere.h36
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleWhile.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleZerosLike.h37
-rw-r--r--compiler/luci/import/include/luci/Importer.h2
-rw-r--r--compiler/luci/import/src/CircleReader.cpp43
-rw-r--r--compiler/luci/import/src/GraphBuilder.cpp37
-rw-r--r--compiler/luci/import/src/GraphBuilderContext.cpp23
-rw-r--r--compiler/luci/import/src/GraphBuilderRegistry.cpp209
-rw-r--r--compiler/luci/import/src/Importer.cpp113
-rw-r--r--compiler/luci/import/src/Nodes/CircleAddN.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleArgMin.cpp48
-rw-r--r--compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp62
-rw-r--r--compiler/luci/import/src/Nodes/CircleBCQGather.cpp52
-rw-r--r--compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp47
-rw-r--r--compiler/luci/import/src/Nodes/CircleCast.cpp99
-rw-r--r--compiler/luci/import/src/Nodes/CircleCeil.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleConst.cpp108
-rw-r--r--compiler/luci/import/src/Nodes/CircleConv2D.cpp3
-rw-r--r--compiler/luci/import/src/Nodes/CircleCustom.cpp88
-rw-r--r--compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp67
-rw-r--r--compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp3
-rw-r--r--compiler/luci/import/src/Nodes/CircleElu.cpp64
-rw-r--r--compiler/luci/import/src/Nodes/CircleExp.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleExpandDims.cpp51
-rw-r--r--compiler/luci/import/src/Nodes/CircleFill.cpp49
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloor.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloorDiv.cpp68
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloorMod.cpp57
-rw-r--r--compiler/luci/import/src/Nodes/CircleFullyConnected.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleGather.cpp68
-rw-r--r--compiler/luci/import/src/Nodes/CircleGatherNd.cpp64
-rw-r--r--compiler/luci/import/src/Nodes/CircleGreater.cpp76
-rw-r--r--compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp62
-rw-r--r--compiler/luci/import/src/Nodes/CircleIf.cpp138
-rw-r--r--compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp52
-rw-r--r--compiler/luci/import/src/Nodes/CircleL2Normalize.cpp56
-rw-r--r--compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp54
-rw-r--r--compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleLess.cpp78
-rw-r--r--compiler/luci/import/src/Nodes/CircleLessEqual.cpp62
-rw-r--r--compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp51
-rw-r--r--compiler/luci/import/src/Nodes/CircleLog.cpp65
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp46
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp55
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogistic.cpp66
-rw-r--r--compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp56
-rw-r--r--compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp57
-rw-r--r--compiler/luci/import/src/Nodes/CircleMaximum.cpp72
-rw-r--r--compiler/luci/import/src/Nodes/CircleMinimum.cpp72
-rw-r--r--compiler/luci/import/src/Nodes/CircleMirrorPad.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleNeg.cpp44
-rw-r--r--compiler/luci/import/src/Nodes/CircleNotEqual.cpp62
-rw-r--r--compiler/luci/import/src/Nodes/CircleOneHot.cpp77
-rw-r--r--compiler/luci/import/src/Nodes/CirclePRelu.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CirclePow.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleRange.cpp46
-rw-r--r--compiler/luci/import/src/Nodes/CircleRank.cpp46
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceAny.cpp69
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceMax.cpp64
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceMin.cpp64
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceProd.cpp64
-rw-r--r--compiler/luci/import/src/Nodes/CircleRelu6.cpp47
-rw-r--r--compiler/luci/import/src/Nodes/CircleReluN1To1.cpp49
-rw-r--r--compiler/luci/import/src/Nodes/CircleReshape.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp51
-rw-r--r--compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp49
-rw-r--r--compiler/luci/import/src/Nodes/CircleReverseSequence.cpp71
-rw-r--r--compiler/luci/import/src/Nodes/CircleReverseV2.cpp67
-rw-r--r--compiler/luci/import/src/Nodes/CircleRound.cpp71
-rw-r--r--compiler/luci/import/src/Nodes/CircleScatterNd.cpp58
-rw-r--r--compiler/luci/import/src/Nodes/CircleSegmentSum.cpp68
-rw-r--r--compiler/luci/import/src/Nodes/CircleSelect.cpp56
-rw-r--r--compiler/luci/import/src/Nodes/CircleSelectV2.cpp60
-rw-r--r--compiler/luci/import/src/Nodes/CircleShape.cpp53
-rw-r--r--compiler/luci/import/src/Nodes/CircleSin.cpp63
-rw-r--r--compiler/luci/import/src/Nodes/CircleSlice.cpp52
-rw-r--r--compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp80
-rw-r--r--compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp52
-rw-r--r--compiler/luci/import/src/Nodes/CircleSparseToDense.cpp50
-rw-r--r--compiler/luci/import/src/Nodes/CircleSplit.cpp119
-rw-r--r--compiler/luci/import/src/Nodes/CircleSplitV.cpp121
-rw-r--r--compiler/luci/import/src/Nodes/CircleSqrt.cpp44
-rw-r--r--compiler/luci/import/src/Nodes/CircleSquare.cpp63
-rw-r--r--compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp77
-rw-r--r--compiler/luci/import/src/Nodes/CircleSqueeze.cpp51
-rw-r--r--compiler/luci/import/src/Nodes/CircleStridedSlice.cpp60
-rw-r--r--compiler/luci/import/src/Nodes/CircleSum.cpp46
-rw-r--r--compiler/luci/import/src/Nodes/CircleTanh.cpp60
-rw-r--r--compiler/luci/import/src/Nodes/CircleTile.cpp68
-rw-r--r--compiler/luci/import/src/Nodes/CircleTopKV2.cpp117
-rw-r--r--compiler/luci/import/src/Nodes/CircleTransposeConv.cpp54
-rw-r--r--compiler/luci/import/src/Nodes/CircleUnpack.cpp151
-rw-r--r--compiler/luci/import/src/Nodes/CircleWhere.cpp60
-rw-r--r--compiler/luci/import/src/Nodes/CircleWhile.cpp123
-rw-r--r--compiler/luci/import/src/Nodes/CircleZerosLike.cpp49
-rw-r--r--compiler/luci/import/src/PostImport.cpp354
-rw-r--r--compiler/luci/import/src/PostImport.h34
181 files changed, 9026 insertions, 219 deletions
diff --git a/compiler/luci/import/CMakeLists.txt b/compiler/luci/import/CMakeLists.txt
index bc9a9152a..2ae00b837 100644
--- a/compiler/luci/import/CMakeLists.txt
+++ b/compiler/luci/import/CMakeLists.txt
@@ -7,6 +7,7 @@ target_include_directories(luci_import PRIVATE src)
target_include_directories(luci_import PUBLIC include)
target_link_libraries(luci_import PUBLIC luci_lang)
target_link_libraries(luci_import PUBLIC mio_circle)
+target_link_libraries(luci_import PRIVATE luci_env)
target_link_libraries(luci_import PRIVATE luci_log)
target_link_libraries(luci_import PRIVATE luci_logex)
target_link_libraries(luci_import PRIVATE nncc_common)
diff --git a/compiler/luci/import/include/luci/Import/CircleReader.h b/compiler/luci/import/include/luci/Import/CircleReader.h
index fcbe09ceb..3d85b9e35 100644
--- a/compiler/luci/import/include/luci/Import/CircleReader.h
+++ b/compiler/luci/import/include/luci/Import/CircleReader.h
@@ -21,6 +21,7 @@
#include <luci/IR/AttrFusedActFunc.h>
#include <luci/IR/AttrPadding.h>
+#include <luci/IR/CircleNode.h>
#include <luci/IR/CircleQuantParam.h>
#include <loco.h>
@@ -42,9 +43,13 @@ const circle::QuantizationParametersT *tensor_quantization(const circle::TensorT
loco::DataType luci_datatype(circle::TensorType type);
FusedActFunc luci_actfunc(const circle::ActivationFunctionType type);
Padding luci_padding(const circle::Padding padding);
+MirrorPadMode luci_mirrorpad_mode(const circle::MirrorPadMode mode);
std::unique_ptr<CircleQuantParam>
luci_quantparam(const circle::QuantizationParametersT *quantization);
+/// @brief Copy common tensor attributes such as name, type, etc. to node.
+void copy_tensor_attributes(const circle::TensorT &tensor, CircleNode *node);
+
/**
* @brief Loads Circle file and provides helpers to access attributes
*/
@@ -56,6 +61,9 @@ private:
using CircleOperators_t = std::vector<std::unique_ptr<circle::OperatorT>>;
using CircleOperatorCodes_t = std::vector<std::unique_ptr<circle::OperatorCodeT>>;
+ using CircleSubGraphsPtr_t = flatbuffers::Vector<flatbuffers::Offset<circle::SubGraph>>;
+ using CircleTensorsPtr_t = flatbuffers::Vector<flatbuffers::Offset<circle::Tensor>>;
+
public:
CircleReader() = default;
@@ -68,6 +76,8 @@ public:
const std::vector<int32_t> &outputs() const { return _current_subgraph->outputs; }
const std::string &name() const { return _current_subgraph->name; }
+ const CircleTensorsPtr_t *tensors_ptr() const { return _tensors_ptr; }
+
uint32_t num_subgraph() const { return _model->subgraphs.size(); }
circle::BuiltinOperator builtin_code(const circle::OperatorT &op) const;
@@ -80,6 +90,9 @@ public:
private:
std::unique_ptr<const circle::ModelT> _model;
const circle::SubGraphT *_current_subgraph{nullptr};
+
+ const circle::Model *_model_ptr{nullptr};
+ const CircleTensorsPtr_t *_tensors_ptr{nullptr};
};
} // namespace luci
diff --git a/compiler/luci/import/include/luci/Import/GraphBuilder.h b/compiler/luci/import/include/luci/Import/GraphBuilder.h
index 61f673fb6..548264dac 100644
--- a/compiler/luci/import/include/luci/Import/GraphBuilder.h
+++ b/compiler/luci/import/include/luci/Import/GraphBuilder.h
@@ -18,6 +18,7 @@
#define __LUCI_IMPORT_GRAPH_BUILDER_H__
#include "GraphBuilderContext.h"
+#include "GraphBuilderBase.h"
#include <mio/circle/schema_generated.h>
@@ -25,25 +26,14 @@ namespace luci
{
/**
- * @brief Interface of convert circle:: NodeDef to loco::Node (e.g., Conv2DGraphBuilder)
+ * @brief Base of general single output graph builder(e.g., Conv2DGraphBuilder)
*/
-class GraphBuilder
+class GraphBuilder : public GraphBuilderBase
{
public:
- struct ValidateArgs
- {
- ValidateArgs(const circle::OperatorT &o, const CircleReader &r) : op(o), reader(r) {}
-
- const circle::OperatorT &op;
- const CircleReader &reader;
- };
-
-public:
virtual ~GraphBuilder() = default;
- virtual bool validate(const ValidateArgs &) const = 0;
-
- void build(const circle::OperatorT &op, GraphBuilderContext *context) const;
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
private:
virtual CircleNode *build_node(const circle::OperatorT &op,
diff --git a/compiler/luci/import/include/luci/Import/GraphBuilderBase.h b/compiler/luci/import/include/luci/Import/GraphBuilderBase.h
new file mode 100644
index 000000000..a0cd008e0
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/GraphBuilderBase.h
@@ -0,0 +1,48 @@
+/*
+ * 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 __LUCI_IMPORT_GRAPH_BUILDER_BASE_H__
+#define __LUCI_IMPORT_GRAPH_BUILDER_BASE_H__
+
+#include "GraphBuilderContext.h"
+
+#include <mio/circle/schema_generated.h>
+
+namespace luci
+{
+
+/**
+ * @brief Interface of convert circle::OperatorT to CircleNode
+ */
+struct GraphBuilderBase
+{
+ struct ValidateArgs
+ {
+ ValidateArgs(const circle::OperatorT &o, const CircleReader &r) : op(o), reader(r) {}
+
+ const circle::OperatorT &op;
+ const CircleReader &reader;
+ };
+
+ virtual bool validate(const ValidateArgs &) const = 0;
+ virtual void build(const circle::OperatorT &op, GraphBuilderContext *context) const = 0;
+
+ virtual ~GraphBuilderBase() = default;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_GRAPH_BUILDER_BASE_H__
diff --git a/compiler/luci/import/include/luci/Import/GraphBuilderContext.h b/compiler/luci/import/include/luci/Import/GraphBuilderContext.h
index 8d464181d..72e237abc 100644
--- a/compiler/luci/import/include/luci/Import/GraphBuilderContext.h
+++ b/compiler/luci/import/include/luci/Import/GraphBuilderContext.h
@@ -24,6 +24,7 @@
#include <loco.h>
#include <map>
+#include <set>
namespace luci
{
@@ -48,13 +49,29 @@ private:
};
/**
+ * @brief Set of Tensor Index of outputs of operators
+ * including graph input nodes
+ */
+class IndexTensorOutputs
+{
+public:
+ void enroll(TensorIndex idx);
+
+ bool find(TensorIndex idx);
+
+private:
+ std::set<TensorIndex> _set;
+};
+
+/**
* @brief Class to store context to build loco graph IR from TensorFlow
*/
class GraphBuilderContext
{
public:
- GraphBuilderContext(loco::Graph *g, CircleReader *reader, IndexNodeFinder *nodefinder)
- : _g(g), _reader(reader), _indexnodefinder(nodefinder)
+ GraphBuilderContext(loco::Graph *g, CircleReader *reader, IndexNodeFinder *nodefinder,
+ IndexTensorOutputs *tensoroutputs)
+ : _g(g), _reader(reader), _indexnodefinder(nodefinder), _indextensoroutputs(tensoroutputs)
{
// DO NOTHING
}
@@ -67,11 +84,13 @@ public:
CircleReader *reader() { return _reader; }
IndexNodeFinder *nodefinder() { return _indexnodefinder; }
+ IndexTensorOutputs *tensoroutputs() { return _indextensoroutputs; }
private:
loco::Graph *_g;
CircleReader *_reader;
IndexNodeFinder *_indexnodefinder;
+ IndexTensorOutputs *_indextensoroutputs;
};
} // namespace luci
diff --git a/compiler/luci/import/include/luci/Import/GraphBuilderRegistry.h b/compiler/luci/import/include/luci/Import/GraphBuilderRegistry.h
index 99054e7b6..b8dc22fdd 100644
--- a/compiler/luci/import/include/luci/Import/GraphBuilderRegistry.h
+++ b/compiler/luci/import/include/luci/Import/GraphBuilderRegistry.h
@@ -17,7 +17,7 @@
#ifndef __LUCI_IMPORT_GRAPH_BUILDER_REGISTRY_H__
#define __LUCI_IMPORT_GRAPH_BUILDER_REGISTRY_H__
-#include "GraphBuilder.h"
+#include "GraphBuilderBase.h"
#include <map>
@@ -31,11 +31,11 @@ struct GraphBuilderSource
/**
* @brief Returns registered GraphBuilder pointer for operator (nullptr if not present)
*/
- virtual const GraphBuilder *lookup(const circle::BuiltinOperator &op) const = 0;
+ virtual const GraphBuilderBase *lookup(const circle::BuiltinOperator &op) const = 0;
};
/**
- * @brief Class to return graph builder for TF nodes
+ * @brief Class to return graph builder for Circle nodes
*/
class GraphBuilderRegistry final : public GraphBuilderSource
{
@@ -53,7 +53,7 @@ public:
* @brief Returns registered GraphBuilder pointer for operator or
* nullptr if not registered
*/
- const GraphBuilder *lookup(const circle::BuiltinOperator &op) const final
+ const GraphBuilderBase *lookup(const circle::BuiltinOperator &op) const final
{
if (_builder_map.find(op) == _builder_map.end())
return (_parent == nullptr) ? nullptr : _parent->lookup(op);
@@ -68,7 +68,7 @@ public:
}
public:
- void add(const circle::BuiltinOperator op, std::unique_ptr<GraphBuilder> &&builder)
+ void add(const circle::BuiltinOperator op, std::unique_ptr<GraphBuilderBase> &&builder)
{
_builder_map[op] = std::move(builder);
}
@@ -77,7 +77,7 @@ private:
const GraphBuilderSource *_parent = nullptr;
private:
- std::map<const circle::BuiltinOperator, std::unique_ptr<GraphBuilder>> _builder_map;
+ std::map<const circle::BuiltinOperator, std::unique_ptr<GraphBuilderBase>> _builder_map;
};
} // namespace luci
diff --git a/compiler/luci/import/include/luci/Import/Nodes.h b/compiler/luci/import/include/luci/Import/Nodes.h
index 381d02b97..2719a5aec 100644
--- a/compiler/luci/import/include/luci/Import/Nodes.h
+++ b/compiler/luci/import/include/luci/Import/Nodes.h
@@ -19,30 +19,110 @@
#include "Nodes/CircleAbs.h"
#include "Nodes/CircleAdd.h"
+#include "Nodes/CircleAddN.h"
#include "Nodes/CircleArgMax.h"
+#include "Nodes/CircleArgMin.h"
#include "Nodes/CircleAveragePool2D.h"
+#include "Nodes/CircleBatchMatMul.h"
#include "Nodes/CircleBatchToSpaceND.h"
+#include "Nodes/CircleBCQFullyConnected.h"
+#include "Nodes/CircleBCQGather.h"
+#include "Nodes/CircleCast.h"
+#include "Nodes/CircleCeil.h"
#include "Nodes/CircleConcatenation.h"
#include "Nodes/CircleConst.h"
#include "Nodes/CircleConv2D.h"
#include "Nodes/CircleCos.h"
+#include "Nodes/CircleCustom.h"
+#include "Nodes/CircleDepthToSpace.h"
#include "Nodes/CircleDepthwiseConv2D.h"
#include "Nodes/CircleDiv.h"
+#include "Nodes/CircleElu.h"
#include "Nodes/CircleEqual.h"
#include "Nodes/CircleExp.h"
+#include "Nodes/CircleExpandDims.h"
+#include "Nodes/CircleFill.h"
+#include "Nodes/CircleFloor.h"
+#include "Nodes/CircleFloorDiv.h"
+#include "Nodes/CircleFloorMod.h"
#include "Nodes/CircleFullyConnected.h"
+#include "Nodes/CircleGather.h"
+#include "Nodes/CircleGatherNd.h"
+#include "Nodes/CircleGreater.h"
+#include "Nodes/CircleGreaterEqual.h"
+#include "Nodes/CircleIf.h"
+#include "Nodes/CircleInstanceNorm.h"
+#include "Nodes/CircleL2Normalize.h"
+#include "Nodes/CircleL2Pool2D.h"
+#include "Nodes/CircleLeakyRelu.h"
+#include "Nodes/CircleLess.h"
+#include "Nodes/CircleLessEqual.h"
+#include "Nodes/CircleLocalResponseNormalization.h"
+#include "Nodes/CircleLog.h"
+#include "Nodes/CircleLogicalAnd.h"
#include "Nodes/CircleLogicalNot.h"
#include "Nodes/CircleLogicalOr.h"
+#include "Nodes/CircleLogistic.h"
+#include "Nodes/CircleLogSoftmax.h"
+#include "Nodes/CircleMatrixSetDiag.h"
+#include "Nodes/CircleMaximum.h"
#include "Nodes/CircleMaxPool2D.h"
+#include "Nodes/CircleMatrixDiag.h"
#include "Nodes/CircleMean.h"
+#include "Nodes/CircleMinimum.h"
+#include "Nodes/CircleMirrorPad.h"
#include "Nodes/CircleMul.h"
+#include "Nodes/CircleNeg.h"
+#include "Nodes/CircleNotEqual.h"
+#include "Nodes/CircleOneHot.h"
#include "Nodes/CirclePack.h"
#include "Nodes/CirclePad.h"
+#include "Nodes/CirclePow.h"
+#include "Nodes/CirclePRelu.h"
+#include "Nodes/CircleRange.h"
+#include "Nodes/CircleRank.h"
+#include "Nodes/CircleReduceAny.h"
+#include "Nodes/CircleReduceMax.h"
+#include "Nodes/CircleReduceMin.h"
+#include "Nodes/CircleReduceProd.h"
#include "Nodes/CircleRelu.h"
+#include "Nodes/CircleRelu6.h"
+#include "Nodes/CircleReluN1To1.h"
#include "Nodes/CircleReshape.h"
+#include "Nodes/CircleResizeBilinear.h"
+#include "Nodes/CircleResizeNearestNeighbor.h"
+#include "Nodes/CircleReverseSequence.h"
+#include "Nodes/CircleReverseV2.h"
+#include "Nodes/CircleRound.h"
#include "Nodes/CircleRsqrt.h"
+#include "Nodes/CircleScatterNd.h"
+#include "Nodes/CircleSegmentSum.h"
+#include "Nodes/CircleSelect.h"
+#include "Nodes/CircleSelectV2.h"
+#include "Nodes/CircleShape.h"
+#include "Nodes/CircleSin.h"
+#include "Nodes/CircleSlice.h"
#include "Nodes/CircleSoftmax.h"
+#include "Nodes/CircleSpaceToBatchND.h"
+#include "Nodes/CircleSpaceToDepth.h"
+#include "Nodes/CircleSparseToDense.h"
+#include "Nodes/CircleSplit.h"
+#include "Nodes/CircleSplitV.h"
+#include "Nodes/CircleSqrt.h"
+#include "Nodes/CircleSquare.h"
+#include "Nodes/CircleSquaredDifference.h"
+#include "Nodes/CircleSqueeze.h"
+#include "Nodes/CircleStridedSlice.h"
#include "Nodes/CircleSub.h"
+#include "Nodes/CircleSum.h"
+#include "Nodes/CircleTanh.h"
+#include "Nodes/CircleTile.h"
+#include "Nodes/CircleTopKV2.h"
#include "Nodes/CircleTranspose.h"
+#include "Nodes/CircleTransposeConv.h"
+#include "Nodes/CircleUnpack.h"
+#include "Nodes/CircleWhere.h"
+#include "Nodes/CircleWhile.h"
+#include "Nodes/CircleZerosLike.h"
#endif // __LUCI_IMPORT_NODES_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleAddN.h b/compiler/luci/import/include/luci/Import/Nodes/CircleAddN.h
new file mode 100644
index 000000000..3ec6b2a45
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleAddN.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ADD_N_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ADD_N_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleAddNGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ADD_N_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleArgMin.h b/compiler/luci/import/include/luci/Import/Nodes/CircleArgMin.h
new file mode 100644
index 000000000..746f52837
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleArgMin.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ARGMIN_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ARGMIN_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleArgMinGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ARGMIN_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleBCQFullyConnected.h b/compiler/luci/import/include/luci/Import/Nodes/CircleBCQFullyConnected.h
new file mode 100644
index 000000000..be58acd8d
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleBCQFullyConnected.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_BCQFULLYCONNECTED_H__
+#define __LUCI_IMPORT_OP_CIRCLE_BCQFULLYCONNECTED_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleBCQFullyConnectedGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_BCQFULLYCONNECTED_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleBCQGather.h b/compiler/luci/import/include/luci/Import/Nodes/CircleBCQGather.h
new file mode 100644
index 000000000..ff1c1f7e9
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleBCQGather.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_BCQGATHER_H__
+#define __LUCI_IMPORT_OP_CIRCLE_BCQGATHER_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleBCQGatherGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_BCQGATHER_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleBatchMatMul.h b/compiler/luci/import/include/luci/Import/Nodes/CircleBatchMatMul.h
new file mode 100644
index 000000000..b46a8715c
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleBatchMatMul.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_BATCHMATMUL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_BATCHMATMUL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleBatchMatMulGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_BATCHMATMUL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleCast.h b/compiler/luci/import/include/luci/Import/Nodes/CircleCast.h
new file mode 100644
index 000000000..1cd850bc7
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleCast.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_CAST_H__
+#define __LUCI_IMPORT_OP_CIRCLE_CAST_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleCastGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_CAST_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleCeil.h b/compiler/luci/import/include/luci/Import/Nodes/CircleCeil.h
new file mode 100644
index 000000000..f1bdf2397
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleCeil.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_CEIL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_CEIL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleCeilGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_CEIL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleCustom.h b/compiler/luci/import/include/luci/Import/Nodes/CircleCustom.h
new file mode 100644
index 000000000..65745be4b
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleCustom.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_CUSTOM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_CUSTOM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleCustomGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_CUSTOM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleDepthToSpace.h b/compiler/luci/import/include/luci/Import/Nodes/CircleDepthToSpace.h
new file mode 100644
index 000000000..a479cbd20
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleDepthToSpace.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_DEPTHTOSPACE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_DEPTHTOSPACE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleDepthToSpaceGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_DEPTHTOSPACE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleElu.h b/compiler/luci/import/include/luci/Import/Nodes/CircleElu.h
new file mode 100644
index 000000000..2ec5642ce
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleElu.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ELU_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ELU_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleEluGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ELU_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleExpandDims.h b/compiler/luci/import/include/luci/Import/Nodes/CircleExpandDims.h
new file mode 100644
index 000000000..acbfe7aea
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleExpandDims.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_EXPAND_DIMS_H__
+#define __LUCI_IMPORT_OP_CIRCLE_EXPAND_DIMS_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleExpandDimsGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_EXPAND_DIMS_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleFill.h b/compiler/luci/import/include/luci/Import/Nodes/CircleFill.h
new file mode 100644
index 000000000..3539dcd56
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleFill.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_FILL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_FILL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleFillGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_FILL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleFloor.h b/compiler/luci/import/include/luci/Import/Nodes/CircleFloor.h
new file mode 100644
index 000000000..057800865
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleFloor.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_FLOOR_H__
+#define __LUCI_IMPORT_OP_CIRCLE_FLOOR_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleFloorGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_FLOOR_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleFloorDiv.h b/compiler/luci/import/include/luci/Import/Nodes/CircleFloorDiv.h
new file mode 100644
index 000000000..ddc2ab2ff
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleFloorDiv.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_FLOOR_DIV_H__
+#define __LUCI_IMPORT_OP_CIRCLE_FLOOR_DIV_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleFloorDivGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_FLOOR_DIV_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleFloorMod.h b/compiler/luci/import/include/luci/Import/Nodes/CircleFloorMod.h
new file mode 100644
index 000000000..1d6aa87c2
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleFloorMod.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_FLOOR_MOD_H__
+#define __LUCI_IMPORT_OP_CIRCLE_FLOOR_MOD_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleFloorModGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_FLOOR_MOD_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleGather.h b/compiler/luci/import/include/luci/Import/Nodes/CircleGather.h
new file mode 100644
index 000000000..0680c9451
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleGather.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_GATHER_H__
+#define __LUCI_IMPORT_OP_CIRCLE_GATHER_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleGatherGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_GATHER_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleGatherNd.h b/compiler/luci/import/include/luci/Import/Nodes/CircleGatherNd.h
new file mode 100644
index 000000000..be96b7dbe
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleGatherNd.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_GATHER_ND_H__
+#define __LUCI_IMPORT_OP_CIRCLE_GATHER_ND_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleGatherNdGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_GATHER_ND_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleGreater.h b/compiler/luci/import/include/luci/Import/Nodes/CircleGreater.h
new file mode 100644
index 000000000..87f0a8d83
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleGreater.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_GREATER_H__
+#define __LUCI_IMPORT_OP_CIRCLE_GREATER_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleGreaterGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_GREATER_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleGreaterEqual.h b/compiler/luci/import/include/luci/Import/Nodes/CircleGreaterEqual.h
new file mode 100644
index 000000000..4d24314e9
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleGreaterEqual.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_GREATEREQUAL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_GREATEREQUAL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleGreaterEqualGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_GREATEREQUAL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleIf.h b/compiler/luci/import/include/luci/Import/Nodes/CircleIf.h
new file mode 100644
index 000000000..8faf09cae
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleIf.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_IF_H__
+#define __LUCI_IMPORT_OP_CIRCLE_IF_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleIfGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_IF_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleInstanceNorm.h b/compiler/luci/import/include/luci/Import/Nodes/CircleInstanceNorm.h
new file mode 100644
index 000000000..5fd8f148a
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleInstanceNorm.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_INSTANCE_NORM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_INSTANCE_NORM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleInstanceNormGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_INSTANCE_NORM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleL2Normalize.h b/compiler/luci/import/include/luci/Import/Nodes/CircleL2Normalize.h
new file mode 100644
index 000000000..116605f09
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleL2Normalize.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_L2_NORMALIZE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_L2_NORMALIZE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleL2NormalizeGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_L2_NORMALIZE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleL2Pool2D.h b/compiler/luci/import/include/luci/Import/Nodes/CircleL2Pool2D.h
new file mode 100644
index 000000000..2211c4751
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleL2Pool2D.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_L2_POOL2D_H__
+#define __LUCI_IMPORT_OP_CIRCLE_L2_POOL2D_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleL2Pool2DGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_L2_POOL2D_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLeakyRelu.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLeakyRelu.h
new file mode 100644
index 000000000..b7fa41f25
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLeakyRelu.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LEAKY_RELU_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LEAKY_RELU_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLeakyReluGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LEAKY_RELU_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLess.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLess.h
new file mode 100644
index 000000000..b93155bc4
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLess.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LESS_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LESS_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLessGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LESS_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLessEqual.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLessEqual.h
new file mode 100644
index 000000000..e54a4cb8c
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLessEqual.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LESS_EQUAL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LESS_EQUAL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLessEqualGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LESS_EQUAL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLocalResponseNormalization.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLocalResponseNormalization.h
new file mode 100644
index 000000000..95e6ea880
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLocalResponseNormalization.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LOCAL_RESPONSE_NORMALIZATION_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LOCAL_RESPONSE_NORMALIZATION_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLocalResponseNormalizationGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LOCAL_RESPONSE_NORMALIZATION_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLog.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLog.h
new file mode 100644
index 000000000..5b3321014
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLog.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LOG_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LOG_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLogGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LOG_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLogSoftmax.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLogSoftmax.h
new file mode 100644
index 000000000..ef29833f5
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLogSoftmax.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LOG_SOFTMAX_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LOG_SOFTMAX_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLogSoftmaxGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LOG_SOFTMAX_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLogicalAnd.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLogicalAnd.h
new file mode 100644
index 000000000..9336f4ac8
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLogicalAnd.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LOGICALAND_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LOGICALAND_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLogicalAndGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LOGICALAND_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleLogistic.h b/compiler/luci/import/include/luci/Import/Nodes/CircleLogistic.h
new file mode 100644
index 000000000..67c6c1f1f
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleLogistic.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_LOGISTIC_H__
+#define __LUCI_IMPORT_OP_CIRCLE_LOGISTIC_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleLogisticGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_LOGISTIC_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixDiag.h b/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixDiag.h
new file mode 100644
index 000000000..e038c3e0a
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixDiag.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_MATRIX_DIAG_H__
+#define __LUCI_IMPORT_OP_CIRCLE_MATRIX_DIAG_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleMatrixDiagGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_MATRIX_DIAG_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixSetDiag.h b/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixSetDiag.h
new file mode 100644
index 000000000..a9ea0ac3d
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleMatrixSetDiag.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_MATRIX_SET_DIAG_H__
+#define __LUCI_IMPORT_OP_CIRCLE_MATRIX_SET_DIAG_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleMatrixSetDiagGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_MATRIX_SET_DIAG_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleMaximum.h b/compiler/luci/import/include/luci/Import/Nodes/CircleMaximum.h
new file mode 100644
index 000000000..9705d3a36
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleMaximum.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_MAXIMUM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_MAXIMUM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleMaximumGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_MAXIMUM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleMinimum.h b/compiler/luci/import/include/luci/Import/Nodes/CircleMinimum.h
new file mode 100644
index 000000000..d9546ecf8
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleMinimum.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_MINIMUM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_MINIMUM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleMinimumGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_MINIMUM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleMirrorPad.h b/compiler/luci/import/include/luci/Import/Nodes/CircleMirrorPad.h
new file mode 100644
index 000000000..7f512cda7
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleMirrorPad.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_MIRROR_PAD_H__
+#define __LUCI_IMPORT_OP_CIRCLE_MIRROR_PAD_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleMirrorPadGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_MIRROR_PAD_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleNeg.h b/compiler/luci/import/include/luci/Import/Nodes/CircleNeg.h
new file mode 100644
index 000000000..3d0bac19f
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleNeg.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_NEG_H__
+#define __LUCI_IMPORT_OP_CIRCLE_NEG_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleNegGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_NEG_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleNotEqual.h b/compiler/luci/import/include/luci/Import/Nodes/CircleNotEqual.h
new file mode 100644
index 000000000..10c79b75e
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleNotEqual.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_NOTEQUAL_H__
+#define __LUCI_IMPORT_OP_CIRCLE_NOTEQUAL_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleNotEqualGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_NOTEQUAL_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleOneHot.h b/compiler/luci/import/include/luci/Import/Nodes/CircleOneHot.h
new file mode 100644
index 000000000..8d9526d0e
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleOneHot.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ONEHOT_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ONEHOT_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleOneHotGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ONEHOT_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CirclePRelu.h b/compiler/luci/import/include/luci/Import/Nodes/CirclePRelu.h
new file mode 100644
index 000000000..822862cfd
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CirclePRelu.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_PRELU_H__
+#define __LUCI_IMPORT_OP_CIRCLE_PRELU_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CirclePReluGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_PRELU_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CirclePow.h b/compiler/luci/import/include/luci/Import/Nodes/CirclePow.h
new file mode 100644
index 000000000..284aa9b89
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CirclePow.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_POW_H__
+#define __LUCI_IMPORT_OP_CIRCLE_POW_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CirclePowGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_POW_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleRange.h b/compiler/luci/import/include/luci/Import/Nodes/CircleRange.h
new file mode 100644
index 000000000..bc63286b2
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleRange.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RANGE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RANGE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleRangeGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RANGE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleRank.h b/compiler/luci/import/include/luci/Import/Nodes/CircleRank.h
new file mode 100644
index 000000000..43a7fdb7b
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleRank.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RANK_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RANK_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleRankGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RANK_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReduceAny.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceAny.h
new file mode 100644
index 000000000..5ee517999
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceAny.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REDUCE_ANY_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REDUCE_ANY_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReduceAnyGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REDUCE_ANY_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMax.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMax.h
new file mode 100644
index 000000000..0bc7021c1
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMax.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REDUCE_MAX_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REDUCE_MAX_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReduceMaxGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REDUCE_MAX_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMin.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMin.h
new file mode 100644
index 000000000..0c05457f0
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceMin.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REDUCE_MIN_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REDUCE_MIN_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReduceMinGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REDUCE_MIN_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReduceProd.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceProd.h
new file mode 100644
index 000000000..446bc7866
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReduceProd.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REDUCE_PROD_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REDUCE_PROD_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReduceProdGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REDUCE_PROD_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleRelu6.h b/compiler/luci/import/include/luci/Import/Nodes/CircleRelu6.h
new file mode 100644
index 000000000..d17b4e200
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleRelu6.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RELU6_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RELU6_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleRelu6GraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RELU6_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReluN1To1.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReluN1To1.h
new file mode 100644
index 000000000..059431565
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReluN1To1.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RELU_N1_TO_1_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RELU_N1_TO_1_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReluN1To1GraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RELU_N1_TO_1_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleResizeBilinear.h b/compiler/luci/import/include/luci/Import/Nodes/CircleResizeBilinear.h
new file mode 100644
index 000000000..8c20ecc24
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleResizeBilinear.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RESIZE_BILINEAR_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RESIZE_BILINEAR_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleResizeBilinearGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RESIZE_BILINEAR_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleResizeNearestNeighbor.h b/compiler/luci/import/include/luci/Import/Nodes/CircleResizeNearestNeighbor.h
new file mode 100644
index 000000000..5b0647163
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleResizeNearestNeighbor.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_RESIZE_NEAREST_NEIGHBOR_H__
+#define __LUCI_IMPORT_OP_CIRCLE_RESIZE_NEAREST_NEIGHBOR_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleResizeNearestNeighborGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_RESIZE_NEAREST_NEIGHBOR_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReverseSequence.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReverseSequence.h
new file mode 100644
index 000000000..cbeed3013
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReverseSequence.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REVERSE_SEQUENCE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REVERSE_SEQUENCE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReverseSequenceGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REVERSE_SEQUENCE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleReverseV2.h b/compiler/luci/import/include/luci/Import/Nodes/CircleReverseV2.h
new file mode 100644
index 000000000..f354298dd
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleReverseV2.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_REVERSE_V2_H__
+#define __LUCI_IMPORT_OP_CIRCLE_REVERSE_V2_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleReverseV2GraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_REVERSE_V2_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleRound.h b/compiler/luci/import/include/luci/Import/Nodes/CircleRound.h
new file mode 100644
index 000000000..8b027d7ef
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleRound.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ROUND_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ROUND_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleRoundGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ROUND_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleScatterNd.h b/compiler/luci/import/include/luci/Import/Nodes/CircleScatterNd.h
new file mode 100644
index 000000000..8fa7a2f91
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleScatterNd.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SCATTER_ND_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SCATTER_ND_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleScatterNdGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SCATTER_ND_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSegmentSum.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSegmentSum.h
new file mode 100644
index 000000000..7c33dee41
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSegmentSum.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SEGMENT_SUM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SEGMENT_SUM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSegmentSumGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SEGMENT_SUM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSelect.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSelect.h
new file mode 100644
index 000000000..87bd1a7fe
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSelect.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SELECT_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SELECT_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSelectGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SELECT_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSelectV2.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSelectV2.h
new file mode 100644
index 000000000..28c73b087
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSelectV2.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SELECT_V2_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SELECT_V2_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSelectV2GraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SELECT_V2_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleShape.h b/compiler/luci/import/include/luci/Import/Nodes/CircleShape.h
new file mode 100644
index 000000000..3002084a5
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleShape.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SHAPE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SHAPE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleShapeGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SHAPE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSin.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSin.h
new file mode 100644
index 000000000..605f5a5a0
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSin.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SIN_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SIN_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSinGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SIN_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSlice.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSlice.h
new file mode 100644
index 000000000..3bb4c51b7
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSlice.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SLICE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SLICE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSliceGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SLICE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToBatchND.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToBatchND.h
new file mode 100644
index 000000000..b8723098d
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToBatchND.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SPACETOBATCHND_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SPACETOBATCHND_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSpaceToBatchNDGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SPACETOBATCHND_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToDepth.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToDepth.h
new file mode 100644
index 000000000..75a54dd26
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSpaceToDepth.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SPACETODEPTH_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SPACETODEPTH_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSpaceToDepthGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SPACETODEPTH_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSparseToDense.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSparseToDense.h
new file mode 100644
index 000000000..baf240919
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSparseToDense.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SPARSETODENSE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SPARSETODENSE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSparseToDenseGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SPARSETODENSE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSplit.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSplit.h
new file mode 100644
index 000000000..3395e40fd
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSplit.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SPLIT_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SPLIT_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleSplitGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SPLIT_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSplitV.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSplitV.h
new file mode 100644
index 000000000..3e53df362
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSplitV.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SPLIT_V_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SPLIT_V_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleSplitVGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SPLIT_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSqrt.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSqrt.h
new file mode 100644
index 000000000..4fd79951c
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSqrt.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SQRT_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SQRT_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSqrtGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SQRT_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSquare.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSquare.h
new file mode 100644
index 000000000..3a1299102
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSquare.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SQUARE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SQUARE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSquareGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SQUARE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSquaredDifference.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSquaredDifference.h
new file mode 100644
index 000000000..95f08412b
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSquaredDifference.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SQUAREDDIFFERENCE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SQUAREDDIFFERENCE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSquaredDifferenceGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SQUAREDDIFFERENCE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSqueeze.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSqueeze.h
new file mode 100644
index 000000000..4f0dfb5ef
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSqueeze.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SQUEEZE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SQUEEZE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSqueezeGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SQUEEZE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleStridedSlice.h b/compiler/luci/import/include/luci/Import/Nodes/CircleStridedSlice.h
new file mode 100644
index 000000000..f535c3a61
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleStridedSlice.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_STRIDED_SLICE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_STRIDED_SLICE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleStridedSliceGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_STRIDED_SLICE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleSum.h b/compiler/luci/import/include/luci/Import/Nodes/CircleSum.h
new file mode 100644
index 000000000..e65dd46ad
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleSum.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_SUM_H__
+#define __LUCI_IMPORT_OP_CIRCLE_SUM_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleSumGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_SUM_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleTanh.h b/compiler/luci/import/include/luci/Import/Nodes/CircleTanh.h
new file mode 100644
index 000000000..b3795acba
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleTanh.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_TANH_H__
+#define __LUCI_IMPORT_OP_CIRCLE_TANH_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleTanhGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_TANH_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleTile.h b/compiler/luci/import/include/luci/Import/Nodes/CircleTile.h
new file mode 100644
index 000000000..1da6cdbde
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleTile.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_TILE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_TILE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleTileGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_TILE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleTopKV2.h b/compiler/luci/import/include/luci/Import/Nodes/CircleTopKV2.h
new file mode 100644
index 000000000..8ec3f3311
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleTopKV2.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_TOPK_V2_H__
+#define __LUCI_IMPORT_OP_CIRCLE_TOPK_V2_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleTopKV2GraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_TOPK_V2_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleTransposeConv.h b/compiler/luci/import/include/luci/Import/Nodes/CircleTransposeConv.h
new file mode 100644
index 000000000..2614d0d0d
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleTransposeConv.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_TRANSPOSE_CONV_H__
+#define __LUCI_IMPORT_OP_CIRCLE_TRANSPOSE_CONV_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleTransposeConvGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_TRANSPOSE_CONV_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleUnpack.h b/compiler/luci/import/include/luci/Import/Nodes/CircleUnpack.h
new file mode 100644
index 000000000..f1a21de22
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleUnpack.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_UNPACK_H__
+#define __LUCI_IMPORT_OP_CIRCLE_UNPACK_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleUnpackGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_UNPACK_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleWhere.h b/compiler/luci/import/include/luci/Import/Nodes/CircleWhere.h
new file mode 100644
index 000000000..72f98ef92
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleWhere.h
@@ -0,0 +1,36 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_WHERE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_WHERE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleWhereGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const override;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_WHERE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleWhile.h b/compiler/luci/import/include/luci/Import/Nodes/CircleWhile.h
new file mode 100644
index 000000000..68c56b3c6
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleWhile.h
@@ -0,0 +1,35 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_WHILE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_WHILE_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleWhileGraphBuilder : public GraphBuilderBase
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+ void build(const circle::OperatorT &op, GraphBuilderContext *context) const final;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_WHILE_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleZerosLike.h b/compiler/luci/import/include/luci/Import/Nodes/CircleZerosLike.h
new file mode 100644
index 000000000..2a3410379
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleZerosLike.h
@@ -0,0 +1,37 @@
+/*
+ * 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 __LUCI_IMPORT_OP_CIRCLE_ZEROS_LIKE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_ZEROS_LIKE_H__
+
+#include "luci/Import/GraphBuilder.h"
+
+namespace luci
+{
+
+class CircleZerosLikeGraphBuilder : public GraphBuilder
+{
+public:
+ bool validate(const ValidateArgs &args) const final;
+
+private:
+ CircleNode *build_node(const circle::OperatorT &op, const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const override;
+};
+
+} // namespace luci
+
+#endif // __LUCI_IMPORT_OP_CIRCLE_ZEROS_LIKE_H__
diff --git a/compiler/luci/import/include/luci/Importer.h b/compiler/luci/import/include/luci/Importer.h
index 246df9f27..f08ddcda7 100644
--- a/compiler/luci/import/include/luci/Importer.h
+++ b/compiler/luci/import/include/luci/Importer.h
@@ -51,4 +51,4 @@ private:
} // namespace luci
-#endif // __MOCO_IMPORTER_H__
+#endif // __LUCI_IMPORTER_H__
diff --git a/compiler/luci/import/src/CircleReader.cpp b/compiler/luci/import/src/CircleReader.cpp
index ead0093b8..81e945dd1 100644
--- a/compiler/luci/import/src/CircleReader.cpp
+++ b/compiler/luci/import/src/CircleReader.cpp
@@ -136,6 +136,19 @@ Padding luci_padding(const circle::Padding padding)
return Padding::UNDEFINED;
}
+MirrorPadMode luci_mirrorpad_mode(const circle::MirrorPadMode mode)
+{
+ switch (mode)
+ {
+ case circle::MirrorPadMode::MirrorPadMode_REFLECT:
+ return MirrorPadMode::REFLECT;
+ case circle::MirrorPadMode::MirrorPadMode_SYMMETRIC:
+ return MirrorPadMode::SYMMETRIC;
+ }
+ assert(false);
+ return MirrorPadMode::UNDEFINED;
+}
+
std::unique_ptr<CircleQuantParam>
luci_quantparam(const circle::QuantizationParametersT *quantization)
{
@@ -159,6 +172,27 @@ luci_quantparam(const circle::QuantizationParametersT *quantization)
return nullptr;
}
+void copy_tensor_attributes(const circle::TensorT &tensor, CircleNode *node)
+{
+ node->name(tensor_name(tensor));
+ node->dtype(luci_datatype(tensor.type));
+
+ std::vector<int32_t> dims = tensor.shape; // in NHWC
+ node->rank(dims.size());
+ for (uint32_t r = 0; r < dims.size(); ++r)
+ {
+ node->dim(r) = loco::Dimension(dims[r]);
+ }
+
+ const auto *quantization = tensor.quantization.get();
+ if (quantization != nullptr)
+ {
+ auto quantparam = luci_quantparam(quantization);
+ if (quantparam)
+ node->quantparam(std::move(quantparam));
+ }
+}
+
circle::BuiltinOperator CircleReader::builtin_code(const circle::OperatorT &op) const
{
const auto &op_codes = opcodes();
@@ -192,6 +226,9 @@ bool CircleReader::parse(const circle::Model *model)
_model.reset(model->UnPack());
+ // for direct pointer access
+ _model_ptr = model;
+
return true;
}
@@ -205,6 +242,12 @@ bool CircleReader::select_subgraph(uint32_t sgindex)
_current_subgraph = _model->subgraphs[sgindex].get();
+ // for direct pointer access
+ auto subgraphs = _model_ptr->subgraphs();
+ const circle::SubGraph *subgraph = (*subgraphs)[sgindex];
+
+ _tensors_ptr = subgraph->tensors();
+
return true;
}
diff --git a/compiler/luci/import/src/GraphBuilder.cpp b/compiler/luci/import/src/GraphBuilder.cpp
index e0ec9ded5..80a9f986a 100644
--- a/compiler/luci/import/src/GraphBuilder.cpp
+++ b/compiler/luci/import/src/GraphBuilder.cpp
@@ -16,21 +16,39 @@
#include "luci/Import/GraphBuilder.h"
+#include <luci/Log.h>
+
namespace luci
{
void GraphBuilder::build(const circle::OperatorT &op, GraphBuilderContext *context) const
{
+ LOGGER(l);
+
assert(context != nullptr);
const std::vector<int32_t> &inputs = op.inputs;
const std::vector<int32_t> &outputs = op.outputs;
const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
std::vector<CircleNode *> input_nodes;
for (const int32_t input_tensor_index : inputs)
{
- input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ if (input_tensor_index >= 0)
+ {
+ auto input = context->nodefinder()->node(input_tensor_index);
+ if (input == nullptr)
+ INFO(l) << "[luci] Warning: input node is null " << input_tensor_index << std::endl;
+ input_nodes.push_back(input);
+ }
+ else
+ {
+ // If there is no tensor, insert CircleOutputExclude.
+ input_nodes.push_back(context->graph()->nodes()->create<luci::CircleOutputExclude>());
+ }
}
CircleNode *node = build_node(op, input_nodes, context->graph());
@@ -39,16 +57,15 @@ void GraphBuilder::build(const circle::OperatorT &op, GraphBuilderContext *conte
assert(outputs.size() == 1);
{
const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ copy_tensor_attributes(output_tensor, node);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[0])->shape() == nullptr)
+ node->shape_status(ShapeStatus::NOSHAPE);
+ else
+ node->shape_status(ShapeStatus::VALID);
- node->name(tensor_name(output_tensor));
-
- auto quantization = tensor_quantization(output_tensor);
- if (quantization)
- {
- auto quantparam = luci_quantparam(quantization);
- if (quantparam)
- node->quantparam(std::move(quantparam));
- }
+ // mark operator version
+ node->op_version(opcodes[op.opcode_index].get()->version);
}
// Register node's only output.
diff --git a/compiler/luci/import/src/GraphBuilderContext.cpp b/compiler/luci/import/src/GraphBuilderContext.cpp
index a5162ce83..21adfa7e2 100644
--- a/compiler/luci/import/src/GraphBuilderContext.cpp
+++ b/compiler/luci/import/src/GraphBuilderContext.cpp
@@ -25,10 +25,12 @@ namespace luci
void IndexNodeFinder::enroll(TensorIndex idx, CircleNode *node)
{
- if (_table.find(idx) != _table.end())
+ auto iter = _table.find(idx);
+ if (iter != _table.end())
{
LOGGER(l);
- INFO(l) << "[luci] NodeFinder SKIP (" << idx << ") " << node << std::endl;
+ INFO(l) << "[luci] NodeFinder SKIP (" << idx << ") " << node << ":" << node->name()
+ << " existing: " << iter->second << ":" << iter->second->name() << std::endl;
return;
}
@@ -39,9 +41,22 @@ CircleNode *IndexNodeFinder::node(TensorIndex idx) const
{
MapIndexNode_t::const_iterator iter = _table.find(idx);
- assert(iter != _table.end() && iter->second != nullptr);
+ // dangle output node may exist that are not enrolled
+ return (iter != _table.end()) ? iter->second : nullptr;
+}
- return iter->second;
+void IndexTensorOutputs::enroll(TensorIndex idx)
+{
+ auto iter = _set.find(idx);
+ if (iter != _set.end())
+ {
+ LOGGER(l);
+ INFO(l) << "[luci] TensorOutputs SKIP (" << idx << ") existing" << std::endl;
+ return;
+ }
+ _set.insert(idx);
}
+bool IndexTensorOutputs::find(TensorIndex idx) { return (_set.find(idx) != _set.end()); }
+
} // namespace luci
diff --git a/compiler/luci/import/src/GraphBuilderRegistry.cpp b/compiler/luci/import/src/GraphBuilderRegistry.cpp
index 929b71a7d..d29557f74 100644
--- a/compiler/luci/import/src/GraphBuilderRegistry.cpp
+++ b/compiler/luci/import/src/GraphBuilderRegistry.cpp
@@ -27,137 +27,140 @@ GraphBuilderRegistry::GraphBuilderRegistry()
{
#define CIRCLE_NODE(OPCODE, CLASS) add(circle::BuiltinOperator_##OPCODE, std::make_unique<CLASS>());
- CIRCLE_NODE(ABS, CircleAbsGraphBuilder); // 101
- CIRCLE_NODE(ADD, CircleAddGraphBuilder); // 0
- CIRCLE_NODE(ARG_MAX, CircleArgMaxGraphBuilder); // 56
- CIRCLE_NODE(AVERAGE_POOL_2D, CircleAveragePool2DGraphBuilder); // 1
- CIRCLE_NODE(BATCH_TO_SPACE_ND, CircleBatchToSpaceNDGraphBuilder); // 37
- CIRCLE_NODE(CONCATENATION, CircleConcatenationGraphBuilder); // 2
- CIRCLE_NODE(CONV_2D, CircleConv2DGraphBuilder); // 3
- CIRCLE_NODE(COS, CircleCosGraphBuilder); // 108
- CIRCLE_NODE(DEPTHWISE_CONV_2D, CircleDepthwiseConv2DGraphBuilder); // 4
- CIRCLE_NODE(DIV, CircleDivGraphBuilder); // 42
- CIRCLE_NODE(EQUAL, CircleEqualGraphBuilder); // 71
- CIRCLE_NODE(EXP, CircleExpGraphBuilder); // 47
- CIRCLE_NODE(FULLY_CONNECTED, CircleFullyConnectedGraphBuilder); // 9
- CIRCLE_NODE(LOGICAL_NOT, CircleLogicalNotGraphBuilder); // 87
- CIRCLE_NODE(LOGICAL_OR, CircleLogicalOrGraphBuilder); // 84
- CIRCLE_NODE(MAX_POOL_2D, CircleMaxPool2DGraphBuilder); // 17
- CIRCLE_NODE(MEAN, CircleMeanGraphBuilder); // 40
- CIRCLE_NODE(MUL, CircleMulGraphBuilder); // 18
- CIRCLE_NODE(PACK, CirclePackGraphBuilder); // 83
- CIRCLE_NODE(PAD, CirclePadGraphBuilder); // 34
- CIRCLE_NODE(RELU, CircleReluGraphBuilder); // 19
- CIRCLE_NODE(RESHAPE, CircleReshapeGraphBuilder); // 22
- CIRCLE_NODE(RSQRT, CircleRsqrtGraphBuilder); // 76
- CIRCLE_NODE(SOFTMAX, CircleSoftmaxGraphBuilder); // 25
- CIRCLE_NODE(SUB, CircleSubGraphBuilder); // 41
- CIRCLE_NODE(TRANSPOSE, CircleTransposeGraphBuilder); // 39
+ CIRCLE_NODE(ABS, CircleAbsGraphBuilder); // 101
+ CIRCLE_NODE(ADD, CircleAddGraphBuilder); // 0
+ CIRCLE_NODE(ADD_N, CircleAddNGraphBuilder); // 106
+ CIRCLE_NODE(ARG_MAX, CircleArgMaxGraphBuilder); // 56
+ CIRCLE_NODE(ARG_MIN, CircleArgMinGraphBuilder); // 79
+ CIRCLE_NODE(AVERAGE_POOL_2D, CircleAveragePool2DGraphBuilder); // 1
+ CIRCLE_NODE(BATCH_MATMUL, CircleBatchMatMulGraphBuilder); // 126
+ CIRCLE_NODE(BATCH_TO_SPACE_ND, CircleBatchToSpaceNDGraphBuilder); // 37
+ CIRCLE_NODE(BCQ_FULLY_CONNECTED, CircleBCQFullyConnectedGraphBuilder); // 253
+ CIRCLE_NODE(BCQ_GATHER, CircleBCQGatherGraphBuilder); // 252
+ CIRCLE_NODE(CAST, CircleCastGraphBuilder); // 53
+ CIRCLE_NODE(CEIL, CircleCeilGraphBuilder); // 104
+ CIRCLE_NODE(CUSTOM, CircleCustomGraphBuilder); // 32
+ CIRCLE_NODE(CONCATENATION, CircleConcatenationGraphBuilder); // 2
+ CIRCLE_NODE(CONV_2D, CircleConv2DGraphBuilder); // 3
+ CIRCLE_NODE(COS, CircleCosGraphBuilder); // 108
+ CIRCLE_NODE(DEPTH_TO_SPACE, CircleDepthToSpaceGraphBuilder); // 5
+ CIRCLE_NODE(DEPTHWISE_CONV_2D, CircleDepthwiseConv2DGraphBuilder); // 4
+ CIRCLE_NODE(DIV, CircleDivGraphBuilder); // 42
+ CIRCLE_NODE(ELU, CircleEluGraphBuilder); // 111
+ CIRCLE_NODE(EQUAL, CircleEqualGraphBuilder); // 71
+ CIRCLE_NODE(EXP, CircleExpGraphBuilder); // 47
+ CIRCLE_NODE(EXPAND_DIMS, CircleExpandDimsGraphBuilder); // 70
+ CIRCLE_NODE(FILL, CircleFillGraphBuilder); // 94
+ CIRCLE_NODE(FLOOR, CircleFloorGraphBuilder); // 8
+ CIRCLE_NODE(FLOOR_DIV, CircleFloorDivGraphBuilder); // 90
+ CIRCLE_NODE(FLOOR_MOD, CircleFloorModGraphBuilder); // 95
+ CIRCLE_NODE(FULLY_CONNECTED, CircleFullyConnectedGraphBuilder); // 9
+ CIRCLE_NODE(GATHER, CircleGatherGraphBuilder); // 36
+ CIRCLE_NODE(GATHER_ND, CircleGatherNdGraphBuilder); // 107
+ CIRCLE_NODE(GREATER, CircleGreaterGraphBuilder); // 61
+ CIRCLE_NODE(GREATER_EQUAL, CircleGreaterEqualGraphBuilder); // 62
+ CIRCLE_NODE(IF, CircleIfGraphBuilder); // 118
+ CIRCLE_NODE(INSTANCE_NORM, CircleInstanceNormGraphBuilder); // 254
+ CIRCLE_NODE(L2_NORMALIZATION, CircleL2NormalizeGraphBuilder); // 11
+ CIRCLE_NODE(L2_POOL_2D, CircleL2Pool2DGraphBuilder); // 12
+ CIRCLE_NODE(LEAKY_RELU, CircleLeakyReluGraphBuilder); // 98,
+ CIRCLE_NODE(LESS, CircleLessGraphBuilder); // 58
+ CIRCLE_NODE(LESS_EQUAL, CircleLessEqualGraphBuilder); // 63
+ CIRCLE_NODE(LOCAL_RESPONSE_NORMALIZATION, CircleLocalResponseNormalizationGraphBuilder); // 13
+ CIRCLE_NODE(LOG, CircleLogGraphBuilder); // 73
+ CIRCLE_NODE(LOGICAL_AND, CircleLogicalAndGraphBuilder); // 86
+ CIRCLE_NODE(LOGICAL_NOT, CircleLogicalNotGraphBuilder); // 87
+ CIRCLE_NODE(LOGICAL_OR, CircleLogicalOrGraphBuilder); // 84
+ CIRCLE_NODE(LOGISTIC, CircleLogisticGraphBuilder); // 14
+ CIRCLE_NODE(LOG_SOFTMAX, CircleLogSoftmaxGraphBuilder); // 50
+ CIRCLE_NODE(MATRIX_DIAG, CircleMatrixDiagGraphBuilder); // 113
+ CIRCLE_NODE(MATRIX_SET_DIAG, CircleMatrixSetDiagGraphBuilder); // 115
+ CIRCLE_NODE(MAXIMUM, CircleMaximumGraphBuilder); // 55
+ CIRCLE_NODE(MAX_POOL_2D, CircleMaxPool2DGraphBuilder); // 17
+ CIRCLE_NODE(MEAN, CircleMeanGraphBuilder); // 40
+ CIRCLE_NODE(MINIMUM, CircleMinimumGraphBuilder); // 57
+ CIRCLE_NODE(MIRROR_PAD, CircleMirrorPadGraphBuilder); // 100
+ CIRCLE_NODE(MUL, CircleMulGraphBuilder); // 18
+ CIRCLE_NODE(NEG, CircleNegGraphBuilder); // 59
+ CIRCLE_NODE(NOT_EQUAL, CircleNotEqualGraphBuilder); // 72
+ CIRCLE_NODE(ONE_HOT, CircleOneHotGraphBuilder); // 85
+ CIRCLE_NODE(PACK, CirclePackGraphBuilder); // 83
+ CIRCLE_NODE(PAD, CirclePadGraphBuilder); // 34
+ CIRCLE_NODE(POW, CirclePowGraphBuilder); // 78
+ CIRCLE_NODE(PRELU, CirclePReluGraphBuilder); // 54,
+ CIRCLE_NODE(RANGE, CircleRangeGraphBuilder); // 96
+ CIRCLE_NODE(RANK, CircleRankGraphBuilder); // 110
+ CIRCLE_NODE(REDUCE_ANY, CircleReduceAnyGraphBuilder); // 91
+ CIRCLE_NODE(REDUCE_MAX, CircleReduceMaxGraphBuilder); // 82
+ CIRCLE_NODE(REDUCE_MIN, CircleReduceMinGraphBuilder); // 89
+ CIRCLE_NODE(REDUCE_PROD, CircleReduceProdGraphBuilder); // 81
+ CIRCLE_NODE(RELU, CircleReluGraphBuilder); // 19
+ CIRCLE_NODE(RELU6, CircleRelu6GraphBuilder); // 21
+ CIRCLE_NODE(RELU_N1_TO_1, CircleReluN1To1GraphBuilder); // 20
+ CIRCLE_NODE(RESHAPE, CircleReshapeGraphBuilder); // 22
+ CIRCLE_NODE(RESIZE_BILINEAR, CircleResizeBilinearGraphBuilder); // 23
+ CIRCLE_NODE(RESIZE_NEAREST_NEIGHBOR, CircleResizeNearestNeighborGraphBuilder); // 97
+ CIRCLE_NODE(REVERSE_SEQUENCE, CircleReverseSequenceGraphBuilder); // 112
+ CIRCLE_NODE(REVERSE_V2, CircleReverseV2GraphBuilder); // 105
+ CIRCLE_NODE(ROUND, CircleRoundGraphBuilder); // 116
+ CIRCLE_NODE(RSQRT, CircleRsqrtGraphBuilder); // 76
+ CIRCLE_NODE(SCATTER_ND, CircleScatterNdGraphBuilder); // 122
+ CIRCLE_NODE(SEGMENT_SUM, CircleSegmentSumGraphBuilder); // 125
+ CIRCLE_NODE(SELECT, CircleSelectGraphBuilder); // 64
+ CIRCLE_NODE(SELECT_V2, CircleSelectV2GraphBuilder); // 123
+ CIRCLE_NODE(SHAPE, CircleShapeGraphBuilder); // 77
+ CIRCLE_NODE(SIN, CircleSinGraphBuilder); // 66
+ CIRCLE_NODE(SLICE, CircleSliceGraphBuilder); // 65
+ CIRCLE_NODE(SOFTMAX, CircleSoftmaxGraphBuilder); // 25
+ CIRCLE_NODE(SPACE_TO_BATCH_ND, CircleSpaceToBatchNDGraphBuilder); // 38
+ CIRCLE_NODE(SPACE_TO_DEPTH, CircleSpaceToDepthGraphBuilder); // 26
+ CIRCLE_NODE(SPARSE_TO_DENSE, CircleSparseToDenseGraphBuilder); // 68
+ CIRCLE_NODE(SPLIT, CircleSplitGraphBuilder); // 49
+ CIRCLE_NODE(SPLIT_V, CircleSplitVGraphBuilder); // 102
+ CIRCLE_NODE(SQRT, CircleSqrtGraphBuilder); // 75
+ CIRCLE_NODE(SQUARE, CircleSquareGraphBuilder); // 92
+ CIRCLE_NODE(SQUARED_DIFFERENCE, CircleSquaredDifferenceGraphBuilder); // 99
+ CIRCLE_NODE(SQUEEZE, CircleSqueezeGraphBuilder); // 43
+ CIRCLE_NODE(STRIDED_SLICE, CircleStridedSliceGraphBuilder); // 45
+ CIRCLE_NODE(SUB, CircleSubGraphBuilder); // 41
+ CIRCLE_NODE(SUM, CircleSumGraphBuilder); // 74
+ CIRCLE_NODE(TANH, CircleTanhGraphBuilder); // 28
+ CIRCLE_NODE(TILE, CircleTileGraphBuilder); // 69
+ CIRCLE_NODE(TOPK_V2, CircleTopKV2GraphBuilder); // 48
+ CIRCLE_NODE(TRANSPOSE, CircleTransposeGraphBuilder); // 39
+ CIRCLE_NODE(TRANSPOSE_CONV, CircleTransposeConvGraphBuilder); // 67
+ CIRCLE_NODE(UNPACK, CircleUnpackGraphBuilder); // 88
+ CIRCLE_NODE(WHERE, CircleWhereGraphBuilder); // 109
+ CIRCLE_NODE(WHILE, CircleWhileGraphBuilder); // 119
+ CIRCLE_NODE(ZEROS_LIKE, CircleZerosLikeGraphBuilder); // 93
#undef CIRCLE_NODE
// BuiltinOperator_DEQUANTIZE = 6,
// BuiltinOperator_EMBEDDING_LOOKUP = 7,
- // BuiltinOperator_FLOOR = 8,
// BuiltinOperator_HASHTABLE_LOOKUP = 10,
- // BuiltinOperator_L2_NORMALIZATION = 11,
- // BuiltinOperator_L2_POOL_2D = 12,
- // BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION = 13,
- // BuiltinOperator_LOGISTIC = 14,
// BuiltinOperator_LSH_PROJECTION = 15,
// BuiltinOperator_LSTM = 16,
- // BuiltinOperator_RELU_N1_TO_1 = 20,
- // BuiltinOperator_RELU6 = 21,
- // BuiltinOperator_RESIZE_BILINEAR = 23,
// BuiltinOperator_RNN = 24,
- // BuiltinOperator_SPACE_TO_DEPTH = 26,
// BuiltinOperator_SVDF = 27,
- // BuiltinOperator_TANH = 28,
// BuiltinOperator_CONCAT_EMBEDDINGS = 29,
// BuiltinOperator_SKIP_GRAM = 30,
// BuiltinOperator_CALL = 31,
- // BuiltinOperator_CUSTOM = 32,
// BuiltinOperator_EMBEDDING_LOOKUP_SPARSE = 33,
// BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_RNN = 35,
- // BuiltinOperator_GATHER = 36,
- // BuiltinOperator_SPACE_TO_BATCH_ND = 38,
- // BuiltinOperator_SQUEEZE = 43,
// BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM = 44,
- // BuiltinOperator_STRIDED_SLICE = 45,
// BuiltinOperator_BIDIRECTIONAL_SEQUENCE_RNN = 46,
- // BuiltinOperator_TOPK_V2 = 48,
- // BuiltinOperator_SPLIT = 49,
- // BuiltinOperator_LOG_SOFTMAX = 50,
// BuiltinOperator_DELEGATE = 51,
// BuiltinOperator_BIDIRECTIONAL_SEQUENCE_LSTM = 52,
- // BuiltinOperator_CAST = 53,
- // BuiltinOperator_PRELU = 54,
- // BuiltinOperator_MAXIMUM = 55,
// BuiltinOperator_ARG_MAX = 56,
- // BuiltinOperator_MINIMUM = 57,
- // BuiltinOperator_LESS = 58,
- // BuiltinOperator_NEG = 59,
// BuiltinOperator_PADV2 = 60,
- // BuiltinOperator_GREATER = 61,
- // BuiltinOperator_GREATER_EQUAL = 62,
- // BuiltinOperator_LESS_EQUAL = 63,
- // BuiltinOperator_SELECT = 64,
- // BuiltinOperator_SLICE = 65,
- // BuiltinOperator_SIN = 66,
- // BuiltinOperator_TRANSPOSE_CONV = 67,
- // BuiltinOperator_SPARSE_TO_DENSE = 68,
- // BuiltinOperator_TILE = 69,
- // BuiltinOperator_EXPAND_DIMS = 70,
- // BuiltinOperator_NOT_EQUAL = 72,
- // BuiltinOperator_LOG = 73,
- // BuiltinOperator_SUM = 74,
- // BuiltinOperator_SQRT = 75,
- // BuiltinOperator_SHAPE = 77,
- // BuiltinOperator_POW = 78,
- // BuiltinOperator_ARG_MIN = 79,
// BuiltinOperator_FAKE_QUANT = 80,
- // BuiltinOperator_REDUCE_PROD = 81,
- // BuiltinOperator_REDUCE_MAX = 82,
- // BuiltinOperator_ONE_HOT = 85,
- // BuiltinOperator_LOGICAL_AND = 86,
- // BuiltinOperator_UNPACK = 88,
- // BuiltinOperator_REDUCE_MIN = 89,
- // BuiltinOperator_FLOOR_DIV = 90,
- // BuiltinOperator_REDUCE_ANY = 91,
- // BuiltinOperator_SQUARE = 92,
- // BuiltinOperator_ZEROS_LIKE = 93,
- // BuiltinOperator_FILL = 94,
- // BuiltinOperator_FLOOR_MOD = 95,
- // BuiltinOperator_RANGE = 96,
- // BuiltinOperator_RESIZE_NEAREST_NEIGHBOR = 97,
- // BuiltinOperator_LEAKY_RELU = 98,
- // BuiltinOperator_SQUARED_DIFFERENCE = 99,
- // BuiltinOperator_MIRROR_PAD = 100,
- // BuiltinOperator_SPLIT_V = 102,
// BuiltinOperator_UNIQUE = 103,
- // BuiltinOperator_CEIL = 104,
- // BuiltinOperator_REVERSE_V2 = 105,
- // BuiltinOperator_ADD_N = 106,
- // BuiltinOperator_GATHER_ND = 107,
- // BuiltinOperator_WHERE = 109,
- // BuiltinOperator_RANK = 110,
- // BuiltinOperator_ELU = 111,
- // BuiltinOperator_REVERSE_SEQUENCE = 112,
- // BuiltinOperator_MATRIX_DIAG = 113,
// BuiltinOperator_QUANTIZE = 114,
- // BuiltinOperator_MATRIX_SET_DIAG = 115,
- // BuiltinOperator_ROUND = 116,
// BuiltinOperator_HARD_SWISH = 117,
- // BuiltinOperator_IF = 118,
- // BuiltinOperator_WHILE = 119,
// BuiltinOperator_NON_MAX_SUPPRESSION_V4 = 120,
// BuiltinOperator_NON_MAX_SUPPRESSION_V5 = 121,
- // BuiltinOperator_SCATTER_ND = 122,
- // BuiltinOperator_SELECT_V2 = 123,
// BuiltinOperator_DENSIFY = 124,
- // BuiltinOperator_SEGMENT_SUM = 125,
- // BuiltinOperator_BATCH_MATMUL = 126,
- // BuiltinOperator_INSTANCE_NORM = 254,
}
} // namespace luci
diff --git a/compiler/luci/import/src/Importer.cpp b/compiler/luci/import/src/Importer.cpp
index 964c47633..ab89f3587 100644
--- a/compiler/luci/import/src/Importer.cpp
+++ b/compiler/luci/import/src/Importer.cpp
@@ -15,6 +15,7 @@
*/
#include "luci/Importer.h"
+#include "PostImport.h"
#include "luci/Import/GraphBuilder.h"
#include "luci/Import/GraphBuilderContext.h"
@@ -27,6 +28,7 @@
#include <luci/Log.h>
#include <luci/LogHelper.h>
+#include <oops/InternalExn.h>
#include <oops/UserExn.h>
#include <memory>
@@ -40,11 +42,28 @@ void convert_graph(const luci::GraphBuilderSource &source, luci::CircleReader &r
LOGGER(l);
auto nodefinder = std::make_unique<luci::IndexNodeFinder>();
+ auto tensoroutputs = std::make_unique<luci::IndexTensorOutputs>();
- luci::GraphBuilderContext gb_context(graph, &reader, nodefinder.get());
+ luci::GraphBuilderContext gb_context(graph, &reader, nodefinder.get(), tensoroutputs.get());
const auto &operators = reader.operators();
const auto &tensors = reader.tensors();
+ auto tensors_ptr = reader.tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ // build a cache to identify if a tensor is output of an operator
+ // if this is set, we should not create a CircleConst for this tensor
+ for (uint32_t i = 0; i < operators.size(); ++i)
+ {
+ const circle::OperatorT &op = *operators[i];
+ const auto &outputs = op.outputs;
+
+ for (uint32_t j = 0; j < outputs.size(); ++j)
+ {
+ auto tidx = outputs[j];
+ tensoroutputs->enroll(tidx);
+ }
+ }
// graph inputs; there are no input nodes in TFlite but just Tensors
// creating virtual input nodes will make possible to connect nodes that uses them
@@ -55,51 +74,43 @@ void convert_graph(const luci::GraphBuilderSource &source, luci::CircleReader &r
assert(input_node != nullptr);
const circle::TensorT &tensor = *tensors[input];
- auto tname = luci::tensor_name(tensor);
- input_node->name(tname);
- auto quantization = luci::tensor_quantization(tensor);
- if (quantization)
- {
- auto quantparam = luci::luci_quantparam(quantization);
- if (quantparam.get())
- input_node->quantparam(std::move(quantparam));
- }
+ luci::copy_tensor_attributes(tensor, input_node);
+ if (tensors_ptr->Get(input)->shape() == nullptr)
+ input_node->shape_status(luci::ShapeStatus::NOSHAPE);
+ else
+ input_node->shape_status(luci::ShapeStatus::VALID);
INFO(l) << "[luci] NodeFinder INPUT(" << input << ") = " << input_node << std::endl;
nodefinder->enroll(input, input_node);
- // Shape of Input
- const std::vector<int32_t> &input_dims = tensor.shape; // in NHWC
- input_node->rank(input_dims.size());
- for (uint32_t r = 0; r < input_dims.size(); ++r)
- input_node->dim(r) = loco::Dimension(input_dims[r]);
-
- // Data type of Input
- auto dtype = luci::luci_datatype(tensor.type);
- input_node->dtype(dtype);
+ // input_node is also an output to a tensor
+ tensoroutputs->enroll(input);
// Name
auto graph_input = graph->inputs()->create();
- graph_input->name(tname);
+ graph_input->name(input_node->name());
// Set GraphInputOutputIndex for graph
input_node->index(graph_input->index());
// Data type
- graph_input->dtype(dtype);
+ graph_input->dtype(input_node->dtype());
+
+ // Shape of GraphInput
+ auto input_shape = std::make_unique<loco::TensorShape>();
+ const std::vector<int32_t> &input_dims = tensor.shape; // in NHWC
+ input_shape->rank(input_dims.size());
+ for (uint32_t r = 0; r < input_dims.size(); ++r)
+ input_shape->dim(r) = loco::Dimension(input_dims[r]);
+ graph_input->shape(std::move(input_shape));
}
// Create CircleConst nodes for constant tensors.
- const auto &buffers = reader.buffers();
for (uint32_t i = 0; i < tensors.size(); ++i)
{
- const circle::TensorT &tensor = *tensors[i];
- const std::vector<uint8_t> &buffer = buffers[tensor.buffer]->data;
- if (!buffer.empty())
- {
- luci::CircleConst *const_node = luci::create_circleconst(&gb_context, i);
+ luci::CircleConst *const_node = luci::create_circleconst(&gb_context, i);
+ if (const_node != nullptr)
nodefinder->enroll(i, const_node);
- }
}
// Import the operators.
@@ -130,18 +141,38 @@ void convert_graph(const luci::GraphBuilderSource &source, luci::CircleReader &r
// graph outputs
for (auto output : reader.outputs())
{
+ const circle::TensorT &tensor = *tensors[output];
+
auto output_node = graph->nodes()->create<luci::CircleOutput>();
assert(output_node != nullptr);
- output_node->from(nodefinder->node(output));
+ auto output_from = nodefinder->node(output);
+ if (output_from != nullptr)
+ output_node->from(output_from);
+ else
+ {
+ // NOTE loco::Graph requires all input node(s) to a node should exist.
+ // Here, CircleOutput needs an input node.
+ // We add a dummy node to make it happy.
+ auto output_dummy = graph->nodes()->create<luci::CircleOutputDummy>();
+ assert(output_dummy != nullptr);
+ output_node->from(output_dummy);
+
+ luci::copy_tensor_attributes(tensor, output_dummy);
+ if (tensors_ptr->Get(output)->shape() == nullptr)
+ output_dummy->shape_status(luci::ShapeStatus::NOSHAPE);
+ else
+ output_dummy->shape_status(luci::ShapeStatus::VALID);
+ }
INFO(l) << "[luci] NodeFinder OUTPUT(" << output << ") = " << output_node << std::endl;
// set the graph output name and node object
- const circle::TensorT &tensor = *tensors[output];
auto graph_output = graph->outputs()->create();
std::string tname = luci::tensor_name(tensor);
graph_output->name("output_" + tname);
+ luci::copy_tensor_attributes(tensor, output_node);
+
// Set GraphInputOutputIndex for graph
output_node->index(graph_output->index());
@@ -195,8 +226,10 @@ std::unique_ptr<loco::Graph> Importer::import(const circle::Model *model) const
if (!reader.parse(model))
return nullptr;
- // TODO support multiple subgraph when Circle supports
- assert(reader.num_subgraph() == 1);
+ if (reader.num_subgraph() != 1)
+ {
+ INTERNAL_EXN("Use 'importModule()' for multiple subgraphs");
+ }
if (!reader.select_subgraph(0))
return nullptr;
@@ -204,11 +237,14 @@ std::unique_ptr<loco::Graph> Importer::import(const circle::Model *model) const
convert_graph(*source_ptr, reader, graph.get());
LOGGER(l);
- INFO(l) << fmt(graph.get());
+ VERBOSE(l, 3) << "--- graph dump begin -------------------------------------------";
+ VERBOSE(l, 3) << "Name: " << graph->name();
+ VERBOSE(l, 3) << fmt(graph.get());
+ VERBOSE(l, 3) << "--- graph dump end ---------------------------------------------";
assert(loco::valid(graph.get(), std::make_unique<ValidateCollector>()));
- return std::move(graph);
+ return graph;
}
std::unique_ptr<Module> Importer::importModule(const circle::Model *model) const
@@ -240,14 +276,19 @@ std::unique_ptr<Module> Importer::importModule(const circle::Model *model) const
convert_graph(*source_ptr, reader, graph.get());
LOGGER(l);
- INFO(l) << fmt(graph.get());
+ VERBOSE(l, 3) << "--- graph dump begin -------------------------------------------";
+ VERBOSE(l, 3) << "Name: " << graph->name();
+ VERBOSE(l, 3) << fmt(graph.get());
+ VERBOSE(l, 3) << "--- graph dump end ---------------------------------------------";
assert(loco::valid(graph.get(), std::make_unique<ValidateCollector>()));
module->add(std::move(graph));
}
- return std::move(module);
+ post_import_graph(module.get(), reader);
+
+ return module;
}
} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleAddN.cpp b/compiler/luci/import/src/Nodes/CircleAddN.cpp
new file mode 100644
index 000000000..2f1716e62
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleAddN.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleAddN.h"
+
+#include <luci/IR/Nodes/CircleAdd.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleAddNGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() < 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleAddNGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleAddN>(inputs.size());
+ for (uint32_t i = 0; i < inputs.size(); ++i)
+ {
+ node->inputs(i, inputs[i]);
+ }
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleArgMin.cpp b/compiler/luci/import/src/Nodes/CircleArgMin.cpp
new file mode 100644
index 000000000..4d85bbff0
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleArgMin.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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 "luci/Import/Nodes/CircleArgMin.h"
+
+#include <luci/IR/Nodes/CircleArgMin.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleArgMinGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleArgMinGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleArgMin>();
+ node->input(inputs[0]);
+ node->dimension(inputs[1]);
+
+ const auto *options = op.builtin_options.AsArgMinOptions();
+ node->output_type(luci_datatype(options->output_type));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp b/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp
new file mode 100644
index 000000000..7cc077ed6
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 "luci/Import/Nodes/CircleBCQFullyConnected.h"
+
+#include <luci/IR/Nodes/CircleBCQFullyConnected.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleBCQFullyConnectedGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 5)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleBCQFullyConnectedGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleBCQFullyConnected>();
+
+ node->input(inputs[0]);
+ node->weights_scales(inputs[1]);
+ node->weights_binary(inputs[2]);
+ node->bias(inputs[3]);
+ node->weights_clusters(inputs[4]);
+
+ // TODO Find and move to appropriate place for setting optional input
+ if (auto bias = dynamic_cast<luci::CircleOutputExclude *>(node->bias()))
+ {
+ // bias is not used for type inference, but node itself should have a type
+ bias->dtype(loco::DataType::FLOAT32);
+
+ // bias is not used for shape inference
+ }
+
+ const auto *options = op.builtin_options.AsBCQFullyConnectedOptions();
+ node->weights_hidden_size(options->weights_hidden_size);
+ node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleBCQGather.cpp b/compiler/luci/import/src/Nodes/CircleBCQGather.cpp
new file mode 100644
index 000000000..c6d2ab559
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleBCQGather.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "luci/Import/Nodes/CircleBCQGather.h"
+
+#include <luci/IR/Nodes/CircleBCQGather.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleBCQGatherGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 4)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleBCQGatherGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleBCQGather>();
+
+ node->input_scales(inputs[0]);
+ node->input_binary(inputs[1]);
+ node->indices(inputs[2]);
+ node->input_clusters(inputs[3]);
+
+ const auto *options = op.builtin_options.AsBCQGatherOptions();
+ node->input_hidden_size(options->input_hidden_size);
+ node->axis(options->axis);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp b/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp
new file mode 100644
index 000000000..6026b2a72
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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 "luci/Import/Nodes/CircleBatchMatMul.h"
+
+#include <luci/IR/Nodes/CircleBatchMatMul.h>
+
+namespace luci
+{
+
+bool CircleBatchMatMulGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleBatchMatMulGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleBatchMatMul>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ const auto *options = op.builtin_options.AsBatchMatMulOptions();
+ node->adj_x(options->adjoint_lhs);
+ node->adj_y(options->adjoint_rhs);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleCast.cpp b/compiler/luci/import/src/Nodes/CircleCast.cpp
new file mode 100644
index 000000000..a4d09b505
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleCast.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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 "luci/Import/Nodes/CircleCast.h"
+
+#include <luci/IR/Nodes/CircleCast.h>
+
+#include <luci/UserSettings.h>
+#include <luci/Log.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleCastGraphBuilder::validate(const ValidateArgs &args) const
+{
+ LOGGER(l);
+
+ auto settings = luci::UserSettings::settings();
+
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 1)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ // NOTE real models do have type mismatch
+ const auto *options = args.op.builtin_options.AsCastOptions();
+ if (options != nullptr)
+ {
+ const auto &tensors = args.reader.tensors();
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ auto name = tensor_name(output_tensor);
+
+ const auto &tensor_in = tensors.at(inputs[0]);
+ if (tensor_in->type != options->in_data_type)
+ {
+ if (settings->get(luci::UserSettings::Key::DisableValidation))
+ {
+ WARN(l) << "Warning: import Cast(" << name << ") dtype mismatch";
+ }
+ else
+ return false;
+ }
+ const auto &tensor_out = tensors.at(outputs[0]);
+ if (tensor_out->type != options->out_data_type)
+ {
+ if (settings->get(luci::UserSettings::Key::DisableValidation))
+ {
+ WARN(l) << "Warning: import Cast(" << name << ") dtype mismatch";
+ }
+ else
+ return false;
+ }
+ }
+
+ return true;
+}
+
+CircleNode *CircleCastGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleCast>();
+ node->x(inputs[0]);
+
+ const auto *options = op.builtin_options.AsCastOptions();
+ if (options != nullptr)
+ {
+ node->in_data_type(luci_datatype(options->in_data_type));
+ node->out_data_type(luci_datatype(options->out_data_type));
+ }
+ else
+ {
+ node->in_data_type(inputs[0]->dtype());
+ node->out_data_type(loco::DataType::Unknown);
+ // type inference should use node->dtype() for Unknown
+ // export should use BuiltinOptions_NONE for Unknown
+ }
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleCeil.cpp b/compiler/luci/import/src/Nodes/CircleCeil.cpp
new file mode 100644
index 000000000..d3d6cd945
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleCeil.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleCeil.h"
+
+#include <luci/IR/Nodes/CircleCeil.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleCeilGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 1)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ // TODO dtype check
+
+ return true;
+}
+
+CircleNode *CircleCeilGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleCeil>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleConst.cpp b/compiler/luci/import/src/Nodes/CircleConst.cpp
index 1d798983b..7131dc115 100644
--- a/compiler/luci/import/src/Nodes/CircleConst.cpp
+++ b/compiler/luci/import/src/Nodes/CircleConst.cpp
@@ -24,6 +24,24 @@
#include <cassert>
+namespace
+{
+
+std::ostream &operator<<(std::ostream &os, const std::vector<int32_t> &vect)
+{
+ uint32_t seq = 0;
+ for (auto &v : vect)
+ {
+ if (seq)
+ os << ", ";
+ os << v;
+ seq++;
+ }
+ return os;
+}
+
+} // namespace
+
namespace luci
{
@@ -53,55 +71,73 @@ CircleConst *create_circleconst(GraphBuilderContext *context, int32_t tensor_ind
auto graph = context->graph();
auto reader = context->reader();
const auto &tensors = reader->tensors();
-
- // (1) create CircleConst
- auto const_node = graph->nodes()->create<CircleConst>();
const circle::TensorT &const_tensor = *tensors[tensor_index];
- const_node->name(tensor_name(const_tensor));
- auto quantization = luci::tensor_quantization(const_tensor);
- if (quantization)
+
+ const std::vector<uint8_t> &buffer = reader->buffers()[const_tensor.buffer]->data;
+ std::vector<int32_t> const_dims = const_tensor.shape; // in NHWC
+ if (const_dims.size() == 0 && buffer.empty())
{
- auto quantparam = luci::luci_quantparam(quantization);
- if (quantparam.get())
- const_node->quantparam(std::move(quantparam));
+ // unknown shape tensor
+ return nullptr;
}
- INFO(l) << "[luci] NodeFinder const_node(" << tensor_index << ") -> " << const_node << std::endl;
-
- // (2) set data_type to CircleConst
- const_node->dtype(luci_datatype(const_tensor.type));
+ // if tensor_index is used as output to some other operator, this is not a constant
+ auto tensoroutputs = context->tensoroutputs();
+ if (tensoroutputs->find(tensor_index))
+ {
+ // other operator output tensor
+ return nullptr;
+ }
- // (3) set shape to CicleConst
- std::vector<int32_t> const_dims = const_tensor.shape; // in NHWC
- const_node->rank(const_dims.size());
uint32_t num_elements = 1;
for (uint32_t r = 0; r < const_dims.size(); ++r)
{
- const_node->dim(r) = loco::Dimension(const_dims[r]);
num_elements = num_elements * const_dims[r];
}
- // (4) constant values from circle buffer
- const std::vector<uint8_t> &buffer = reader->buffers()[const_tensor.buffer]->data;
- if (buffer.empty())
- throw oops::UserExn("Empty buffer");
-
- switch (luci_datatype(const_tensor.type))
+ if (buffer.empty() && num_elements > 0)
{
- case loco::DataType::FLOAT32:
- copy_data<loco::DataType::FLOAT32>(buffer, num_elements, const_node);
- break;
-
- case loco::DataType::U8:
- copy_data<loco::DataType::U8>(buffer, num_elements, const_node);
- break;
-
- case loco::DataType::S32:
- copy_data<loco::DataType::S32>(buffer, num_elements, const_node);
- break;
+ // normal empty tensor
+ return nullptr;
+ }
- default:
- throw oops::UserExn("Unsupported tensor type", circle::EnumNameTensorType(const_tensor.type));
+ auto const_node = graph->nodes()->create<CircleConst>();
+ copy_tensor_attributes(const_tensor, const_node);
+ const_node->shape_status(luci::ShapeStatus::VALID);
+ INFO(l) << "[luci] NodeFinder const_node(" << tensor_index << ") -> " << const_node << " "
+ << const_dims << std::endl;
+ if (num_elements > 0)
+ {
+ switch (luci_datatype(const_tensor.type))
+ {
+ case loco::DataType::FLOAT32:
+ copy_data<loco::DataType::FLOAT32>(buffer, num_elements, const_node);
+ break;
+
+ case loco::DataType::U8:
+ copy_data<loco::DataType::U8>(buffer, num_elements, const_node);
+ break;
+
+ case loco::DataType::S16:
+ copy_data<loco::DataType::S16>(buffer, num_elements, const_node);
+ break;
+
+ case loco::DataType::S32:
+ copy_data<loco::DataType::S32>(buffer, num_elements, const_node);
+ break;
+
+ case loco::DataType::S64:
+ copy_data<loco::DataType::S64>(buffer, num_elements, const_node);
+ break;
+
+ case loco::DataType::BOOL:
+ copy_data<loco::DataType::BOOL>(buffer, num_elements, const_node);
+ break;
+
+ default:
+ throw oops::UserExn("Unsupported tensor type",
+ circle::EnumNameTensorType(const_tensor.type));
+ }
}
return const_node;
diff --git a/compiler/luci/import/src/Nodes/CircleConv2D.cpp b/compiler/luci/import/src/Nodes/CircleConv2D.cpp
index ec9dce0d2..42c5c265a 100644
--- a/compiler/luci/import/src/Nodes/CircleConv2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleConv2D.cpp
@@ -50,7 +50,8 @@ CircleNode *CircleConv2DGraphBuilder::build_node(const circle::OperatorT &op,
node->stride()->w(options->stride_w);
node->stride()->h(options->stride_h);
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
- // FIXME Check dilation_w_factor, dilation_h_factor.
+ node->dilation()->w(options->dilation_w_factor);
+ node->dilation()->h(options->dilation_h_factor);
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleCustom.cpp b/compiler/luci/import/src/Nodes/CircleCustom.cpp
new file mode 100644
index 000000000..d541ee87b
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleCustom.cpp
@@ -0,0 +1,88 @@
+/*
+ * 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 "luci/Import/Nodes/CircleCustom.h"
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleCustomGraphBuilder::validate(const ValidateArgs &) const
+{
+ // DO NOTHING
+ return true;
+}
+
+void CircleCustomGraphBuilder::build(const circle::OperatorT &op,
+ GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ // Create CircleCustom
+ const auto &opcodes = context->reader()->opcodes();
+ const uint32_t opcode_index = op.opcode_index;
+ const circle::OperatorCodeT &opcode = *opcodes[opcode_index];
+
+ auto *node = graph->nodes()->create<CircleCustom>(inputs.size());
+ uint32_t input_idx = 0;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ node->inputs(input_idx++, context->nodefinder()->node(input_tensor_index));
+ }
+ node->custom_options(std::vector<uint8_t>{op.custom_options.begin(), op.custom_options.end()});
+ node->custom_code(opcode.custom_code);
+ // Operator version of custom is always 1, so do nothing
+
+ uint32_t output_count = outputs.size();
+
+ assert(output_count > 0);
+ {
+ // Let's use attributes from output 0 for this node
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->dtype(luci_datatype(output_tensor.type));
+ }
+
+ // Create virtual outputs of Custom
+ for (uint32_t n = 0; n < output_count; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleCustomOut>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp b/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp
new file mode 100644
index 000000000..827b63468
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "luci/Import/Nodes/CircleDepthToSpace.h"
+
+#include <luci/IR/Nodes/CircleDepthToSpace.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleDepthToSpaceGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ const auto *options = args.op.builtin_options.AsDepthToSpaceOptions();
+
+ if (inputs.size() != 1)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[outputs[0]]->type != tensors[inputs[0]]->type)
+ {
+ return false;
+ }
+
+ if (options->block_size < 2)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleDepthToSpaceGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleDepthToSpace>();
+ node->input(inputs[0]);
+
+ const auto *options = op.builtin_options.AsDepthToSpaceOptions();
+ node->block_size(options->block_size);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp b/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
index c6d3b1f1e..2b13f9ebb 100644
--- a/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
@@ -52,7 +52,8 @@ CircleNode *CircleDepthwiseConv2DGraphBuilder::build_node(const circle::Operator
node->stride()->h(options->stride_h);
node->depthMultiplier(options->depth_multiplier);
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
- // FIXME Check dilation_w_factor, dilation_h_factor.
+ node->dilation()->w(options->dilation_w_factor);
+ node->dilation()->h(options->dilation_h_factor);
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleElu.cpp b/compiler/luci/import/src/Nodes/CircleElu.cpp
new file mode 100644
index 000000000..37a290cb1
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleElu.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "luci/Import/Nodes/CircleElu.h"
+
+#include <luci/IR/Nodes/CircleElu.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleEluGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 1)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT32:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensors[outputs[0]]->type != tensor->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleEluGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleElu>();
+ node->features(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleExp.cpp b/compiler/luci/import/src/Nodes/CircleExp.cpp
index 44fc93d09..a32851458 100644
--- a/compiler/luci/import/src/Nodes/CircleExp.cpp
+++ b/compiler/luci/import/src/Nodes/CircleExp.cpp
@@ -16,7 +16,7 @@
#include "luci/Import/Nodes/CircleExp.h"
-#include <luci/IR/Nodes/CircleAbs.h>
+#include <luci/IR/Nodes/CircleExp.h>
#include <loco.h>
@@ -50,7 +50,7 @@ CircleNode *CircleExpGraphBuilder::build_node(const circle::OperatorT &,
const std::vector<CircleNode *> &inputs,
loco::Graph *graph) const
{
- auto *node = graph->nodes()->create<CircleAbs>();
+ auto *node = graph->nodes()->create<CircleExp>();
node->x(inputs[0]);
return node;
diff --git a/compiler/luci/import/src/Nodes/CircleExpandDims.cpp b/compiler/luci/import/src/Nodes/CircleExpandDims.cpp
new file mode 100644
index 000000000..1cef67a83
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleExpandDims.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "luci/Import/Nodes/CircleExpandDims.h"
+
+#include <luci/IR/Nodes/CircleExpandDims.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleExpandDimsGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+
+ return tensors[inputs[1]]->type == circle::TensorType_INT32;
+}
+
+CircleNode *CircleExpandDimsGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleExpandDims>();
+ node->input(inputs[0]);
+ node->axis(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleFill.cpp b/compiler/luci/import/src/Nodes/CircleFill.cpp
new file mode 100644
index 000000000..6c3d3a247
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleFill.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "luci/Import/Nodes/CircleFill.h"
+
+#include <luci/IR/Nodes/CircleFill.h>
+
+namespace luci
+{
+
+bool CircleFillGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleFillGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleFill>();
+ node->dims(inputs[0]);
+ node->value(inputs[1]);
+
+ const auto *options = op.builtin_options.AsFillOptions();
+ (void)options;
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleFloor.cpp b/compiler/luci/import/src/Nodes/CircleFloor.cpp
new file mode 100644
index 000000000..302a9eae3
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleFloor.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleFloor.h"
+
+#include <luci/IR/Nodes/CircleFloor.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleFloorGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 1)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ // TODO dtype check
+
+ return true;
+}
+
+CircleNode *CircleFloorGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleFloor>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp b/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp
new file mode 100644
index 000000000..875197890
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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 "luci/Import/Nodes/CircleFloorDiv.h"
+
+#include <luci/IR/Nodes/CircleFloorDiv.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleFloorDivGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in_0 = tensors.at(inputs[0]);
+ const auto &tensor_in_1 = tensors.at(inputs[1]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+
+ if (tensor_in_0->type != tensor_in_1->type)
+ return false;
+
+ if (tensor_out->type != tensor_in_1->type)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleFloorDivGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleFloorDiv>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleFloorMod.cpp b/compiler/luci/import/src/Nodes/CircleFloorMod.cpp
new file mode 100644
index 000000000..3ccdce0cd
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleFloorMod.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "luci/Import/Nodes/CircleFloorMod.h"
+
+#include <luci/IR/Nodes/CircleFloorMod.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleFloorModGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in_0 = tensors.at(inputs[0]);
+ const auto &tensor_in_1 = tensors.at(inputs[1]);
+ if (tensor_in_0->type != tensor_in_1->type)
+ return false;
+
+ // TODO dtype check
+
+ return true;
+}
+
+CircleNode *CircleFloorModGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleFloorMod>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp b/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
index 8f74fe9ce..8937e78f1 100644
--- a/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
@@ -17,6 +17,7 @@
#include "luci/Import/Nodes/CircleFullyConnected.h"
#include <luci/IR/Nodes/CircleFullyConnected.h>
+#include <luci/IR/Nodes/CircleOutput.h>
#include <loco.h>
#include <oops/UserExn.h>
@@ -39,7 +40,16 @@ CircleNode *CircleFullyConnectedGraphBuilder::build_node(const circle::OperatorT
auto *node = graph->nodes()->create<CircleFullyConnected>();
node->input(inputs[0]);
node->weights(inputs[1]);
- node->bias(inputs[2]);
+ node->bias(inputs[2]); // bias is optional
+
+ // TODO Find and move to appropriate place for setting optional input
+ if (auto bias = dynamic_cast<luci::CircleOutputExclude *>(node->bias()))
+ {
+ // bias is not used for type inference, but node itself should have a type
+ bias->dtype(loco::DataType::FLOAT32);
+
+ // bias is not used for shape inference
+ }
const auto *options = op.builtin_options.AsFullyConnectedOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleGather.cpp b/compiler/luci/import/src/Nodes/CircleGather.cpp
new file mode 100644
index 000000000..1caa05ec2
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleGather.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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 "luci/Import/Nodes/CircleGather.h"
+
+#include <luci/IR/Nodes/CircleGather.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleGatherGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ const auto *options = args.op.builtin_options.AsGatherOptions();
+
+ int32_t axis = options->axis;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ if (axis < 0)
+ axis += inputs.size();
+
+ if (axis < 0)
+ return false;
+
+ // TODO do indices type check
+ // TODO do axis check when shape information is given
+
+ return true;
+}
+
+CircleNode *CircleGatherGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleGather>();
+
+ node->params(inputs[0]);
+ node->indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsGatherOptions();
+ node->axis(options->axis);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleGatherNd.cpp b/compiler/luci/import/src/Nodes/CircleGatherNd.cpp
new file mode 100644
index 000000000..621d4ae92
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleGatherNd.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "luci/Import/Nodes/CircleGatherNd.h"
+
+#include <luci/IR/Nodes/CircleGatherNd.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+#include <mio/circle/schema_generated.h>
+
+namespace luci
+{
+
+bool CircleGatherNdGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ auto &indices_tensor = args.reader.tensors()[inputs[1]];
+
+ if (!(indices_tensor->type == circle::TensorType::TensorType_INT32 ||
+ indices_tensor->type == circle::TensorType::TensorType_INT64))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleGatherNdGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleGatherNd>();
+
+ node->params(inputs[0]);
+ node->indices(inputs[1]);
+
+ // GatherNd options empty
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleGreater.cpp b/compiler/luci/import/src/Nodes/CircleGreater.cpp
new file mode 100644
index 000000000..88107589c
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleGreater.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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 "luci/Import/Nodes/CircleGreater.h"
+
+#include <luci/IR/Nodes/CircleGreater.h>
+
+#include <luci/UserSettings.h>
+#include <luci/Log.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleGreaterGraphBuilder::validate(const ValidateArgs &args) const
+{
+ LOGGER(l);
+
+ auto settings = luci::UserSettings::settings();
+
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ return false;
+
+ // NOTE: real models do have output dtype NOT BOOL
+ if (tensors[outputs[0]]->type != circle::TensorType_BOOL)
+ {
+ if (settings->get(luci::UserSettings::Key::DisableValidation))
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ auto name = tensor_name(output_tensor);
+ WARN(l) << "Warning: import Greater(" << name << ") output dtype is not boolean";
+ }
+ else
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleGreaterGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleGreater>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp b/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp
new file mode 100644
index 000000000..dff1510c5
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 "luci/Import/Nodes/CircleGreaterEqual.h"
+
+#include <luci/IR/Nodes/CircleGreaterEqual.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleGreaterEqualGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ {
+ return false;
+ }
+
+ return tensors[outputs[0]]->type == circle::TensorType::TensorType_BOOL;
+}
+
+CircleNode *CircleGreaterEqualGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleGreaterEqual>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleIf.cpp b/compiler/luci/import/src/Nodes/CircleIf.cpp
new file mode 100644
index 000000000..d6090640d
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleIf.cpp
@@ -0,0 +1,138 @@
+/*
+ * 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 "luci/Import/Nodes/CircleIf.h"
+
+#include <luci/IR/Nodes/CircleIf.h>
+#include <luci/IR/Nodes/CircleIfOut.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleIfGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto *options = args.op.builtin_options.AsIfOptions();
+
+ if (inputs.size() < 2) // cond + input
+ return false;
+ if (args.op.outputs.size() < 1) // output
+ return false;
+
+ auto num_graphs = static_cast<int32_t>(args.reader.num_subgraph());
+ if (options->then_subgraph_index >= num_graphs)
+ return false;
+ if (options->else_subgraph_index >= num_graphs)
+ return false;
+
+ // input 0 should be BOOL type
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ if (tensor->type != circle::TensorType_BOOL)
+ return false;
+
+ const auto &shape = tensor->shape;
+ if (shape.size() != 1 && shape.size() != 0)
+ return false;
+
+ return true;
+}
+
+/**
+ * @brief If Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleIfOut nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleIf --- Node ---
+ * \- Node ---
+ *
+ * will be created like this
+ *
+ * --- CircleIf --- CircleIfOut --- Node ---
+ * \- CircleIfOut --- Node ---
+ */
+
+void CircleIfGraphBuilder::build(const circle::OperatorT &op, GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ uint32_t input_count = inputs.size() - 1;
+ uint32_t output_count = outputs.size();
+
+ // Create CircleIf
+ CircleIf *node = graph->nodes()->create<CircleIf>(input_count, output_count);
+
+ node->cond(input_nodes[0]);
+ for (uint32_t idx = 0; idx < input_count; ++idx)
+ {
+ node->input(idx, input_nodes[idx + 1]);
+ }
+
+ const auto *options = op.builtin_options.AsIfOptions();
+ node->then_branch(options->then_subgraph_index);
+ node->else_branch(options->else_subgraph_index);
+
+ assert(outputs.size() > 0);
+ {
+ // Lets use name of output 0 as If name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for If itself but to virtual outputs
+ }
+
+ // Create virtual outputs of If
+ for (uint32_t n = 0; n < output_count; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleIfOut>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp b/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp
new file mode 100644
index 000000000..b95c54c89
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "luci/Import/Nodes/CircleInstanceNorm.h"
+
+#include <luci/IR/Nodes/CircleInstanceNorm.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleInstanceNormGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 3)
+ return false;
+
+ // TODO check dtypes
+
+ return true;
+}
+
+CircleNode *CircleInstanceNormGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleInstanceNorm>();
+ node->input(inputs[0]);
+ node->gamma(inputs[1]);
+ node->beta(inputs[2]);
+
+ const auto *options = op.builtin_options.AsInstanceNormOptions();
+ node->epsilon(options->epsilon);
+ node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp b/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp
new file mode 100644
index 000000000..fe10a8572
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp
@@ -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.
+ */
+
+#include "luci/Import/Nodes/CircleL2Normalize.h"
+
+#include <luci/IR/Nodes/CircleL2Normalize.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleL2NormalizeGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 1)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleL2NormalizeGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleL2Normalize>();
+ node->x(inputs[0]);
+ const auto *options = op.builtin_options.AsL2NormOptions();
+ node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp b/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp
new file mode 100644
index 000000000..023206695
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "luci/Import/Nodes/CircleL2Pool2D.h"
+
+#include <luci/IR/Nodes/CircleL2Pool2D.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleL2Pool2DGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ // TODO check dtypes
+
+ return true;
+}
+
+CircleNode *CircleL2Pool2DGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleL2Pool2D>();
+ node->value(inputs[0]);
+
+ const auto *options = op.builtin_options.AsPool2DOptions();
+ node->padding(luci_padding(options->padding));
+ node->stride()->w(options->stride_w);
+ node->stride()->h(options->stride_h);
+ node->filter()->w(options->filter_width);
+ node->filter()->h(options->filter_height);
+ node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp b/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp
new file mode 100644
index 000000000..4957ceae0
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLeakyRelu.h"
+
+#include <luci/IR/Nodes/CircleLeakyRelu.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLeakyReluGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleLeakyReluGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLeakyRelu>();
+ node->features(inputs[0]);
+
+ const auto *options = op.builtin_options.AsLeakyReluOptions();
+ node->alpha(options->alpha);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLess.cpp b/compiler/luci/import/src/Nodes/CircleLess.cpp
new file mode 100644
index 000000000..40ad28c6e
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLess.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLess.h"
+
+#include <luci/IR/Nodes/CircleLess.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLessGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_INT32:
+ case circle::TensorType_UINT8:
+ case circle::TensorType_INT16:
+ case circle::TensorType_INT8:
+ case circle::TensorType_INT64:
+ case circle::TensorType_FLOAT16:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensors[inputs[1]]->type != tensor->type)
+ {
+ return false;
+ }
+
+ return tensors[outputs[0]]->type == circle::TensorType_BOOL;
+}
+
+CircleNode *CircleLessGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLess>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLessEqual.cpp b/compiler/luci/import/src/Nodes/CircleLessEqual.cpp
new file mode 100644
index 000000000..13e995069
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLessEqual.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLessEqual.h"
+
+#include <luci/IR/Nodes/CircleLessEqual.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLessEqualGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ {
+ return false;
+ }
+
+ return tensors[outputs[0]]->type == circle::TensorType::TensorType_BOOL;
+}
+
+CircleNode *CircleLessEqualGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLessEqual>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp b/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp
new file mode 100644
index 000000000..7b1f0db56
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLocalResponseNormalization.h"
+
+#include <luci/IR/Nodes/CircleLocalResponseNormalization.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLocalResponseNormalizationGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ // TODO do attribute checks
+
+ return true;
+}
+
+CircleNode *CircleLocalResponseNormalizationGraphBuilder::build_node(
+ const circle::OperatorT &op, const std::vector<CircleNode *> &inputs, loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLocalResponseNormalization>();
+ node->input(inputs[0]);
+
+ const auto *options = op.builtin_options.AsLocalResponseNormalizationOptions();
+ node->radius(options->radius);
+ node->bias(options->bias);
+ node->alpha(options->alpha);
+ node->beta(options->beta);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLog.cpp b/compiler/luci/import/src/Nodes/CircleLog.cpp
new file mode 100644
index 000000000..21408327d
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLog.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLog.h"
+
+#include <luci/IR/Nodes/CircleLog.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLogGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ // input type check
+ // Must be one of bfloat16, half, float32, float64, complex64, complex128.
+ // Currently circle supports half(float16), float32, float64, complex64.
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_COMPLEX64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleLogGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLog>();
+ node->x(inputs[0]);
+
+ // No options for Log
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp b/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp
new file mode 100644
index 000000000..e738c4a0c
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLogSoftmax.h"
+
+#include <luci/IR/Nodes/CircleLogSoftmax.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLogSoftmaxGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ // TODO do attribute checks
+
+ return true;
+}
+
+CircleNode *CircleLogSoftmaxGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLogSoftmax>();
+ node->logits(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp b/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp
new file mode 100644
index 000000000..8509dbaf3
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLogicalAnd.h"
+
+#include <luci/IR/Nodes/CircleLogicalAnd.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLogicalAndGraphBuilder::validate(const ValidateArgs &args) const
+{
+ // Only BOOL type is allowed for inputs
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 2)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ for (auto input : inputs)
+ {
+ const auto &tensor = tensors.at(input);
+ if (tensor->type != circle::TensorType::TensorType_BOOL)
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleLogicalAndGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLogicalAnd>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleLogistic.cpp b/compiler/luci/import/src/Nodes/CircleLogistic.cpp
new file mode 100644
index 000000000..85e7e55b2
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleLogistic.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 "luci/Import/Nodes/CircleLogistic.h"
+
+#include <luci/IR/Nodes/CircleLogistic.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleLogisticGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+ const auto &outputs = args.op.outputs;
+ if (outputs.size() != 1)
+ return false;
+
+ // Must be one of the following types
+ // float16, float32, float64, complex64, or complex128
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_COMPLEX64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensors.at(inputs[0])->type != tensors.at(outputs[0])->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleLogisticGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleLogistic>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp b/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp
new file mode 100644
index 000000000..f4ae03c58
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp
@@ -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.
+ */
+
+#include "luci/Import/Nodes/CircleMatrixDiag.h"
+
+#include <luci/IR/Nodes/CircleMatrixDiag.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleMatrixDiagGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 1)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ if (tensors[outputs[0]]->type != tensor->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleMatrixDiagGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleMatrixDiag>();
+ node->diagonal(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp b/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp
new file mode 100644
index 000000000..d6f6aee33
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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 "luci/Import/Nodes/CircleMatrixSetDiag.h"
+
+#include <luci/IR/Nodes/CircleMatrixSetDiag.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleMatrixSetDiagGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ if (tensors[outputs[0]]->type != tensor->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleMatrixSetDiagGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleMatrixSetDiag>();
+ node->input(inputs[0]);
+ node->diagonal(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleMaximum.cpp b/compiler/luci/import/src/Nodes/CircleMaximum.cpp
new file mode 100644
index 000000000..6ca7e4079
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleMaximum.cpp
@@ -0,0 +1,72 @@
+/*
+ * 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 "luci/Import/Nodes/CircleMaximum.h"
+
+#include <luci/IR/Nodes/CircleMaximum.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleMaximumGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensors[inputs[1]]->type != tensor->type)
+ return false;
+
+ if (tensors[outputs[0]]->type != tensor->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleMaximumGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleMaximum>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleMinimum.cpp b/compiler/luci/import/src/Nodes/CircleMinimum.cpp
new file mode 100644
index 000000000..b770f365f
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleMinimum.cpp
@@ -0,0 +1,72 @@
+/*
+ * 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 "luci/Import/Nodes/CircleMinimum.h"
+
+#include <luci/IR/Nodes/CircleMinimum.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleMinimumGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensors[inputs[1]]->type != tensor->type)
+ return false;
+
+ if (tensors[outputs[0]]->type != tensor->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleMinimumGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleMinimum>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp b/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp
new file mode 100644
index 000000000..41b5e5d80
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleMirrorPad.h"
+
+#include <luci/IR/Nodes/CircleMirrorPad.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleMirrorPadGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ // TODO check others
+
+ return true;
+}
+
+CircleNode *CircleMirrorPadGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleMirrorPad>();
+ node->input(inputs[0]);
+ node->paddings(inputs[1]);
+
+ const auto *options = op.builtin_options.AsMirrorPadOptions();
+ node->mode(luci_mirrorpad_mode(options->mode));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleNeg.cpp b/compiler/luci/import/src/Nodes/CircleNeg.cpp
new file mode 100644
index 000000000..3d3079ca2
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleNeg.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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 "luci/Import/Nodes/CircleNeg.h"
+
+#include <luci/IR/Nodes/CircleNeg.h>
+
+#include <loco.h>
+
+namespace luci
+{
+bool CircleNegGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ // TODO Support type check
+ return true;
+}
+
+CircleNode *CircleNegGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleNeg>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleNotEqual.cpp b/compiler/luci/import/src/Nodes/CircleNotEqual.cpp
new file mode 100644
index 000000000..5b04856db
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleNotEqual.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 "luci/Import/Nodes/CircleNotEqual.h"
+
+#include <luci/IR/Nodes/CircleNotEqual.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleNotEqualGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ {
+ return false;
+ }
+
+ if (outputs.size() != 1)
+ {
+ return false;
+ }
+
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ {
+ return false;
+ }
+
+ return tensors[outputs[0]]->type == circle::TensorType::TensorType_BOOL;
+}
+
+CircleNode *CircleNotEqualGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleNotEqual>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleOneHot.cpp b/compiler/luci/import/src/Nodes/CircleOneHot.cpp
new file mode 100644
index 000000000..9fdbfa84d
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleOneHot.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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 "luci/Import/Nodes/CircleOneHot.h"
+
+#include <luci/IR/Nodes/CircleOneHot.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleOneHotGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ const auto *options = args.op.builtin_options.AsOneHotOptions();
+
+ // Only 4 Input come refered from
+ if (inputs.size() != 4)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &indices = tensors.at(inputs[0]);
+ const auto &depth = tensors.at(inputs[1]);
+ const auto &on_value = tensors.at(inputs[2]);
+ const auto &off_value = tensors.at(inputs[3]);
+
+ if (options->axis < -1 || options->axis > static_cast<int32_t>(indices->shape.size()))
+ return false;
+ if (depth->shape.size() != 0)
+ return false;
+ if (on_value->shape.size() != 0)
+ return false;
+ if (off_value->shape.size() != 0)
+ return false;
+ if (on_value->type != off_value->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleOneHotGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleOneHot>();
+
+ node->indices(inputs[0]);
+ node->depth(inputs[1]);
+ node->on_value(inputs[2]);
+ node->off_value(inputs[3]);
+
+ const auto *options = op.builtin_options.AsOneHotOptions();
+ node->axis(options->axis);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CirclePRelu.cpp b/compiler/luci/import/src/Nodes/CirclePRelu.cpp
new file mode 100644
index 000000000..0d87cd423
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CirclePRelu.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CirclePRelu.h"
+
+#include <luci/IR/Nodes/CirclePRelu.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CirclePReluGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CirclePReluGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CirclePRelu>();
+ node->input(inputs[0]);
+ node->alpha(inputs[1]);
+
+ // PRelu options are empty
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CirclePow.cpp b/compiler/luci/import/src/Nodes/CirclePow.cpp
new file mode 100644
index 000000000..ff9833165
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CirclePow.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CirclePow.h"
+
+#include <luci/IR/Nodes/CirclePow.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CirclePowGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CirclePowGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CirclePow>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ // Pow options are empty
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleRange.cpp b/compiler/luci/import/src/Nodes/CircleRange.cpp
new file mode 100644
index 000000000..c21191605
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleRange.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "luci/Import/Nodes/CircleRange.h"
+
+#include <luci/IR/Nodes/CircleRange.h>
+
+#include <loco.h>
+
+namespace luci
+{
+bool CircleRangeGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 3)
+ return false;
+
+ // TODO Support type check
+ return true;
+}
+
+CircleNode *CircleRangeGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleRange>();
+ node->start(inputs[0]);
+ node->limit(inputs[1]);
+ node->delta(inputs[2]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleRank.cpp b/compiler/luci/import/src/Nodes/CircleRank.cpp
new file mode 100644
index 000000000..705ae0120
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleRank.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "luci/Import/Nodes/CircleRank.h"
+
+#include <luci/IR/Nodes/CircleRank.h>
+
+#include <loco.h>
+
+namespace luci
+{
+bool CircleRankGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleRankGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleRank>();
+ node->input(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReduceAny.cpp b/compiler/luci/import/src/Nodes/CircleReduceAny.cpp
new file mode 100644
index 000000000..030c5304c
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReduceAny.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReduceAny.h"
+
+#include <luci/IR/Nodes/CircleReduceAny.h>
+
+namespace luci
+{
+
+bool CircleReduceAnyGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_0 = tensors.at(inputs[0]);
+ const auto &tensor_1 = tensors.at(inputs[1]);
+ const auto &tensor_o = tensors.at(outputs[0]);
+
+ if (tensor_0->type != circle::TensorType_BOOL)
+ return false;
+ if (tensor_o->type != circle::TensorType_BOOL)
+ return false;
+
+ switch (tensor_1->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleReduceAnyGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReduceAny>();
+ node->input(inputs[0]);
+ node->reduction_indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReducerOptions();
+ node->keep_dims(options->keep_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReduceMax.cpp b/compiler/luci/import/src/Nodes/CircleReduceMax.cpp
new file mode 100644
index 000000000..8ca8e2e34
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReduceMax.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReduceMax.h"
+
+#include <luci/IR/Nodes/CircleReduceMax.h>
+
+namespace luci
+{
+
+bool CircleReduceMaxGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_axis = tensors.at(inputs[1]);
+
+ switch (tensor_axis->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleReduceMaxGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReduceMax>();
+ node->input(inputs[0]);
+ node->reduction_indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReducerOptions();
+ node->keep_dims(options->keep_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReduceMin.cpp b/compiler/luci/import/src/Nodes/CircleReduceMin.cpp
new file mode 100644
index 000000000..3020c3778
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReduceMin.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReduceMin.h"
+
+#include <luci/IR/Nodes/CircleReduceMin.h>
+
+namespace luci
+{
+
+bool CircleReduceMinGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_axis = tensors.at(inputs[1]);
+
+ switch (tensor_axis->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleReduceMinGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReduceMin>();
+ node->input(inputs[0]);
+ node->reduction_indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReducerOptions();
+ node->keep_dims(options->keep_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReduceProd.cpp b/compiler/luci/import/src/Nodes/CircleReduceProd.cpp
new file mode 100644
index 000000000..2bb43f6ce
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReduceProd.cpp
@@ -0,0 +1,64 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReduceProd.h"
+
+#include <luci/IR/Nodes/CircleReduceProd.h>
+
+namespace luci
+{
+
+bool CircleReduceProdGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 2)
+ return false;
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_1 = tensors.at(inputs[1]);
+
+ // TODO check input types
+
+ // Check for reduction_indices types
+ switch (tensor_1->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleReduceProdGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReduceProd>();
+ node->input(inputs[0]);
+ node->reduction_indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReducerOptions();
+ node->keep_dims(options->keep_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleRelu6.cpp b/compiler/luci/import/src/Nodes/CircleRelu6.cpp
new file mode 100644
index 000000000..5b443993b
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleRelu6.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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 "luci/Import/Nodes/CircleRelu6.h"
+
+#include <luci/IR/Nodes/CircleRelu6.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleRelu6GraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleRelu6GraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleRelu6>();
+ node->features(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp b/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp
new file mode 100644
index 000000000..edf662fb9
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReluN1To1.h"
+
+#include <luci/IR/Nodes/CircleReluN1To1.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleReluN1To1GraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ // TODO check dtypes
+
+ return true;
+}
+
+CircleNode *CircleReluN1To1GraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReluN1To1>();
+ node->features(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReshape.cpp b/compiler/luci/import/src/Nodes/CircleReshape.cpp
index c83f143a6..f72c152b1 100644
--- a/compiler/luci/import/src/Nodes/CircleReshape.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReshape.cpp
@@ -66,7 +66,14 @@ CircleNode *CircleReshapeGraphBuilder::build_node(const circle::OperatorT &op,
if (shape_node == nullptr)
{
const auto *options = op.builtin_options.AsReshapeOptions();
- shape_node = create_shape_node(options->new_shape, graph);
+ if (options != nullptr)
+ shape_node = create_shape_node(options->new_shape, graph);
+ else
+ {
+ shape_node = graph->nodes()->create<CircleOutputDummy>();
+ shape_node->dtype(loco::DataType::S32);
+ shape_node->rank(0);
+ }
}
auto *node = graph->nodes()->create<CircleReshape>();
@@ -74,7 +81,8 @@ CircleNode *CircleReshapeGraphBuilder::build_node(const circle::OperatorT &op,
node->shape(shape_node);
const auto *options = op.builtin_options.AsReshapeOptions();
- setup_shape_attribute(options->new_shape, node);
+ if (options)
+ setup_shape_attribute(options->new_shape, node);
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp b/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp
new file mode 100644
index 000000000..6128f1b86
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "luci/Import/Nodes/CircleResizeBilinear.h"
+
+#include <luci/IR/Nodes/CircleConst.h>
+#include <luci/IR/Nodes/CircleResizeBilinear.h>
+
+namespace luci
+{
+
+bool CircleResizeBilinearGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleResizeBilinearGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleResizeBilinear>();
+ node->input(inputs[0]);
+ node->size(inputs[1]);
+
+ const auto *options = op.builtin_options.AsResizeBilinearOptions();
+ node->align_corners(options->align_corners);
+ node->half_pixel_centers(options->half_pixel_centers);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp b/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp
new file mode 100644
index 000000000..a1f1ef0ff
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "luci/Import/Nodes/CircleResizeNearestNeighbor.h"
+
+#include <luci/IR/Nodes/CircleConst.h>
+#include <luci/IR/Nodes/CircleResizeNearestNeighbor.h>
+
+namespace luci
+{
+
+bool CircleResizeNearestNeighborGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleResizeNearestNeighborGraphBuilder::build_node(
+ const circle::OperatorT &op, const std::vector<CircleNode *> &inputs, loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleResizeNearestNeighbor>();
+ node->input(inputs[0]);
+ node->size(inputs[1]);
+
+ const auto *options = op.builtin_options.AsResizeNearestNeighborOptions();
+ node->align_corners(options->align_corners);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp b/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp
new file mode 100644
index 000000000..72d3b153d
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReverseSequence.h"
+
+#include <luci/IR/Nodes/CircleReverseSequence.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleReverseSequenceGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_lengths = tensors.at(inputs[1]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+
+ switch (tensor_lengths->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensor_in->type != tensor_out->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleReverseSequenceGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReverseSequence>();
+ node->input(inputs[0]);
+ node->seq_lengths(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReverseSequenceOptions();
+ node->seq_axis(options->seq_dim);
+ node->batch_axis(options->batch_dim);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleReverseV2.cpp b/compiler/luci/import/src/Nodes/CircleReverseV2.cpp
new file mode 100644
index 000000000..cd18128a7
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleReverseV2.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "luci/Import/Nodes/CircleReverseV2.h"
+
+#include <luci/IR/Nodes/CircleReverseV2.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleReverseV2GraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_axis = tensors.at(inputs[1]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+
+ switch (tensor_axis->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensor_out->type != tensor_in->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleReverseV2GraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleReverseV2>();
+ node->tensor(inputs[0]);
+ node->axis(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleRound.cpp b/compiler/luci/import/src/Nodes/CircleRound.cpp
new file mode 100644
index 000000000..896489521
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleRound.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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 "luci/Import/Nodes/CircleRound.h"
+
+#include <luci/IR/Nodes/CircleRound.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleRoundGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 1)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ // Must be one of the following types
+ // bfloat16, half (float16), float32, float64, complex64, complex128
+ // Currently, circle supports float16, float32, complex64
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+
+ switch (tensor_in->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensor_out->type != tensor_in->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleRoundGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleRound>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleScatterNd.cpp b/compiler/luci/import/src/Nodes/CircleScatterNd.cpp
new file mode 100644
index 000000000..adcaa0030
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleScatterNd.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "luci/Import/Nodes/CircleScatterNd.h"
+
+#include <luci/IR/Nodes/CircleScatterNd.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleScatterNdGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 3)
+ return false;
+
+ // indices must have the same type as shape
+ const auto &tensors = args.reader.tensors();
+
+ if (tensors[inputs[0]]->type != tensors[inputs[2]]->type)
+ return false;
+
+ // indices must be either int32 or int64
+ if (tensors[inputs[0]]->type != circle::TensorType_INT32 &&
+ tensors[inputs[0]]->type != circle::TensorType_INT64)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleScatterNdGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleScatterNd>();
+ node->indices(inputs[0]);
+ node->updates(inputs[1]);
+ node->shape(inputs[2]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp b/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp
new file mode 100644
index 000000000..1122bdca3
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSegmentSum.h"
+
+#include <luci/IR/Nodes/CircleSegmentSum.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSegmentSumGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+ const auto &tensor_ids = tensors.at(inputs[1]);
+
+ switch (tensor_ids->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ if (tensor_out->type != tensor_in->type)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleSegmentSumGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSegmentSum>();
+ node->input(inputs[0]);
+ node->segment_ids(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSelect.cpp b/compiler/luci/import/src/Nodes/CircleSelect.cpp
new file mode 100644
index 000000000..ff94212c3
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSelect.cpp
@@ -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.
+ */
+
+#include "luci/Import/Nodes/CircleSelect.h"
+
+#include <luci/IR/Nodes/CircleSelect.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSelectGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 3)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ if (tensor->type != circle::TensorType_BOOL)
+ return false;
+ // TODO check dtypes for input 1, 2
+
+ return true;
+}
+
+CircleNode *CircleSelectGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSelect>();
+ node->condition(inputs[0]);
+ node->t(inputs[1]);
+ node->e(inputs[2]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSelectV2.cpp b/compiler/luci/import/src/Nodes/CircleSelectV2.cpp
new file mode 100644
index 000000000..78b2e6459
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSelectV2.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSelectV2.h"
+
+#include <luci/IR/Nodes/CircleSelectV2.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSelectV2GraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 3)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &condition = tensors.at(inputs[0]);
+ if (condition->type != circle::TensorType_BOOL)
+ return false;
+
+ const auto &t = tensors.at(inputs[1]);
+ const auto &e = tensors.at(inputs[2]);
+ if (t->type != e->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSelectV2GraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSelectV2>();
+ node->condition(inputs[0]);
+ node->t(inputs[1]);
+ node->e(inputs[2]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleShape.cpp b/compiler/luci/import/src/Nodes/CircleShape.cpp
new file mode 100644
index 000000000..864b5eb51
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleShape.cpp
@@ -0,0 +1,53 @@
+/*
+ * 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 "luci/Import/Nodes/CircleShape.h"
+
+#include <luci/IR/Nodes/CircleShape.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleShapeGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ if (inputs.size() != 1)
+ return false;
+ if (outputs.size() != 1)
+ return false;
+
+ // TODO check shape, dtype
+
+ return true;
+}
+
+CircleNode *CircleShapeGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleShape>();
+ node->input(inputs[0]);
+
+ const auto *options = op.builtin_options.AsShapeOptions();
+ node->out_type(luci_datatype(options->out_type));
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSin.cpp b/compiler/luci/import/src/Nodes/CircleSin.cpp
new file mode 100644
index 000000000..61d60c78f
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSin.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSin.h"
+
+#include <luci/IR/Nodes/CircleSin.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSinGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ // input type check
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ break;
+ // TODO support TensorType_COMPLEX64, complex128, bfloat16
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleSinGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSin>();
+ node->x(inputs[0]);
+
+ // No options for Sin
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSlice.cpp b/compiler/luci/import/src/Nodes/CircleSlice.cpp
new file mode 100644
index 000000000..313c35599
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSlice.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSlice.h"
+
+#include <luci/IR/Nodes/CircleSlice.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleSliceGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 3)
+ return false;
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ // TODO check shapes and types
+
+ return true;
+}
+
+CircleNode *CircleSliceGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSlice>();
+ node->input(inputs[0]);
+ node->begin(inputs[1]);
+ node->size(inputs[2]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp b/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp
new file mode 100644
index 000000000..f1361fb11
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp
@@ -0,0 +1,80 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSpaceToBatchND.h"
+
+#include <luci/IR/Nodes/CircleSpaceToBatchND.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleSpaceToBatchNDGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 3)
+ return false;
+
+ // input 1 and 2 should have INT32/INT64 type
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_1 = tensors.at(inputs[1]);
+ switch (tensor_1->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+ const auto &tensor_2 = tensors.at(inputs[2]);
+ switch (tensor_2->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ // Only support input shape dimension 3 and 4 only
+ const auto &tensor_0 = tensors.at(inputs[0]);
+ const auto t_0_s = tensor_0->shape.size();
+ if (t_0_s != 3 && t_0_s != 4)
+ return false;
+
+ // TODO check input shape
+
+ return true;
+}
+
+CircleNode *CircleSpaceToBatchNDGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSpaceToBatchND>();
+ node->input(inputs[0]);
+ node->block_shape(inputs[1]);
+ node->paddings(inputs[2]);
+
+ // No options for SpaceToBatchND
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp b/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp
new file mode 100644
index 000000000..b612c9a9a
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp
@@ -0,0 +1,52 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSpaceToDepth.h"
+
+#include <luci/IR/Nodes/CircleSpaceToDepth.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleSpaceToDepthGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+
+ // TODO do attribute checks
+
+ return true;
+}
+
+CircleNode *CircleSpaceToDepthGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSpaceToDepth>();
+ node->input(inputs[0]);
+
+ const auto *options = op.builtin_options.AsSpaceToDepthOptions();
+ node->block_size(options->block_size);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp b/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp
new file mode 100644
index 000000000..bfe790fc1
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSparseToDense.h"
+
+#include <luci/IR/Nodes/CircleSparseToDense.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSparseToDenseGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 4)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSparseToDenseGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSparseToDense>();
+ node->indices(inputs[0]);
+ node->output_shape(inputs[1]);
+ node->values(inputs[2]);
+ node->default_value(inputs[3]);
+
+ const auto *options = op.builtin_options.AsSparseToDenseOptions();
+ node->validate_indices(options->validate_indices);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSplit.cpp b/compiler/luci/import/src/Nodes/CircleSplit.cpp
new file mode 100644
index 000000000..07b6cc939
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSplit.cpp
@@ -0,0 +1,119 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSplit.h"
+
+#include <luci/IR/Nodes/CircleSplit.h>
+#include <luci/IR/Nodes/CircleSplitOut.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleSplitGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ const auto *options = args.op.builtin_options.AsSplitOptions();
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (static_cast<int32_t>(outputs.size()) != options->num_splits)
+ return false;
+
+ // TODO check types
+
+ return true;
+}
+
+/**
+ * @brief Split Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleSplitOut nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleSplit --- FullyConnected ---
+ * \- FullyConnected ---
+ *
+ * will be created like this
+ *
+ * --- CircleSplit --- CircleSplitOut --- FullyConnected ---
+ * \- CircleSplitOut --- FullyConnected ---
+ */
+
+void CircleSplitGraphBuilder::build(const circle::OperatorT &op, GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ // Create CircleSplit
+ auto node = graph->nodes()->create<CircleSplit>();
+ node->split_dim(input_nodes[0]);
+ node->input(input_nodes[1]);
+
+ const auto *options = op.builtin_options.AsSplitOptions();
+ node->num_split(options->num_splits);
+
+ assert(outputs.size() > 0);
+ assert(int32_t(outputs.size()) == options->num_splits);
+ {
+ // Let's use name of output 0 as Split name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for Split itself but to virtual outputs
+ }
+
+ // Create virtual outputs of Split
+ for (int32_t n = 0; n < options->num_splits; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleSplitOut>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSplitV.cpp b/compiler/luci/import/src/Nodes/CircleSplitV.cpp
new file mode 100644
index 000000000..7c6e83e17
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSplitV.cpp
@@ -0,0 +1,121 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSplitV.h"
+
+#include <luci/IR/Nodes/CircleSplitV.h>
+#include <luci/IR/Nodes/CircleSplitVOut.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleSplitVGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ const auto *options = args.op.builtin_options.AsSplitVOptions();
+
+ if (inputs.size() != 3)
+ return false;
+
+ if (static_cast<int32_t>(outputs.size()) != options->num_splits)
+ return false;
+
+ // TODO check types
+
+ return true;
+}
+
+/**
+ * @brief SplitV Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleSplitVOut nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleSplitV --- FullyConnected ---
+ * \- FullyConnected ---
+ *
+ * will be created like this
+ *
+ * --- CircleSplitV --- CircleSplitVOut --- FullyConnected ---
+ * \- CircleSplitVOut --- FullyConnected ---
+ */
+
+void CircleSplitVGraphBuilder::build(const circle::OperatorT &op,
+ GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ // Create CircleSplitV
+ auto node = graph->nodes()->create<CircleSplitV>();
+ node->input(input_nodes[0]);
+ node->size_splits(input_nodes[1]);
+ node->split_dim(input_nodes[2]);
+
+ const auto *options = op.builtin_options.AsSplitVOptions();
+ node->num_split(options->num_splits);
+
+ assert(outputs.size() > 0);
+ assert(int32_t(outputs.size()) == options->num_splits);
+ {
+ // Let's use name of output 0 as Split name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for Split itself but to virtual outputs
+ }
+
+ // Create virtual outputs of Split
+ for (int32_t n = 0; n < options->num_splits; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleSplitVOut>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSqrt.cpp b/compiler/luci/import/src/Nodes/CircleSqrt.cpp
new file mode 100644
index 000000000..8a90f6691
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSqrt.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSqrt.h"
+
+#include <luci/IR/Nodes/CircleSqrt.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSqrtGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSqrtGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSqrt>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSquare.cpp b/compiler/luci/import/src/Nodes/CircleSquare.cpp
new file mode 100644
index 000000000..8398548b6
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSquare.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSquare.h"
+
+#include <luci/IR/Nodes/CircleSquare.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSquareGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+
+ // Must be one of the following types
+ // bfloat16, half (float16), float32, float64, complex64, complex128
+ // Currently, circle supports float16, float32, complex64
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_COMPLEX64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleSquareGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSquare>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp b/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp
new file mode 100644
index 000000000..93ce959e2
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp
@@ -0,0 +1,77 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSquaredDifference.h"
+
+#include <luci/IR/Nodes/CircleSquaredDifference.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleSquaredDifferenceGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ // Inputs must be one of the following types
+ // bfloat16, half(float16), float32, float64, int32, int64, complex64, complex128
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_FLOAT64:
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ case circle::TensorType_COMPLEX64:
+ break;
+ // TODO support bfloat16, complex128
+ default:
+ return false;
+ }
+
+ // Input types must match
+ if (tensors.at(inputs[0])->type != tensors.at(inputs[1])->type)
+ return false;
+
+ // Input and output types must match
+ if (tensors.at(inputs[0])->type != tensors.at(outputs[0])->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSquaredDifferenceGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSquaredDifference>();
+ node->x(inputs[0]);
+ node->y(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSqueeze.cpp b/compiler/luci/import/src/Nodes/CircleSqueeze.cpp
new file mode 100644
index 000000000..a5252d0bb
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSqueeze.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSqueeze.h"
+
+#include <luci/IR/Nodes/CircleConst.h>
+#include <luci/IR/Nodes/CircleSqueeze.h>
+
+namespace luci
+{
+
+bool CircleSqueezeGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSqueezeGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSqueeze>();
+ node->input(inputs[0]);
+
+ const auto *options = op.builtin_options.AsSqueezeOptions();
+ assert(options);
+
+ node->squeeze_dims(options->squeeze_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp b/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp
new file mode 100644
index 000000000..95e446704
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "luci/Import/Nodes/CircleStridedSlice.h"
+
+#include <luci/IR/Nodes/CircleStridedSlice.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleStridedSliceGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 4)
+ return false;
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ // TODO check shapes and types
+
+ return true;
+}
+
+CircleNode *CircleStridedSliceGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleStridedSlice>();
+ node->input(inputs[0]);
+ node->begin(inputs[1]);
+ node->end(inputs[2]);
+ node->strides(inputs[3]);
+
+ const auto *options = op.builtin_options.AsStridedSliceOptions();
+ node->begin_mask(options->begin_mask);
+ node->end_mask(options->end_mask);
+ node->ellipsis_mask(options->ellipsis_mask);
+ node->new_axis_mask(options->new_axis_mask);
+ node->shrink_axis_mask(options->shrink_axis_mask);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleSum.cpp b/compiler/luci/import/src/Nodes/CircleSum.cpp
new file mode 100644
index 000000000..b4865de59
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleSum.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "luci/Import/Nodes/CircleSum.h"
+
+#include <luci/IR/Nodes/CircleSum.h>
+
+namespace luci
+{
+
+bool CircleSumGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 2)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleSumGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleSum>();
+ node->input(inputs[0]);
+ node->reduction_indices(inputs[1]);
+
+ const auto *options = op.builtin_options.AsReducerOptions();
+ node->keep_dims(options->keep_dims);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleTanh.cpp b/compiler/luci/import/src/Nodes/CircleTanh.cpp
new file mode 100644
index 000000000..8986378c4
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleTanh.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "luci/Import/Nodes/CircleTanh.h"
+
+#include <luci/IR/Nodes/CircleTanh.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleTanhGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ if (inputs.size() != 1)
+ return false;
+
+ // Must be one of the following types
+ // bfloat16, half (float16), float32, float64, complex64, complex128
+ // Currently, circle supports float16, float32, complex64
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_FLOAT16:
+ case circle::TensorType_FLOAT32:
+ case circle::TensorType_COMPLEX64:
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+CircleNode *CircleTanhGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleTanh>();
+ node->x(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleTile.cpp b/compiler/luci/import/src/Nodes/CircleTile.cpp
new file mode 100644
index 000000000..91054ce7f
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleTile.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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 "luci/Import/Nodes/CircleTile.h"
+
+#include <luci/IR/Nodes/CircleTile.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleTileGraphBuilder::validate(const ValidateArgs &args) const
+{
+ auto inputs = args.op.inputs;
+ auto outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ // Multiples (inputs[1]) must be one of the following types
+ // int32, int64
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[1]);
+ switch (tensor->type)
+ {
+ case circle::TensorType_INT32:
+ case circle::TensorType_INT64:
+ break;
+ default:
+ return false;
+ }
+
+ // Type of input and output must be the same
+ if (tensors.at(inputs[0])->type != tensors.at(outputs[0])->type)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleTileGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleTile>();
+ node->input(inputs[0]);
+ node->multiples(inputs[1]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleTopKV2.cpp b/compiler/luci/import/src/Nodes/CircleTopKV2.cpp
new file mode 100644
index 000000000..5c1051c43
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleTopKV2.cpp
@@ -0,0 +1,117 @@
+/*
+ * 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 "luci/Import/Nodes/CircleTopKV2.h"
+
+#include <luci/IR/Nodes/CircleTopKV2.h>
+#include <luci/IR/Nodes/CircleTopKV2Out.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleTopKV2GraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 2)
+ return false;
+ if (outputs.size() != 2)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[1]);
+ if (tensor->type != circle::TensorType_INT32)
+ return false;
+
+ return true;
+}
+
+/**
+ * @brief TopKV2 Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleTopKV2Out nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleTopKV2--- FullyConnected ---
+ * \- FullyConnected ---
+ *
+ * will be created like this
+ *
+ * --- CircleTopKV2 --- CircleTopKV2Out --- FullyConnected ---
+ * \- CircleTopKV2Out --- FullyConnected ---
+ */
+
+void CircleTopKV2GraphBuilder::build(const circle::OperatorT &op,
+ GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ // Create CircleTopKV2
+ auto node = graph->nodes()->create<CircleTopKV2>();
+ node->input(input_nodes[0]);
+ node->k(input_nodes[1]);
+
+ assert(outputs.size() == 2);
+ {
+ // Let's use name of output 0 as TopKV2 name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for TopKV2 itself but to virtual outputs
+ }
+
+ // Create virtual outputs of TopKV2
+ for (size_t n = 0; n < outputs.size(); ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleTopKV2Out>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp b/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp
new file mode 100644
index 000000000..7bdf46daa
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "luci/Import/Nodes/CircleTransposeConv.h"
+
+#include <luci/IR/Nodes/CircleTransposeConv.h>
+
+#include <loco.h>
+
+#include <cassert>
+
+namespace luci
+{
+
+bool CircleTransposeConvGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 3)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleTransposeConvGraphBuilder::build_node(const circle::OperatorT &op,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleTransposeConv>();
+
+ node->inputSizes(inputs[0]);
+ node->filter(inputs[1]);
+ node->outBackprop(inputs[2]);
+
+ const auto *options = op.builtin_options.AsTransposeConvOptions();
+ node->padding(luci_padding(options->padding));
+ node->stride()->w(options->stride_w);
+ node->stride()->h(options->stride_h);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleUnpack.cpp b/compiler/luci/import/src/Nodes/CircleUnpack.cpp
new file mode 100644
index 000000000..c4282e24f
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleUnpack.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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 "luci/Import/Nodes/CircleUnpack.h"
+
+#include <luci/IR/Nodes/CircleUnpack.h>
+#include <luci/IR/Nodes/CircleUnpackOut.h>
+
+#include <luci/UserSettings.h>
+#include <luci/Log.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleUnpackGraphBuilder::validate(const ValidateArgs &args) const
+{
+ LOGGER(l);
+
+ auto settings = luci::UserSettings::settings();
+
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+ const auto *options = args.op.builtin_options.AsUnpackOptions();
+
+ if (inputs.size() != 1)
+ return false;
+
+ // NOTE real models may have mismatch
+ if (static_cast<int32_t>(outputs.size()) != options->num)
+ {
+ if (settings->get(luci::UserSettings::Key::DisableValidation))
+ {
+ const auto &tensors = args.reader.tensors();
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ auto name = tensor_name(output_tensor);
+ WARN(l) << "Warning: import Unpack(" << name << ") 'num' is not same as outputs used";
+ }
+ else
+ return false;
+ }
+
+ if (options->num < 0)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor = tensors.at(inputs[0]);
+ const auto &shape = tensor->shape;
+ auto shape_size = static_cast<int32_t>(shape.size());
+ if (shape_size > 0)
+ {
+ // NOTE for unknown shape, shape_size is 0
+ if (options->axis < -shape_size || options->axis >= shape_size)
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * @brief Unpack Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleUnpackOut nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleUnpack --- FullyConnected ---
+ * \- FullyConnected ---
+ *
+ * will be created like this
+ *
+ * --- CircleUnpack --- CircleUnpackOut --- FullyConnected ---
+ * \- CircleUnpackOut --- FullyConnected ---
+ */
+
+void CircleUnpackGraphBuilder::build(const circle::OperatorT &op,
+ GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+ auto tensors_ptr = context->reader()->tensors_ptr();
+ assert(tensors_ptr != nullptr);
+
+ // NOTE Unpack has only one input so running a loop is not necessary
+ // This is provided as a reference for other Ops as a reference
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ // Create CircleUnpack
+ CircleUnpack *node = graph->nodes()->create<CircleUnpack>();
+ node->value(input_nodes[0]);
+
+ const auto *options = op.builtin_options.AsUnpackOptions();
+ node->num(options->num);
+ node->axis(options->axis);
+
+ assert(outputs.size() > 0);
+ {
+ // Let's use name of output 0 as Unpack name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for Unpack itself but to virtual outputs
+ }
+
+ // Create virtual outputs of Unpack
+ for (int32_t n = 0; n < options->num; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleUnpackOut>();
+ copy_tensor_attributes(output_tensor, nodeout);
+ // mark shape_status
+ if (tensors_ptr->Get(outputs[n])->shape() == nullptr)
+ nodeout->shape_status(ShapeStatus::NOSHAPE);
+ else
+ nodeout->shape_status(ShapeStatus::VALID);
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleWhere.cpp b/compiler/luci/import/src/Nodes/CircleWhere.cpp
new file mode 100644
index 000000000..a13c4d6c9
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleWhere.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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 "luci/Import/Nodes/CircleWhere.h"
+
+#include <luci/IR/Nodes/CircleWhere.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleWhereGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 1)
+ return false;
+
+ if (outputs.size() != 1)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &tensor_condition = tensors.at(inputs[0]);
+ const auto &tensor_out = tensors.at(outputs[0]);
+
+ if (tensor_condition->type != circle::TensorType_BOOL)
+ return false;
+
+ if (tensor_out->type != circle::TensorType_INT64)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleWhereGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleWhere>();
+ node->condition(inputs[0]);
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleWhile.cpp b/compiler/luci/import/src/Nodes/CircleWhile.cpp
new file mode 100644
index 000000000..aead25071
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleWhile.cpp
@@ -0,0 +1,123 @@
+/*
+ * 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 "luci/Import/Nodes/CircleWhile.h"
+
+#include <luci/IR/Nodes/CircleWhile.h>
+#include <luci/IR/Nodes/CircleWhileOut.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleWhileGraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto *options = args.op.builtin_options.AsWhileOptions();
+
+ if (inputs.size() != args.op.outputs.size())
+ return false;
+
+ auto num_graphs = static_cast<int32_t>(args.reader.num_subgraph());
+ if (options->cond_subgraph_index >= num_graphs)
+ return false;
+ if (options->body_subgraph_index >= num_graphs)
+ return false;
+
+ return true;
+}
+
+/**
+ * @brief While Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple CircleWhileOut nodes to emulate this
+ * For two outputs that may look like this
+ *
+ * --- CircleWhile --- Node ---
+ * \- Node ---
+ *
+ * will be created like this
+ *
+ * --- CircleWhile --- CircleWhileOut --- Node ---
+ * \- CircleWhileOut --- Node ---
+ */
+
+void CircleWhileGraphBuilder::build(const circle::OperatorT &op, GraphBuilderContext *context) const
+{
+ assert(context != nullptr);
+
+ auto graph = context->graph();
+
+ const std::vector<int32_t> &inputs = op.inputs;
+ const std::vector<int32_t> &outputs = op.outputs;
+ const auto &tensors = context->reader()->tensors();
+ const auto &opcodes = context->reader()->opcodes();
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ auto input_node = context->nodefinder()->node(input_tensor_index);
+ assert(input_node != nullptr);
+ input_nodes.push_back(input_node);
+ }
+
+ uint32_t input_count = inputs.size();
+ uint32_t output_count = outputs.size();
+
+ // Create CircleWhile
+ CircleWhile *node = graph->nodes()->create<CircleWhile>(input_count, output_count);
+
+ for (uint32_t idx = 0; idx < input_count; ++idx)
+ {
+ node->input(idx, input_nodes[idx]);
+ }
+
+ const auto *options = op.builtin_options.AsWhileOptions();
+ node->cond_branch(options->cond_subgraph_index);
+ node->body_branch(options->body_subgraph_index);
+
+ assert(outputs.size() > 0);
+ {
+ // Lets use name of output 0 as While name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+ node->op_version(opcodes[op.opcode_index].get()->version);
+
+ // NOTE We don't set quantization for While itself but to virtual outputs
+ }
+
+ // Create virtual outputs of While
+ for (uint32_t n = 0; n < output_count; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleWhileOut>();
+
+ nodeout->input(node);
+ nodeout->index(n);
+
+ copy_tensor_attributes(output_tensor, nodeout);
+
+ // Note: leave shape_status to UNKNOWN to run shape inference
+
+ context->nodefinder()->enroll(outputs[n], nodeout);
+ }
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/Nodes/CircleZerosLike.cpp b/compiler/luci/import/src/Nodes/CircleZerosLike.cpp
new file mode 100644
index 000000000..4362925cd
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleZerosLike.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "luci/Import/Nodes/CircleZerosLike.h"
+
+#include <luci/IR/Nodes/CircleZerosLike.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleZerosLikeGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 1)
+ return false;
+
+ return true;
+}
+
+CircleNode *CircleZerosLikeGraphBuilder::build_node(const circle::OperatorT &,
+ const std::vector<CircleNode *> &inputs,
+ loco::Graph *graph) const
+{
+ auto *node = graph->nodes()->create<CircleZerosLike>();
+ node->input(inputs[0]);
+
+ // ZerosLikeOptinos are empty
+
+ return node;
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/PostImport.cpp b/compiler/luci/import/src/PostImport.cpp
new file mode 100644
index 000000000..f436b48e8
--- /dev/null
+++ b/compiler/luci/import/src/PostImport.cpp
@@ -0,0 +1,354 @@
+/*
+ * 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 "PostImport.h"
+
+#include "luci/Import/CircleReader.h"
+
+#include <luci/IR/CircleNodes.h>
+#include <luci/IR/CircleDialect.h>
+#include <luci/IR/CircleNodeVisitor.h>
+#include <luci/Log.h>
+
+#include <loco.h>
+#include <oops/InternalExn.h>
+
+namespace
+{
+
+/**
+ * @brief FixInterGraphNodes will fix inter graph connections for each Nodes
+ */
+class FixInterGraphNodes final : public luci::CircleNodeMutableVisitor<void>
+{
+public:
+ FixInterGraphNodes(const luci::Module *m, const luci::CircleReader &r) : _module(m), _reader(r) {}
+
+ /**
+ * @note This will set Graph* to every CircleIf nodes 'else' and 'then'
+ */
+ void visit(luci::CircleIf *node) final
+ {
+ LOGGER(l);
+ INFO(l) << "CircleIf " << node->name() << std::endl;
+
+ auto then_branch = node->then_branch();
+ auto else_branch = node->else_branch();
+ auto num_graphs = static_cast<int32_t>(_module->size());
+ (void)num_graphs;
+
+ assert(num_graphs > 0);
+ assert(then_branch >= 0 && then_branch < num_graphs);
+ assert(else_branch >= 0 && else_branch < num_graphs);
+
+ auto then_graph = _module->graph(then_branch);
+ auto else_graph = _module->graph(else_branch);
+ assert(then_graph != nullptr);
+ assert(else_graph != nullptr);
+
+ node->then_graph(then_graph);
+ node->else_graph(else_graph);
+ }
+
+ void visit(luci::CircleWhile *node) final
+ {
+ LOGGER(l);
+ INFO(l) << "CircleWhile " << node->name() << std::endl;
+
+ auto cond_branch = node->cond_branch();
+ auto body_branch = node->body_branch();
+ auto num_graphs = static_cast<int32_t>(_module->size());
+ (void)num_graphs;
+
+ assert(num_graphs > 0);
+ assert(cond_branch >= 0 && cond_branch < num_graphs);
+ assert(body_branch >= 0 && body_branch < num_graphs);
+
+ auto cond_graph = _module->graph(cond_branch);
+ auto body_graph = _module->graph(body_branch);
+ assert(cond_graph != nullptr);
+ assert(body_graph != nullptr);
+
+ node->cond_graph(cond_graph);
+ node->body_graph(body_graph);
+ }
+
+ void visit(luci::CircleNode *) final
+ {
+ // DO NOTHING
+ }
+
+private:
+ const luci::Module *_module;
+ const luci::CircleReader &_reader;
+};
+
+/**
+ * @brief FixInterGraph will fix inter graph connections
+ */
+class FixInterGraph final
+{
+public:
+ void run(loco::Graph *g, const luci::Module *m, const luci::CircleReader &r)
+ {
+ for (auto node : loco::postorder_traversal(loco::output_nodes(g)))
+ {
+ if (recognize(node->dialect()))
+ {
+ auto cn = loco::must_cast<luci::CircleNode *>(node);
+
+ fix(cn, m, r);
+ }
+ }
+ }
+
+private:
+ bool recognize(const loco::Dialect *dialect) { return (dialect == luci::CircleDialect::get()); }
+
+ void fix(luci::CircleNode *node, const luci::Module *module, const luci::CircleReader &reader)
+ {
+ FixInterGraphNodes fix(module, reader);
+ node->accept(&fix);
+ }
+};
+
+} // namespace
+
+namespace
+{
+/**
+ * @brief ValidateNodeProp will validate inter graph connections for each Nodes
+ */
+class ValidateNodeProp final : public luci::CircleNodeMutableVisitor<void>
+{
+public:
+ ValidateNodeProp(const luci::Module *m, const luci::CircleReader &r) : _module(m), _reader(r) {}
+
+ /**
+ * @note Validate CircleIf node 'else' and 'then' graph input/output count
+ * shape and type
+ */
+ void visit(luci::CircleIf *node) final
+ {
+ LOGGER(l);
+ INFO(l) << "CircleIf " << node->name() << std::endl;
+
+ auto then_graph = node->then_graph();
+ auto else_graph = node->else_graph();
+ assert(then_graph != nullptr);
+ assert(else_graph != nullptr);
+
+ // TODO support for differnt shape; but how?
+ // NODE Shape/Type inference assume below conditions
+
+ // Check both "then" and "else" subgraph outputs are same in count
+ auto then_outputs = loco::output_nodes(then_graph); // CircleOutput nodes
+ auto else_outputs = loco::output_nodes(else_graph);
+ if (then_outputs.size() != else_outputs.size())
+ {
+ INTERNAL_EXN("CircleIf THEN and ELSE Graph are not same in size");
+ }
+
+ // check outputs have same shape and dtype
+ auto then_graph_outputs = then_graph->outputs(); // loco::GraphOutput items
+ auto else_graph_outputs = else_graph->outputs();
+ for (size_t idx = 0; idx < then_outputs.size(); ++idx)
+ {
+ auto then_out = loco::must_cast<luci::CircleOutput *>(then_outputs.at(idx));
+ auto else_out = loco::must_cast<luci::CircleOutput *>(else_outputs.at(idx));
+
+ auto then_graph_output = then_graph_outputs->at(then_out->index());
+ auto else_graph_output = else_graph_outputs->at(else_out->index());
+ if (!(*then_graph_output->shape() == *else_graph_output->shape()))
+ {
+ INTERNAL_EXN_V("CircleIf THEN and ELSE Graph Output shape mismatch ", idx);
+ }
+ if (then_graph_output->dtype() != else_graph_output->dtype())
+ {
+ INTERNAL_EXN_V("CircleIf THEN and ELSE Graph Output type mismatch ", idx);
+ }
+ }
+ }
+
+ /**
+ * @note Validate CircleWhile node 'cond' and 'body' graph input/output count
+ * shape and type
+ */
+ void visit(luci::CircleWhile *node) final
+ {
+ LOGGER(l);
+ INFO(l) << "CircleWhile " << node->name() << std::endl;
+
+ auto cond_graph = node->cond_graph();
+ auto body_graph = node->body_graph();
+ assert(cond_graph != nullptr);
+ assert(body_graph != nullptr);
+
+ // Check input of "cond" and input/output of "body" subgraph have the same size
+ auto cond_inputs = loco::input_nodes(cond_graph);
+ auto cond_outputs = loco::output_nodes(cond_graph);
+ auto body_inputs = loco::input_nodes(body_graph);
+ auto body_outputs = loco::output_nodes(body_graph);
+ if (cond_inputs.size() != body_outputs.size())
+ {
+ INTERNAL_EXN("CircleWhile COND input and BODY output have different sizes");
+ }
+ if (cond_inputs.size() != body_inputs.size())
+ {
+ INTERNAL_EXN("CircleWhile COND input and BODY input have different sizes");
+ }
+ if (cond_outputs.size() != 1)
+ {
+ INTERNAL_EXN("CircleWhile COND output must have size 1");
+ }
+ auto cond_out = loco::must_cast<luci::CircleOutput *>(cond_outputs.at(0));
+ if (cond_out->dtype() != loco::DataType::BOOL)
+ {
+ INTERNAL_EXN("CircleWhile COND output must have bool type");
+ }
+
+ // input of "cond" and input/output of "body" subgraph must have the same shape and type
+ // First we compare input of "cond" with input of "body"
+ auto cond_graph_inputs = cond_graph->inputs();
+ auto body_graph_inputs = body_graph->inputs();
+ for (size_t idx = 0; idx < cond_inputs.size(); ++idx)
+ {
+ auto cond_in = loco::must_cast<luci::CircleInput *>(cond_inputs.at(idx));
+ auto body_in = loco::must_cast<luci::CircleInput *>(body_inputs.at(idx));
+
+ auto cond_graph_input = cond_graph_inputs->at(cond_in->index());
+ auto body_graph_input = body_graph_inputs->at(body_in->index());
+ if ((cond_in->rank() != body_in->rank()))
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY input shape mismatch ", idx);
+ }
+ if (cond_in->rank() > 0 && body_in->rank() > 0)
+ {
+ if (!(*cond_graph_input->shape() == *body_graph_input->shape()))
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY input shape mismatch ", idx);
+ }
+ }
+ if (cond_in->dtype() != body_in->dtype())
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY input type mismatch ", idx);
+ }
+ }
+
+ // Next we compare input of "cond" with output of "body"
+ auto body_graph_outputs = body_graph->outputs();
+ for (size_t idx = 0; idx < cond_inputs.size(); ++idx)
+ {
+ auto cond_in = loco::must_cast<luci::CircleInput *>(cond_inputs.at(idx));
+ auto body_out = loco::must_cast<luci::CircleOutput *>(body_outputs.at(idx));
+
+ auto cond_graph_input = cond_graph_inputs->at(cond_in->index());
+ auto body_graph_output = body_graph_outputs->at(body_out->index());
+ if ((cond_in->rank() != body_out->rank()))
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY output shape mismatch ", idx);
+ }
+ if (cond_in->rank() > 0 && body_out->rank() > 0)
+ {
+ if (!(*cond_graph_input->shape() == *body_graph_output->shape()))
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY output shape mismatch ", idx);
+ }
+ }
+ if (cond_in->dtype() != body_out->dtype())
+ {
+ INTERNAL_EXN_V("CircleWhile COND input and BODY output type mismatch ", idx);
+ }
+ }
+ }
+
+ void visit(luci::CircleNode *) final
+ {
+ // DO NOTHING
+ }
+
+private:
+ const luci::Module *_module;
+ const luci::CircleReader &_reader;
+};
+
+/**
+ * @brief ValidateGraphProp will validate inter graph node properties
+ */
+class ValidateGraphProp final
+{
+public:
+ void run(loco::Graph *g, const luci::Module *m, const luci::CircleReader &r)
+ {
+ for (auto node : loco::postorder_traversal(loco::output_nodes(g)))
+ {
+ if (recognize(node->dialect()))
+ {
+ auto cn = loco::must_cast<luci::CircleNode *>(node);
+
+ eval(cn, m, r);
+ }
+ }
+ }
+
+private:
+ bool recognize(const loco::Dialect *dialect) { return (dialect == luci::CircleDialect::get()); }
+
+ void eval(luci::CircleNode *node, const luci::Module *module, const luci::CircleReader &reader)
+ {
+ ValidateNodeProp val(module, reader);
+ node->accept(&val);
+ }
+};
+
+} // namespace
+
+namespace luci
+{
+
+/**
+ * @brief Do post import actions
+ */
+void post_import_graph(luci::Module *module, const luci::CircleReader &reader)
+{
+ LOGGER(l);
+
+ auto count = module->size();
+
+ for (size_t s = 0; s < count; ++s)
+ {
+ auto g = module->graph(s);
+ assert(g != nullptr);
+
+ INFO(l) << "--- FixInterGraph " << g->name() << "-------------------------";
+ FixInterGraph fix;
+ fix.run(g, module, reader);
+ }
+
+ for (size_t s = 0; s < count; ++s)
+ {
+ auto g = module->graph(s);
+ assert(g != nullptr);
+
+ INFO(l) << "--- ValidateGraphProp " << g->name() << "---------------------";
+ ValidateGraphProp prop;
+ prop.run(g, module, reader);
+ }
+
+ INFO(l) << "--- post_import_graph done -------------------------------------";
+}
+
+} // namespace luci
diff --git a/compiler/luci/import/src/PostImport.h b/compiler/luci/import/src/PostImport.h
new file mode 100644
index 000000000..c719c588a
--- /dev/null
+++ b/compiler/luci/import/src/PostImport.h
@@ -0,0 +1,34 @@
+/*
+ * 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 __LUCI_POST_IMPORT_H__
+#define __LUCI_POST_IMPORT_H__
+
+#include "luci/Import/CircleReader.h"
+
+#include "luci/IR/Module.h"
+
+namespace luci
+{
+
+/**
+ * @brief Do post import actions
+ */
+void post_import_graph(luci::Module *module, const luci::CircleReader &reader);
+
+} // namespace luci
+
+#endif // __LUCI_POST_IMPORT_H__