Georgios Pinitas | 284cfe2 | 2018-02-13 12:15:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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/NEPermute.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 | { |
Georgios Pinitas | 69af6cf | 2018-02-14 19:23:44 +0000 | [diff] [blame] | 45 | const auto PermuteParametersSmall = combine(concat(concat(datasets::Small2DShapes(), datasets::Small3DShapes()), datasets::Small4DShapes()), |
Georgios Pinitas | 284cfe2 | 2018-02-13 12:15:13 +0000 | [diff] [blame] | 46 | framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U) })); |
| 47 | const auto PermuteParametersLarge = combine(datasets::Large4DShapes(), |
| 48 | framework::dataset::make("PermutationVector", { PermutationVector(2U, 0U, 1U), PermutationVector(1U, 2U, 0U) })); |
| 49 | } // namespace |
| 50 | TEST_SUITE(NEON) |
| 51 | TEST_SUITE(Permute) |
| 52 | |
| 53 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small4DShapes(), framework::dataset::make("DataType", { DataType::S8, DataType::U8, DataType::S16, DataType::U16, DataType::U32, DataType::S32, DataType::F16, DataType::F32 })), |
| 54 | shape, data_type) |
| 55 | { |
| 56 | // Define permutation vector |
| 57 | const PermutationVector perm(2U, 0U, 1U); |
| 58 | |
| 59 | // Permute shapes |
| 60 | TensorShape output_shape = shape; |
| 61 | permute(output_shape, perm); |
| 62 | |
| 63 | // Create tensors |
| 64 | Tensor ref_src = create_tensor<Tensor>(shape, data_type); |
| 65 | Tensor dst = create_tensor<Tensor>(output_shape, data_type); |
| 66 | |
| 67 | // Create and Configure function |
| 68 | NEPermute perm_func; |
| 69 | perm_func.configure(&ref_src, &dst, perm); |
| 70 | |
| 71 | // Validate valid region |
| 72 | const ValidRegion valid_region = shape_to_valid_region(output_shape); |
| 73 | validate(dst.info()->valid_region(), valid_region); |
| 74 | } |
| 75 | |
| 76 | template <typename T> |
| 77 | using NEPermuteFixture = PermuteValidationFixture<Tensor, Accessor, NEPermute, T>; |
| 78 | |
| 79 | TEST_SUITE(U8) |
| 80 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U8))) |
| 81 | { |
| 82 | // Validate output |
| 83 | validate(Accessor(_target), _reference); |
| 84 | } |
| 85 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U8))) |
| 86 | { |
| 87 | // Validate output |
| 88 | validate(Accessor(_target), _reference); |
| 89 | } |
| 90 | TEST_SUITE_END() |
| 91 | |
| 92 | TEST_SUITE(U16) |
| 93 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture<uint16_t>, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U16))) |
| 94 | { |
| 95 | // Validate output |
| 96 | validate(Accessor(_target), _reference); |
| 97 | } |
| 98 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture<uint16_t>, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U16))) |
| 99 | { |
| 100 | // Validate output |
| 101 | validate(Accessor(_target), _reference); |
| 102 | } |
| 103 | TEST_SUITE_END() |
| 104 | |
| 105 | TEST_SUITE(U32) |
| 106 | FIXTURE_DATA_TEST_CASE(RunSmall, NEPermuteFixture<uint32_t>, framework::DatasetMode::PRECOMMIT, combine(PermuteParametersSmall, framework::dataset::make("DataType", DataType::U32))) |
| 107 | { |
| 108 | // Validate output |
| 109 | validate(Accessor(_target), _reference); |
| 110 | } |
| 111 | FIXTURE_DATA_TEST_CASE(RunLarge, NEPermuteFixture<uint32_t>, framework::DatasetMode::NIGHTLY, combine(PermuteParametersLarge, framework::dataset::make("DataType", DataType::U32))) |
| 112 | { |
| 113 | // Validate output |
| 114 | validate(Accessor(_target), _reference); |
| 115 | } |
| 116 | TEST_SUITE_END() |
| 117 | |
| 118 | TEST_SUITE_END() |
| 119 | TEST_SUITE_END() |
| 120 | } // namespace validation |
| 121 | } // namespace test |
| 122 | } // namespace arm_compute |