2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "luci/IR/Nodes/CircleNonMaxSuppressionV5.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleNonMaxSuppressionV5Test, constructor)
26 luci::CircleNonMaxSuppressionV5 nmsv5_node;
28 ASSERT_EQ(luci::CircleDialect::get(), nmsv5_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::NON_MAX_SUPPRESSION_V5, nmsv5_node.opcode());
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());
39 TEST(CircleNonMaxSuppressionV5Test, input_NEG)
41 luci::CircleNonMaxSuppressionV5 nmsv5_node;
42 luci::CircleNonMaxSuppressionV5 node;
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());
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());
71 TEST(CircleNonMaxSuppressionV5Test, arity_NEG)
73 luci::CircleNonMaxSuppressionV5 nmsv5_node;
75 ASSERT_NO_THROW(nmsv5_node.arg(5));
76 ASSERT_THROW(nmsv5_node.arg(6), std::out_of_range);
79 TEST(CircleNonMaxSuppressionV5Test, visit_mutable_NEG)
81 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
85 luci::CircleNonMaxSuppressionV5 nmsv5_node;
88 ASSERT_THROW(nmsv5_node.accept(&tv), std::exception);
91 TEST(CircleNonMaxSuppressionV5Test, visit_NEG)
93 struct TestVisitor final : public luci::CircleNodeVisitor<void>
97 luci::CircleNonMaxSuppressionV5 nmsv5_node;
100 ASSERT_THROW(nmsv5_node.accept(&tv), std::exception);