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/CircleNonMaxSuppressionV4.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleNonMaxSuppressionV4Test, constructor)
26 luci::CircleNonMaxSuppressionV4 nmsv4_node;
28 ASSERT_EQ(luci::CircleDialect::get(), nmsv4_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::NON_MAX_SUPPRESSION_V4, nmsv4_node.opcode());
31 ASSERT_EQ(nullptr, nmsv4_node.boxes());
32 ASSERT_EQ(nullptr, nmsv4_node.scores());
33 ASSERT_EQ(nullptr, nmsv4_node.max_output_size());
34 ASSERT_EQ(nullptr, nmsv4_node.iou_threshold());
35 ASSERT_EQ(nullptr, nmsv4_node.score_threshold());
38 TEST(CircleNonMaxSuppressionV4Test, input_NEG)
40 luci::CircleNonMaxSuppressionV4 nmsv4_node;
41 luci::CircleNonMaxSuppressionV4 node;
43 nmsv4_node.boxes(&node);
44 nmsv4_node.scores(&node);
45 nmsv4_node.max_output_size(&node);
46 nmsv4_node.iou_threshold(&node);
47 nmsv4_node.score_threshold(&node);
48 ASSERT_NE(nullptr, nmsv4_node.boxes());
49 ASSERT_NE(nullptr, nmsv4_node.scores());
50 ASSERT_NE(nullptr, nmsv4_node.max_output_size());
51 ASSERT_NE(nullptr, nmsv4_node.iou_threshold());
52 ASSERT_NE(nullptr, nmsv4_node.score_threshold());
54 nmsv4_node.boxes(nullptr);
55 nmsv4_node.scores(nullptr);
56 nmsv4_node.max_output_size(nullptr);
57 nmsv4_node.iou_threshold(nullptr);
58 nmsv4_node.score_threshold(nullptr);
59 ASSERT_EQ(nullptr, nmsv4_node.boxes());
60 ASSERT_EQ(nullptr, nmsv4_node.scores());
61 ASSERT_EQ(nullptr, nmsv4_node.max_output_size());
62 ASSERT_EQ(nullptr, nmsv4_node.iou_threshold());
63 ASSERT_EQ(nullptr, nmsv4_node.score_threshold());
66 TEST(CircleNonMaxSuppressionV4Test, arity_NEG)
68 luci::CircleNonMaxSuppressionV4 nmsv4_node;
70 ASSERT_NO_THROW(nmsv4_node.arg(4));
71 ASSERT_THROW(nmsv4_node.arg(5), std::out_of_range);
74 TEST(CircleNonMaxSuppressionV4Test, visit_mutable_NEG)
76 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
80 luci::CircleNonMaxSuppressionV4 nmsv4_node;
83 ASSERT_THROW(nmsv4_node.accept(&tv), std::exception);
86 TEST(CircleNonMaxSuppressionV4Test, visit_NEG)
88 struct TestVisitor final : public luci::CircleNodeVisitor<void>
92 luci::CircleNonMaxSuppressionV4 nmsv4_node;
95 ASSERT_THROW(nmsv4_node.accept(&tv), std::exception);