summaryrefslogtreecommitdiff
path: root/compiler/luci/import
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2020-08-14 15:19:19 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2020-08-14 15:19:19 +0900
commit042b262b3633b6c0f577aed6cb4b980ad0c1dcf3 (patch)
treee79fb9ffe65b21bdc5863306db2757ab187a3306 /compiler/luci/import
parent05e0ec30a632339a8533082476f27bda31ccde16 (diff)
downloadnnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.gz
nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.tar.bz2
nnfw-042b262b3633b6c0f577aed6cb4b980ad0c1dcf3.zip
Imported Upstream version 1.8.0upstream/1.8.0submit/tizen/20200814.062151
Diffstat (limited to 'compiler/luci/import')
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes.h2
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleNonMaxSuppressionV4.h35
-rw-r--r--compiler/luci/import/include/luci/Import/Nodes/CircleUnique.h35
-rw-r--r--compiler/luci/import/src/CircleReader.cpp2
-rw-r--r--compiler/luci/import/src/GraphBuilderRegistry.cpp4
-rw-r--r--compiler/luci/import/src/Importer.test.cpp7
-rw-r--r--compiler/luci/import/src/Nodes/CircleAbs.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleAdd.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleArgMax.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleArgMin.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleAveragePool2D.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp10
-rw-r--r--compiler/luci/import/src/Nodes/CircleBCQGather.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleBatchToSpaceND.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleCast.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleCeil.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleConv2D.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleCos.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleDiv.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleElu.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleEqual.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleExp.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleExpandDims.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleFill.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloor.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloorDiv.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleFloorMod.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleFullyConnected.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleGather.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleGatherNd.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleGreater.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleIf.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleL2Normalize.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleLess.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleLessEqual.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleLog.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogicalNot.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogicalOr.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleLogistic.cpp18
-rw-r--r--compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleMaxPool2D.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleMaximum.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleMean.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleMinimum.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleMirrorPad.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleMul.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleNeg.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleNonMaxSuppressionV4.cpp123
-rw-r--r--compiler/luci/import/src/Nodes/CircleNotEqual.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleOneHot.cpp16
-rw-r--r--compiler/luci/import/src/Nodes/CirclePRelu.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CirclePad.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CirclePow.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleRange.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleRank.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceAny.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceMax.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceMin.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleReduceProd.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleRelu.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleRelu6.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleReluN1To1.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleReshape.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleReverseSequence.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleReverseV2.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleRound.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleRsqrt.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleScatterNd.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleSegmentSum.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleSelect.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleSelectV2.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleShape.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleSin.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleSlice.cpp6
-rw-r--r--compiler/luci/import/src/Nodes/CircleSoftmax.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp12
-rw-r--r--compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleSparseToDense.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleSqrt.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleSquare.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp10
-rw-r--r--compiler/luci/import/src/Nodes/CircleSqueeze.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleStridedSlice.cpp8
-rw-r--r--compiler/luci/import/src/Nodes/CircleSub.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleSum.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleTanh.cpp20
-rw-r--r--compiler/luci/import/src/Nodes/CircleTile.cpp10
-rw-r--r--compiler/luci/import/src/Nodes/CircleTopKV2.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleTranspose.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleTransposeConv.cpp24
-rw-r--r--compiler/luci/import/src/Nodes/CircleUnique.cpp89
-rw-r--r--compiler/luci/import/src/Nodes/CircleUnpack.cpp2
-rw-r--r--compiler/luci/import/src/Nodes/CircleWhere.cpp4
-rw-r--r--compiler/luci/import/src/Nodes/CircleZerosLike.cpp2
107 files changed, 565 insertions, 278 deletions
diff --git a/compiler/luci/import/include/luci/Import/Nodes.h b/compiler/luci/import/include/luci/Import/Nodes.h
index 2719a5aec..825c2147d 100644
--- a/compiler/luci/import/include/luci/Import/Nodes.h
+++ b/compiler/luci/import/include/luci/Import/Nodes.h
@@ -73,6 +73,7 @@
#include "Nodes/CircleMirrorPad.h"
#include "Nodes/CircleMul.h"
#include "Nodes/CircleNeg.h"
+#include "Nodes/CircleNonMaxSuppressionV4.h"
#include "Nodes/CircleNotEqual.h"
#include "Nodes/CircleOneHot.h"
#include "Nodes/CirclePack.h"
@@ -120,6 +121,7 @@
#include "Nodes/CircleTopKV2.h"
#include "Nodes/CircleTranspose.h"
#include "Nodes/CircleTransposeConv.h"
+#include "Nodes/CircleUnique.h"
#include "Nodes/CircleUnpack.h"
#include "Nodes/CircleWhere.h"
#include "Nodes/CircleWhile.h"
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleNonMaxSuppressionV4.h b/compiler/luci/import/include/luci/Import/Nodes/CircleNonMaxSuppressionV4.h
new file mode 100644
index 000000000..f193aae35
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleNonMaxSuppressionV4.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_NON_MAX_SUPPRESSION_V4_H__
+#define __LUCI_IMPORT_OP_CIRCLE_NON_MAX_SUPPRESSION_V4_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleNonMaxSuppressionV4GraphBuilder : 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_NON_MAX_SUPPRESSION_V4_H__
diff --git a/compiler/luci/import/include/luci/Import/Nodes/CircleUnique.h b/compiler/luci/import/include/luci/Import/Nodes/CircleUnique.h
new file mode 100644
index 000000000..ed5b5035d
--- /dev/null
+++ b/compiler/luci/import/include/luci/Import/Nodes/CircleUnique.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_UNIQUE_H__
+#define __LUCI_IMPORT_OP_CIRCLE_UNIQUE_H__
+
+#include "luci/Import/GraphBuilderBase.h"
+
+namespace luci
+{
+
+class CircleUniqueGraphBuilder : 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_UNIQUE_H__
diff --git a/compiler/luci/import/src/CircleReader.cpp b/compiler/luci/import/src/CircleReader.cpp
index 81e945dd1..bc7f39762 100644
--- a/compiler/luci/import/src/CircleReader.cpp
+++ b/compiler/luci/import/src/CircleReader.cpp
@@ -156,6 +156,7 @@ luci_quantparam(const circle::QuantizationParametersT *quantization)
const auto &max = quantization->max;
const auto &scale = quantization->scale;
const auto &zero_point = quantization->zero_point;
+ const auto &quantized_dimension = quantization->quantized_dimension;
if ((!min.empty() && !max.empty()) || (!scale.empty() && !zero_point.empty()))
{
@@ -165,6 +166,7 @@ luci_quantparam(const circle::QuantizationParametersT *quantization)
quantparam->max = max;
quantparam->scale = scale;
quantparam->zerop = zero_point;
+ quantparam->quantized_dimension = quantized_dimension;
return quantparam;
}
diff --git a/compiler/luci/import/src/GraphBuilderRegistry.cpp b/compiler/luci/import/src/GraphBuilderRegistry.cpp
index d29557f74..cc328cc16 100644
--- a/compiler/luci/import/src/GraphBuilderRegistry.cpp
+++ b/compiler/luci/import/src/GraphBuilderRegistry.cpp
@@ -82,6 +82,7 @@ GraphBuilderRegistry::GraphBuilderRegistry()
CIRCLE_NODE(MIRROR_PAD, CircleMirrorPadGraphBuilder); // 100
CIRCLE_NODE(MUL, CircleMulGraphBuilder); // 18
CIRCLE_NODE(NEG, CircleNegGraphBuilder); // 59
+ CIRCLE_NODE(NON_MAX_SUPPRESSION_V4, CircleNonMaxSuppressionV4GraphBuilder); // 120,
CIRCLE_NODE(NOT_EQUAL, CircleNotEqualGraphBuilder); // 72
CIRCLE_NODE(ONE_HOT, CircleOneHotGraphBuilder); // 85
CIRCLE_NODE(PACK, CirclePackGraphBuilder); // 83
@@ -129,6 +130,7 @@ GraphBuilderRegistry::GraphBuilderRegistry()
CIRCLE_NODE(TOPK_V2, CircleTopKV2GraphBuilder); // 48
CIRCLE_NODE(TRANSPOSE, CircleTransposeGraphBuilder); // 39
CIRCLE_NODE(TRANSPOSE_CONV, CircleTransposeConvGraphBuilder); // 67
+ CIRCLE_NODE(UNIQUE, CircleUniqueGraphBuilder); // 103
CIRCLE_NODE(UNPACK, CircleUnpackGraphBuilder); // 88
CIRCLE_NODE(WHERE, CircleWhereGraphBuilder); // 109
CIRCLE_NODE(WHILE, CircleWhileGraphBuilder); // 119
@@ -155,10 +157,8 @@ GraphBuilderRegistry::GraphBuilderRegistry()
// BuiltinOperator_ARG_MAX = 56,
// BuiltinOperator_PADV2 = 60,
// BuiltinOperator_FAKE_QUANT = 80,
- // BuiltinOperator_UNIQUE = 103,
// BuiltinOperator_QUANTIZE = 114,
// BuiltinOperator_HARD_SWISH = 117,
- // BuiltinOperator_NON_MAX_SUPPRESSION_V4 = 120,
// BuiltinOperator_NON_MAX_SUPPRESSION_V5 = 121,
// BuiltinOperator_DENSIFY = 124,
}
diff --git a/compiler/luci/import/src/Importer.test.cpp b/compiler/luci/import/src/Importer.test.cpp
index 4426e15fd..8366546f0 100644
--- a/compiler/luci/import/src/Importer.test.cpp
+++ b/compiler/luci/import/src/Importer.test.cpp
@@ -20,4 +20,9 @@
#include <gtest/gtest.h>
-TEST(TensorFlowLiteImport, Dummy) { luci::Importer import; }
+TEST(TensorFlowLiteImport, Dummy)
+{
+ luci::Importer import;
+
+ SUCCEED();
+}
diff --git a/compiler/luci/import/src/Nodes/CircleAbs.cpp b/compiler/luci/import/src/Nodes/CircleAbs.cpp
index 9054986bd..3556dc7fa 100644
--- a/compiler/luci/import/src/Nodes/CircleAbs.cpp
+++ b/compiler/luci/import/src/Nodes/CircleAbs.cpp
@@ -36,7 +36,7 @@ CircleNode *CircleAbsGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleAbs>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleAdd.cpp b/compiler/luci/import/src/Nodes/CircleAdd.cpp
index 3b1bb734f..b767d4af2 100644
--- a/compiler/luci/import/src/Nodes/CircleAdd.cpp
+++ b/compiler/luci/import/src/Nodes/CircleAdd.cpp
@@ -36,8 +36,8 @@ CircleNode *CircleAddGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleAdd>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
const auto *options = op.builtin_options.AsAddOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleArgMax.cpp b/compiler/luci/import/src/Nodes/CircleArgMax.cpp
index 2679827e2..10e8516f4 100644
--- a/compiler/luci/import/src/Nodes/CircleArgMax.cpp
+++ b/compiler/luci/import/src/Nodes/CircleArgMax.cpp
@@ -36,8 +36,8 @@ CircleNode *CircleArgMaxGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleArgMax>();
- node->input(inputs[0]);
- node->dimension(inputs[1]);
+ node->input(inputs.at(0));
+ node->dimension(inputs.at(1));
const auto *options = op.builtin_options.AsArgMaxOptions();
node->output_type(luci_datatype(options->output_type));
diff --git a/compiler/luci/import/src/Nodes/CircleArgMin.cpp b/compiler/luci/import/src/Nodes/CircleArgMin.cpp
index 4d85bbff0..5ff534dbb 100644
--- a/compiler/luci/import/src/Nodes/CircleArgMin.cpp
+++ b/compiler/luci/import/src/Nodes/CircleArgMin.cpp
@@ -36,8 +36,8 @@ CircleNode *CircleArgMinGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleArgMin>();
- node->input(inputs[0]);
- node->dimension(inputs[1]);
+ node->input(inputs.at(0));
+ node->dimension(inputs.at(1));
const auto *options = op.builtin_options.AsArgMinOptions();
node->output_type(luci_datatype(options->output_type));
diff --git a/compiler/luci/import/src/Nodes/CircleAveragePool2D.cpp b/compiler/luci/import/src/Nodes/CircleAveragePool2D.cpp
index cfc3cf126..ad011f71f 100644
--- a/compiler/luci/import/src/Nodes/CircleAveragePool2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleAveragePool2D.cpp
@@ -34,7 +34,7 @@ CircleNode *CircleAveragePool2DGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleAveragePool2D>();
- node->value(inputs[0]);
+ node->value(inputs.at(0));
const auto *options = op.builtin_options.AsPool2DOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp b/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp
index 7cc077ed6..16ecebd5c 100644
--- a/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp
+++ b/compiler/luci/import/src/Nodes/CircleBCQFullyConnected.cpp
@@ -37,11 +37,11 @@ CircleNode *CircleBCQFullyConnectedGraphBuilder::build_node(const circle::Operat
{
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]);
+ node->input(inputs.at(0));
+ node->weights_scales(inputs.at(1));
+ node->weights_binary(inputs.at(2));
+ node->bias(inputs.at(3));
+ node->weights_clusters(inputs.at(4));
// TODO Find and move to appropriate place for setting optional input
if (auto bias = dynamic_cast<luci::CircleOutputExclude *>(node->bias()))
diff --git a/compiler/luci/import/src/Nodes/CircleBCQGather.cpp b/compiler/luci/import/src/Nodes/CircleBCQGather.cpp
index c6d2ab559..464f1ac18 100644
--- a/compiler/luci/import/src/Nodes/CircleBCQGather.cpp
+++ b/compiler/luci/import/src/Nodes/CircleBCQGather.cpp
@@ -37,10 +37,10 @@ CircleNode *CircleBCQGatherGraphBuilder::build_node(const circle::OperatorT &op,
{
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]);
+ node->input_scales(inputs.at(0));
+ node->input_binary(inputs.at(1));
+ node->indices(inputs.at(2));
+ node->input_clusters(inputs.at(3));
const auto *options = op.builtin_options.AsBCQGatherOptions();
node->input_hidden_size(options->input_hidden_size);
diff --git a/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp b/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp
index 6026b2a72..330775691 100644
--- a/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp
+++ b/compiler/luci/import/src/Nodes/CircleBatchMatMul.cpp
@@ -34,8 +34,8 @@ CircleNode *CircleBatchMatMulGraphBuilder::build_node(const circle::OperatorT &o
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleBatchMatMul>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
const auto *options = op.builtin_options.AsBatchMatMulOptions();
node->adj_x(options->adjoint_lhs);
diff --git a/compiler/luci/import/src/Nodes/CircleBatchToSpaceND.cpp b/compiler/luci/import/src/Nodes/CircleBatchToSpaceND.cpp
index 4bbfadf64..8c2039fff 100644
--- a/compiler/luci/import/src/Nodes/CircleBatchToSpaceND.cpp
+++ b/compiler/luci/import/src/Nodes/CircleBatchToSpaceND.cpp
@@ -33,7 +33,7 @@ bool CircleBatchToSpaceNDGraphBuilder::validate(const ValidateArgs &args) const
// input 1 and 2 should have INT32/INT64 type
const auto &tensors = args.reader.tensors();
- const auto &tensor_1 = tensors.at(inputs[1]);
+ const auto &tensor_1 = tensors.at(inputs.at(1));
switch (tensor_1->type)
{
case circle::TensorType_INT32:
@@ -42,7 +42,7 @@ bool CircleBatchToSpaceNDGraphBuilder::validate(const ValidateArgs &args) const
default:
return false;
}
- const auto &tensor_2 = tensors.at(inputs[2]);
+ const auto &tensor_2 = tensors.at(inputs.at(2));
switch (tensor_2->type)
{
case circle::TensorType_INT32:
@@ -53,7 +53,7 @@ bool CircleBatchToSpaceNDGraphBuilder::validate(const ValidateArgs &args) const
}
// Only support input shape dimension 3 and 4 only
- const auto &tensor_0 = tensors.at(inputs[0]);
+ const auto &tensor_0 = tensors.at(inputs.at(0));
const auto t_0_s = tensor_0->shape.size();
if (t_0_s != 3 && t_0_s != 4)
return false;
@@ -68,9 +68,9 @@ CircleNode *CircleBatchToSpaceNDGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleBatchToSpaceND>();
- node->input(inputs[0]);
- node->block_shape(inputs[1]);
- node->crops(inputs[2]);
+ node->input(inputs.at(0));
+ node->block_shape(inputs.at(1));
+ node->crops(inputs.at(2));
// No options for BatchToSpaceND
diff --git a/compiler/luci/import/src/Nodes/CircleCast.cpp b/compiler/luci/import/src/Nodes/CircleCast.cpp
index a4d09b505..7bdb63044 100644
--- a/compiler/luci/import/src/Nodes/CircleCast.cpp
+++ b/compiler/luci/import/src/Nodes/CircleCast.cpp
@@ -47,7 +47,7 @@ bool CircleCastGraphBuilder::validate(const ValidateArgs &args) const
const circle::TensorT &output_tensor = *tensors[outputs[0]];
auto name = tensor_name(output_tensor);
- const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_in = tensors.at(inputs.at(0));
if (tensor_in->type != options->in_data_type)
{
if (settings->get(luci::UserSettings::Key::DisableValidation))
@@ -77,7 +77,7 @@ CircleNode *CircleCastGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleCast>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
const auto *options = op.builtin_options.AsCastOptions();
if (options != nullptr)
@@ -87,7 +87,7 @@ CircleNode *CircleCastGraphBuilder::build_node(const circle::OperatorT &op,
}
else
{
- node->in_data_type(inputs[0]->dtype());
+ node->in_data_type(inputs.at(0)->dtype());
node->out_data_type(loco::DataType::Unknown);
// type inference should use node->dtype() for Unknown
// export should use BuiltinOptions_NONE for Unknown
diff --git a/compiler/luci/import/src/Nodes/CircleCeil.cpp b/compiler/luci/import/src/Nodes/CircleCeil.cpp
index d3d6cd945..2e1aaa295 100644
--- a/compiler/luci/import/src/Nodes/CircleCeil.cpp
+++ b/compiler/luci/import/src/Nodes/CircleCeil.cpp
@@ -42,7 +42,7 @@ CircleNode *CircleCeilGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleCeil>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleConv2D.cpp b/compiler/luci/import/src/Nodes/CircleConv2D.cpp
index 42c5c265a..9516ef16a 100644
--- a/compiler/luci/import/src/Nodes/CircleConv2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleConv2D.cpp
@@ -39,11 +39,11 @@ CircleNode *CircleConv2DGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleConv2D>();
- node->input(inputs[0]);
- node->filter(inputs[1]);
+ node->input(inputs.at(0));
+ node->filter(inputs.at(1));
// For now, bias is required (checked in `verify` method).
assert(inputs.size() == 3);
- node->bias(inputs[2]);
+ node->bias(inputs.at(2));
const auto *options = op.builtin_options.AsConv2DOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleCos.cpp b/compiler/luci/import/src/Nodes/CircleCos.cpp
index 5f61cc7f6..27d60c62c 100644
--- a/compiler/luci/import/src/Nodes/CircleCos.cpp
+++ b/compiler/luci/import/src/Nodes/CircleCos.cpp
@@ -36,7 +36,7 @@ CircleNode *CircleCosGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleCos>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
// No options for Cos
diff --git a/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp b/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp
index 827b63468..49d31bb99 100644
--- a/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp
+++ b/compiler/luci/import/src/Nodes/CircleDepthToSpace.cpp
@@ -40,7 +40,7 @@ bool CircleDepthToSpaceGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- if (tensors[outputs[0]]->type != tensors[inputs[0]]->type)
+ if (tensors[outputs[0]]->type != tensors[inputs.at(0)]->type)
{
return false;
}
@@ -56,7 +56,7 @@ CircleNode *CircleDepthToSpaceGraphBuilder::build_node(const circle::OperatorT &
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleDepthToSpace>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
const auto *options = op.builtin_options.AsDepthToSpaceOptions();
node->block_size(options->block_size);
diff --git a/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp b/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
index 2b13f9ebb..53f85f2f5 100644
--- a/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleDepthwiseConv2D.cpp
@@ -40,11 +40,11 @@ CircleNode *CircleDepthwiseConv2DGraphBuilder::build_node(const circle::Operator
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleDepthwiseConv2D>();
- node->input(inputs[0]);
- node->filter(inputs[1]);
+ node->input(inputs.at(0));
+ node->filter(inputs.at(1));
if (inputs.size() != 3)
throw oops::UserExn("DepthwiseConv2d without bias is unsupported");
- node->bias(inputs[2]);
+ node->bias(inputs.at(2));
const auto *options = op.builtin_options.AsDepthwiseConv2DOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleDiv.cpp b/compiler/luci/import/src/Nodes/CircleDiv.cpp
index d09cfb815..615c224d7 100644
--- a/compiler/luci/import/src/Nodes/CircleDiv.cpp
+++ b/compiler/luci/import/src/Nodes/CircleDiv.cpp
@@ -37,8 +37,8 @@ CircleNode *CircleDivGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto node = graph->nodes()->create<CircleDiv>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
const auto *options = op.builtin_options.AsDivOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleElu.cpp b/compiler/luci/import/src/Nodes/CircleElu.cpp
index 37a290cb1..919e95ee4 100644
--- a/compiler/luci/import/src/Nodes/CircleElu.cpp
+++ b/compiler/luci/import/src/Nodes/CircleElu.cpp
@@ -35,7 +35,7 @@ bool CircleEluGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
@@ -56,7 +56,7 @@ CircleNode *CircleEluGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleElu>();
- node->features(inputs[0]);
+ node->features(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleEqual.cpp b/compiler/luci/import/src/Nodes/CircleEqual.cpp
index a53f6e94b..1db33b8ac 100644
--- a/compiler/luci/import/src/Nodes/CircleEqual.cpp
+++ b/compiler/luci/import/src/Nodes/CircleEqual.cpp
@@ -34,7 +34,7 @@ bool CircleEqualGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- return tensors[inputs[0]]->type == tensors[inputs[1]]->type;
+ return tensors[inputs.at(0)]->type == tensors[inputs.at(1)]->type;
}
CircleNode *CircleEqualGraphBuilder::build_node(const circle::OperatorT &,
@@ -42,8 +42,8 @@ CircleNode *CircleEqualGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleEqual>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleExp.cpp b/compiler/luci/import/src/Nodes/CircleExp.cpp
index a32851458..2c031d6b3 100644
--- a/compiler/luci/import/src/Nodes/CircleExp.cpp
+++ b/compiler/luci/import/src/Nodes/CircleExp.cpp
@@ -31,7 +31,7 @@ bool CircleExpGraphBuilder::validate(const ValidateArgs &args) const
// input type check
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_FLOAT16:
@@ -51,7 +51,7 @@ CircleNode *CircleExpGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleExp>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleExpandDims.cpp b/compiler/luci/import/src/Nodes/CircleExpandDims.cpp
index 1cef67a83..ab537c710 100644
--- a/compiler/luci/import/src/Nodes/CircleExpandDims.cpp
+++ b/compiler/luci/import/src/Nodes/CircleExpandDims.cpp
@@ -34,7 +34,7 @@ bool CircleExpandDimsGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- return tensors[inputs[1]]->type == circle::TensorType_INT32;
+ return tensors[inputs.at(1)]->type == circle::TensorType_INT32;
}
CircleNode *CircleExpandDimsGraphBuilder::build_node(const circle::OperatorT &,
@@ -42,8 +42,8 @@ CircleNode *CircleExpandDimsGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleExpandDims>();
- node->input(inputs[0]);
- node->axis(inputs[1]);
+ node->input(inputs.at(0));
+ node->axis(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleFill.cpp b/compiler/luci/import/src/Nodes/CircleFill.cpp
index 6c3d3a247..95d5b876b 100644
--- a/compiler/luci/import/src/Nodes/CircleFill.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFill.cpp
@@ -37,8 +37,8 @@ CircleNode *CircleFillGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleFill>();
- node->dims(inputs[0]);
- node->value(inputs[1]);
+ node->dims(inputs.at(0));
+ node->value(inputs.at(1));
const auto *options = op.builtin_options.AsFillOptions();
(void)options;
diff --git a/compiler/luci/import/src/Nodes/CircleFloor.cpp b/compiler/luci/import/src/Nodes/CircleFloor.cpp
index 302a9eae3..ce756b3b1 100644
--- a/compiler/luci/import/src/Nodes/CircleFloor.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFloor.cpp
@@ -42,7 +42,7 @@ CircleNode *CircleFloorGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleFloor>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp b/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp
index 875197890..55f385d60 100644
--- a/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFloorDiv.cpp
@@ -39,8 +39,8 @@ bool CircleFloorDivGraphBuilder::validate(const ValidateArgs &args) const
}
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_in_0 = tensors.at(inputs.at(0));
+ const auto &tensor_in_1 = tensors.at(inputs.at(1));
const auto &tensor_out = tensors.at(outputs[0]);
if (tensor_in_0->type != tensor_in_1->type)
@@ -59,8 +59,8 @@ CircleNode *CircleFloorDivGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleFloorDiv>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleFloorMod.cpp b/compiler/luci/import/src/Nodes/CircleFloorMod.cpp
index 3ccdce0cd..2101e417e 100644
--- a/compiler/luci/import/src/Nodes/CircleFloorMod.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFloorMod.cpp
@@ -33,8 +33,8 @@ bool CircleFloorModGraphBuilder::validate(const ValidateArgs &args) const
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_in_0 = tensors.at(inputs.at(0));
+ const auto &tensor_in_1 = tensors.at(inputs.at(1));
if (tensor_in_0->type != tensor_in_1->type)
return false;
@@ -48,8 +48,8 @@ CircleNode *CircleFloorModGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleFloorMod>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp b/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
index 8937e78f1..65a863bde 100644
--- a/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
+++ b/compiler/luci/import/src/Nodes/CircleFullyConnected.cpp
@@ -38,9 +38,9 @@ CircleNode *CircleFullyConnectedGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleFullyConnected>();
- node->input(inputs[0]);
- node->weights(inputs[1]);
- node->bias(inputs[2]); // bias is optional
+ node->input(inputs.at(0));
+ node->weights(inputs.at(1));
+ node->bias(inputs.at(2)); // bias is optional
// TODO Find and move to appropriate place for setting optional input
if (auto bias = dynamic_cast<luci::CircleOutputExclude *>(node->bias()))
diff --git a/compiler/luci/import/src/Nodes/CircleGather.cpp b/compiler/luci/import/src/Nodes/CircleGather.cpp
index 1caa05ec2..75447a38a 100644
--- a/compiler/luci/import/src/Nodes/CircleGather.cpp
+++ b/compiler/luci/import/src/Nodes/CircleGather.cpp
@@ -56,8 +56,8 @@ CircleNode *CircleGatherGraphBuilder::build_node(const circle::OperatorT &op,
{
auto *node = graph->nodes()->create<CircleGather>();
- node->params(inputs[0]);
- node->indices(inputs[1]);
+ node->params(inputs.at(0));
+ node->indices(inputs.at(1));
const auto *options = op.builtin_options.AsGatherOptions();
node->axis(options->axis);
diff --git a/compiler/luci/import/src/Nodes/CircleGatherNd.cpp b/compiler/luci/import/src/Nodes/CircleGatherNd.cpp
index 621d4ae92..981adbf63 100644
--- a/compiler/luci/import/src/Nodes/CircleGatherNd.cpp
+++ b/compiler/luci/import/src/Nodes/CircleGatherNd.cpp
@@ -36,7 +36,7 @@ bool CircleGatherNdGraphBuilder::validate(const ValidateArgs &args) const
if (outputs.size() != 1)
return false;
- auto &indices_tensor = args.reader.tensors()[inputs[1]];
+ auto &indices_tensor = args.reader.tensors()[inputs.at(1)];
if (!(indices_tensor->type == circle::TensorType::TensorType_INT32 ||
indices_tensor->type == circle::TensorType::TensorType_INT64))
@@ -53,8 +53,8 @@ CircleNode *CircleGatherNdGraphBuilder::build_node(const circle::OperatorT &,
{
auto *node = graph->nodes()->create<CircleGatherNd>();
- node->params(inputs[0]);
- node->indices(inputs[1]);
+ node->params(inputs.at(0));
+ node->indices(inputs.at(1));
// GatherNd options empty
diff --git a/compiler/luci/import/src/Nodes/CircleGreater.cpp b/compiler/luci/import/src/Nodes/CircleGreater.cpp
index 88107589c..1ad0467e4 100644
--- a/compiler/luci/import/src/Nodes/CircleGreater.cpp
+++ b/compiler/luci/import/src/Nodes/CircleGreater.cpp
@@ -43,7 +43,7 @@ bool CircleGreaterGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ if (tensors[inputs.at(0)]->type != tensors[inputs.at(1)]->type)
return false;
// NOTE: real models do have output dtype NOT BOOL
@@ -67,8 +67,8 @@ CircleNode *CircleGreaterGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleGreater>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp b/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp
index dff1510c5..0ac63b017 100644
--- a/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp
+++ b/compiler/luci/import/src/Nodes/CircleGreaterEqual.cpp
@@ -40,7 +40,7 @@ bool CircleGreaterEqualGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ if (tensors[inputs.at(0)]->type != tensors[inputs.at(1)]->type)
{
return false;
}
@@ -53,8 +53,8 @@ CircleNode *CircleGreaterEqualGraphBuilder::build_node(const circle::OperatorT &
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleGreaterEqual>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleIf.cpp b/compiler/luci/import/src/Nodes/CircleIf.cpp
index d6090640d..db9ffe1cd 100644
--- a/compiler/luci/import/src/Nodes/CircleIf.cpp
+++ b/compiler/luci/import/src/Nodes/CircleIf.cpp
@@ -43,7 +43,7 @@ bool CircleIfGraphBuilder::validate(const ValidateArgs &args) const
// input 0 should be BOOL type
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
if (tensor->type != circle::TensorType_BOOL)
return false;
diff --git a/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp b/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp
index b95c54c89..6349fd3b7 100644
--- a/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp
+++ b/compiler/luci/import/src/Nodes/CircleInstanceNorm.cpp
@@ -38,9 +38,9 @@ CircleNode *CircleInstanceNormGraphBuilder::build_node(const circle::OperatorT &
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleInstanceNorm>();
- node->input(inputs[0]);
- node->gamma(inputs[1]);
- node->beta(inputs[2]);
+ node->input(inputs.at(0));
+ node->gamma(inputs.at(1));
+ node->beta(inputs.at(2));
const auto *options = op.builtin_options.AsInstanceNormOptions();
node->epsilon(options->epsilon);
diff --git a/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp b/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp
index fe10a8572..e4fdc200c 100644
--- a/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp
+++ b/compiler/luci/import/src/Nodes/CircleL2Normalize.cpp
@@ -46,7 +46,7 @@ CircleNode *CircleL2NormalizeGraphBuilder::build_node(const circle::OperatorT &o
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleL2Normalize>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
const auto *options = op.builtin_options.AsL2NormOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp b/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp
index 023206695..202d9d6fb 100644
--- a/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleL2Pool2D.cpp
@@ -38,7 +38,7 @@ CircleNode *CircleL2Pool2DGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleL2Pool2D>();
- node->value(inputs[0]);
+ node->value(inputs.at(0));
const auto *options = op.builtin_options.AsPool2DOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp b/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp
index 4957ceae0..ad4979f39 100644
--- a/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLeakyRelu.cpp
@@ -39,7 +39,7 @@ CircleNode *CircleLeakyReluGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLeakyRelu>();
- node->features(inputs[0]);
+ node->features(inputs.at(0));
const auto *options = op.builtin_options.AsLeakyReluOptions();
node->alpha(options->alpha);
diff --git a/compiler/luci/import/src/Nodes/CircleLess.cpp b/compiler/luci/import/src/Nodes/CircleLess.cpp
index 40ad28c6e..506036908 100644
--- a/compiler/luci/import/src/Nodes/CircleLess.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLess.cpp
@@ -39,7 +39,7 @@ bool CircleLessGraphBuilder::validate(const ValidateArgs &args) const
}
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
@@ -56,7 +56,7 @@ bool CircleLessGraphBuilder::validate(const ValidateArgs &args) const
return false;
}
- if (tensors[inputs[1]]->type != tensor->type)
+ if (tensors[inputs.at(1)]->type != tensor->type)
{
return false;
}
@@ -69,8 +69,8 @@ CircleNode *CircleLessGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLess>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLessEqual.cpp b/compiler/luci/import/src/Nodes/CircleLessEqual.cpp
index 13e995069..9b4f934a5 100644
--- a/compiler/luci/import/src/Nodes/CircleLessEqual.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLessEqual.cpp
@@ -40,7 +40,7 @@ bool CircleLessEqualGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ if (tensors[inputs.at(0)]->type != tensors[inputs.at(1)]->type)
{
return false;
}
@@ -53,8 +53,8 @@ CircleNode *CircleLessEqualGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLessEqual>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp b/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp
index 7b1f0db56..0e32f62de 100644
--- a/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLocalResponseNormalization.cpp
@@ -37,7 +37,7 @@ 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]);
+ node->input(inputs.at(0));
const auto *options = op.builtin_options.AsLocalResponseNormalizationOptions();
node->radius(options->radius);
diff --git a/compiler/luci/import/src/Nodes/CircleLog.cpp b/compiler/luci/import/src/Nodes/CircleLog.cpp
index 21408327d..346fc43bb 100644
--- a/compiler/luci/import/src/Nodes/CircleLog.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLog.cpp
@@ -35,7 +35,7 @@ bool CircleLogGraphBuilder::validate(const ValidateArgs &args) const
// 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]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_FLOAT16:
@@ -55,7 +55,7 @@ CircleNode *CircleLogGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLog>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
// No options for Log
diff --git a/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp b/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp
index e738c4a0c..ef69e868a 100644
--- a/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLogSoftmax.cpp
@@ -38,7 +38,7 @@ CircleNode *CircleLogSoftmaxGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLogSoftmax>();
- node->logits(inputs[0]);
+ node->logits(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp b/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp
index 8509dbaf3..7844da0f6 100644
--- a/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLogicalAnd.cpp
@@ -46,8 +46,8 @@ CircleNode *CircleLogicalAndGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLogicalAnd>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLogicalNot.cpp b/compiler/luci/import/src/Nodes/CircleLogicalNot.cpp
index b1ed3ea37..3758642e4 100644
--- a/compiler/luci/import/src/Nodes/CircleLogicalNot.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLogicalNot.cpp
@@ -31,7 +31,7 @@ bool CircleLogicalNotGraphBuilder::validate(const ValidateArgs &args) const
// Only BOOL type is allowed for the input
const auto &inputs = args.op.inputs;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
if (tensor->type != circle::TensorType::TensorType_BOOL)
return false;
@@ -43,7 +43,7 @@ CircleNode *CircleLogicalNotGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLogicalNot>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLogicalOr.cpp b/compiler/luci/import/src/Nodes/CircleLogicalOr.cpp
index 00eb9c5df..1b87e6f9c 100644
--- a/compiler/luci/import/src/Nodes/CircleLogicalOr.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLogicalOr.cpp
@@ -46,8 +46,8 @@ CircleNode *CircleLogicalOrGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLogicalOr>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleLogistic.cpp b/compiler/luci/import/src/Nodes/CircleLogistic.cpp
index 85e7e55b2..9606e19cd 100644
--- a/compiler/luci/import/src/Nodes/CircleLogistic.cpp
+++ b/compiler/luci/import/src/Nodes/CircleLogistic.cpp
@@ -32,22 +32,8 @@ bool CircleLogisticGraphBuilder::validate(const ValidateArgs &args) const
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)
+ if (tensors.at(inputs.at(0))->type != tensors.at(outputs[0])->type)
return false;
return true;
@@ -58,7 +44,7 @@ CircleNode *CircleLogisticGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleLogistic>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp b/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp
index f4ae03c58..a4a21a8b7 100644
--- a/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMatrixDiag.cpp
@@ -35,7 +35,7 @@ bool CircleMatrixDiagGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
if (tensors[outputs[0]]->type != tensor->type)
return false;
@@ -48,7 +48,7 @@ CircleNode *CircleMatrixDiagGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMatrixDiag>();
- node->diagonal(inputs[0]);
+ node->diagonal(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp b/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp
index d6f6aee33..cf0313149 100644
--- a/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMatrixSetDiag.cpp
@@ -35,7 +35,7 @@ bool CircleMatrixSetDiagGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
if (tensors[outputs[0]]->type != tensor->type)
return false;
@@ -48,8 +48,8 @@ CircleNode *CircleMatrixSetDiagGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMatrixSetDiag>();
- node->input(inputs[0]);
- node->diagonal(inputs[1]);
+ node->input(inputs.at(0));
+ node->diagonal(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleMaxPool2D.cpp b/compiler/luci/import/src/Nodes/CircleMaxPool2D.cpp
index 1798819cf..4bca0f40b 100644
--- a/compiler/luci/import/src/Nodes/CircleMaxPool2D.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMaxPool2D.cpp
@@ -36,7 +36,7 @@ CircleNode *CircleMaxPool2DGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMaxPool2D>();
- node->value(inputs[0]);
+ node->value(inputs.at(0));
const auto *options = op.builtin_options.AsPool2DOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleMaximum.cpp b/compiler/luci/import/src/Nodes/CircleMaximum.cpp
index 6ca7e4079..4d1468f19 100644
--- a/compiler/luci/import/src/Nodes/CircleMaximum.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMaximum.cpp
@@ -35,7 +35,7 @@ bool CircleMaximumGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
@@ -49,7 +49,7 @@ bool CircleMaximumGraphBuilder::validate(const ValidateArgs &args) const
return false;
}
- if (tensors[inputs[1]]->type != tensor->type)
+ if (tensors[inputs.at(1)]->type != tensor->type)
return false;
if (tensors[outputs[0]]->type != tensor->type)
@@ -63,8 +63,8 @@ CircleNode *CircleMaximumGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMaximum>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleMean.cpp b/compiler/luci/import/src/Nodes/CircleMean.cpp
index 8261c7b38..d8fa9a53d 100644
--- a/compiler/luci/import/src/Nodes/CircleMean.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMean.cpp
@@ -34,8 +34,8 @@ CircleNode *CircleMeanGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMean>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleMinimum.cpp b/compiler/luci/import/src/Nodes/CircleMinimum.cpp
index b770f365f..8b4daf197 100644
--- a/compiler/luci/import/src/Nodes/CircleMinimum.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMinimum.cpp
@@ -35,7 +35,7 @@ bool CircleMinimumGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
@@ -49,7 +49,7 @@ bool CircleMinimumGraphBuilder::validate(const ValidateArgs &args) const
return false;
}
- if (tensors[inputs[1]]->type != tensor->type)
+ if (tensors[inputs.at(1)]->type != tensor->type)
return false;
if (tensors[outputs[0]]->type != tensor->type)
@@ -63,8 +63,8 @@ CircleNode *CircleMinimumGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMinimum>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp b/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp
index 41b5e5d80..e0ddd4c11 100644
--- a/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMirrorPad.cpp
@@ -38,8 +38,8 @@ CircleNode *CircleMirrorPadGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMirrorPad>();
- node->input(inputs[0]);
- node->paddings(inputs[1]);
+ node->input(inputs.at(0));
+ node->paddings(inputs.at(1));
const auto *options = op.builtin_options.AsMirrorPadOptions();
node->mode(luci_mirrorpad_mode(options->mode));
diff --git a/compiler/luci/import/src/Nodes/CircleMul.cpp b/compiler/luci/import/src/Nodes/CircleMul.cpp
index d4412b96b..e3c4a7ee5 100644
--- a/compiler/luci/import/src/Nodes/CircleMul.cpp
+++ b/compiler/luci/import/src/Nodes/CircleMul.cpp
@@ -37,8 +37,8 @@ CircleNode *CircleMulGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleMul>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
const auto *options = op.builtin_options.AsMulOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleNeg.cpp b/compiler/luci/import/src/Nodes/CircleNeg.cpp
index 3d3079ca2..a64a69560 100644
--- a/compiler/luci/import/src/Nodes/CircleNeg.cpp
+++ b/compiler/luci/import/src/Nodes/CircleNeg.cpp
@@ -36,7 +36,7 @@ CircleNode *CircleNegGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleNeg>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleNonMaxSuppressionV4.cpp b/compiler/luci/import/src/Nodes/CircleNonMaxSuppressionV4.cpp
new file mode 100644
index 000000000..a4ad4a53d
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleNonMaxSuppressionV4.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/CircleNonMaxSuppressionV4.h"
+
+#include <luci/IR/Nodes/CircleNonMaxSuppressionV4.h>
+#include <luci/IR/Nodes/CircleNonMaxSuppressionV4Out.h>
+
+#include <loco.h>
+#include <oops/UserExn.h>
+
+namespace luci
+{
+
+bool CircleNonMaxSuppressionV4GraphBuilder::validate(const ValidateArgs &args) const
+{
+ const auto &inputs = args.op.inputs;
+ const auto &outputs = args.op.outputs;
+
+ if (inputs.size() != 5)
+ return false;
+ if (outputs.size() != 2)
+ return false;
+
+ const auto &tensors = args.reader.tensors();
+ const auto &boxes_tensor = tensors.at(inputs[0]);
+ if (boxes_tensor->shape.size() != 2)
+ return false;
+ if (boxes_tensor->shape.at(1) != 4)
+ return false;
+ if (boxes_tensor->shape.at(0) != tensors.at(inputs[1])->shape.at(0))
+ return false;
+
+ if (tensors.at(inputs[2])->type != circle::TensorType_INT32)
+ return false;
+ if (tensors.at(inputs[3])->type != circle::TensorType_FLOAT32)
+ return false;
+ if (tensors.at(inputs[4])->type != circle::TensorType_FLOAT32)
+ return false;
+
+ return true;
+}
+
+/**
+ * @brief NonMaxSuppressionV4 Node builder
+ *
+ * @note Current loco does not provide multiple outputs
+ * We will create multiple NonMasSuppressionV4Oout nodes to emulate this
+ */
+
+void CircleNonMaxSuppressionV4GraphBuilder::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 CircleNonMaxSuppressionV4
+ auto node = graph->nodes()->create<CircleNonMaxSuppressionV4>();
+ node->boxes(input_nodes[0]);
+ node->scores(input_nodes[1]);
+ node->max_output_size(input_nodes[2]);
+ node->iou_threshold(input_nodes[3]);
+ node->score_threshold(input_nodes[4]);
+
+ assert(outputs.size() == 2);
+ {
+ // Let's use name of output 0 as NonMaxSuppressionV4 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 NonMaxSuppressionV4 itself but to virtual outputs
+ }
+
+ // Create virtual outputs of NonMaxSuppressionV4
+ for (size_t n = 0; n < outputs.size(); ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleNonMaxSuppressionV4Out>();
+ 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/CircleNotEqual.cpp b/compiler/luci/import/src/Nodes/CircleNotEqual.cpp
index 5b04856db..77e986de1 100644
--- a/compiler/luci/import/src/Nodes/CircleNotEqual.cpp
+++ b/compiler/luci/import/src/Nodes/CircleNotEqual.cpp
@@ -40,7 +40,7 @@ bool CircleNotEqualGraphBuilder::validate(const ValidateArgs &args) const
const auto &tensors = args.reader.tensors();
- if (tensors[inputs[0]]->type != tensors[inputs[1]]->type)
+ if (tensors[inputs.at(0)]->type != tensors[inputs.at(1)]->type)
{
return false;
}
@@ -53,8 +53,8 @@ CircleNode *CircleNotEqualGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleNotEqual>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleOneHot.cpp b/compiler/luci/import/src/Nodes/CircleOneHot.cpp
index 9fdbfa84d..69294e1ed 100644
--- a/compiler/luci/import/src/Nodes/CircleOneHot.cpp
+++ b/compiler/luci/import/src/Nodes/CircleOneHot.cpp
@@ -38,10 +38,10 @@ bool CircleOneHotGraphBuilder::validate(const ValidateArgs &args) const
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]);
+ const auto &indices = tensors.at(inputs.at(0));
+ const auto &depth = tensors.at(inputs.at(1));
+ const auto &on_value = tensors.at(inputs.at(2));
+ const auto &off_value = tensors.at(inputs.at(3));
if (options->axis < -1 || options->axis > static_cast<int32_t>(indices->shape.size()))
return false;
@@ -63,10 +63,10 @@ CircleNode *CircleOneHotGraphBuilder::build_node(const circle::OperatorT &op,
{
auto *node = graph->nodes()->create<CircleOneHot>();
- node->indices(inputs[0]);
- node->depth(inputs[1]);
- node->on_value(inputs[2]);
- node->off_value(inputs[3]);
+ node->indices(inputs.at(0));
+ node->depth(inputs.at(1));
+ node->on_value(inputs.at(2));
+ node->off_value(inputs.at(3));
const auto *options = op.builtin_options.AsOneHotOptions();
node->axis(options->axis);
diff --git a/compiler/luci/import/src/Nodes/CirclePRelu.cpp b/compiler/luci/import/src/Nodes/CirclePRelu.cpp
index 0d87cd423..c07920f7c 100644
--- a/compiler/luci/import/src/Nodes/CirclePRelu.cpp
+++ b/compiler/luci/import/src/Nodes/CirclePRelu.cpp
@@ -39,8 +39,8 @@ CircleNode *CirclePReluGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CirclePRelu>();
- node->input(inputs[0]);
- node->alpha(inputs[1]);
+ node->input(inputs.at(0));
+ node->alpha(inputs.at(1));
// PRelu options are empty
diff --git a/compiler/luci/import/src/Nodes/CirclePad.cpp b/compiler/luci/import/src/Nodes/CirclePad.cpp
index 6abcf2d6c..999173b90 100644
--- a/compiler/luci/import/src/Nodes/CirclePad.cpp
+++ b/compiler/luci/import/src/Nodes/CirclePad.cpp
@@ -38,8 +38,8 @@ CircleNode *CirclePadGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CirclePad>();
- node->input(inputs[0]);
- node->paddings(inputs[1]);
+ node->input(inputs.at(0));
+ node->paddings(inputs.at(1));
const auto *options = op.builtin_options.AsPadOptions();
(void)options; // There are no options.
diff --git a/compiler/luci/import/src/Nodes/CirclePow.cpp b/compiler/luci/import/src/Nodes/CirclePow.cpp
index ff9833165..def012614 100644
--- a/compiler/luci/import/src/Nodes/CirclePow.cpp
+++ b/compiler/luci/import/src/Nodes/CirclePow.cpp
@@ -39,8 +39,8 @@ CircleNode *CirclePowGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CirclePow>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
// Pow options are empty
diff --git a/compiler/luci/import/src/Nodes/CircleRange.cpp b/compiler/luci/import/src/Nodes/CircleRange.cpp
index c21191605..38dc44ed6 100644
--- a/compiler/luci/import/src/Nodes/CircleRange.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRange.cpp
@@ -36,9 +36,9 @@ CircleNode *CircleRangeGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRange>();
- node->start(inputs[0]);
- node->limit(inputs[1]);
- node->delta(inputs[2]);
+ node->start(inputs.at(0));
+ node->limit(inputs.at(1));
+ node->delta(inputs.at(2));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleRank.cpp b/compiler/luci/import/src/Nodes/CircleRank.cpp
index 705ae0120..12658b192 100644
--- a/compiler/luci/import/src/Nodes/CircleRank.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRank.cpp
@@ -38,7 +38,7 @@ CircleNode *CircleRankGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRank>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleReduceAny.cpp b/compiler/luci/import/src/Nodes/CircleReduceAny.cpp
index 030c5304c..21a821951 100644
--- a/compiler/luci/import/src/Nodes/CircleReduceAny.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReduceAny.cpp
@@ -31,8 +31,8 @@ bool CircleReduceAnyGraphBuilder::validate(const ValidateArgs &args) const
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_0 = tensors.at(inputs.at(0));
+ const auto &tensor_1 = tensors.at(inputs.at(1));
const auto &tensor_o = tensors.at(outputs[0]);
if (tensor_0->type != circle::TensorType_BOOL)
@@ -57,8 +57,8 @@ CircleNode *CircleReduceAnyGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReduceAny>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleReduceMax.cpp b/compiler/luci/import/src/Nodes/CircleReduceMax.cpp
index 8ca8e2e34..05492dbc6 100644
--- a/compiler/luci/import/src/Nodes/CircleReduceMax.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReduceMax.cpp
@@ -33,7 +33,7 @@ bool CircleReduceMaxGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor_axis = tensors.at(inputs[1]);
+ const auto &tensor_axis = tensors.at(inputs.at(1));
switch (tensor_axis->type)
{
@@ -52,8 +52,8 @@ CircleNode *CircleReduceMaxGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReduceMax>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleReduceMin.cpp b/compiler/luci/import/src/Nodes/CircleReduceMin.cpp
index 3020c3778..117d5295a 100644
--- a/compiler/luci/import/src/Nodes/CircleReduceMin.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReduceMin.cpp
@@ -33,7 +33,7 @@ bool CircleReduceMinGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor_axis = tensors.at(inputs[1]);
+ const auto &tensor_axis = tensors.at(inputs.at(1));
switch (tensor_axis->type)
{
@@ -52,8 +52,8 @@ CircleNode *CircleReduceMinGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReduceMin>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleReduceProd.cpp b/compiler/luci/import/src/Nodes/CircleReduceProd.cpp
index 2bb43f6ce..5f054586e 100644
--- a/compiler/luci/import/src/Nodes/CircleReduceProd.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReduceProd.cpp
@@ -30,7 +30,7 @@ bool CircleReduceProdGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor_1 = tensors.at(inputs[1]);
+ const auto &tensor_1 = tensors.at(inputs.at(1));
// TODO check input types
@@ -52,8 +52,8 @@ CircleNode *CircleReduceProdGraphBuilder::build_node(const circle::OperatorT &op
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReduceProd>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleRelu.cpp b/compiler/luci/import/src/Nodes/CircleRelu.cpp
index 056268a5b..8e1c32a3a 100644
--- a/compiler/luci/import/src/Nodes/CircleRelu.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRelu.cpp
@@ -39,7 +39,7 @@ CircleNode *CircleReluGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRelu>();
- node->features(inputs[0]);
+ node->features(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleRelu6.cpp b/compiler/luci/import/src/Nodes/CircleRelu6.cpp
index 5b443993b..0283d7350 100644
--- a/compiler/luci/import/src/Nodes/CircleRelu6.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRelu6.cpp
@@ -39,7 +39,7 @@ CircleNode *CircleRelu6GraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRelu6>();
- node->features(inputs[0]);
+ node->features(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp b/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp
index edf662fb9..7f517bc0d 100644
--- a/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReluN1To1.cpp
@@ -41,7 +41,7 @@ CircleNode *CircleReluN1To1GraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReluN1To1>();
- node->features(inputs[0]);
+ node->features(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleReshape.cpp b/compiler/luci/import/src/Nodes/CircleReshape.cpp
index f72c152b1..996ae9d20 100644
--- a/compiler/luci/import/src/Nodes/CircleReshape.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReshape.cpp
@@ -62,7 +62,7 @@ CircleNode *CircleReshapeGraphBuilder::build_node(const circle::OperatorT &op,
{
// If the second input is not provided, generate it based on the value of the attribute.
// TODO Presence of the second input is the current requirement of the IR.
- auto *shape_node = (inputs.size() == 2) ? inputs[1] : nullptr;
+ auto *shape_node = (inputs.size() == 2) ? inputs.at(1) : nullptr;
if (shape_node == nullptr)
{
const auto *options = op.builtin_options.AsReshapeOptions();
@@ -77,7 +77,7 @@ CircleNode *CircleReshapeGraphBuilder::build_node(const circle::OperatorT &op,
}
auto *node = graph->nodes()->create<CircleReshape>();
- node->tensor(inputs[0]);
+ node->tensor(inputs.at(0));
node->shape(shape_node);
const auto *options = op.builtin_options.AsReshapeOptions();
diff --git a/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp b/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp
index 6128f1b86..0fccb7b44 100644
--- a/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp
+++ b/compiler/luci/import/src/Nodes/CircleResizeBilinear.cpp
@@ -38,8 +38,8 @@ CircleNode *CircleResizeBilinearGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleResizeBilinear>();
- node->input(inputs[0]);
- node->size(inputs[1]);
+ node->input(inputs.at(0));
+ node->size(inputs.at(1));
const auto *options = op.builtin_options.AsResizeBilinearOptions();
node->align_corners(options->align_corners);
diff --git a/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp b/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp
index a1f1ef0ff..324323f59 100644
--- a/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp
+++ b/compiler/luci/import/src/Nodes/CircleResizeNearestNeighbor.cpp
@@ -37,8 +37,8 @@ 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]);
+ node->input(inputs.at(0));
+ node->size(inputs.at(1));
const auto *options = op.builtin_options.AsResizeNearestNeighborOptions();
node->align_corners(options->align_corners);
diff --git a/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp b/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp
index 72d3b153d..ad11d4c63 100644
--- a/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReverseSequence.cpp
@@ -34,8 +34,8 @@ bool CircleReverseSequenceGraphBuilder::validate(const ValidateArgs &args) const
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_in = tensors.at(inputs.at(0));
+ const auto &tensor_lengths = tensors.at(inputs.at(1));
const auto &tensor_out = tensors.at(outputs[0]);
switch (tensor_lengths->type)
@@ -58,8 +58,8 @@ CircleNode *CircleReverseSequenceGraphBuilder::build_node(const circle::Operator
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReverseSequence>();
- node->input(inputs[0]);
- node->seq_lengths(inputs[1]);
+ node->input(inputs.at(0));
+ node->seq_lengths(inputs.at(1));
const auto *options = op.builtin_options.AsReverseSequenceOptions();
node->seq_axis(options->seq_dim);
diff --git a/compiler/luci/import/src/Nodes/CircleReverseV2.cpp b/compiler/luci/import/src/Nodes/CircleReverseV2.cpp
index cd18128a7..e2e53bb4b 100644
--- a/compiler/luci/import/src/Nodes/CircleReverseV2.cpp
+++ b/compiler/luci/import/src/Nodes/CircleReverseV2.cpp
@@ -34,8 +34,8 @@ bool CircleReverseV2GraphBuilder::validate(const ValidateArgs &args) const
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_in = tensors.at(inputs.at(0));
+ const auto &tensor_axis = tensors.at(inputs.at(1));
const auto &tensor_out = tensors.at(outputs[0]);
switch (tensor_axis->type)
@@ -58,8 +58,8 @@ CircleNode *CircleReverseV2GraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleReverseV2>();
- node->tensor(inputs[0]);
- node->axis(inputs[1]);
+ node->tensor(inputs.at(0));
+ node->axis(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleRound.cpp b/compiler/luci/import/src/Nodes/CircleRound.cpp
index 896489521..ad77f9f03 100644
--- a/compiler/luci/import/src/Nodes/CircleRound.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRound.cpp
@@ -37,7 +37,7 @@ bool CircleRoundGraphBuilder::validate(const ValidateArgs &args) const
// 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_in = tensors.at(inputs.at(0));
const auto &tensor_out = tensors.at(outputs[0]);
switch (tensor_in->type)
@@ -63,7 +63,7 @@ CircleNode *CircleRoundGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRound>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleRsqrt.cpp b/compiler/luci/import/src/Nodes/CircleRsqrt.cpp
index b5de0b575..ae05fbbf9 100644
--- a/compiler/luci/import/src/Nodes/CircleRsqrt.cpp
+++ b/compiler/luci/import/src/Nodes/CircleRsqrt.cpp
@@ -33,7 +33,7 @@ bool CircleRsqrtGraphBuilder::validate(const ValidateArgs &args) const
// 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]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_FLOAT16:
@@ -52,7 +52,7 @@ CircleNode *CircleRsqrtGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleRsqrt>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleScatterNd.cpp b/compiler/luci/import/src/Nodes/CircleScatterNd.cpp
index adcaa0030..7f86aeb74 100644
--- a/compiler/luci/import/src/Nodes/CircleScatterNd.cpp
+++ b/compiler/luci/import/src/Nodes/CircleScatterNd.cpp
@@ -32,12 +32,12 @@ bool CircleScatterNdGraphBuilder::validate(const ValidateArgs &args) const
// indices must have the same type as shape
const auto &tensors = args.reader.tensors();
- if (tensors[inputs[0]]->type != tensors[inputs[2]]->type)
+ if (tensors[inputs.at(0)]->type != tensors[inputs.at(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)
+ if (tensors[inputs.at(0)]->type != circle::TensorType_INT32 &&
+ tensors[inputs.at(0)]->type != circle::TensorType_INT64)
return false;
return true;
@@ -48,9 +48,9 @@ CircleNode *CircleScatterNdGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleScatterNd>();
- node->indices(inputs[0]);
- node->updates(inputs[1]);
- node->shape(inputs[2]);
+ node->indices(inputs.at(0));
+ node->updates(inputs.at(1));
+ node->shape(inputs.at(2));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp b/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp
index 1122bdca3..fb84e5d52 100644
--- a/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSegmentSum.cpp
@@ -33,9 +33,9 @@ bool CircleSegmentSumGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor_in = tensors.at(inputs[0]);
+ const auto &tensor_in = tensors.at(inputs.at(0));
const auto &tensor_out = tensors.at(outputs[0]);
- const auto &tensor_ids = tensors.at(inputs[1]);
+ const auto &tensor_ids = tensors.at(inputs.at(1));
switch (tensor_ids->type)
{
@@ -59,8 +59,8 @@ CircleNode *CircleSegmentSumGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSegmentSum>();
- node->input(inputs[0]);
- node->segment_ids(inputs[1]);
+ node->input(inputs.at(0));
+ node->segment_ids(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSelect.cpp b/compiler/luci/import/src/Nodes/CircleSelect.cpp
index ff94212c3..1e649f1e0 100644
--- a/compiler/luci/import/src/Nodes/CircleSelect.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSelect.cpp
@@ -33,7 +33,7 @@ bool CircleSelectGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
if (tensor->type != circle::TensorType_BOOL)
return false;
// TODO check dtypes for input 1, 2
@@ -46,9 +46,9 @@ CircleNode *CircleSelectGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSelect>();
- node->condition(inputs[0]);
- node->t(inputs[1]);
- node->e(inputs[2]);
+ node->condition(inputs.at(0));
+ node->t(inputs.at(1));
+ node->e(inputs.at(2));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSelectV2.cpp b/compiler/luci/import/src/Nodes/CircleSelectV2.cpp
index 78b2e6459..e6dd04de0 100644
--- a/compiler/luci/import/src/Nodes/CircleSelectV2.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSelectV2.cpp
@@ -33,12 +33,12 @@ bool CircleSelectV2GraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &condition = tensors.at(inputs[0]);
+ const auto &condition = tensors.at(inputs.at(0));
if (condition->type != circle::TensorType_BOOL)
return false;
- const auto &t = tensors.at(inputs[1]);
- const auto &e = tensors.at(inputs[2]);
+ const auto &t = tensors.at(inputs.at(1));
+ const auto &e = tensors.at(inputs.at(2));
if (t->type != e->type)
return false;
@@ -50,9 +50,9 @@ CircleNode *CircleSelectV2GraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSelectV2>();
- node->condition(inputs[0]);
- node->t(inputs[1]);
- node->e(inputs[2]);
+ node->condition(inputs.at(0));
+ node->t(inputs.at(1));
+ node->e(inputs.at(2));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleShape.cpp b/compiler/luci/import/src/Nodes/CircleShape.cpp
index 864b5eb51..bd7dfc9d9 100644
--- a/compiler/luci/import/src/Nodes/CircleShape.cpp
+++ b/compiler/luci/import/src/Nodes/CircleShape.cpp
@@ -42,7 +42,7 @@ CircleNode *CircleShapeGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleShape>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
const auto *options = op.builtin_options.AsShapeOptions();
node->out_type(luci_datatype(options->out_type));
diff --git a/compiler/luci/import/src/Nodes/CircleSin.cpp b/compiler/luci/import/src/Nodes/CircleSin.cpp
index 61d60c78f..4b245ef6b 100644
--- a/compiler/luci/import/src/Nodes/CircleSin.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSin.cpp
@@ -33,7 +33,7 @@ bool CircleSinGraphBuilder::validate(const ValidateArgs &args) const
// input type check
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_FLOAT16:
@@ -53,7 +53,7 @@ CircleNode *CircleSinGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSin>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
// No options for Sin
diff --git a/compiler/luci/import/src/Nodes/CircleSlice.cpp b/compiler/luci/import/src/Nodes/CircleSlice.cpp
index 313c35599..8601fbf21 100644
--- a/compiler/luci/import/src/Nodes/CircleSlice.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSlice.cpp
@@ -42,9 +42,9 @@ CircleNode *CircleSliceGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSlice>();
- node->input(inputs[0]);
- node->begin(inputs[1]);
- node->size(inputs[2]);
+ node->input(inputs.at(0));
+ node->begin(inputs.at(1));
+ node->size(inputs.at(2));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSoftmax.cpp b/compiler/luci/import/src/Nodes/CircleSoftmax.cpp
index 0d316e18c..0ef0b5418 100644
--- a/compiler/luci/import/src/Nodes/CircleSoftmax.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSoftmax.cpp
@@ -38,7 +38,7 @@ CircleNode *CircleSoftmaxGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSoftmax>();
- node->logits(inputs[0]);
+ node->logits(inputs.at(0));
const auto *options = op.builtin_options.AsSoftmaxOptions();
node->beta(options->beta);
diff --git a/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp b/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp
index f1361fb11..c1d508e3e 100644
--- a/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSpaceToBatchND.cpp
@@ -33,7 +33,7 @@ bool CircleSpaceToBatchNDGraphBuilder::validate(const ValidateArgs &args) const
// input 1 and 2 should have INT32/INT64 type
const auto &tensors = args.reader.tensors();
- const auto &tensor_1 = tensors.at(inputs[1]);
+ const auto &tensor_1 = tensors.at(inputs.at(1));
switch (tensor_1->type)
{
case circle::TensorType_INT32:
@@ -42,7 +42,7 @@ bool CircleSpaceToBatchNDGraphBuilder::validate(const ValidateArgs &args) const
default:
return false;
}
- const auto &tensor_2 = tensors.at(inputs[2]);
+ const auto &tensor_2 = tensors.at(inputs.at(2));
switch (tensor_2->type)
{
case circle::TensorType_INT32:
@@ -53,7 +53,7 @@ bool CircleSpaceToBatchNDGraphBuilder::validate(const ValidateArgs &args) const
}
// Only support input shape dimension 3 and 4 only
- const auto &tensor_0 = tensors.at(inputs[0]);
+ const auto &tensor_0 = tensors.at(inputs.at(0));
const auto t_0_s = tensor_0->shape.size();
if (t_0_s != 3 && t_0_s != 4)
return false;
@@ -68,9 +68,9 @@ CircleNode *CircleSpaceToBatchNDGraphBuilder::build_node(const circle::OperatorT
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSpaceToBatchND>();
- node->input(inputs[0]);
- node->block_shape(inputs[1]);
- node->paddings(inputs[2]);
+ node->input(inputs.at(0));
+ node->block_shape(inputs.at(1));
+ node->paddings(inputs.at(2));
// No options for SpaceToBatchND
diff --git a/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp b/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp
index b612c9a9a..8ccd55dc6 100644
--- a/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSpaceToDepth.cpp
@@ -41,7 +41,7 @@ CircleNode *CircleSpaceToDepthGraphBuilder::build_node(const circle::OperatorT &
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSpaceToDepth>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
const auto *options = op.builtin_options.AsSpaceToDepthOptions();
node->block_size(options->block_size);
diff --git a/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp b/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp
index bfe790fc1..26d575e90 100644
--- a/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSparseToDense.cpp
@@ -36,10 +36,10 @@ CircleNode *CircleSparseToDenseGraphBuilder::build_node(const circle::OperatorT
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]);
+ node->indices(inputs.at(0));
+ node->output_shape(inputs.at(1));
+ node->values(inputs.at(2));
+ node->default_value(inputs.at(3));
const auto *options = op.builtin_options.AsSparseToDenseOptions();
node->validate_indices(options->validate_indices);
diff --git a/compiler/luci/import/src/Nodes/CircleSqrt.cpp b/compiler/luci/import/src/Nodes/CircleSqrt.cpp
index 8a90f6691..c8beaee0d 100644
--- a/compiler/luci/import/src/Nodes/CircleSqrt.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSqrt.cpp
@@ -36,7 +36,7 @@ CircleNode *CircleSqrtGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSqrt>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSquare.cpp b/compiler/luci/import/src/Nodes/CircleSquare.cpp
index 8398548b6..b5ba048d7 100644
--- a/compiler/luci/import/src/Nodes/CircleSquare.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSquare.cpp
@@ -33,7 +33,7 @@ bool CircleSquareGraphBuilder::validate(const ValidateArgs &args) const
// 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]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_INT32:
@@ -55,7 +55,7 @@ CircleNode *CircleSquareGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSquare>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp b/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp
index 93ce959e2..6deae94c5 100644
--- a/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSquaredDifference.cpp
@@ -37,7 +37,7 @@ bool CircleSquaredDifferenceGraphBuilder::validate(const ValidateArgs &args) con
// 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]);
+ const auto &tensor = tensors.at(inputs.at(0));
switch (tensor->type)
{
case circle::TensorType_FLOAT16:
@@ -53,11 +53,11 @@ bool CircleSquaredDifferenceGraphBuilder::validate(const ValidateArgs &args) con
}
// Input types must match
- if (tensors.at(inputs[0])->type != tensors.at(inputs[1])->type)
+ if (tensors.at(inputs.at(0))->type != tensors.at(inputs.at(1))->type)
return false;
// Input and output types must match
- if (tensors.at(inputs[0])->type != tensors.at(outputs[0])->type)
+ if (tensors.at(inputs.at(0))->type != tensors.at(outputs[0])->type)
return false;
return true;
@@ -68,8 +68,8 @@ CircleNode *CircleSquaredDifferenceGraphBuilder::build_node(const circle::Operat
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSquaredDifference>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleSqueeze.cpp b/compiler/luci/import/src/Nodes/CircleSqueeze.cpp
index a5252d0bb..32792c266 100644
--- a/compiler/luci/import/src/Nodes/CircleSqueeze.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSqueeze.cpp
@@ -38,7 +38,7 @@ CircleNode *CircleSqueezeGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSqueeze>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
const auto *options = op.builtin_options.AsSqueezeOptions();
assert(options);
diff --git a/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp b/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp
index 95e446704..8f943a682 100644
--- a/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp
+++ b/compiler/luci/import/src/Nodes/CircleStridedSlice.cpp
@@ -42,10 +42,10 @@ CircleNode *CircleStridedSliceGraphBuilder::build_node(const circle::OperatorT &
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]);
+ node->input(inputs.at(0));
+ node->begin(inputs.at(1));
+ node->end(inputs.at(2));
+ node->strides(inputs.at(3));
const auto *options = op.builtin_options.AsStridedSliceOptions();
node->begin_mask(options->begin_mask);
diff --git a/compiler/luci/import/src/Nodes/CircleSub.cpp b/compiler/luci/import/src/Nodes/CircleSub.cpp
index 968e9f51f..9acf83d40 100644
--- a/compiler/luci/import/src/Nodes/CircleSub.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSub.cpp
@@ -39,8 +39,8 @@ CircleNode *CircleSubGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSub>();
- node->x(inputs[0]);
- node->y(inputs[1]);
+ node->x(inputs.at(0));
+ node->y(inputs.at(1));
const auto *options = op.builtin_options.AsSubOptions();
node->fusedActivationFunction(luci_actfunc(options->fused_activation_function));
diff --git a/compiler/luci/import/src/Nodes/CircleSum.cpp b/compiler/luci/import/src/Nodes/CircleSum.cpp
index b4865de59..bd3cb6239 100644
--- a/compiler/luci/import/src/Nodes/CircleSum.cpp
+++ b/compiler/luci/import/src/Nodes/CircleSum.cpp
@@ -34,8 +34,8 @@ CircleNode *CircleSumGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleSum>();
- node->input(inputs[0]);
- node->reduction_indices(inputs[1]);
+ node->input(inputs.at(0));
+ node->reduction_indices(inputs.at(1));
const auto *options = op.builtin_options.AsReducerOptions();
node->keep_dims(options->keep_dims);
diff --git a/compiler/luci/import/src/Nodes/CircleTanh.cpp b/compiler/luci/import/src/Nodes/CircleTanh.cpp
index 8986378c4..018f5701b 100644
--- a/compiler/luci/import/src/Nodes/CircleTanh.cpp
+++ b/compiler/luci/import/src/Nodes/CircleTanh.cpp
@@ -28,21 +28,13 @@ bool CircleTanhGraphBuilder::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
- // 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;
- }
+ if (tensors.at(inputs.at(0))->type != tensors.at(outputs[0])->type)
+ return false;
return true;
}
@@ -52,7 +44,7 @@ CircleNode *CircleTanhGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleTanh>();
- node->x(inputs[0]);
+ node->x(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleTile.cpp b/compiler/luci/import/src/Nodes/CircleTile.cpp
index 91054ce7f..bc6f320ba 100644
--- a/compiler/luci/import/src/Nodes/CircleTile.cpp
+++ b/compiler/luci/import/src/Nodes/CircleTile.cpp
@@ -34,10 +34,10 @@ bool CircleTileGraphBuilder::validate(const ValidateArgs &args) const
if (outputs.size() != 1)
return false;
- // Multiples (inputs[1]) must be one of the following types
+ // Multiples (inputs.at(1)) must be one of the following types
// int32, int64
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[1]);
+ const auto &tensor = tensors.at(inputs.at(1));
switch (tensor->type)
{
case circle::TensorType_INT32:
@@ -48,7 +48,7 @@ bool CircleTileGraphBuilder::validate(const ValidateArgs &args) const
}
// Type of input and output must be the same
- if (tensors.at(inputs[0])->type != tensors.at(outputs[0])->type)
+ if (tensors.at(inputs.at(0))->type != tensors.at(outputs[0])->type)
return false;
return true;
@@ -59,8 +59,8 @@ CircleNode *CircleTileGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleTile>();
- node->input(inputs[0]);
- node->multiples(inputs[1]);
+ node->input(inputs.at(0));
+ node->multiples(inputs.at(1));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleTopKV2.cpp b/compiler/luci/import/src/Nodes/CircleTopKV2.cpp
index 5c1051c43..f0677de86 100644
--- a/compiler/luci/import/src/Nodes/CircleTopKV2.cpp
+++ b/compiler/luci/import/src/Nodes/CircleTopKV2.cpp
@@ -36,7 +36,7 @@ bool CircleTopKV2GraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[1]);
+ const auto &tensor = tensors.at(inputs.at(1));
if (tensor->type != circle::TensorType_INT32)
return false;
diff --git a/compiler/luci/import/src/Nodes/CircleTranspose.cpp b/compiler/luci/import/src/Nodes/CircleTranspose.cpp
index 8622c8b80..cc3153085 100644
--- a/compiler/luci/import/src/Nodes/CircleTranspose.cpp
+++ b/compiler/luci/import/src/Nodes/CircleTranspose.cpp
@@ -39,8 +39,8 @@ CircleNode *CircleTransposeGraphBuilder::build_node(const circle::OperatorT &op,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleTranspose>();
- node->a(inputs[0]);
- node->perm(inputs[1]);
+ node->a(inputs.at(0));
+ node->perm(inputs.at(1));
const auto *options = op.builtin_options.AsTransposeOptions();
(void)options;
diff --git a/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp b/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp
index 7bdf46daa..ddb196657 100644
--- a/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp
+++ b/compiler/luci/import/src/Nodes/CircleTransposeConv.cpp
@@ -30,6 +30,24 @@ bool CircleTransposeConvGraphBuilder::validate(const ValidateArgs &args) const
if (args.op.inputs.size() != 3)
return false;
+ const auto &inputs = args.op.inputs;
+ const auto &tensors = args.reader.tensors();
+ const auto &filter_tensor = tensors.at(inputs.at(1));
+ const auto &filter_shape = filter_tensor.get()->shape;
+ const auto &ifm_tensor = tensors.at(inputs.at(2));
+ const auto &ifm_shape = ifm_tensor.get()->shape;
+
+ // ifm and filters must be 4-D tensor
+ if (ifm_shape.size() != 4)
+ return false;
+ if (filter_shape.size() != 4)
+ return false;
+
+ // input shape : [batch, height, width, in_channels]
+ // filters shape : [output_channels, height, weight, in_channels]
+ if (ifm_tensor.get()->shape.at(3) != filter_tensor.get()->shape.at(3))
+ return false;
+
return true;
}
@@ -39,9 +57,9 @@ CircleNode *CircleTransposeConvGraphBuilder::build_node(const circle::OperatorT
{
auto *node = graph->nodes()->create<CircleTransposeConv>();
- node->inputSizes(inputs[0]);
- node->filter(inputs[1]);
- node->outBackprop(inputs[2]);
+ node->inputSizes(inputs.at(0));
+ node->filter(inputs.at(1));
+ node->outBackprop(inputs.at(2));
const auto *options = op.builtin_options.AsTransposeConvOptions();
node->padding(luci_padding(options->padding));
diff --git a/compiler/luci/import/src/Nodes/CircleUnique.cpp b/compiler/luci/import/src/Nodes/CircleUnique.cpp
new file mode 100644
index 000000000..5e79a2920
--- /dev/null
+++ b/compiler/luci/import/src/Nodes/CircleUnique.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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/CircleUnique.h"
+
+#include <luci/IR/Nodes/CircleUnique.h>
+#include <luci/IR/Nodes/CircleUniqueOut.h>
+
+#include <loco.h>
+
+namespace luci
+{
+
+bool CircleUniqueGraphBuilder::validate(const ValidateArgs &args) const
+{
+ if (args.op.inputs.size() != 1)
+ return false;
+
+ if (args.op.outputs.size() != 2)
+ return false;
+
+ return true;
+}
+
+void CircleUniqueGraphBuilder::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);
+
+ std::vector<CircleNode *> input_nodes;
+ for (const int32_t input_tensor_index : inputs)
+ {
+ input_nodes.push_back(context->nodefinder()->node(input_tensor_index));
+ }
+
+ // Create CircleUnique
+ auto node = graph->nodes()->create<CircleUnique>();
+ node->input(input_nodes[0]);
+
+ const auto *options = op.builtin_options.AsUniqueOptions();
+ node->output_type(luci_datatype(options->idx_out_type));
+
+ assert(int32_t(outputs.size()) == 2);
+ // Let's use name of output 0 as Unique name
+ const circle::TensorT &output_tensor = *tensors[outputs[0]];
+ node->name(tensor_name(output_tensor));
+
+ // Create virtual outputs of Unique
+ for (int32_t n = 0; n < 2; ++n)
+ {
+ const circle::TensorT &output_tensor = *tensors[outputs[n]];
+
+ auto *nodeout = graph->nodes()->create<CircleUniqueOut>();
+ 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/CircleUnpack.cpp b/compiler/luci/import/src/Nodes/CircleUnpack.cpp
index c4282e24f..9e7f3d3e1 100644
--- a/compiler/luci/import/src/Nodes/CircleUnpack.cpp
+++ b/compiler/luci/import/src/Nodes/CircleUnpack.cpp
@@ -59,7 +59,7 @@ bool CircleUnpackGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor = tensors.at(inputs[0]);
+ const auto &tensor = tensors.at(inputs.at(0));
const auto &shape = tensor->shape;
auto shape_size = static_cast<int32_t>(shape.size());
if (shape_size > 0)
diff --git a/compiler/luci/import/src/Nodes/CircleWhere.cpp b/compiler/luci/import/src/Nodes/CircleWhere.cpp
index a13c4d6c9..f4c5f0c66 100644
--- a/compiler/luci/import/src/Nodes/CircleWhere.cpp
+++ b/compiler/luci/import/src/Nodes/CircleWhere.cpp
@@ -35,7 +35,7 @@ bool CircleWhereGraphBuilder::validate(const ValidateArgs &args) const
return false;
const auto &tensors = args.reader.tensors();
- const auto &tensor_condition = tensors.at(inputs[0]);
+ const auto &tensor_condition = tensors.at(inputs.at(0));
const auto &tensor_out = tensors.at(outputs[0]);
if (tensor_condition->type != circle::TensorType_BOOL)
@@ -52,7 +52,7 @@ CircleNode *CircleWhereGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleWhere>();
- node->condition(inputs[0]);
+ node->condition(inputs.at(0));
return node;
}
diff --git a/compiler/luci/import/src/Nodes/CircleZerosLike.cpp b/compiler/luci/import/src/Nodes/CircleZerosLike.cpp
index 4362925cd..e60424def 100644
--- a/compiler/luci/import/src/Nodes/CircleZerosLike.cpp
+++ b/compiler/luci/import/src/Nodes/CircleZerosLike.cpp
@@ -39,7 +39,7 @@ CircleNode *CircleZerosLikeGraphBuilder::build_node(const circle::OperatorT &,
loco::Graph *graph) const
{
auto *node = graph->nodes()->create<CircleZerosLike>();
- node->input(inputs[0]);
+ node->input(inputs.at(0));
// ZerosLikeOptinos are empty