Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / compiler / angkor / src / ADT / tensor / LexicalLayout.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 "nncc/core/ADT/tensor/LexicalLayout.h"
18
19 #include <type_traits>
20
21 #include <gtest/gtest.h>
22
23 TEST(ADT_TENSOR_LEXICAL_LAYOUT, last)
24 {
25   const nncc::core::ADT::tensor::Shape shape{4, 3, 6};
26   const nncc::core::ADT::tensor::Index curr{1, 1, 1};
27   const nncc::core::ADT::tensor::Index next{1, 1, 2};
28
29   const nncc::core::ADT::tensor::LexicalLayout l;
30
31   ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 1);
32 }
33
34 TEST(ADT_TENSOR_LEXICAL_LAYOUT, lexical_middle)
35 {
36   const nncc::core::ADT::tensor::Shape shape{4, 3, 6};
37   const nncc::core::ADT::tensor::Index curr{1, 1, 1};
38   const nncc::core::ADT::tensor::Index next{1, 2, 1};
39
40   const nncc::core::ADT::tensor::LexicalLayout l;
41
42   ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 6);
43 }
44
45 TEST(ADT_TENSOR_LEXICAL_LAYOUT, lexical_first)
46 {
47   const nncc::core::ADT::tensor::Shape shape{4, 3, 6};
48   const nncc::core::ADT::tensor::Index curr{1, 1, 1};
49   const nncc::core::ADT::tensor::Index next{2, 1, 1};
50
51   const nncc::core::ADT::tensor::LexicalLayout l;
52
53   ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 6 * 3);
54 }