X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2F_validation_8h_source.xhtml;h=8fbbfffa0cde101bdfb772f9ae7d3c2ad01925fb;hb=06ea048f062a50404b1b3998a61a45449c2d1f0f;hp=957fe76e3f6ad2b6d4cfdd57bdced265d57d686d;hpb=292227986edb37b01061afcad6df18ba9d6ccbeb;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/_validation_8h_source.xhtml b/documentation/_validation_8h_source.xhtml index 957fe76..8fbbfff 100644 --- a/documentation/_validation_8h_source.xhtml +++ b/documentation/_validation_8h_source.xhtml @@ -40,7 +40,7 @@
Compute Library -  18.01 +  18.02
@@ -117,27 +117,27 @@ $(document).ready(function(){initNavTree('_validation_8h_source.xhtml','');});
Validation.h
-Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, 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 #ifndef __ARM_COMPUTE_TEST_VALIDATION_H__
25 #define __ARM_COMPUTE_TEST_VALIDATION_H__
26 
29 #include "arm_compute/core/Types.h"
31 #include "tests/IAccessor.h"
32 #include "tests/SimpleTensor.h"
33 #include "tests/Types.h"
34 #include "tests/Utils.h"
37 #include "utils/TypePrinter.h"
38 
39 #include <iomanip>
40 #include <ios>
41 #include <vector>
42 
43 namespace arm_compute
44 {
45 namespace test
46 {
47 namespace validation
48 {
50 template <typename T>
52 {
53 public:
55  using value_type = T;
56 
57  /* Default constructor.
58  *
59  * Initialises the tolerance to 0.
60  */
61  AbsoluteTolerance() = default;
62 
67  explicit constexpr AbsoluteTolerance(T value)
68  : _value{ value }
69  {
70  }
71 
73  constexpr operator T() const
74  {
75  return _value;
76  }
77 
78 private:
79  T _value{ std::numeric_limits<T>::epsilon() };
80 };
81 
83 template <typename T>
85 {
86 public:
88  using value_type = T;
89 
90  /* Default constructor.
91  *
92  * Initialises the tolerance to 0.
93  */
94  RelativeTolerance() = default;
95 
100  explicit constexpr RelativeTolerance(value_type value)
101  : _value{ value }
102  {
103  }
104 
106  constexpr operator value_type() const
107  {
108  return _value;
109  }
110 
111 private:
112  value_type _value{ std::numeric_limits<T>::epsilon() };
113 };
114 
116 template <typename T>
117 inline ::std::ostream &operator<<(::std::ostream &os, const AbsoluteTolerance<T> &tolerance)
118 {
119  os << static_cast<typename AbsoluteTolerance<T>::value_type>(tolerance);
120 
121  return os;
122 }
123 
125 template <typename T>
126 inline ::std::ostream &operator<<(::std::ostream &os, const RelativeTolerance<T> &tolerance)
127 {
128  os << static_cast<typename RelativeTolerance<T>::value_type>(tolerance);
129 
130  return os;
131 }
132 
133 template <typename T>
134 bool compare_dimensions(const Dimensions<T> &dimensions1, const Dimensions<T> &dimensions2)
135 {
136  if(dimensions1.num_dimensions() != dimensions2.num_dimensions())
137  {
138  return false;
139  }
140 
141  for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i)
142  {
143  if(dimensions1[i] != dimensions2[i])
144  {
145  return false;
146  }
147  }
148 
149  return true;
150 }
151 
158 void validate(const arm_compute::ValidRegion &region, const arm_compute::ValidRegion &reference);
159 
165 
170 void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &width_reference, const arm_compute::PaddingSize &height_reference);
171 
182 template <typename T, typename U = AbsoluteTolerance<T>>
183 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value = U(), float tolerance_number = 0.f);
184 
195 template <typename T, typename U = AbsoluteTolerance<T>>
196 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f);
197 
208 template <typename T, typename U = AbsoluteTolerance<T>>
209 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value = U(), float tolerance_number = 0.f);
210 
215 void validate(const IAccessor &tensor, const void *reference_value);
216 
223 void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value);
224 
229 void validate(std::vector<unsigned int> classified_labels, std::vector<unsigned int> expected_labels);
230 
235 template <typename T, typename U = AbsoluteTolerance<T>>
236 bool validate(T target, T reference, U tolerance = AbsoluteTolerance<T>());
237 
239 template <typename T, typename U, typename V = AbsoluteTolerance<float>>
240 void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance = AbsoluteTolerance<float>(),
241  float allowed_missing_percentage = 5.f, float allowed_mismatch_percentage = 5.f);
242 
243 template <typename T>
245 {
246  compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0))
247  : _target{ target }, _reference{ reference }, _tolerance{ tolerance }
248  {
249  }
250 
251  typename T::value_type _target{};
252  typename T::value_type _reference{};
253  T _tolerance{};
254 };
255 
256 template <typename T>
257 struct compare;
258 
259 template <typename U>
260 struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>>
261 {
263 
264  operator bool() const
265  {
266  if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference))
267  {
268  return false;
269  }
270  else if(this->_target == this->_reference)
271  {
272  return true;
273  }
274 
275  using comparison_type = typename std::conditional<std::is_integral<U>::value, int64_t, U>::type;
276 
277  const comparison_type abs_difference(std::abs(static_cast<comparison_type>(this->_target) - static_cast<comparison_type>(this->_reference)));
278 
279  return abs_difference <= static_cast<comparison_type>(this->_tolerance);
280  }
281 };
282 
283 template <typename U>
284 struct compare<RelativeTolerance<U>> : public compare_base<RelativeTolerance<U>>
285 {
287 
288  operator bool() const
289  {
290  if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference))
291  {
292  return false;
293  }
294  else if(this->_target == this->_reference)
295  {
296  return true;
297  }
298 
299  const U epsilon = (std::is_same<half, typename std::remove_cv<U>::type>::value || (this->_reference == 0)) ? static_cast<U>(0.01) : static_cast<U>(1e-05);
300 
301  if(std::abs(static_cast<double>(this->_reference) - static_cast<double>(this->_target)) <= epsilon)
302  {
303  return true;
304  }
305  else
306  {
307  if(static_cast<double>(this->_reference) == 0.0f) // We have checked whether _reference and _target is closing. If _reference is 0 but not closed to _target, it should return false
308  {
309  return false;
310  }
311 
312  const double relative_change = std::abs(static_cast<double>(this->_target) - static_cast<double>(this->_reference)) / this->_reference;
313 
314  return relative_change <= static_cast<U>(this->_tolerance);
315  }
316  }
317 };
318 
319 template <typename T, typename U>
320 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number)
321 {
322  // Validate with valid region covering the entire shape
323  validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number);
324 }
325 
327 void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number)
328 {
329  // Validate with valid region covering the entire shape
330  validate_wrap(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number);
331 }
332 
333 template <typename T, typename U>
334 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number)
335 {
336  int64_t num_mismatches = 0;
337  int64_t num_elements = 0;
338 
341 
342  if(reference.format() != Format::UNKNOWN)
343  {
345  }
346 
349 
350  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
351  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
352 
353  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
354  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
355  {
356  const Coordinates id = index2coord(reference.shape(), element_idx);
357 
358  if(is_in_valid_region(valid_region, id))
359  {
360  // Iterate over all channels within one element
361  for(int c = 0; c < min_channels; ++c)
362  {
363  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
364  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
365 
366  if(!compare<U>(target_value, reference_value, tolerance_value))
367  {
368  ARM_COMPUTE_TEST_INFO("id = " << id);
369  ARM_COMPUTE_TEST_INFO("channel = " << c);
370  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
371  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
372  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
374 
375  ++num_mismatches;
376  }
377 
378  ++num_elements;
379  }
380  }
381  }
382 
383  if(num_elements > 0)
384  {
385  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
386  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
387 
388  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
389  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
390  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
391  }
392 }
393 
395 void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number)
396 {
397  int64_t num_mismatches = 0;
398  int64_t num_elements = 0;
399 
402 
403  if(reference.format() != Format::UNKNOWN)
404  {
406  }
407 
410 
411  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
412  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
413 
414  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
415  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
416  {
417  const Coordinates id = index2coord(reference.shape(), element_idx);
418 
419  if(is_in_valid_region(valid_region, id))
420  {
421  // Iterate over all channels within one element
422  for(int c = 0; c < min_channels; ++c)
423  {
424  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
425  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
426 
427  bool equal = compare<U>(target_value, reference_value, tolerance_value);
428 
429  // check for wrapping
430  if(!equal)
431  {
432  if(!support::cpp11::isfinite(target_value) || !support::cpp11::isfinite(reference_value))
433  {
434  equal = false;
435  }
436  else
437  {
438  using limits_type = typename std::make_unsigned<T>::type;
439 
441  uint64_t abs_sum = std::abs(static_cast<int64_t>(target_value)) + std::abs(static_cast<int64_t>(reference_value));
442  uint64_t wrap_difference = max - abs_sum;
443 
444  equal = wrap_difference < static_cast<uint64_t>(tolerance_value);
445  }
446  }
447 
448  if(!equal)
449  {
450  ARM_COMPUTE_TEST_INFO("id = " << id);
451  ARM_COMPUTE_TEST_INFO("channel = " << c);
452  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
453  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
454  ARM_COMPUTE_TEST_INFO("wrap_tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
456 
457  ++num_mismatches;
458  }
459 
460  ++num_elements;
461  }
462  }
463  }
464 
465  if(num_elements > 0)
466  {
467  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
468  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
469 
470  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
471  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
472  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
473  }
474 }
475 
477 template <typename T, typename U, typename V>
478 std::pair<int64_t, int64_t> compare_keypoints(T first1, T last1, U first2, U last2, V tolerance)
479 {
480  int64_t num_missing = 0;
481  int64_t num_mismatches = 0;
482 
483  while(first1 != last1)
484  {
485  const auto point = std::find_if(first2, last2, [&](KeyPoint point)
486  {
487  return point.x == first1->x && point.y == first1->y;
488  });
489 
490  if(point == last2)
491  {
492  ++num_missing;
493  ARM_COMPUTE_TEST_INFO("Key point not found" << *first1)
494  ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1)
495  }
496  else if(!validate(point->tracking_status, first1->tracking_status) || !validate(point->strength, first1->strength, tolerance) || !validate(point->scale, first1->scale)
497  || !validate(point->orientation, first1->orientation) || !validate(point->error, first1->error))
498  {
499  ++num_mismatches;
500  ARM_COMPUTE_TEST_INFO("Mismatching keypoint")
501  ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1)
502  ARM_COMPUTE_TEST_INFO("keypoint2 = " << *point)
503  }
504 
505  ++first1;
506  }
507 
508  return std::make_pair(num_missing, num_mismatches);
509 }
510 
511 template <typename T, typename U, typename V>
512 void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance,
513  float allowed_missing_percentage, float allowed_mismatch_percentage)
514 {
515  const int64_t num_elements_target = std::distance(target_first, target_last);
516  const int64_t num_elements_reference = std::distance(reference_first, reference_last);
517 
518  int64_t num_missing = 0;
519  int64_t num_mismatches = 0;
520 
521  if(num_elements_reference > 0)
522  {
523  std::tie(num_missing, num_mismatches) = compare_keypoints(reference_first, reference_last, target_first, target_last, tolerance);
524 
525  const float percent_missing = static_cast<float>(num_missing) / num_elements_reference * 100.f;
526  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements_reference * 100.f;
527 
528  ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) are missing in target");
529  ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS);
530 
531  ARM_COMPUTE_TEST_INFO(num_mismatches << " keypoints (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched");
532  ARM_COMPUTE_EXPECT(percent_mismatches <= allowed_mismatch_percentage, framework::LogLevel::ERRORS);
533  }
534 
535  if(num_elements_target > 0)
536  {
537  std::tie(num_missing, num_mismatches) = compare_keypoints(target_first, target_last, reference_first, reference_last, tolerance);
538 
539  const float percent_missing = static_cast<float>(num_missing) / num_elements_target * 100.f;
540 
541  ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) are not part of target");
542  ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS);
543  }
544 }
545 
546 template <typename T, typename U>
547 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value, float tolerance_number)
548 {
549  int64_t num_mismatches = 0;
550  int64_t num_elements = 0;
551 
554 
555  if(reference.format() != Format::UNKNOWN)
556  {
558  }
559 
562 
563  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
564  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
565 
566  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
567  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
568  {
569  const Coordinates id = index2coord(reference.shape(), element_idx);
570 
571  if(valid_mask[element_idx] == 1)
572  {
573  // Iterate over all channels within one element
574  for(int c = 0; c < min_channels; ++c)
575  {
576  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
577  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
578 
579  if(!compare<U>(target_value, reference_value, tolerance_value))
580  {
581  ARM_COMPUTE_TEST_INFO("id = " << id);
582  ARM_COMPUTE_TEST_INFO("channel = " << c);
583  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
584  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
585  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
587 
588  ++num_mismatches;
589  }
590 
591  ++num_elements;
592  }
593  }
594  else
595  {
596  ++num_elements;
597  }
598  }
599 
600  if(num_elements > 0)
601  {
602  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
603  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
604 
605  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
606  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
607  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
608  }
609 }
610 
611 template <typename T, typename U>
612 bool validate(T target, T reference, U tolerance)
613 {
614  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference));
615  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target));
616  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance)));
617 
618  const bool equal = compare<U>(target, reference, tolerance);
619 
621 
622  return equal;
623 }
624 
625 template <typename T, typename U>
627 {
630 
631  ARM_COMPUTE_EXPECT_EQUAL(target.min_loc.size(), reference.min_loc.size(), framework::LogLevel::ERRORS);
632  ARM_COMPUTE_EXPECT_EQUAL(target.max_loc.size(), reference.max_loc.size(), framework::LogLevel::ERRORS);
633 
634  for(uint32_t i = 0; i < target.min_loc.size(); ++i)
635  {
636  const auto same_coords = std::find_if(reference.min_loc.begin(), reference.min_loc.end(), [&target, i](Coordinates2D coord)
637  {
638  return coord.x == target.min_loc.at(i).x && coord.y == target.min_loc.at(i).y;
639  });
640 
641  ARM_COMPUTE_EXPECT(same_coords != reference.min_loc.end(), framework::LogLevel::ERRORS);
642  }
643 
644  for(uint32_t i = 0; i < target.max_loc.size(); ++i)
645  {
646  const auto same_coords = std::find_if(reference.max_loc.begin(), reference.max_loc.end(), [&target, i](Coordinates2D coord)
647  {
648  return coord.x == target.max_loc.at(i).x && coord.y == target.max_loc.at(i).y;
649  });
650 
651  ARM_COMPUTE_EXPECT(same_coords != reference.max_loc.end(), framework::LogLevel::ERRORS);
652  }
653 }
654 
655 } // namespace validation
656 } // namespace test
657 } // namespace arm_compute
658 #endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */
constexpr AbsoluteTolerance(T value)
Constructor.
Definition: Validation.h:67
-
BorderMode
Methods available to handle borders.
Definition: Types.h:198
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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 #ifndef __ARM_COMPUTE_TEST_VALIDATION_H__
25 #define __ARM_COMPUTE_TEST_VALIDATION_H__
26 
29 #include "arm_compute/core/Types.h"
31 #include "tests/IAccessor.h"
32 #include "tests/SimpleTensor.h"
33 #include "tests/Types.h"
34 #include "tests/Utils.h"
37 #include "utils/TypePrinter.h"
38 
39 #include <iomanip>
40 #include <ios>
41 #include <vector>
42 
43 namespace arm_compute
44 {
45 namespace test
46 {
47 namespace validation
48 {
50 template <typename T>
52 {
53 public:
55  using value_type = T;
56 
57  /* Default constructor.
58  *
59  * Initialises the tolerance to 0.
60  */
61  AbsoluteTolerance() = default;
62 
67  explicit constexpr AbsoluteTolerance(T value)
68  : _value{ value }
69  {
70  }
71 
73  constexpr operator T() const
74  {
75  return _value;
76  }
77 
78 private:
79  T _value{ std::numeric_limits<T>::epsilon() };
80 };
81 
83 template <typename T>
85 {
86 public:
88  using value_type = T;
89 
90  /* Default constructor.
91  *
92  * Initialises the tolerance to 0.
93  */
94  RelativeTolerance() = default;
95 
100  explicit constexpr RelativeTolerance(value_type value)
101  : _value{ value }
102  {
103  }
104 
106  constexpr operator value_type() const
107  {
108  return _value;
109  }
110 
111 private:
112  value_type _value{ std::numeric_limits<T>::epsilon() };
113 };
114 
116 template <typename T>
117 inline ::std::ostream &operator<<(::std::ostream &os, const AbsoluteTolerance<T> &tolerance)
118 {
119  os << static_cast<typename AbsoluteTolerance<T>::value_type>(tolerance);
120 
121  return os;
122 }
123 
125 template <typename T>
126 inline ::std::ostream &operator<<(::std::ostream &os, const RelativeTolerance<T> &tolerance)
127 {
128  os << static_cast<typename RelativeTolerance<T>::value_type>(tolerance);
129 
130  return os;
131 }
132 
133 template <typename T>
134 bool compare_dimensions(const Dimensions<T> &dimensions1, const Dimensions<T> &dimensions2)
135 {
136  if(dimensions1.num_dimensions() != dimensions2.num_dimensions())
137  {
138  return false;
139  }
140 
141  for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i)
142  {
143  if(dimensions1[i] != dimensions2[i])
144  {
145  return false;
146  }
147  }
148 
149  return true;
150 }
151 
158 void validate(const arm_compute::ValidRegion &region, const arm_compute::ValidRegion &reference);
159 
165 
170 void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &width_reference, const arm_compute::PaddingSize &height_reference);
171 
182 template <typename T, typename U = AbsoluteTolerance<T>>
183 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value = U(), float tolerance_number = 0.f);
184 
195 template <typename T, typename U = AbsoluteTolerance<T>>
196 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f);
197 
208 template <typename T, typename U = AbsoluteTolerance<T>>
209 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value = U(), float tolerance_number = 0.f);
210 
215 void validate(const IAccessor &tensor, const void *reference_value);
216 
223 void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value);
224 
229 void validate(std::vector<unsigned int> classified_labels, std::vector<unsigned int> expected_labels);
230 
235 template <typename T, typename U = AbsoluteTolerance<T>>
236 bool validate(T target, T reference, U tolerance = AbsoluteTolerance<T>());
237 
239 template <typename T, typename U, typename V = AbsoluteTolerance<float>>
240 void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance = AbsoluteTolerance<float>(),
241  float allowed_missing_percentage = 5.f, float allowed_mismatch_percentage = 5.f);
242 
243 template <typename T>
245 {
246  compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0))
247  : _target{ target }, _reference{ reference }, _tolerance{ tolerance }
248  {
249  }
250 
251  typename T::value_type _target{};
252  typename T::value_type _reference{};
253  T _tolerance{};
254 };
255 
256 template <typename T>
257 struct compare;
258 
259 template <typename U>
260 struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>>
261 {
263 
264  operator bool() const
265  {
266  if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference))
267  {
268  return false;
269  }
270  else if(this->_target == this->_reference)
271  {
272  return true;
273  }
274 
275  using comparison_type = typename std::conditional<std::is_integral<U>::value, int64_t, U>::type;
276 
277  const comparison_type abs_difference(std::abs(static_cast<comparison_type>(this->_target) - static_cast<comparison_type>(this->_reference)));
278 
279  return abs_difference <= static_cast<comparison_type>(this->_tolerance);
280  }
281 };
282 
283 template <typename U>
284 struct compare<RelativeTolerance<U>> : public compare_base<RelativeTolerance<U>>
285 {
287 
288  operator bool() const
289  {
290  if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference))
291  {
292  return false;
293  }
294  else if(this->_target == this->_reference)
295  {
296  return true;
297  }
298 
299  const U epsilon = (std::is_same<half, typename std::remove_cv<U>::type>::value || (this->_reference == 0)) ? static_cast<U>(0.01) : static_cast<U>(1e-05);
300 
301  if(std::abs(static_cast<double>(this->_reference) - static_cast<double>(this->_target)) <= epsilon)
302  {
303  return true;
304  }
305  else
306  {
307  if(static_cast<double>(this->_reference) == 0.0f) // We have checked whether _reference and _target is closing. If _reference is 0 but not closed to _target, it should return false
308  {
309  return false;
310  }
311 
312  const double relative_change = std::abs(static_cast<double>(this->_target) - static_cast<double>(this->_reference)) / this->_reference;
313 
314  return relative_change <= static_cast<U>(this->_tolerance);
315  }
316  }
317 };
318 
319 template <typename T, typename U>
320 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number)
321 {
322  // Validate with valid region covering the entire shape
323  validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number);
324 }
325 
327 void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, U tolerance_value, float tolerance_number)
328 {
329  // Validate with valid region covering the entire shape
330  validate_wrap(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number);
331 }
332 
333 template <typename T, typename U>
334 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number)
335 {
336  int64_t num_mismatches = 0;
337  int64_t num_elements = 0;
338 
341 
342  if(reference.format() != Format::UNKNOWN)
343  {
345  }
346 
349 
350  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
351  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
352 
353  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
354  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
355  {
356  const Coordinates id = index2coord(reference.shape(), element_idx);
357 
358  if(is_in_valid_region(valid_region, id))
359  {
360  // Iterate over all channels within one element
361  for(int c = 0; c < min_channels; ++c)
362  {
363  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
364  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
365 
366  // Truncate numbers to the 4th decimal
367  const T target_truncated_value = static_cast<T>(static_cast<int>(target_value * 10000) / 10000);
368  const T reference_truncated_value = static_cast<T>(static_cast<int>(target_value * 10000) / 10000);
369  if(!compare<U>(target_truncated_value, reference_truncated_value, tolerance_value))
370  {
371  ARM_COMPUTE_TEST_INFO("id = " << id);
372  ARM_COMPUTE_TEST_INFO("channel = " << c);
373  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
374  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
375  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
377 
378  ++num_mismatches;
379  }
380 
381  ++num_elements;
382  }
383  }
384  }
385 
386  if(num_elements > 0)
387  {
388  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
389  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
390 
391  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
392  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
393  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
394  }
395 }
396 
398 void validate_wrap(const IAccessor &tensor, const SimpleTensor<T> &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number)
399 {
400  int64_t num_mismatches = 0;
401  int64_t num_elements = 0;
402 
405 
406  if(reference.format() != Format::UNKNOWN)
407  {
409  }
410 
413 
414  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
415  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
416 
417  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
418  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
419  {
420  const Coordinates id = index2coord(reference.shape(), element_idx);
421 
422  if(is_in_valid_region(valid_region, id))
423  {
424  // Iterate over all channels within one element
425  for(int c = 0; c < min_channels; ++c)
426  {
427  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
428  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
429 
430  bool equal = compare<U>(target_value, reference_value, tolerance_value);
431 
432  // check for wrapping
433  if(!equal)
434  {
435  if(!support::cpp11::isfinite(target_value) || !support::cpp11::isfinite(reference_value))
436  {
437  equal = false;
438  }
439  else
440  {
441  using limits_type = typename std::make_unsigned<T>::type;
442 
444  uint64_t abs_sum = std::abs(static_cast<int64_t>(target_value)) + std::abs(static_cast<int64_t>(reference_value));
445  uint64_t wrap_difference = max - abs_sum;
446 
447  equal = wrap_difference < static_cast<uint64_t>(tolerance_value);
448  }
449  }
450 
451  if(!equal)
452  {
453  ARM_COMPUTE_TEST_INFO("id = " << id);
454  ARM_COMPUTE_TEST_INFO("channel = " << c);
455  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
456  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
457  ARM_COMPUTE_TEST_INFO("wrap_tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
459 
460  ++num_mismatches;
461  }
462 
463  ++num_elements;
464  }
465  }
466  }
467 
468  if(num_elements > 0)
469  {
470  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
471  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
472 
473  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
474  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
475  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
476  }
477 }
478 
479 template <typename T, typename U>
480 void validate(const IAccessor &tensor, const SimpleTensor<T> &reference, const SimpleTensor<T> &valid_mask, U tolerance_value, float tolerance_number)
481 {
482  int64_t num_mismatches = 0;
483  int64_t num_elements = 0;
484 
487 
488  if(reference.format() != Format::UNKNOWN)
489  {
491  }
492 
495 
496  const int min_elements = std::min(tensor.num_elements(), reference.num_elements());
497  const int min_channels = std::min(tensor.num_channels(), reference.num_channels());
498 
499  // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ...
500  for(int element_idx = 0; element_idx < min_elements; ++element_idx)
501  {
502  const Coordinates id = index2coord(reference.shape(), element_idx);
503 
504  if(valid_mask[element_idx] == 1)
505  {
506  // Iterate over all channels within one element
507  for(int c = 0; c < min_channels; ++c)
508  {
509  const T &target_value = reinterpret_cast<const T *>(tensor(id))[c];
510  const T &reference_value = reinterpret_cast<const T *>(reference(id))[c];
511 
512  if(!compare<U>(target_value, reference_value, tolerance_value))
513  {
514  ARM_COMPUTE_TEST_INFO("id = " << id);
515  ARM_COMPUTE_TEST_INFO("channel = " << c);
516  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value));
517  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value));
518  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance_value)));
520 
521  ++num_mismatches;
522  }
523 
524  ++num_elements;
525  }
526  }
527  else
528  {
529  ++num_elements;
530  }
531  }
532 
533  if(num_elements > 0)
534  {
535  const int64_t absolute_tolerance_number = tolerance_number * num_elements;
536  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements * 100.f;
537 
538  ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches
539  << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)");
540  ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS);
541  }
542 }
543 
544 template <typename T, typename U>
545 bool validate(T target, T reference, U tolerance)
546 {
547  ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference));
548  ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target));
549  ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast<typename U::value_type>(tolerance)));
550 
551  const bool equal = compare<U>(target, reference, tolerance);
552 
554 
555  return equal;
556 }
557 
558 template <typename T, typename U>
560 {
563 
564  ARM_COMPUTE_EXPECT_EQUAL(target.min_loc.size(), reference.min_loc.size(), framework::LogLevel::ERRORS);
565  ARM_COMPUTE_EXPECT_EQUAL(target.max_loc.size(), reference.max_loc.size(), framework::LogLevel::ERRORS);
566 
567  for(uint32_t i = 0; i < target.min_loc.size(); ++i)
568  {
569  const auto same_coords = std::find_if(reference.min_loc.begin(), reference.min_loc.end(), [&target, i](Coordinates2D coord)
570  {
571  return coord.x == target.min_loc.at(i).x && coord.y == target.min_loc.at(i).y;
572  });
573 
574  ARM_COMPUTE_EXPECT(same_coords != reference.min_loc.end(), framework::LogLevel::ERRORS);
575  }
576 
577  for(uint32_t i = 0; i < target.max_loc.size(); ++i)
578  {
579  const auto same_coords = std::find_if(reference.max_loc.begin(), reference.max_loc.end(), [&target, i](Coordinates2D coord)
580  {
581  return coord.x == target.max_loc.at(i).x && coord.y == target.max_loc.at(i).y;
582  });
583 
584  ARM_COMPUTE_EXPECT(same_coords != reference.max_loc.end(), framework::LogLevel::ERRORS);
585  }
586 }
587 
589 template <typename T, typename U, typename V>
590 std::pair<int64_t, int64_t> compare_keypoints(T first1, T last1, U first2, U last2, V tolerance, bool check_mismatches = true)
591 {
592  /* Keypoint (x,y) should have similar strength (within tolerance) and other properties in both reference and target */
593  const auto compare_props_eq = [&](const KeyPoint & lhs, const KeyPoint & rhs)
594  {
595  return compare<V>(lhs.strength, rhs.strength, tolerance)
596  && lhs.tracking_status == rhs.tracking_status
597  && lhs.scale == rhs.scale
598  && lhs.orientation == rhs.orientation
599  && lhs.error == rhs.error;
600  };
601 
602  /* Used to sort KeyPoints by coordinates (x, y) */
603  const auto compare_coords_lt = [](const KeyPoint & lhs, const KeyPoint & rhs)
604  {
605  return std::tie(lhs.x, lhs.y) < std::tie(rhs.x, rhs.y);
606  };
607 
608  std::sort(first1, last1, compare_coords_lt);
609  std::sort(first2, last2, compare_coords_lt);
610 
611  if(check_mismatches)
612  {
613  ARM_COMPUTE_TEST_INFO("Checking for mismatches: ref count = " << std::distance(first1, last1) << " \ttarget count = " << std::distance(first2, last2));
614  }
615 
616  int64_t num_missing = 0;
617  int64_t num_mismatches = 0;
618  bool rest_missing = false;
619 
620  while(first1 != last1)
621  {
622  if(first2 == last2)
623  {
624  rest_missing = true;
625  break;
626  }
627 
628  if(compare_coords_lt(*first1, *first2))
629  {
630  ++num_missing;
631  ARM_COMPUTE_TEST_INFO("Key point not found");
632  ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1++);
633  }
634  else
635  {
636  if(!compare_coords_lt(*first2, *first1)) // Equal coordinates
637  {
638  if(check_mismatches && !compare_props_eq(*first1, *first2)) // Check other properties
639  {
640  ++num_mismatches;
641  ARM_COMPUTE_TEST_INFO("Mismatching keypoint");
642  ARM_COMPUTE_TEST_INFO("keypoint1 [ref] = " << *first1);
643  ARM_COMPUTE_TEST_INFO("keypoint2 [tgt] = " << *first2);
644  }
645  ++first1;
646  }
647  ++first2;
648  }
649  }
650 
651  if(rest_missing)
652  {
653  while(first1 != last1)
654  {
655  ++num_missing;
656  ARM_COMPUTE_TEST_INFO("Key point not found");
657  ARM_COMPUTE_TEST_INFO("keypoint1 = " << *first1++);
658  }
659  }
660 
661  return std::make_pair(num_missing, num_mismatches);
662 }
663 
664 template <typename T, typename U, typename V>
665 void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance, float allowed_missing_percentage, float allowed_mismatch_percentage)
666 {
667  const int64_t num_elements_target = std::distance(target_first, target_last);
668  const int64_t num_elements_reference = std::distance(reference_first, reference_last);
669 
670  int64_t num_missing = 0;
671  int64_t num_mismatches = 0;
672 
673  if(num_elements_reference > 0)
674  {
675  std::tie(num_missing, num_mismatches) = compare_keypoints(reference_first, reference_last, target_first, target_last, tolerance);
676 
677  const float percent_missing = static_cast<float>(num_missing) / num_elements_reference * 100.f;
678  const float percent_mismatches = static_cast<float>(num_mismatches) / num_elements_reference * 100.f;
679 
680  ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) in ref are missing from target");
681  ARM_COMPUTE_TEST_INFO("Missing (not in tgt): " << num_missing << "/" << num_elements_reference << " = " << std::fixed << std::setprecision(2) << percent_missing
682  << "% \tMax allowed: " << allowed_missing_percentage << "%");
683  ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS);
684 
685  ARM_COMPUTE_TEST_INFO(num_mismatches << " keypoints (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched");
686  ARM_COMPUTE_TEST_INFO("Mismatched keypoints: " << num_mismatches << "/" << num_elements_reference << " = " << std::fixed << std::setprecision(2) << percent_mismatches
687  << "% \tMax allowed: " << allowed_mismatch_percentage << "%");
688  ARM_COMPUTE_EXPECT(percent_mismatches <= allowed_mismatch_percentage, framework::LogLevel::ERRORS);
689  }
690 
691  if(num_elements_target > 0)
692  {
693  // Note: no need to check for mismatches a second time (last argument is 'false')
694  std::tie(num_missing, num_mismatches) = compare_keypoints(target_first, target_last, reference_first, reference_last, tolerance, false);
695 
696  const float percent_missing = static_cast<float>(num_missing) / num_elements_target * 100.f;
697 
698  ARM_COMPUTE_TEST_INFO(num_missing << " keypoints (" << std::fixed << std::setprecision(2) << percent_missing << "%) in target are missing from ref");
699  ARM_COMPUTE_TEST_INFO("Missing (not in ref): " << num_missing << "/" << num_elements_target << " = " << std::fixed << std::setprecision(2) << percent_missing
700  << "% \tMax allowed: " << allowed_missing_percentage << "%");
701  ARM_COMPUTE_EXPECT(percent_missing <= allowed_missing_percentage, framework::LogLevel::ERRORS);
702  }
703 }
704 
705 } // namespace validation
706 } // namespace test
707 } // namespace arm_compute
708 #endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */
constexpr AbsoluteTolerance(T value)
Constructor.
Definition: Validation.h:67
+
BorderMode
Methods available to handle borders.
Definition: Types.h:221
bool compare_dimensions(const Dimensions< T > &dimensions1, const Dimensions< T > &dimensions2)
Definition: Validation.h:134
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:884
size_t element_size() const override
Size of each element in the tensor in bytes.
Definition: SimpleTensor.h:251
-
float scale
Scale initialized to 0 by the corner detector.
Definition: Types.h:338
+
float scale
Scale initialized to 0 by the corner detector.
Definition: Types.h:361
Class reprensenting an absolute tolerance value.
Definition: Validation.h:51
std::vector< Coordinates2D > min_loc
Definition: Types.h:58
virtual Format format() const =0
Image format of the tensor.
-
Container for 2D border size.
Definition: Types.h:206
-
int32_t x
X coordinates.
Definition: Types.h:335
-
float orientation
Orientation initialized to 0 by the corner detector.
Definition: Types.h:339
+
Container for 2D border size.
Definition: Types.h:229
+
int32_t x
X coordinates.
Definition: Types.h:358
+
float orientation
Orientation initialized to 0 by the corner detector.
Definition: Types.h:362
Cr/V/Value channel.
int make_printable(int8_t value)
Definition: Asserts.h:40
-
int32_t tracking_status
Status initialized to 1 by the corner detector, set to 0 when the point is lost.
Definition: Types.h:340
+
int32_t tracking_status
Status initialized to 1 by the corner detector, set to 0 when the point is lost.
Definition: Types.h:363
Format format() const override
Image format of the tensor.
Definition: SimpleTensor.h:276
DataType data_type() const override
Data type of the tensor.
Definition: SimpleTensor.h:282
compare_base(typename T::value_type target, typename T::value_type reference, T tolerance=T(0))
Definition: Validation.h:246
@@ -148,15 +148,15 @@ $(document).ready(function(){initNavTree('_validation_8h_source.xhtml','');});
#define ARM_COMPUTE_TEST_INFO(INFO)
Definition: Asserts.h:65
This file contains all available output stages for GEMMLowp on OpenCL.
Definition: 01_library.dox:1
-
Keypoint type.
Definition: Types.h:333
+
Keypoint type.
Definition: Types.h:356
-
float strength
Strength of the point.
Definition: Types.h:337
+
float strength
Strength of the point.
Definition: Types.h:360
-
void validate_min_max_loc(const MinMaxLocationValues< T > &target, const MinMaxLocationValues< U > &reference)
Definition: Validation.h:626
- +
void validate_min_max_loc(const MinMaxLocationValues< T > &target, const MinMaxLocationValues< U > &reference)
Definition: Validation.h:559
+
validate(dst.info() ->valid_region(), dst_valid_region)
-
float error
Tracking error initialized to 0 by the corner detector.
Definition: Types.h:341
+
float error
Tracking error initialized to 0 by the corner detector.
Definition: Types.h:364
bool is_in_valid_region(const ValidRegion &valid_region, Coordinates coord)
Check if a coordinate is within a valid region.
Definition: Utils.h:450
@@ -166,15 +166,14 @@ $(document).ready(function(){initNavTree('_validation_8h_source.xhtml','');});
virtual int num_elements() const =0
Number of elements of the tensor.
Coordinates index2coord(const TensorShape &shape, int index)
Convert a linear index into n-dimensional coordinates.
Definition: Utils.h:403
-
std::pair< int64_t, int64_t > compare_keypoints(T first1, T last1, U first2, U last2, V tolerance)
Check which keypoints from [first1, last1) are missing in [first2, last2)
Definition: Validation.h:478
-
int32_t y
Y coordinates.
Definition: Types.h:336
+
int32_t y
Y coordinates.
Definition: Types.h:359
void * value
Definition: hwc.hpp:278
uint8_t padding[4]
Definition: hwc.hpp:273
Simple tensor object that stores elements in a consecutive chunk of memory.
Definition: SimpleTensor.h:59
int num_channels() const override
Number of channels of the tensor.
Definition: SimpleTensor.h:295
-
Coordinate type.
Definition: Types.h:356
+
Coordinate type.
Definition: Types.h:379
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
Definition: Dimensions.h:122
ARM_COMPUTE_EXPECT(src.info() ->is_resizable(), framework::LogLevel::ERRORS)
Class reprensenting a relative tolerance value.
Definition: Validation.h:84
@@ -183,19 +182,20 @@ $(document).ready(function(){initNavTree('_validation_8h_source.xhtml','');});
Common interface to provide information and access to tensor like structures.
Definition: IAccessor.h:37
-
void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance=AbsoluteTolerance< float >(), float allowed_missing_percentage=5.f, float allowed_mismatch_percentage=5.f)
Validate key points.
Definition: Validation.h:512
-
int num_elements() const override
Number of elements of the tensor.
Definition: SimpleTensor.h:316
+
void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance=AbsoluteTolerance< float >(), float allowed_missing_percentage=5.f, float allowed_mismatch_percentage=5.f)
Validate key points.
Definition: Validation.h:665
+
int num_elements() const override
Number of elements of the tensor.
Definition: SimpleTensor.h:331
virtual size_t element_size() const =0
Size of each element in the tensor in bytes.
constexpr RelativeTolerance(value_type value)
Constructor.
Definition: Validation.h:100
- +
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
Definition: FixedPoint.h:889
fixed_point< T > abs(fixed_point< T > x)
Definition: FixedPoint.h:914
- +
virtual int num_channels() const =0
Number of channels of the tensor.
ValidRegion shape_to_valid_region(const TensorShape &a_shape, bool border_undefined=false, BorderSize border_size=BorderSize(0))
Create a valid region based on tensor shape, border mode and border size.
Definition: Utils.h:212
+
std::pair< int64_t, int64_t > compare_keypoints(T first1, T last1, U first2, U last2, V tolerance, bool check_mismatches=true)
Check which keypoints from [first1, last1) are missing in [first2, last2)
Definition: Validation.h:590
void validate_wrap(const IAccessor &tensor, const SimpleTensor< T > &reference, U tolerance_value, float tolerance_number)
Definition: Validation.h:327
std::vector< Coordinates2D > max_loc
Definition: Types.h:59
@@ -206,7 +206,7 @@ $(document).ready(function(){initNavTree('_validation_8h_source.xhtml','');});