Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +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 "Validation.h" |
| 25 | |
| 26 | #include "IAccessor.h" |
| 27 | #include "RawTensor.h" |
| 28 | #include "TypePrinter.h" |
| 29 | #include "Utils.h" |
| 30 | |
| 31 | #include "arm_compute/core/Coordinates.h" |
| 32 | #include "arm_compute/core/Error.h" |
| 33 | #include "arm_compute/core/FixedPoint.h" |
| 34 | #include "arm_compute/core/TensorShape.h" |
| 35 | #include "arm_compute/runtime/Tensor.h" |
| 36 | |
| 37 | #include <array> |
| 38 | #include <cmath> |
| 39 | #include <cstddef> |
| 40 | #include <cstdint> |
| 41 | #include <iomanip> |
| 42 | |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 43 | #ifdef ARM_COMPUTE_ENABLE_FP16 |
Pablo Tello | 383deec | 2017-06-23 10:40:05 +0100 | [diff] [blame] | 44 | #include <arm_fp16.h> // needed for float16_t |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 45 | #endif /* ARM_COMPUTE_ENABLE_FP16 */ |
Pablo Tello | 383deec | 2017-06-23 10:40:05 +0100 | [diff] [blame] | 46 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 47 | namespace arm_compute |
| 48 | { |
| 49 | namespace test |
| 50 | { |
| 51 | namespace validation |
| 52 | { |
| 53 | namespace |
| 54 | { |
| 55 | /** Get the data from *ptr after casting according to @p data_type and then convert the data to double. |
| 56 | * |
| 57 | * @param[in] ptr Pointer to value. |
| 58 | * @param[in] data_type Data type of both values. |
| 59 | * |
| 60 | * @return The data from the ptr after converted to double. |
| 61 | */ |
| 62 | double get_double_data(const void *ptr, DataType data_type) |
| 63 | { |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 64 | if(ptr == nullptr) |
| 65 | { |
| 66 | ARM_COMPUTE_ERROR("Can't dereference a null pointer!"); |
| 67 | } |
| 68 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 69 | switch(data_type) |
| 70 | { |
| 71 | case DataType::U8: |
| 72 | return *reinterpret_cast<const uint8_t *>(ptr); |
| 73 | case DataType::S8: |
| 74 | return *reinterpret_cast<const int8_t *>(ptr); |
| 75 | case DataType::QS8: |
| 76 | return *reinterpret_cast<const qint8_t *>(ptr); |
| 77 | case DataType::U16: |
| 78 | return *reinterpret_cast<const uint16_t *>(ptr); |
| 79 | case DataType::S16: |
| 80 | return *reinterpret_cast<const int16_t *>(ptr); |
Michalis Spyrou | 0a8334c | 2017-06-14 18:00:05 +0100 | [diff] [blame] | 81 | case DataType::QS16: |
| 82 | return *reinterpret_cast<const qint16_t *>(ptr); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 83 | case DataType::U32: |
| 84 | return *reinterpret_cast<const uint32_t *>(ptr); |
| 85 | case DataType::S32: |
| 86 | return *reinterpret_cast<const int32_t *>(ptr); |
| 87 | case DataType::U64: |
| 88 | return *reinterpret_cast<const uint64_t *>(ptr); |
| 89 | case DataType::S64: |
| 90 | return *reinterpret_cast<const int64_t *>(ptr); |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 91 | #ifdef ARM_COMPUTE_ENABLE_FP16 |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 92 | case DataType::F16: |
| 93 | return *reinterpret_cast<const float16_t *>(ptr); |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 94 | #endif /* ARM_COMPUTE_ENABLE_FP16 */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 95 | case DataType::F32: |
| 96 | return *reinterpret_cast<const float *>(ptr); |
| 97 | case DataType::F64: |
| 98 | return *reinterpret_cast<const double *>(ptr); |
| 99 | case DataType::SIZET: |
| 100 | return *reinterpret_cast<const size_t *>(ptr); |
| 101 | default: |
| 102 | ARM_COMPUTE_ERROR("NOT SUPPORTED!"); |
| 103 | } |
| 104 | } |
| 105 | |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 106 | bool is_equal(double target, double ref, double max_absolute_error = std::numeric_limits<double>::epsilon(), double max_relative_error = 0.0001f) |
| 107 | { |
| 108 | if(!std::isfinite(target) || !std::isfinite(ref)) |
| 109 | { |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | // No need further check if they are equal |
| 114 | if(ref == target) |
| 115 | { |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | // Need this check for the situation when the two values close to zero but have different sign |
| 120 | if(std::abs(std::abs(ref) - std::abs(target)) <= max_absolute_error) |
| 121 | { |
| 122 | return true; |
| 123 | } |
| 124 | |
| 125 | double relative_error = 0; |
| 126 | |
| 127 | if(std::abs(target) > std::abs(ref)) |
| 128 | { |
| 129 | relative_error = std::abs((target - ref) / target); |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | relative_error = std::abs((ref - target) / ref); |
| 134 | } |
| 135 | |
| 136 | return relative_error <= max_relative_error; |
| 137 | } |
| 138 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 139 | void check_border_element(const IAccessor &tensor, const Coordinates &id, |
| 140 | const BorderMode &border_mode, const void *border_value, |
| 141 | int64_t &num_elements, int64_t &num_mismatches) |
| 142 | { |
| 143 | const size_t channel_size = element_size_from_data_type(tensor.data_type()); |
| 144 | const auto ptr = static_cast<const uint8_t *>(tensor(id)); |
| 145 | |
| 146 | if(border_mode == BorderMode::REPLICATE) |
| 147 | { |
| 148 | Coordinates border_id{ id }; |
| 149 | border_id.set(1, 0); |
| 150 | border_value = tensor(border_id); |
| 151 | } |
| 152 | |
| 153 | // Iterate over all channels within one element |
| 154 | for(int channel = 0; channel < tensor.num_channels(); ++channel) |
| 155 | { |
| 156 | const size_t channel_offset = channel * channel_size; |
| 157 | const double target = get_double_data(ptr + channel_offset, tensor.data_type()); |
| 158 | const double ref = get_double_data(static_cast<const uint8_t *>(border_value) + channel_offset, tensor.data_type()); |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 159 | const bool equal = is_equal(target, ref); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 160 | |
| 161 | BOOST_TEST_INFO("id = " << id); |
| 162 | BOOST_TEST_INFO("channel = " << channel); |
| 163 | BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); |
| 164 | BOOST_TEST_INFO("target = " << std::setprecision(5) << target); |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 165 | BOOST_TEST_WARN(equal); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 166 | |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 167 | if(!equal) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 168 | { |
| 169 | ++num_mismatches; |
| 170 | } |
| 171 | |
| 172 | ++num_elements; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | void check_single_element(const Coordinates &id, const IAccessor &tensor, const RawTensor &reference, float tolerance_value, |
| 177 | uint64_t wrap_range, int min_channels, size_t channel_size, int64_t &num_mismatches, int64_t &num_elements) |
| 178 | { |
| 179 | const auto ptr = static_cast<const uint8_t *>(tensor(id)); |
| 180 | const auto ref_ptr = static_cast<const uint8_t *>(reference(id)); |
| 181 | |
| 182 | // Iterate over all channels within one element |
| 183 | for(int channel = 0; channel < min_channels; ++channel) |
| 184 | { |
| 185 | const size_t channel_offset = channel * channel_size; |
| 186 | const double target = get_double_data(ptr + channel_offset, reference.data_type()); |
| 187 | const double ref = get_double_data(ref_ptr + channel_offset, reference.data_type()); |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 188 | bool equal = is_equal(target, ref, tolerance_value); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 189 | |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 190 | if(wrap_range != 0 && !equal) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 191 | { |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 192 | equal = is_equal(target, ref, wrap_range - tolerance_value); |
| 193 | } |
| 194 | |
| 195 | if(!equal) |
| 196 | { |
| 197 | BOOST_TEST_INFO("id = " << id); |
| 198 | BOOST_TEST_INFO("channel = " << channel); |
| 199 | BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); |
| 200 | BOOST_TEST_INFO("target = " << std::setprecision(5) << target); |
| 201 | BOOST_TEST_WARN(equal); |
| 202 | |
| 203 | ++num_mismatches; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 204 | } |
| 205 | ++num_elements; |
| 206 | } |
| 207 | } |
| 208 | } // namespace |
| 209 | |
| 210 | void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) |
| 211 | { |
| 212 | BOOST_TEST(region.anchor.num_dimensions() == reference.anchor.num_dimensions()); |
| 213 | BOOST_TEST(region.shape.num_dimensions() == reference.shape.num_dimensions()); |
| 214 | |
| 215 | for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) |
| 216 | { |
| 217 | BOOST_TEST(region.anchor[d] == reference.anchor[d]); |
| 218 | } |
| 219 | |
| 220 | for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) |
| 221 | { |
| 222 | BOOST_TEST(region.shape[d] == reference.shape[d]); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) |
| 227 | { |
| 228 | BOOST_TEST(padding.top == reference.top); |
| 229 | BOOST_TEST(padding.right == reference.right); |
| 230 | BOOST_TEST(padding.bottom == reference.bottom); |
| 231 | BOOST_TEST(padding.left == reference.left); |
| 232 | } |
| 233 | |
| 234 | void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value, float tolerance_number, uint64_t wrap_range) |
| 235 | { |
| 236 | // Validate with valid region covering the entire shape |
| 237 | validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number, wrap_range); |
| 238 | } |
| 239 | |
| 240 | void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value, float tolerance_number, uint64_t wrap_range) |
| 241 | { |
| 242 | int64_t num_mismatches = 0; |
| 243 | int64_t num_elements = 0; |
| 244 | |
| 245 | BOOST_TEST(tensor.element_size() == reference.element_size()); |
| 246 | BOOST_TEST(tensor.format() == reference.format()); |
| 247 | BOOST_TEST(tensor.data_type() == reference.data_type()); |
| 248 | BOOST_TEST(tensor.num_channels() == reference.num_channels()); |
| 249 | BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); |
| 250 | |
| 251 | const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); |
| 252 | const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); |
| 253 | const size_t channel_size = element_size_from_data_type(reference.data_type()); |
| 254 | |
| 255 | // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... |
| 256 | for(int element_idx = 0; element_idx < min_elements; ++element_idx) |
| 257 | { |
| 258 | const Coordinates id = index2coord(reference.shape(), element_idx); |
| 259 | if(is_in_valid_region(valid_region, id)) |
| 260 | { |
| 261 | check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | const int64_t absolute_tolerance_number = tolerance_number * num_elements; |
| 266 | const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f; |
| 267 | |
| 268 | BOOST_TEST(num_mismatches <= absolute_tolerance_number, |
| 269 | num_mismatches << " values (" << std::setprecision(2) << percent_mismatches |
| 270 | << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); |
| 271 | } |
| 272 | |
| 273 | void validate(const IAccessor &tensor, const void *reference_value) |
| 274 | { |
| 275 | BOOST_TEST_REQUIRE((reference_value != nullptr)); |
| 276 | |
| 277 | int64_t num_mismatches = 0; |
| 278 | int64_t num_elements = 0; |
| 279 | const size_t channel_size = element_size_from_data_type(tensor.data_type()); |
| 280 | |
| 281 | // Iterate over all elements, e.g. U8, S16, RGB888, ... |
| 282 | for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) |
| 283 | { |
| 284 | const Coordinates id = index2coord(tensor.shape(), element_idx); |
| 285 | |
| 286 | const auto ptr = static_cast<const uint8_t *>(tensor(id)); |
| 287 | |
| 288 | // Iterate over all channels within one element |
| 289 | for(int channel = 0; channel < tensor.num_channels(); ++channel) |
| 290 | { |
| 291 | const size_t channel_offset = channel * channel_size; |
| 292 | const double target = get_double_data(ptr + channel_offset, tensor.data_type()); |
| 293 | const double ref = get_double_data(reference_value, tensor.data_type()); |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 294 | const bool equal = is_equal(target, ref); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 295 | |
| 296 | BOOST_TEST_INFO("id = " << id); |
| 297 | BOOST_TEST_INFO("channel = " << channel); |
| 298 | BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); |
| 299 | BOOST_TEST_INFO("target = " << std::setprecision(5) << target); |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 300 | BOOST_TEST_WARN(equal); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 301 | |
steniu01 | 9746fd8 | 2017-06-15 10:49:37 +0100 | [diff] [blame] | 302 | if(!equal) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 303 | { |
| 304 | ++num_mismatches; |
| 305 | } |
| 306 | |
| 307 | ++num_elements; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f; |
| 312 | |
| 313 | BOOST_TEST(num_mismatches == 0, |
| 314 | num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); |
| 315 | } |
| 316 | |
| 317 | void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value) |
| 318 | { |
| 319 | if(border_mode == BorderMode::UNDEFINED) |
| 320 | { |
| 321 | return; |
| 322 | } |
| 323 | else if(border_mode == BorderMode::CONSTANT) |
| 324 | { |
| 325 | BOOST_TEST((border_value != nullptr)); |
| 326 | } |
| 327 | |
| 328 | int64_t num_mismatches = 0; |
| 329 | int64_t num_elements = 0; |
| 330 | const int slice_size = tensor.shape()[0] * tensor.shape()[1]; |
| 331 | |
| 332 | for(int element_idx = 0; element_idx < tensor.num_elements(); element_idx += slice_size) |
| 333 | { |
| 334 | Coordinates id = index2coord(tensor.shape(), element_idx); |
| 335 | |
| 336 | // Top border |
| 337 | for(int y = -border_size.top; y < 0; ++y) |
| 338 | { |
| 339 | id.set(1, y); |
| 340 | |
| 341 | for(int x = -border_size.left; x < static_cast<int>(tensor.shape()[0]) + static_cast<int>(border_size.right); ++x) |
| 342 | { |
| 343 | id.set(0, x); |
| 344 | |
| 345 | check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Bottom border |
| 350 | for(int y = tensor.shape()[1]; y < static_cast<int>(tensor.shape()[1]) + static_cast<int>(border_size.bottom); ++y) |
| 351 | { |
| 352 | id.set(1, y); |
| 353 | |
| 354 | for(int x = -border_size.left; x < static_cast<int>(tensor.shape()[0]) + static_cast<int>(border_size.right); ++x) |
| 355 | { |
| 356 | id.set(0, x); |
| 357 | |
| 358 | check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | // Left/right border |
| 363 | for(int y = 0; y < static_cast<int>(tensor.shape()[1]); ++y) |
| 364 | { |
| 365 | id.set(1, y); |
| 366 | |
| 367 | // Left border |
| 368 | for(int x = -border_size.left; x < 0; ++x) |
| 369 | { |
| 370 | id.set(0, x); |
| 371 | |
| 372 | check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); |
| 373 | } |
| 374 | |
| 375 | // Right border |
| 376 | for(int x = tensor.shape()[0]; x < static_cast<int>(tensor.shape()[0]) + static_cast<int>(border_size.right); ++x) |
| 377 | { |
| 378 | id.set(0, x); |
| 379 | |
| 380 | check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f; |
| 386 | |
| 387 | BOOST_TEST(num_mismatches == 0, |
| 388 | num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); |
| 389 | } |
| 390 | |
| 391 | void validate(std::vector<unsigned int> classified_labels, std::vector<unsigned int> expected_labels) |
| 392 | { |
Pablo Tello | 383deec | 2017-06-23 10:40:05 +0100 | [diff] [blame] | 393 | ARM_COMPUTE_UNUSED(classified_labels); |
| 394 | ARM_COMPUTE_UNUSED(expected_labels); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 395 | BOOST_TEST(expected_labels.size() != 0); |
| 396 | BOOST_TEST(classified_labels.size() == expected_labels.size()); |
| 397 | |
| 398 | for(unsigned int i = 0; i < expected_labels.size(); ++i) |
| 399 | { |
| 400 | BOOST_TEST(classified_labels[i] == expected_labels[i]); |
| 401 | } |
| 402 | } |
steniu01 | 423d88f | 2017-06-22 10:20:37 +0100 | [diff] [blame] | 403 | |
steniu01 | 960b084 | 2017-06-23 11:44:34 +0100 | [diff] [blame] | 404 | void validate(float target, float ref, float tolerance_abs_error, float tolerance_relative_error) |
steniu01 | 423d88f | 2017-06-22 10:20:37 +0100 | [diff] [blame] | 405 | { |
| 406 | const bool equal = is_equal(target, ref, tolerance_abs_error, tolerance_relative_error); |
| 407 | |
| 408 | BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); |
| 409 | BOOST_TEST_INFO("target = " << std::setprecision(5) << target); |
| 410 | BOOST_TEST(equal); |
| 411 | } |
| 412 | |
Giorgio Arena | 2ca209e | 2017-06-13 15:49:37 +0100 | [diff] [blame^] | 413 | void validate_min_max_loc(int32_t min, int32_t ref_min, int32_t max, int32_t ref_max, |
| 414 | Coordinates2DArray &min_loc, Coordinates2DArray &ref_min_loc, Coordinates2DArray &max_loc, Coordinates2DArray &ref_max_loc, |
| 415 | uint32_t min_count, uint32_t ref_min_count, uint32_t max_count, uint32_t ref_max_count) |
| 416 | { |
| 417 | BOOST_TEST(min == ref_min); |
| 418 | BOOST_TEST(max == ref_max); |
| 419 | |
| 420 | BOOST_TEST(min_count == min_loc.num_values()); |
| 421 | BOOST_TEST(max_count == max_loc.num_values()); |
| 422 | BOOST_TEST(ref_min_count == ref_min_loc.num_values()); |
| 423 | BOOST_TEST(ref_max_count == ref_max_loc.num_values()); |
| 424 | |
| 425 | BOOST_TEST(min_count == ref_min_count); |
| 426 | BOOST_TEST(max_count == ref_max_count); |
| 427 | |
| 428 | for(uint32_t i = 0; i < min_count; i++) |
| 429 | { |
| 430 | BOOST_TEST(min_loc.at(i).x == ref_min_loc.at(i).x); |
| 431 | BOOST_TEST(min_loc.at(i).y == ref_min_loc.at(i).y); |
| 432 | } |
| 433 | |
| 434 | for(uint32_t i = 0; i < max_count; i++) |
| 435 | { |
| 436 | BOOST_TEST(max_loc.at(i).x == ref_max_loc.at(i).x); |
| 437 | BOOST_TEST(max_loc.at(i).y == ref_max_loc.at(i).y); |
| 438 | } |
| 439 | } |
| 440 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 441 | } // namespace validation |
| 442 | } // namespace test |
| 443 | } // namespace arm_compute |