Imported Upstream version 1.9.0
[platform/core/ml/nnfw.git] / compiler / luci / lang / src / Nodes / CircleNonMaxSuppressionV5.test.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "luci/IR/Nodes/CircleNonMaxSuppressionV5.h"
18
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
21
22 #include <gtest/gtest.h>
23
24 TEST(CircleNonMaxSuppressionV5Test, constructor)
25 {
26   luci::CircleNonMaxSuppressionV5 nmsv5_node;
27
28   ASSERT_EQ(luci::CircleDialect::get(), nmsv5_node.dialect());
29   ASSERT_EQ(luci::CircleOpcode::NON_MAX_SUPPRESSION_V5, nmsv5_node.opcode());
30
31   ASSERT_EQ(nullptr, nmsv5_node.boxes());
32   ASSERT_EQ(nullptr, nmsv5_node.scores());
33   ASSERT_EQ(nullptr, nmsv5_node.max_output_size());
34   ASSERT_EQ(nullptr, nmsv5_node.iou_threshold());
35   ASSERT_EQ(nullptr, nmsv5_node.score_threshold());
36   ASSERT_EQ(nullptr, nmsv5_node.soft_nms_sigma());
37 }
38
39 TEST(CircleNonMaxSuppressionV5Test, input_NEG)
40 {
41   luci::CircleNonMaxSuppressionV5 nmsv5_node;
42   luci::CircleNonMaxSuppressionV5 node;
43
44   nmsv5_node.boxes(&node);
45   nmsv5_node.scores(&node);
46   nmsv5_node.max_output_size(&node);
47   nmsv5_node.iou_threshold(&node);
48   nmsv5_node.score_threshold(&node);
49   nmsv5_node.soft_nms_sigma(&node);
50   ASSERT_NE(nullptr, nmsv5_node.boxes());
51   ASSERT_NE(nullptr, nmsv5_node.scores());
52   ASSERT_NE(nullptr, nmsv5_node.max_output_size());
53   ASSERT_NE(nullptr, nmsv5_node.iou_threshold());
54   ASSERT_NE(nullptr, nmsv5_node.score_threshold());
55   ASSERT_NE(nullptr, nmsv5_node.soft_nms_sigma());
56
57   nmsv5_node.boxes(nullptr);
58   nmsv5_node.scores(nullptr);
59   nmsv5_node.max_output_size(nullptr);
60   nmsv5_node.iou_threshold(nullptr);
61   nmsv5_node.score_threshold(nullptr);
62   nmsv5_node.soft_nms_sigma(nullptr);
63   ASSERT_EQ(nullptr, nmsv5_node.boxes());
64   ASSERT_EQ(nullptr, nmsv5_node.scores());
65   ASSERT_EQ(nullptr, nmsv5_node.max_output_size());
66   ASSERT_EQ(nullptr, nmsv5_node.iou_threshold());
67   ASSERT_EQ(nullptr, nmsv5_node.score_threshold());
68   ASSERT_EQ(nullptr, nmsv5_node.soft_nms_sigma());
69 }
70
71 TEST(CircleNonMaxSuppressionV5Test, arity_NEG)
72 {
73   luci::CircleNonMaxSuppressionV5 nmsv5_node;
74
75   ASSERT_NO_THROW(nmsv5_node.arg(5));
76   ASSERT_THROW(nmsv5_node.arg(6), std::out_of_range);
77 }
78
79 TEST(CircleNonMaxSuppressionV5Test, visit_mutable_NEG)
80 {
81   struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
82   {
83   };
84
85   luci::CircleNonMaxSuppressionV5 nmsv5_node;
86
87   TestVisitor tv;
88   ASSERT_THROW(nmsv5_node.accept(&tv), std::exception);
89 }
90
91 TEST(CircleNonMaxSuppressionV5Test, visit_NEG)
92 {
93   struct TestVisitor final : public luci::CircleNodeVisitor<void>
94   {
95   };
96
97   luci::CircleNonMaxSuppressionV5 nmsv5_node;
98
99   TestVisitor tv;
100   ASSERT_THROW(nmsv5_node.accept(&tv), std::exception);
101 }