John Richardson | f89a49f | 2017-09-05 11:21:56 +0100 | [diff] [blame] | 1 | /* |
Michalis Spyrou | 5c9f0c4 | 2019-01-16 14:48:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 ARM Limited. |
John Richardson | f89a49f | 2017-09-05 11:21:56 +0100 | [diff] [blame] | 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 | |
| 25 | #include "arm_compute/runtime/NEON/functions/NEMinMaxLocation.h" |
| 26 | #include "tests/NEON/Accessor.h" |
| 27 | #include "tests/NEON/ArrayAccessor.h" |
| 28 | #include "tests/PaddingCalculator.h" |
| 29 | #include "tests/datasets/ShapeDatasets.h" |
| 30 | #include "tests/framework/Macros.h" |
| 31 | #include "tests/validation/Validation.h" |
| 32 | #include "tests/validation/fixtures/MinMaxLocationFixture.h" |
| 33 | |
| 34 | namespace arm_compute |
| 35 | { |
| 36 | namespace test |
| 37 | { |
| 38 | namespace validation |
| 39 | { |
| 40 | TEST_SUITE(NEON) |
| 41 | TEST_SUITE(MinMaxLocation) |
| 42 | |
| 43 | template <typename T> |
| 44 | using NEMinMaxLocationFixture = MinMaxLocationValidationFixture<Tensor, Accessor, Array<Coordinates2D>, ArrayAccessor<Coordinates2D>, NEMinMaxLocation, T>; |
| 45 | |
| 46 | void validate_configuration(const Tensor &src, TensorShape shape) |
| 47 | { |
| 48 | ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); |
| 49 | |
| 50 | // Create output storage |
| 51 | int32_t min{}; |
| 52 | int32_t max{}; |
| 53 | Coordinates2DArray min_loc(shape.total_size()); |
| 54 | Coordinates2DArray max_loc(shape.total_size()); |
| 55 | |
| 56 | // Create and configure function |
| 57 | NEMinMaxLocation min_max_loc; |
| 58 | min_max_loc.configure(&src, &min, &max, &min_loc, &max_loc); |
| 59 | |
| 60 | // Validate padding |
| 61 | const PaddingSize padding = PaddingCalculator(shape.x(), 1).required_padding(); |
| 62 | validate(src.info()->padding(), padding); |
| 63 | } |
| 64 | |
| 65 | TEST_SUITE(U8) |
Michalis Spyrou | 5c9f0c4 | 2019-01-16 14:48:48 +0000 | [diff] [blame] | 66 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8)), shape, data_type) |
John Richardson | f89a49f | 2017-09-05 11:21:56 +0100 | [diff] [blame] | 67 | { |
| 68 | // Create tensors |
| 69 | Tensor src = create_tensor<Tensor>(shape, data_type); |
| 70 | src.info()->set_format(Format::U8); |
| 71 | |
| 72 | validate_configuration(src, shape); |
| 73 | } |
| 74 | |
| 75 | FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", |
| 76 | DataType::U8))) |
| 77 | { |
| 78 | validate_min_max_loc(_target, _reference); |
| 79 | } |
| 80 | |
| 81 | FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", |
| 82 | DataType::U8))) |
| 83 | { |
| 84 | validate_min_max_loc(_target, _reference); |
| 85 | } |
| 86 | |
| 87 | TEST_SUITE_END() // U8 |
| 88 | |
| 89 | TEST_SUITE(S16) |
Michalis Spyrou | 5c9f0c4 | 2019-01-16 14:48:48 +0000 | [diff] [blame] | 90 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::S16)), shape, data_type) |
John Richardson | f89a49f | 2017-09-05 11:21:56 +0100 | [diff] [blame] | 91 | { |
| 92 | // Create tensors |
| 93 | Tensor src = create_tensor<Tensor>(shape, data_type); |
| 94 | src.info()->set_format(Format::S16); |
| 95 | |
| 96 | validate_configuration(src, shape); |
| 97 | } |
| 98 | |
| 99 | FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", |
| 100 | DataType::S16))) |
| 101 | { |
| 102 | validate_min_max_loc(_target, _reference); |
| 103 | } |
| 104 | |
| 105 | FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", |
| 106 | DataType::S16))) |
| 107 | { |
| 108 | validate_min_max_loc(_target, _reference); |
| 109 | } |
| 110 | |
| 111 | TEST_SUITE_END() // S16 |
| 112 | |
| 113 | TEST_SUITE(Float) |
Michalis Spyrou | 5c9f0c4 | 2019-01-16 14:48:48 +0000 | [diff] [blame] | 114 | DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32)), shape, data_type) |
John Richardson | f89a49f | 2017-09-05 11:21:56 +0100 | [diff] [blame] | 115 | { |
| 116 | // Create tensors |
| 117 | Tensor src = create_tensor<Tensor>(shape, data_type); |
| 118 | src.info()->set_format(Format::F32); |
| 119 | |
| 120 | validate_configuration(src, shape); |
| 121 | } |
| 122 | |
| 123 | FIXTURE_DATA_TEST_CASE(RunSmall, NEMinMaxLocationFixture<float>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", |
| 124 | DataType::F32))) |
| 125 | { |
| 126 | validate_min_max_loc(_target, _reference); |
| 127 | } |
| 128 | |
| 129 | FIXTURE_DATA_TEST_CASE(RunLarge, NEMinMaxLocationFixture<float>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", |
| 130 | DataType::F32))) |
| 131 | { |
| 132 | validate_min_max_loc(_target, _reference); |
| 133 | } |
| 134 | |
| 135 | TEST_SUITE_END() // F32 |
| 136 | |
| 137 | TEST_SUITE_END() // MinMaxLocation |
| 138 | TEST_SUITE_END() // NEON |
| 139 | } // namespace validation |
| 140 | } // namespace test |
| 141 | } // namespace arm_compute |