Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / compiler / nest / core / src / FV.test.cpp
1 /*
2  * Copyright (c) 2018 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 "nest/FV.h"
18 #include "nest/Module.h"
19
20 #include <gtest/gtest.h>
21
22 TEST(FV, var_expr)
23 {
24   nest::Module m;
25
26   auto var = m.var().make();
27
28   auto fvs = nest::FV::in(var);
29
30   ASSERT_EQ(1, fvs.size());
31   ASSERT_NE(fvs.find(var.id()), fvs.end());
32 }
33
34 TEST(FV, deref_expr)
35 {
36   nest::Module m;
37
38   auto dom = m.domain().make({16});
39   auto var = m.var().make();
40
41   auto fvs = nest::FV::in(dom(var));
42
43   ASSERT_EQ(1, fvs.size());
44   ASSERT_NE(fvs.find(var.id()), fvs.end());
45 }
46
47 TEST(FV, add_expr)
48 {
49   nest::Module m;
50
51   auto v_0 = m.var().make();
52   auto v_1 = m.var().make();
53
54   auto fvs = nest::FV::in(v_0 + v_1);
55
56   ASSERT_EQ(2, fvs.size());
57   ASSERT_NE(fvs.find(v_0.id()), fvs.end());
58   ASSERT_NE(fvs.find(v_1.id()), fvs.end());
59 }
60
61 TEST(FV, mul_expr)
62 {
63   nest::Module m;
64
65   auto v_0 = m.var().make();
66   auto v_1 = m.var().make();
67
68   nest::FV fv;
69
70   auto fvs = nest::FV::in(v_0 * v_1);
71
72   ASSERT_EQ(2, fvs.size());
73   ASSERT_NE(fvs.find(v_0.id()), fvs.end());
74   ASSERT_NE(fvs.find(v_1.id()), fvs.end());
75 }