return diff / base;
}
-bool epsilon_equal(float expected, float obtained)
+bool epsilon_equal(float expected, float obtained, uint32_t tolerance = 1)
{
if (std::isnan(expected) && std::isnan(obtained))
{
const auto diff = std::fabs(expected - obtained);
const auto max = std::max(std::fabs(expected), std::fabs(obtained));
- return diff <= max * FLT_EPSILON;
+ return diff <= (max * FLT_EPSILON * tolerance);
}
} // namespace fp32
int main(const int argc, char **argv)
{
int verbose = 0;
+ int tolerance = 1;
nnfw::util::env::IntAccessor("VERBOSE").access(verbose);
+ nnfw::util::env::IntAccessor("TOLERANCE").access(tolerance);
const auto filename = argv[1];
assert(pure->inputs() == delegated->inputs());
assert(pure->outputs() == delegated->outputs());
- TfLiteTensorComparator comparator(nnfw::util::fp32::epsilon_equal);
+ auto equals = [tolerance] (float lhs, float rhs)
+ {
+ return nnfw::util::fp32::epsilon_equal(lhs, rhs, tolerance);
+ };
+
+ TfLiteTensorComparator comparator(equals);
for (const auto &id : pure->outputs())
{