blob: 2a6c3365ea905b381231365e30b3d80dba03395e [file] [log] [blame]
John Richardsona36eae12017-09-26 16:55:59 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/TensorInfo.h"
25#include "arm_compute/core/Types.h"
26#include "tests/framework/Asserts.h"
27#include "tests/framework/Macros.h"
28#include "tests/framework/datasets/Datasets.h"
29#include "tests/validation/Validation.h"
30#include "utils/TypePrinter.h"
31
32namespace arm_compute
33{
34namespace test
35{
36namespace validation
37{
38TEST_SUITE(UNIT)
39TEST_SUITE(TensorInfoValidation)
40
41// *INDENT-OFF*
42// clang-format off
43DATA_TEST_CASE(AutoPadding, framework::DatasetMode::ALL, zip(zip(zip(
44 framework::dataset::make("TensorShape", {
45 TensorShape{},
46 TensorShape{ 10U },
47 TensorShape{ 10U, 10U },
48 TensorShape{ 10U, 10U, 10U },
49 TensorShape{ 10U, 10U, 10U, 10U },
50 TensorShape{ 10U, 10U, 10U, 10U, 10U },
51 TensorShape{ 10U, 10U, 10U, 10U, 10U, 10U }}),
52 framework::dataset::make("PaddingSize", {
53 PaddingSize{ 0, 0, 0, 0 },
54 PaddingSize{ 0, 36, 0, 4 },
55 PaddingSize{ 4, 36, 4, 4 },
56 PaddingSize{ 4, 36, 4, 4 },
57 PaddingSize{ 4, 36, 4, 4 },
58 PaddingSize{ 4, 36, 4, 4 },
59 PaddingSize{ 4, 36, 4, 4 }})),
60 framework::dataset::make("Strides", {
61 Strides{},
62 Strides{ 1U, 50U },
63 Strides{ 1U, 50U },
64 Strides{ 1U, 50U, 900U },
65 Strides{ 1U, 50U, 900U, 9000U },
66 Strides{ 1U, 50U, 900U, 9000U, 90000U },
67 Strides{ 1U, 50U, 900U, 9000U, 90000U, 900000U }})),
68 framework::dataset::make("Offset", { 0U, 4U, 204U, 204U, 204U, 204U, 204U })),
69 shape, auto_padding, strides, offset)
70{
71 TensorInfo info{ shape, Format::U8 };
72
73 ARM_COMPUTE_EXPECT(!info.has_padding(), framework::LogLevel::ERRORS);
74
75 info.auto_padding();
76
77 validate(info.padding(), auto_padding);
78
79 ARM_COMPUTE_EXPECT(compare_dimensions(info.strides_in_bytes(), strides), framework::LogLevel::ERRORS);
80 ARM_COMPUTE_EXPECT(info.offset_first_element_in_bytes() == offset, framework::LogLevel::ERRORS);
81}
82// clang-format on
83// *INDENT-ON*
84
85TEST_SUITE_END() // TensorInfoValidation
86TEST_SUITE_END()
87} // namespace validation
88} // namespace test
89} // namespace arm_compute