ArmNN
 21.11
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 35 of file TensorHelpers.hpp.

Member Function Documentation

◆ Compare()

static bool Compare ( a,
b 
)
inlinestatic

Definition at line 37 of file TensorHelpers.hpp.

References g_FloatCloseToZeroTolerance, and armnnUtils::within_percentage_tolerance().

38  {
39  // If a or b is zero, percent_tolerance does an exact match, so compare to a small, constant tolerance instead.
40  if (a == 0.0f || b == 0.0f)
41  {
42  return std::abs(a - b) <= g_FloatCloseToZeroTolerance;
43  }
44 
45  if (std::isinf(a) && a == b)
46  {
47  return true;
48  }
49 
50  if (std::isnan(a) && std::isnan(b))
51  {
52  return true;
53  }
54 
55  // For unquantized floats we use a tolerance of 1%.
57  }
constexpr float g_FloatCloseToZeroTolerance
bool within_percentage_tolerance(float a, float b, float tolerancePercent=1.0f)
Compare two floats and return true if their values are within a specified tolerance of each other...

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