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