blob: d0dbd4fd3ff0d83d2b1de2a92da34d97086d5eaa [file] [log] [blame]
Ioan-Cristian Szabo5a99ddf2017-10-26 16:46:04 +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/Types.h"
25#include "arm_compute/runtime/NEON/functions/NETranspose.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/NEON/Accessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ShapeDatasets.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/TransposeFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43TEST_SUITE(NEON)
44TEST_SUITE(Transpose)
45
46DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", { DataType::S8, DataType::U8, DataType::S16, DataType::U16, DataType::U32, DataType::S32, DataType::F16, DataType::F32 })),
47 shape, data_type)
48{
49 // Make rows the columns of the original shape
50 TensorShape output_shape{ shape[1], shape[0] };
51
52 // Create tensors
53 Tensor ref_src = create_tensor<Tensor>(shape, data_type);
54 Tensor dst = create_tensor<Tensor>(output_shape, data_type);
55
56 // Create and Configure function
57 NETranspose trans;
58 trans.configure(&ref_src, &dst);
59
60 // Validate valid region
61 const ValidRegion valid_region = shape_to_valid_region(output_shape);
62 validate(dst.info()->valid_region(), valid_region);
63
64 // TODO(bsgcomp): Add padding validation (COMPMID-659)
65}
66
67template <typename T>
68using NETransposeFixture = TransposeValidationFixture<Tensor, Accessor, NETranspose, T>;
69
70TEST_SUITE(U8)
71FIXTURE_DATA_TEST_CASE(RunSmall, NETransposeFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8)))
72{
73 // Validate output
74 validate(Accessor(_target), _reference);
75}
76FIXTURE_DATA_TEST_CASE(RunLarge, NETransposeFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U8)))
77{
78 // Validate output
79 validate(Accessor(_target), _reference);
80}
81TEST_SUITE_END()
82
83TEST_SUITE(U16)
84FIXTURE_DATA_TEST_CASE(RunSmall, NETransposeFixture<uint16_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U16)))
85{
86 // Validate output
87 validate(Accessor(_target), _reference);
88}
89FIXTURE_DATA_TEST_CASE(RunLarge, NETransposeFixture<uint16_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U16)))
90{
91 // Validate output
92 validate(Accessor(_target), _reference);
93}
94TEST_SUITE_END()
95
96TEST_SUITE(U32)
97FIXTURE_DATA_TEST_CASE(RunSmall, NETransposeFixture<uint32_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U32)))
98{
99 // Validate output
100 validate(Accessor(_target), _reference);
101}
102FIXTURE_DATA_TEST_CASE(RunLarge, NETransposeFixture<uint32_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U32)))
103{
104 // Validate output
105 validate(Accessor(_target), _reference);
106}
107TEST_SUITE_END()
108
109TEST_SUITE_END()
110TEST_SUITE_END()
111} // namespace validation
112} // namespace test
113} // namespace arm_compute