2 * Copyright (c) 2018 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 "nncc/core/ADT/tensor/LexicalLayout.h"
19 #include <type_traits>
21 #include <gtest/gtest.h>
23 TEST(ADT_TENSOR_LEXICAL_LAYOUT, last)
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};
29 const nncc::core::ADT::tensor::LexicalLayout l;
31 ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 1);
34 TEST(ADT_TENSOR_LEXICAL_LAYOUT, lexical_middle)
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};
40 const nncc::core::ADT::tensor::LexicalLayout l;
42 ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 6);
45 TEST(ADT_TENSOR_LEXICAL_LAYOUT, lexical_first)
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};
51 const nncc::core::ADT::tensor::LexicalLayout l;
53 ASSERT_EQ(l.offset(shape, next), l.offset(shape, curr) + 6 * 3);