ArmNN
 20.08
SelectiveComparer< T, false > Struct Template Reference

#include <TensorHelpers.hpp>

Static Public Member Functions

static bool Compare (T a, T b)
 

Detailed Description

template<typename T>
struct SelectiveComparer< T, false >

Definition at line 36 of file TensorHelpers.hpp.

Member Function Documentation

◆ Compare()

static bool Compare ( a,
b 
)
inlinestatic

Definition at line 38 of file TensorHelpers.hpp.

References g_FloatCloseToZeroTolerance.

39  {
40  // If a or b is zero, percent_tolerance does an exact match, so compare to a small, constant tolerance instead.
41  if (a == 0.0f || b == 0.0f)
42  {
43  return std::abs(a - b) <= g_FloatCloseToZeroTolerance;
44  }
45 
46  if (std::isinf(a) && a == b)
47  {
48  return true;
49  }
50 
51  if (std::isnan(a) && std::isnan(b))
52  {
53  return true;
54  }
55 
56  // For unquantized floats we use a tolerance of 1%.
57  boost::math::fpc::close_at_tolerance<float> comparer(boost::math::fpc::percent_tolerance(1.0f));
58  return comparer(a, b);
59  }
constexpr float g_FloatCloseToZeroTolerance

The documentation for this struct was generated from the following file: