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/CircleMaxPool2D.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleMaxPool2DTest, constructor_P)
26 luci::CircleMaxPool2D maxpool2d_node;
28 ASSERT_EQ(luci::CircleDialect::get(), maxpool2d_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::MAX_POOL_2D, maxpool2d_node.opcode());
31 ASSERT_EQ(nullptr, maxpool2d_node.value());
32 ASSERT_EQ(luci::Padding::UNDEFINED, maxpool2d_node.padding());
33 ASSERT_EQ(1, maxpool2d_node.filter()->h());
34 ASSERT_EQ(1, maxpool2d_node.filter()->w());
35 ASSERT_EQ(1, maxpool2d_node.stride()->h());
36 ASSERT_EQ(1, maxpool2d_node.stride()->w());
39 TEST(CircleMaxPool2DTest, input_NEG)
41 luci::CircleMaxPool2D maxpool2d_node;
42 luci::CircleMaxPool2D node;
44 maxpool2d_node.value(&node);
45 ASSERT_NE(nullptr, maxpool2d_node.value());
47 maxpool2d_node.value(nullptr);
48 ASSERT_EQ(nullptr, maxpool2d_node.value());
50 maxpool2d_node.filter()->h(2);
51 maxpool2d_node.filter()->w(2);
52 maxpool2d_node.stride()->h(2);
53 maxpool2d_node.stride()->w(2);
54 ASSERT_NE(1, maxpool2d_node.filter()->h());
55 ASSERT_NE(1, maxpool2d_node.filter()->w());
56 ASSERT_NE(1, maxpool2d_node.stride()->h());
57 ASSERT_NE(1, maxpool2d_node.stride()->w());
60 TEST(CircleMaxPool2DTest, arity_NEG)
62 luci::CircleMaxPool2D maxpool2d_node;
64 ASSERT_NO_THROW(maxpool2d_node.arg(0));
65 ASSERT_THROW(maxpool2d_node.arg(1), std::out_of_range);
68 TEST(CircleMaxPool2DTest, visit_mutable_NEG)
70 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
74 luci::CircleMaxPool2D maxpool2d_node;
77 ASSERT_THROW(maxpool2d_node.accept(&tv), std::exception);
80 TEST(CircleMaxPool2DTest, visit_NEG)
82 struct TestVisitor final : public luci::CircleNodeVisitor<void>
86 luci::CircleMaxPool2D maxpool2d_node;
89 ASSERT_THROW(maxpool2d_node.accept(&tv), std::exception);