429169744827a633553c0d1437bd9f2e7bb1b054
[platform/core/ml/nnfw.git] / compiler / luci / lang / src / Nodes / CircleTransposeConv.test.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
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
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "luci/IR/Nodes/CircleTransposeConv.h"
18
19 #include "luci/IR/CircleDialect.h"
20 #include "luci/IR/CircleNodeVisitor.h"
21
22 #include <gtest/gtest.h>
23
24 TEST(CircleTransposeConvTest, constructor_P)
25 {
26   luci::CircleTransposeConv trc_node;
27
28   ASSERT_EQ(luci::CircleDialect::get(), trc_node.dialect());
29   ASSERT_EQ(luci::CircleOpcode::TRANSPOSE_CONV, trc_node.opcode());
30
31   ASSERT_EQ(nullptr, trc_node.inputSizes());
32   ASSERT_EQ(nullptr, trc_node.filter());
33   ASSERT_EQ(nullptr, trc_node.outBackprop());
34
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());
38 }
39
40 TEST(CircleTransposeConvTest, input_NEG)
41 {
42   luci::CircleTransposeConv trc_node;
43   luci::CircleTransposeConv node;
44
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());
51
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());
58
59   trc_node.padding(luci::Padding::SAME);
60   ASSERT_NE(luci::Padding::UNDEFINED, trc_node.padding());
61
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());
66 }
67
68 TEST(CircleTransposeConvTest, arity_NEG)
69 {
70   luci::CircleTransposeConv trc_node;
71
72   ASSERT_NO_THROW(trc_node.arg(2));
73   ASSERT_THROW(trc_node.arg(3), std::out_of_range);
74 }
75
76 TEST(CircleTransposeConvTest, visit_mutable_NEG)
77 {
78   struct TestVisitor final : public luci::CircleNodeMutableVisitor<void>
79   {
80   };
81
82   luci::CircleTransposeConv trc_node;
83
84   TestVisitor tv;
85   ASSERT_THROW(trc_node.accept(&tv), std::exception);
86 }
87
88 TEST(CircleTransposeConvTest, visit_NEG)
89 {
90   struct TestVisitor final : public luci::CircleNodeVisitor<void>
91   {
92   };
93
94   luci::CircleTransposeConv trc_node;
95
96   TestVisitor tv;
97   ASSERT_THROW(trc_node.accept(&tv), std::exception);
98 }