blob: 9495fa738e55202befd998e1f292bd417f53f2fb [file] [log] [blame]
Georgios Pinitas8795ffb2017-12-01 16:13:40 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Georgios Pinitas8795ffb2017-12-01 16:13:40 +00003 *
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
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
Pablo Tello35767bc2018-12-05 17:36:30 +000045const 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});
Michalis Spyrou6bff1952019-10-02 17:22:11 +010054const auto PermuteParametersSmall = concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()) * PermuteVectors;
55const auto PermuteParametersLarge = datasets::Large4DShapes() * PermuteVectors;
Pablo Tello35767bc2018-12-05 17:36:30 +000056
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000057} // namespace
58TEST_SUITE(CPP)
59TEST_SUITE(Permute)
60
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000061template <typename T>
62using CPPPermuteFixture = PermuteValidationFixture<Tensor, Accessor, CPPPermute, T>;
63
64TEST_SUITE(U8)
Pablo Tello35767bc2018-12-05 17:36:30 +000065FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
66 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U8))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000067{
68 // Validate output
69 validate(Accessor(_target), _reference);
70}
Pablo Tello35767bc2018-12-05 17:36:30 +000071
72FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
73 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U8))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000074{
75 // Validate output
76 validate(Accessor(_target), _reference);
77}
Pablo Tello35767bc2018-12-05 17:36:30 +000078
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000079TEST_SUITE_END()
80
81TEST_SUITE(U16)
Pablo Tello35767bc2018-12-05 17:36:30 +000082FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint16_t>, framework::DatasetMode::PRECOMMIT,
83 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U16))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000084{
85 // Validate output
86 validate(Accessor(_target), _reference);
87}
Pablo Tello35767bc2018-12-05 17:36:30 +000088
89FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint16_t>, framework::DatasetMode::NIGHTLY,
90 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U16))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +000091{
92 // Validate output
93 validate(Accessor(_target), _reference);
94}
95TEST_SUITE_END()
96
97TEST_SUITE(U32)
Pablo Tello35767bc2018-12-05 17:36:30 +000098FIXTURE_DATA_TEST_CASE(RunSmall, CPPPermuteFixture<uint32_t>, framework::DatasetMode::PRECOMMIT,
99 PermuteParametersSmall * framework::dataset::make("DataType", DataType::U32))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000100{
101 // Validate output
102 validate(Accessor(_target), _reference);
103}
Pablo Tello35767bc2018-12-05 17:36:30 +0000104
105FIXTURE_DATA_TEST_CASE(RunLarge, CPPPermuteFixture<uint32_t>, framework::DatasetMode::NIGHTLY,
106 PermuteParametersLarge * framework::dataset::make("DataType", DataType::U32))
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000107{
108 // Validate output
109 validate(Accessor(_target), _reference);
110}
111TEST_SUITE_END()
112
Sheri Zhanga0352d32020-03-16 14:20:56 +0000113TEST_SUITE(QASYMM8_SINGED)
114FIXTURE_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
121TEST_SUITE_END() // QASYMM8_SINGED
122
Georgios Pinitas8795ffb2017-12-01 16:13:40 +0000123TEST_SUITE_END()
124TEST_SUITE_END()
125} // namespace validation
126} // namespace test
127} // namespace arm_compute