23#ifndef __NNFW_MISC_FP32_H__
24#define __NNFW_MISC_FP32_H__
46 const auto diff = std::fabs(lhs - rhs);
47 const auto base = std::max(std::fabs(lhs), std::fabs(rhs));
60inline bool epsilon_equal(
float expected,
float obtained, uint32_t tolerance = 1)
62 if (std::isnan(expected) && std::isnan(obtained))
68 const auto diff = std::fabs(expected - obtained);
69 const auto max = std::max(std::fabs(expected), std::fabs(obtained));
71 return diff <= (max * FLT_EPSILON * tolerance);
84 if (std::isnan(expected) && std::isnan(obtained))
90 const auto diff = std::fabs(expected - obtained);
92 return diff <= tolerance;
bool epsilon_equal(float expected, float obtained, uint32_t tolerance=1)
Verify that an obtained float value is equal to the expected float value by using FLT_EPSILON.
float relative_diff(float lhs, float rhs)
Get the difference between two float values as a relative value.
bool absolute_epsilon_equal(float expected, float obtained, float tolerance=0.001)
Verify that an obtained float value is equal to the expected float value by comparing absolute tolera...