blob: 11ed9f6dcc8a1d5e3da948234ec4f228bc6b078a [file] [log] [blame]
Anthony Barbierdbdab852017-06-23 15:42:00 +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 "TypePrinter.h"
25#include "validation/Validation.h"
26
27#include "arm_compute/core/TensorInfo.h"
28#include "arm_compute/core/Types.h"
29
30#include "boost_wrapper.h"
31
32using namespace arm_compute;
33using namespace arm_compute::test;
34using namespace arm_compute::test::validation;
35
36#ifndef DOXYGEN_SKIP_THIS
37BOOST_AUTO_TEST_SUITE(UNIT)
38BOOST_AUTO_TEST_SUITE(TensorInfoValidation)
39
40BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
41BOOST_DATA_TEST_CASE(AutoPadding,
42 boost::unit_test::data::make({ TensorShape{},
43 TensorShape{ 10U },
44 TensorShape{ 10U, 10U },
45 TensorShape{ 10U, 10U, 10U },
46 TensorShape{ 10U, 10U, 10U, 10U },
47 TensorShape{ 10U, 10U, 10U, 10U, 10U },
48 TensorShape{ 10U, 10U, 10U, 10U, 10U, 10U }
49 })
50 ^ boost::unit_test::data::make({ PaddingSize{ 0, 0, 0, 0 },
51 PaddingSize{ 0, 36, 0, 4 },
52 PaddingSize{ 4, 36, 4, 4 },
53 PaddingSize{ 4, 36, 4, 4 },
54 PaddingSize{ 4, 36, 4, 4 },
55 PaddingSize{ 4, 36, 4, 4 },
56 PaddingSize{ 4, 36, 4, 4 }
57 })
58 ^ boost::unit_test::data::make({ Strides{},
59 Strides{ 1U },
60 Strides{ 1U, 50U },
61 Strides{ 1U, 50U, 900U },
62 Strides{ 1U, 50U, 900U, 9000U },
63 Strides{ 1U, 50U, 900U, 9000U, 90000U },
64 Strides{ 1U, 50U, 900U, 9000U, 90000U, 900000U }
65 })
66 ^ boost::unit_test::data::make(
67{
68 0,
69 4,
70 204,
71 204,
72 204,
73 204,
74 204,
75}),
76shape, auto_padding, strides, offset)
77{
78 TensorInfo info{ shape, Format::U8 };
79
80 BOOST_TEST(!info.has_padding());
81
82 info.auto_padding();
83
84 validate(info.padding(), auto_padding);
85 BOOST_TEST(compare_dimensions(info.strides_in_bytes(), strides));
86 BOOST_TEST(info.offset_first_element_in_bytes() == offset);
87}
88
89BOOST_AUTO_TEST_SUITE_END()
90BOOST_AUTO_TEST_SUITE_END()
91#endif