Compute Library
 21.05
arm_compute::helpers::float_ops Namespace Reference

Data Structures

union  RawFloat
 

Functions

bool is_equal_ulps (float a, float b, int max_allowed_ulps=0)
 Checks if two floating point numbers are equal given an allowed number of ULPs. More...
 
bool is_one (float a, float epsilon=0.00001f)
 Checks if the input floating point number is 1.0f checking if the difference is within a range defined with epsilon. More...
 
bool is_zero (float a, float epsilon=0.00001f)
 Checks if the input floating point number is 0.0f checking if the difference is within a range defined with epsilon. More...
 

Function Documentation

◆ is_equal_ulps()

bool arm_compute::helpers::float_ops::is_equal_ulps ( float  a,
float  b,
int  max_allowed_ulps = 0 
)
inline

Checks if two floating point numbers are equal given an allowed number of ULPs.

Parameters
[in]aFirst number to compare
[in]bSecond number to compare
[in]max_allowed_ulps(Optional) Number of allowed ULPs
Returns
True if number is close else false

Definition at line 80 of file float_ops.h.

81 {
82  RawFloat ra(a);
83  RawFloat rb(b);
84 
85  // Check ULP distance
86  const int ulps = std::abs(ra.i32 - rb.i32);
87  return ulps <= max_allowed_ulps;
88 }
SimpleTensor< float > b
Definition: DFT.cpp:157

References arm_compute::test::validation::b, and RawFloat::i32.

◆ is_one()

bool arm_compute::helpers::float_ops::is_one ( float  a,
float  epsilon = 0.00001f 
)
inline

Checks if the input floating point number is 1.0f checking if the difference is within a range defined with epsilon.

Parameters
[in]aInput floating point number
[in]epsilon(Optional) Epsilon used to define the error bounds
Returns
True if number is close to 1.0f

Definition at line 97 of file float_ops.h.

98 {
99  return std::abs(1.0f - a) <= epsilon;
100 }

References arm_compute::quantization::epsilon.

Referenced by CLGEMMMatrixMultiplyNativeKernel::configure(), CLGEMMMatrixMultiplyKernel::configure(), and CLGEMMMatrixMultiplyReshapedOnlyRHSKernel::configure().

◆ is_zero()

bool arm_compute::helpers::float_ops::is_zero ( float  a,
float  epsilon = 0.00001f 
)
inline

Checks if the input floating point number is 0.0f checking if the difference is within a range defined with epsilon.

Parameters
[in]aInput floating point number
[in]epsilon(Optional) Epsilon used to define the error bounds
Returns
True if number is close to 0.0f

Definition at line 109 of file float_ops.h.

110 {
111  return std::abs(0.0f - a) <= epsilon;
112 }

References arm_compute::quantization::epsilon.

Referenced by CLGEMMMatrixMultiplyNativeKernel::configure(), CLGEMMMatrixMultiplyKernel::configure(), CLGEMMMatrixMultiplyReshapedOnlyRHSKernel::configure(), CLGEMMMatrixMultiplyReshapedKernel::configure(), CLGEMM::configure(), and CLGEMM::validate().