1 /*
2 * Copyright (c) 2017-2020 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/CPP/functions/CPPPermute.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/PermuteFixture.h"
36
37 namespace arm_compute
38 {
39 namespace test
40 {
41 namespace validation
42 {
43 namespace
44 {
45 const auto PermuteVectors = framework::dataset::make("PermutationVector",
46 {
47 PermutationVector(2U, 0U, 1U),
48 PermutationVector(1U, 2U, 0U),
49 PermutationVector(0U, 1U, 2U),
50 PermutationVector(0U, 2U, 1U),
51 PermutationVector(1U, 0U, 2U),
52 PermutationVector(2U, 1U, 0U),
53 });
54 const auto PermuteParametersSmall = concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()) * PermuteVectors;
55 const auto PermuteParametersLarge = datasets::Large4DShapes() * PermuteVectors;
56
57 } // namespace
58 TEST_SUITE(CPP)
59 TEST_SUITE(Permute)
60
61 template <typename T>
62 using CPPPermuteFixture = PermuteValidationFixture<Tensor, Accessor, CPPPermute, T>;
63
64 TEST_SUITE(U8)
65 FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
66 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U8))
67 {
68 // Validate output
69 validate(Accessor(_target), _reference);
70 }
71
72 FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
73 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U8))
74 {
75 // Validate output
76 validate(Accessor(_target), _reference);
77 }
78
79 TEST_SUITE_END()
80
TEST_SUITE(U16)81 TEST_SUITE(U16)
82 FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint16_t>, framework::DatasetMode::PRECOMMIT,
83 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U16))
84 {
85 // Validate output
86 validate(Accessor(_target), _reference);
87 }
88
89 FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint16_t>, framework::DatasetMode::NIGHTLY,
90 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U16))
91 {
92 // Validate output
93 validate(Accessor(_target), _reference);
94 }
95 TEST_SUITE_END()
96
TEST_SUITE(U32)97 TEST_SUITE(U32)
98 FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint32_t>, framework::DatasetMode::PRECOMMIT,
99 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U32))
100 {
101 // Validate output
102 validate(Accessor(_target), _reference);
103 }
104
105 FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint32_t>, framework::DatasetMode::NIGHTLY,
106 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U32))
107 {
108 // Validate output
109 validate(Accessor(_target), _reference);
110 }
111 TEST_SUITE_END()
112
TEST_SUITE(QASYMM8_SINGED)113 TEST_SUITE(QASYMM8_SINGED)
114 FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<int8_t>, framework::DatasetMode::PRECOMMIT,
115 PermuteParametersSmall * framework::dataset::make("DataType", DataType::QASYMM8_SIGNED))
116 {
117 // Validate output
118 validate(Accessor(_target), _reference);
119 }
120
121 TEST_SUITE_END() // QASYMM8_SINGED
122
123 TEST_SUITE_END()
124 TEST_SUITE_END()
125 } // namespace validation
126 } // namespace test
127 } // namespace arm_compute
128