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/CircleReduceAny.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleReduceAnyTest, constructor)
26 luci::CircleReduceAny reduce_any_node;
28 ASSERT_EQ(luci::CircleDialect::get(), reduce_any_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::REDUCE_ANY, reduce_any_node.opcode());
31 ASSERT_EQ(nullptr, reduce_any_node.input());
32 ASSERT_EQ(nullptr, reduce_any_node.reduction_indices());
34 ASSERT_FALSE(reduce_any_node.keep_dims());
37 TEST(CircleReduceAnyTest, input_NEG)
39 luci::CircleReduceAny reduce_any_node;
40 luci::CircleReduceAny node;
42 reduce_any_node.input(&node);
43 reduce_any_node.reduction_indices(&node);
44 ASSERT_NE(nullptr, reduce_any_node.input());
45 ASSERT_NE(nullptr, reduce_any_node.reduction_indices());
47 reduce_any_node.input(nullptr);
48 reduce_any_node.reduction_indices(nullptr);
49 ASSERT_EQ(nullptr, reduce_any_node.input());
50 ASSERT_EQ(nullptr, reduce_any_node.reduction_indices());
52 reduce_any_node.keep_dims(true);
53 ASSERT_TRUE(reduce_any_node.keep_dims());
56 TEST(CircleReduceAnyTest, arity_NEG)
58 luci::CircleReduceAny reduce_any_node;
60 ASSERT_NO_THROW(reduce_any_node.arg(1));
61 ASSERT_THROW(reduce_any_node.arg(2), std::out_of_range);
64 TEST(CircleReduceAnyTest, visit_mutable_NEG)
66 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
70 luci::CircleReduceAny reduce_any_node;
73 ASSERT_THROW(reduce_any_node.accept(&tv), std::exception);
76 TEST(CircleReduceAnyTest, visit_NEG)
78 struct TestVisitor final : public luci::CircleNodeVisitor<void>
82 luci::CircleReduceAny reduce_any_node;
85 ASSERT_THROW(reduce_any_node.accept(&tv), std::exception);