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/CircleTransposeConv.h"
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
22 #include <gtest/gtest.h>
24 TEST(CircleTransposeConvTest, constructor_P)
26 luci::CircleTransposeConv trc_node;
28 ASSERT_EQ(luci::CircleDialect::get(), trc_node.dialect());
29 ASSERT_EQ(luci::CircleOpcode::TRANSPOSE_CONV, trc_node.opcode());
31 ASSERT_EQ(nullptr, trc_node.inputSizes());
32 ASSERT_EQ(nullptr, trc_node.filter());
33 ASSERT_EQ(nullptr, trc_node.outBackprop());
35 ASSERT_EQ(luci::Padding::UNDEFINED, trc_node.padding());
36 ASSERT_EQ(1, trc_node.stride()->h());
37 ASSERT_EQ(1, trc_node.stride()->w());
40 TEST(CircleTransposeConvTest, input_NEG)
42 luci::CircleTransposeConv trc_node;
43 luci::CircleTransposeConv node;
45 trc_node.inputSizes(&node);
46 trc_node.filter(&node);
47 trc_node.outBackprop(&node);
48 ASSERT_NE(nullptr, trc_node.inputSizes());
49 ASSERT_NE(nullptr, trc_node.filter());
50 ASSERT_NE(nullptr, trc_node.outBackprop());
52 trc_node.inputSizes(nullptr);
53 trc_node.filter(nullptr);
54 trc_node.outBackprop(nullptr);
55 ASSERT_EQ(nullptr, trc_node.inputSizes());
56 ASSERT_EQ(nullptr, trc_node.filter());
57 ASSERT_EQ(nullptr, trc_node.outBackprop());
59 trc_node.padding(luci::Padding::SAME);
60 ASSERT_NE(luci::Padding::UNDEFINED, trc_node.padding());
62 trc_node.stride()->h(2);
63 trc_node.stride()->w(2);
64 ASSERT_EQ(2, trc_node.stride()->h());
65 ASSERT_EQ(2, trc_node.stride()->w());
68 TEST(CircleTransposeConvTest, arity_NEG)
70 luci::CircleTransposeConv trc_node;
72 ASSERT_NO_THROW(trc_node.arg(2));
73 ASSERT_THROW(trc_node.arg(3), std::out_of_range);
76 TEST(CircleTransposeConvTest, visit_mutable_NEG)
78 struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
82 luci::CircleTransposeConv trc_node;
85 ASSERT_THROW(trc_node.accept(&tv), std::exception);
88 TEST(CircleTransposeConvTest, visit_NEG)
90 struct TestVisitor final : public luci::CircleNodeVisitor<void>
94 luci::CircleTransposeConv trc_node;
97 ASSERT_THROW(trc_node.accept(&tv), std::exception);