xref: /aosp_15_r20/external/ComputeLibrary/tests/validation/UNIT/TensorShape.cpp (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
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 "tests/framework/Macros.h"
25 #include "tests/framework/datasets/Datasets.h"
26 #include "tests/validation/Validation.h"
27 
28 namespace arm_compute
29 {
30 namespace test
31 {
32 namespace validation
33 {
34 TEST_SUITE(UNIT)
TEST_SUITE(TensorShapeValidation)35 TEST_SUITE(TensorShapeValidation)
36 
37 // *INDENT-OFF*
38 // clang-format off
39 DATA_TEST_CASE(Construction, framework::DatasetMode::ALL, zip(zip(
40                framework::dataset::make("TensorShape", {
41                TensorShape{},
42                TensorShape{ 1U },
43                TensorShape{ 2U },
44                TensorShape{ 2U, 3U },
45                TensorShape{ 2U, 3U, 5U },
46                TensorShape{ 2U, 3U, 5U, 7U },
47                TensorShape{ 2U, 3U, 5U, 7U, 11U },
48                TensorShape{ 2U, 3U, 5U, 7U, 11U, 13U }}),
49                framework::dataset::make("NumDimensions", { 0U, 1U, 1U, 2U, 3U, 4U, 5U, 6U })),
50                framework::dataset::make("TotalSize", { 0U, 1U, 2U, 6U, 30U, 210U, 2310U, 30030U })),
51                shape, num_dimensions, total_size)
52 {
53     ARM_COMPUTE_EXPECT(shape.num_dimensions() == num_dimensions, framework::LogLevel::ERRORS);
54     ARM_COMPUTE_EXPECT(shape.total_size() == total_size, framework::LogLevel::ERRORS);
55 }
56 // clang-format on
57 // *INDENT-ON*
58 
59 DATA_TEST_CASE(SetEmpty, framework::DatasetMode::ALL, framework::dataset::make("Dimension", { 0U, 1U, 2U, 3U, 4U, 5U }), dimension)
60 {
61     TensorShape shape;
62 
63     shape.set(dimension, 10);
64 
65     ARM_COMPUTE_EXPECT(shape.num_dimensions() == dimension + 1, framework::LogLevel::ERRORS);
66     ARM_COMPUTE_EXPECT(shape.total_size() == 10, framework::LogLevel::ERRORS);
67 }
68 
69 TEST_SUITE_END() // TensorShapeValidation
70 TEST_SUITE_END()
71 } // namespace validation
72 } // namespace test
73 } // namespace arm_compute
74