diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-08-14 15:19:19 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-08-14 15:19:19 +0900 |
commit | 042b262b3633b6c0f577aed6cb4b980ad0c1dcf3 (patch) | |
tree | e79fb9ffe65b21bdc5863306db2757ab187a3306 /compiler/luci/lang | |
parent | 05e0ec30a632339a8533082476f27bda31ccde16 (diff) | |
download | nnfw-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/lang')
17 files changed, 569 insertions, 4 deletions
diff --git a/compiler/luci/lang/include/luci/IR/CircleNodes.h b/compiler/luci/lang/include/luci/IR/CircleNodes.h index 3b31149b2..e57f5bb3e 100644 --- a/compiler/luci/lang/include/luci/IR/CircleNodes.h +++ b/compiler/luci/lang/include/luci/IR/CircleNodes.h @@ -70,10 +70,12 @@ #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" #include "Nodes/CirclePad.h" +#include "Nodes/CirclePadV2.h" #include "Nodes/CirclePow.h" #include "Nodes/CirclePRelu.h" #include "Nodes/CircleRange.h" @@ -117,6 +119,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" @@ -130,7 +133,9 @@ #include "Nodes/CircleOutput.h" #include "Nodes/CircleCustomOut.h" #include "Nodes/CircleIfOut.h" +#include "Nodes/CircleNonMaxSuppressionV4Out.h" #include "Nodes/CircleUnpackOut.h" +#include "Nodes/CircleUniqueOut.h" #include "Nodes/CircleSplitOut.h" #include "Nodes/CircleSplitVOut.h" #include "Nodes/CircleTopKV2Out.h" diff --git a/compiler/luci/lang/include/luci/IR/CircleNodes.lst b/compiler/luci/lang/include/luci/IR/CircleNodes.lst index 488dcfb89..801051848 100644 --- a/compiler/luci/lang/include/luci/IR/CircleNodes.lst +++ b/compiler/luci/lang/include/luci/IR/CircleNodes.lst @@ -22,7 +22,6 @@ CIRCLE_NODE(BATCHMATMUL, luci::CircleBatchMatMul) CIRCLE_NODE(CAST, luci::CircleCast) CIRCLE_NODE(CEIL, luci::CircleCeil) CIRCLE_NODE(CONCATENATION, luci::CircleConcatenation) -CIRCLE_NODE(CONST, luci::CircleConst) CIRCLE_NODE(CONV_2D, luci::CircleConv2D) CIRCLE_NODE(COS, luci::CircleCos) CIRCLE_NODE(CUSTOM, luci::CircleCustom) @@ -64,10 +63,12 @@ CIRCLE_NODE(MINIMUM, luci::CircleMinimum) CIRCLE_NODE(MIRROR_PAD, luci::CircleMirrorPad) CIRCLE_NODE(MUL, luci::CircleMul) CIRCLE_NODE(NEG, luci::CircleNeg) +CIRCLE_NODE(NON_MAX_SUPPRESSION_V4, luci::CircleNonMaxSuppressionV4) CIRCLE_NODE(NOT_EQUAL, luci::CircleNotEqual) CIRCLE_NODE(ONE_HOT, luci::CircleOneHot) CIRCLE_NODE(PACK, luci::CirclePack) CIRCLE_NODE(PAD, luci::CirclePad) +CIRCLE_NODE(PADV2, luci::CirclePadV2) CIRCLE_NODE(POW, luci::CirclePow) CIRCLE_NODE(PRELU, luci::CirclePRelu) CIRCLE_NODE(RANGE, luci::CircleRange) @@ -111,6 +112,7 @@ CIRCLE_NODE(TILE, luci::CircleTile) CIRCLE_NODE(TOPK_V2, luci::CircleTopKV2) CIRCLE_NODE(TRANSPOSE, luci::CircleTranspose) CIRCLE_NODE(TRANSPOSE_CONV, luci::CircleTransposeConv) +CIRCLE_NODE(UNIQUE, luci::CircleUnique) CIRCLE_NODE(UNPACK, luci::CircleUnpack) CIRCLE_NODE(WHERE, luci::CircleWhere) CIRCLE_NODE(WHILE, luci::CircleWhile) @@ -120,14 +122,17 @@ CIRCLE_NODE(BCQ_FULLY_CONNECTED, luci::CircleBCQFullyConnected) CIRCLE_NODE(BCQ_GATHER, luci::CircleBCQGather) CIRCLE_NODE(INSTANCE_NORM, luci::CircleInstanceNorm) // Virtual node(s) +CIRCLE_NODE(CIRCLECONST, luci::CircleConst) CIRCLE_NODE(CIRCLEINPUT, luci::CircleInput) CIRCLE_NODE(CIRCLEOUTPUT, luci::CircleOutput) CIRCLE_NODE(CIRCLEOUTPUTDUMMY, luci::CircleOutputDummy) CIRCLE_NODE(CIRCLEOUTPUTEXCLUDE, luci::CircleOutputExclude) CIRCLE_NODE(CIRCLECUSTOMOUT, luci::CircleCustomOut) CIRCLE_NODE(CIRCLEIFOUT, luci::CircleIfOut) +CIRCLE_NODE(CIRCLENONMAXSUPPRESSIONV4OUT, luci::CircleNonMaxSuppressionV4Out) CIRCLE_NODE(CIRCLESPLITOUT, luci::CircleSplitOut) CIRCLE_NODE(CIRCLESPLITVOUT, luci::CircleSplitVOut) CIRCLE_NODE(CIRCLETOPKV2OUT, luci::CircleTopKV2Out) +CIRCLE_NODE(CIRCLEUNIQUEOUT, luci::CircleUniqueOut) CIRCLE_NODE(CIRCLEUNPACKOUT, luci::CircleUnpackOut) CIRCLE_NODE(CIRCLEWHILEOUT, luci::CircleWhileOut) diff --git a/compiler/luci/lang/include/luci/IR/CircleQuantParam.h b/compiler/luci/lang/include/luci/IR/CircleQuantParam.h index 7253e657b..694437303 100644 --- a/compiler/luci/lang/include/luci/IR/CircleQuantParam.h +++ b/compiler/luci/lang/include/luci/IR/CircleQuantParam.h @@ -29,6 +29,7 @@ struct CircleQuantParam std::vector<float> max; std::vector<float> scale; std::vector<int64_t> zerop; + int32_t quantized_dimension{0}; }; } // namespace luci diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CircleConst.h b/compiler/luci/lang/include/luci/IR/Nodes/CircleConst.h index fc671746f..250282049 100644 --- a/compiler/luci/lang/include/luci/IR/Nodes/CircleConst.h +++ b/compiler/luci/lang/include/luci/IR/Nodes/CircleConst.h @@ -31,7 +31,7 @@ namespace luci * @brief Class to build tensor data * @note This will not be exported as a specific op */ -class CircleConst final : public FixedArityNode<0, CircleNodeImpl<CircleOpcode::CONST>> +class CircleConst final : public FixedArityNode<0, CircleNodeImpl<CircleOpcode::CIRCLECONST>> { public: CircleConst() = default; diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4.h b/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4.h new file mode 100644 index 000000000..69f3368c0 --- /dev/null +++ b/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LUCI_IR_CIRCLE_NON_MAX_SUPPRESSION_V4_H__ +#define __LUCI_IR_CIRCLE_NON_MAX_SUPPRESSION_V4_H__ + +#include "luci/IR/CircleNodeDecl.h" +#include "luci/IR/CircleOpcode.h" + +#include "luci/IR/LuciNodeMixins.h" + +namespace luci +{ + +/** + * @brief NON_MAX_SUPPRESSION_V4 in Circle + */ +class CircleNonMaxSuppressionV4 final + : public FixedArityNode<5, CircleNodeImpl<CircleOpcode::NON_MAX_SUPPRESSION_V4>> +{ +public: + loco::Node *boxes(void) const { return at(0)->node(); } + void boxes(loco::Node *node) { at(0)->node(node); } + + loco::Node *scores(void) const { return at(1)->node(); } + void scores(loco::Node *node) { at(1)->node(node); } + + loco::Node *max_output_size(void) const { return at(2)->node(); } + void max_output_size(loco::Node *node) { at(2)->node(node); } + + loco::Node *iou_threshold(void) const { return at(3)->node(); } + void iou_threshold(loco::Node *node) { at(3)->node(node); } + + loco::Node *score_threshold(void) const { return at(4)->node(); } + void score_threshold(loco::Node *node) { at(4)->node(node); } +}; + +} // namespace luci + +#endif // __LUCI_IR_CIRCLE_NON_MAX_SUPPRESSION_V4_H__ diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4Out.h b/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4Out.h new file mode 100644 index 000000000..a24dc3e9c --- /dev/null +++ b/compiler/luci/lang/include/luci/IR/Nodes/CircleNonMaxSuppressionV4Out.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LUCI_IR_CIRCLE_NONMAXSUPPRESSIONV4OUT_H__ +#define __LUCI_IR_CIRCLE_NONMAXSUPPRESSIONV4OUT_H__ + +#include "luci/IR/CircleNodeDecl.h" +#include "luci/IR/CircleOpcode.h" + +#include "luci/IR/LuciNodeMixins.h" + +namespace luci +{ + +/** + * @brief Virtual NONMAXSUPPRESSIONV4OUT in Circle + */ +class CircleNonMaxSuppressionV4Out final + : public FixedArityNode<1, CircleNodeImpl<CircleOpcode::CIRCLENONMAXSUPPRESSIONV4OUT>> +{ +public: + CircleNonMaxSuppressionV4Out() = default; + +public: + loco::Node *input(void) const { return at(0)->node(); } + void input(loco::Node *node) { at(0)->node(node); } + +public: + int32_t index(void) const { return _index; } + void index(int32_t index) { _index = index; } + +private: + int32_t _index{-1}; +}; + +} // namespace luci + +#endif // __LUCI_IR_CIRCLE_NONMAXSUPPRESSIONV4OUT_H__ diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CirclePadV2.h b/compiler/luci/lang/include/luci/IR/Nodes/CirclePadV2.h new file mode 100644 index 000000000..563cfd9a4 --- /dev/null +++ b/compiler/luci/lang/include/luci/IR/Nodes/CirclePadV2.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LUCI_IR_CIRCLEPADV2_H__ +#define __LUCI_IR_CIRCLEPADV2_H__ + +#include "luci/IR/CircleNodeDecl.h" +#include "luci/IR/CircleOpcode.h" + +#include "luci/IR/LuciNodeMixins.h" + +namespace luci +{ + +/** + * @brief PADV2 in Circle + */ +class CirclePadV2 final : public FixedArityNode<3, CircleNodeImpl<CircleOpcode::PADV2>> +{ +public: + CirclePadV2() = default; + +public: + loco::Node *input(void) const { return at(0)->node(); } + void input(loco::Node *node) { at(0)->node(node); } + + loco::Node *paddings(void) const { return at(1)->node(); } + void paddings(loco::Node *node) { at(1)->node(node); } + + loco::Node *constant_values(void) const { return at(2)->node(); } + void constant_values(loco::Node *node) { at(2)->node(node); } +}; + +} // namespace luci + +#endif // __LUCI_IR_CIRCLEPADV2_H__ diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CircleUnique.h b/compiler/luci/lang/include/luci/IR/Nodes/CircleUnique.h new file mode 100644 index 000000000..719a72362 --- /dev/null +++ b/compiler/luci/lang/include/luci/IR/Nodes/CircleUnique.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LUCI_IR_CIRCELUNIQUE_H__ +#define __LUCI_IR_CIRCELUNIQUE_H__ + +#include "luci/IR/CircleNodeDecl.h" +#include "luci/IR/CircleOpcode.h" + +#include "luci/IR/LuciNodeMixins.h" + +namespace luci +{ + +/** + * @brief Unique in Circle + */ +class CircleUnique final : public FixedArityNode<1, CircleNodeImpl<CircleOpcode::UNIQUE>> +{ +public: + loco::Node *input(void) const { return at(0)->node(); } + void input(loco::Node *node) { at(0)->node(node); } + +public: + loco::DataType idx_out_type(void) const { return _idx_out_type; } + void output_type(loco::DataType ot) { _idx_out_type = ot; } + +private: + loco::DataType _idx_out_type{loco::DataType::S32}; +}; + +} // namespace luci + +#endif // __LUCI_IR_CIRCELUNIQUE_H__ diff --git a/compiler/luci/lang/include/luci/IR/Nodes/CircleUniqueOut.h b/compiler/luci/lang/include/luci/IR/Nodes/CircleUniqueOut.h new file mode 100644 index 000000000..f846403e0 --- /dev/null +++ b/compiler/luci/lang/include/luci/IR/Nodes/CircleUniqueOut.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __LUCI_IR_CIRCLE_UNIQUEOUT_H__ +#define __LUCI_IR_CIRCLE_UNIQUEOUT_H__ + +#include "luci/IR/CircleNodeDecl.h" +#include "luci/IR/CircleOpcode.h" + +#include "luci/IR/LuciNodeMixins.h" + +namespace luci +{ + +/** + * @brief Virtual CIRCLEUNIQUEOUT in Circle + */ +class CircleUniqueOut final + : public FixedArityNode<1, CircleNodeImpl<CircleOpcode::CIRCLEUNIQUEOUT>> +{ +public: + CircleUniqueOut() = default; + +public: + loco::Node *input(void) const { return at(0)->node(); } + void input(loco::Node *node) { at(0)->node(node); } + +public: + int32_t index(void) const { return _index; } + void index(int32_t index) { _index = index; } + +private: + int32_t _index{-1}; +}; + +} // namespace luci + +#endif // __LUCI_IR_CIRCLE_UNIQUEOUT_H__ diff --git a/compiler/luci/lang/src/Module.test.cpp b/compiler/luci/lang/src/Module.test.cpp index 26bf073be..a5973e52d 100644 --- a/compiler/luci/lang/src/Module.test.cpp +++ b/compiler/luci/lang/src/Module.test.cpp @@ -22,7 +22,7 @@ TEST(ModuleTest, consturctor) { auto gs = luci::make_module(); - GTEST_SUCCEED(); + SUCCEED(); } TEST(ModuleTest, add) diff --git a/compiler/luci/lang/src/Nodes/CircleCustom.test.cpp b/compiler/luci/lang/src/Nodes/CircleCustom.test.cpp index 74ea82c6c..c07268cbf 100644 --- a/compiler/luci/lang/src/Nodes/CircleCustom.test.cpp +++ b/compiler/luci/lang/src/Nodes/CircleCustom.test.cpp @@ -35,7 +35,12 @@ TEST(CircleCustomTest, constructor) ASSERT_EQ(0, custom_node.custom_code().size()); } -TEST(CircleCustomTest, constructor_NEG) { ASSERT_DEBUG_DEATH(luci::CircleCustom{0}, ""); } +TEST(CircleCustomTest, constructor_NEG) +{ + ASSERT_DEBUG_DEATH(luci::CircleCustom{0}, ""); + + SUCCEED(); +} TEST(CircleCustomTest, invalidIndex_NEG) { diff --git a/compiler/luci/lang/src/Nodes/CircleIf.test.cpp b/compiler/luci/lang/src/Nodes/CircleIf.test.cpp index e3c8c9f60..35f28e9ac 100644 --- a/compiler/luci/lang/src/Nodes/CircleIf.test.cpp +++ b/compiler/luci/lang/src/Nodes/CircleIf.test.cpp @@ -41,11 +41,15 @@ TEST(CircleIfTest, constructor) TEST(CircleIfTestDeath, invalid_arity_NEG) { ASSERT_DEBUG_DEATH(luci::CircleIf very_long_name_if_node(0, 1), ""); + + SUCCEED(); } TEST(CircleIfTestDeath, invalid_output_count_NEG) { ASSERT_DEBUG_DEATH(luci::CircleIf if_node(2, 0), ""); + + SUCCEED(); } TEST(CircleIfTestDeath, invalid_input_get_index_NEG) diff --git a/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4.test.cpp b/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4.test.cpp new file mode 100644 index 000000000..b25ce4d6d --- /dev/null +++ b/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4.test.cpp @@ -0,0 +1,96 @@ +/* + * 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/IR/Nodes/CircleNonMaxSuppressionV4.h" + +#include "luci/IR/CircleDialect.h" +#include "luci/IR/CircleNodeVisitor.h" + +#include <gtest/gtest.h> + +TEST(CircleNonMaxSuppressionV4Test, constructor) +{ + luci::CircleNonMaxSuppressionV4 nmsv4_node; + + ASSERT_EQ(luci::CircleDialect::get(), nmsv4_node.dialect()); + ASSERT_EQ(luci::CircleOpcode::NON_MAX_SUPPRESSION_V4, nmsv4_node.opcode()); + + ASSERT_EQ(nullptr, nmsv4_node.boxes()); + ASSERT_EQ(nullptr, nmsv4_node.scores()); + ASSERT_EQ(nullptr, nmsv4_node.max_output_size()); + ASSERT_EQ(nullptr, nmsv4_node.iou_threshold()); + ASSERT_EQ(nullptr, nmsv4_node.score_threshold()); +} + +TEST(CircleNonMaxSuppressionV4Test, input_NEG) +{ + luci::CircleNonMaxSuppressionV4 nmsv4_node; + luci::CircleNonMaxSuppressionV4 node; + + nmsv4_node.boxes(&node); + nmsv4_node.scores(&node); + nmsv4_node.max_output_size(&node); + nmsv4_node.iou_threshold(&node); + nmsv4_node.score_threshold(&node); + ASSERT_NE(nullptr, nmsv4_node.boxes()); + ASSERT_NE(nullptr, nmsv4_node.scores()); + ASSERT_NE(nullptr, nmsv4_node.max_output_size()); + ASSERT_NE(nullptr, nmsv4_node.iou_threshold()); + ASSERT_NE(nullptr, nmsv4_node.score_threshold()); + + nmsv4_node.boxes(nullptr); + nmsv4_node.scores(nullptr); + nmsv4_node.max_output_size(nullptr); + nmsv4_node.iou_threshold(nullptr); + nmsv4_node.score_threshold(nullptr); + ASSERT_EQ(nullptr, nmsv4_node.boxes()); + ASSERT_EQ(nullptr, nmsv4_node.scores()); + ASSERT_EQ(nullptr, nmsv4_node.max_output_size()); + ASSERT_EQ(nullptr, nmsv4_node.iou_threshold()); + ASSERT_EQ(nullptr, nmsv4_node.score_threshold()); +} + +TEST(CircleNonMaxSuppressionV4Test, arity_NEG) +{ + luci::CircleNonMaxSuppressionV4 nmsv4_node; + + ASSERT_NO_THROW(nmsv4_node.arg(4)); + ASSERT_THROW(nmsv4_node.arg(5), std::out_of_range); +} + +TEST(CircleNonMaxSuppressionV4Test, visit_mutable_NEG) +{ + struct TestVisitor final : public luci::CircleNodeMutableVisitor<void> + { + }; + + luci::CircleNonMaxSuppressionV4 nmsv4_node; + + TestVisitor tv; + ASSERT_THROW(nmsv4_node.accept(&tv), std::exception); +} + +TEST(CircleNonMaxSuppressionV4Test, visit_NEG) +{ + struct TestVisitor final : public luci::CircleNodeVisitor<void> + { + }; + + luci::CircleNonMaxSuppressionV4 nmsv4_node; + + TestVisitor tv; + ASSERT_THROW(nmsv4_node.accept(&tv), std::exception); +} diff --git a/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4Out.test.cpp b/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4Out.test.cpp new file mode 100644 index 000000000..c6cef4e91 --- /dev/null +++ b/compiler/luci/lang/src/Nodes/CircleNonMaxSuppressionV4Out.test.cpp @@ -0,0 +1,32 @@ +/* + * 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/IR/Nodes/CircleNonMaxSuppressionV4Out.h" + +#include "luci/IR/CircleDialect.h" + +#include <gtest/gtest.h> + +TEST(CircleNonMaxSuppressionV4OutTest, constructor) +{ + luci::CircleNonMaxSuppressionV4Out vout_node; + + ASSERT_EQ(luci::CircleDialect::get(), vout_node.dialect()); + ASSERT_EQ(luci::CircleOpcode::CIRCLENONMAXSUPPRESSIONV4OUT, vout_node.opcode()); + + ASSERT_EQ(nullptr, vout_node.input()); + ASSERT_EQ(-1, vout_node.index()); +} diff --git a/compiler/luci/lang/src/Nodes/CirclePadV2.test.cpp b/compiler/luci/lang/src/Nodes/CirclePadV2.test.cpp new file mode 100644 index 000000000..e09d517b2 --- /dev/null +++ b/compiler/luci/lang/src/Nodes/CirclePadV2.test.cpp @@ -0,0 +1,86 @@ +/* + * 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/IR/Nodes/CirclePadV2.h" + +#include "luci/IR/CircleDialect.h" +#include "luci/IR/CircleNodeVisitor.h" + +#include <gtest/gtest.h> + +TEST(CirclePadV2Test, constructor_P) +{ + luci::CirclePadV2 node; + + ASSERT_EQ(luci::CircleDialect::get(), node.dialect()); + ASSERT_EQ(luci::CircleOpcode::PADV2, node.opcode()); + + ASSERT_EQ(nullptr, node.input()); + ASSERT_EQ(nullptr, node.paddings()); + ASSERT_EQ(nullptr, node.constant_values()); +} + +TEST(CirclePadV2Test, input_NEG) +{ + luci::CirclePadV2 pad_node; + luci::CirclePadV2 node; + + pad_node.input(&node); + pad_node.paddings(&node); + pad_node.constant_values(&node); + ASSERT_NE(nullptr, pad_node.input()); + ASSERT_NE(nullptr, pad_node.paddings()); + ASSERT_NE(nullptr, pad_node.constant_values()); + + pad_node.input(nullptr); + pad_node.paddings(nullptr); + pad_node.constant_values(nullptr); + ASSERT_EQ(nullptr, pad_node.input()); + ASSERT_EQ(nullptr, pad_node.paddings()); + ASSERT_EQ(nullptr, pad_node.constant_values()); +} + +TEST(CirclePadV2Test, arity_NEG) +{ + luci::CirclePadV2 pad_node; + + ASSERT_NO_THROW(pad_node.arg(2)); + ASSERT_THROW(pad_node.arg(3), std::out_of_range); +} + +TEST(CirclePadV2Test, visit_mutable_NEG) +{ + struct TestVisitor final : public luci::CircleNodeMutableVisitor<void> + { + }; + + luci::CirclePadV2 pad_node; + + TestVisitor tv; + ASSERT_THROW(pad_node.accept(&tv), std::exception); +} + +TEST(CirclePadV2Test, visit_NEG) +{ + struct TestVisitor final : public luci::CircleNodeVisitor<void> + { + }; + + luci::CirclePadV2 pad_node; + + TestVisitor tv; + ASSERT_THROW(pad_node.accept(&tv), std::exception); +} diff --git a/compiler/luci/lang/src/Nodes/CircleUnique.test.cpp b/compiler/luci/lang/src/Nodes/CircleUnique.test.cpp new file mode 100644 index 000000000..517ee97d5 --- /dev/null +++ b/compiler/luci/lang/src/Nodes/CircleUnique.test.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "luci/IR/Nodes/CircleUnique.h" + +#include "luci/IR/CircleDialect.h" +#include "luci/IR/CircleNodeVisitor.h" + +#include <gtest/gtest.h> + +TEST(CircleUniqueTest, constructor) +{ + luci::CircleUnique unique_node; + + ASSERT_EQ(luci::CircleDialect::get(), unique_node.dialect()); + ASSERT_EQ(luci::CircleOpcode::UNIQUE, unique_node.opcode()); + + ASSERT_EQ(nullptr, unique_node.input()); +} + +TEST(CircleUniqueTest, input_NEG) +{ + luci::CircleUnique unique_node; + luci::CircleUnique node; + + unique_node.input(&node); + ASSERT_NE(nullptr, unique_node.input()); + + unique_node.input(nullptr); + ASSERT_EQ(nullptr, unique_node.input()); +} + +TEST(CircleUniqueTest, arity_NEG) +{ + luci::CircleUnique unique_node; + + ASSERT_NO_THROW(unique_node.arg(0)); + ASSERT_THROW(unique_node.arg(1), std::out_of_range); +} + +TEST(CircleUniqueTest, visit_mutable_NEG) +{ + struct TestVisitor final : public luci::CircleNodeMutableVisitor<void> + { + }; + + luci::CircleUnique unique_node; + + TestVisitor tv; + ASSERT_THROW(unique_node.accept(&tv), std::exception); +} + +TEST(CircleUniqueTest, visit_NEG) +{ + struct TestVisitor final : public luci::CircleNodeVisitor<void> + { + }; + + luci::CircleUnique unique_node; + + TestVisitor tv; + ASSERT_THROW(unique_node.accept(&tv), std::exception); +} diff --git a/compiler/luci/lang/src/Nodes/CircleWhile.test.cpp b/compiler/luci/lang/src/Nodes/CircleWhile.test.cpp index 19290c0a2..913686fbd 100644 --- a/compiler/luci/lang/src/Nodes/CircleWhile.test.cpp +++ b/compiler/luci/lang/src/Nodes/CircleWhile.test.cpp @@ -41,11 +41,15 @@ TEST(CircleWhileTest, constructor) TEST(CircleWhileTestDeath, invalid_arity_NEG) { ASSERT_DEBUG_DEATH(luci::CircleWhile very_long_name_while_node(0, 1), ""); + + SUCCEED(); } TEST(CircleWhileTestDeath, invalid_output_count_NEG) { ASSERT_DEBUG_DEATH(luci::CircleWhile while_node(2, 0), ""); + + SUCCEED(); } TEST(CircleWhileTestDeath, invalid_input_get_index_NEG) |