From 1cf7e529b59789e054e4bc27a5ac65968139c997 Mon Sep 17 00:00:00 2001
From: Neta Zmora <neta.zmora@intel.com>
Date: Thu, 28 Nov 2019 01:12:08 +0200
Subject: [PATCH] add tolerance (=0.05) when comparing test results

Small variances can occur when using different cudnn versions,
even when the environment and distiller version is the same.
---
 tests/full_flow_tests.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/full_flow_tests.py b/tests/full_flow_tests.py
index 231a7b7..20ee315 100755
--- a/tests/full_flow_tests.py
+++ b/tests/full_flow_tests.py
@@ -21,6 +21,7 @@ import re
 from collections import namedtuple
 import argparse
 import time
+import math
 
 DS_CIFAR = 'cifar10'
 DS_MNIST = 'mnist'
@@ -78,13 +79,13 @@ def success(string):
 # Checkers
 ###########
 
-def compare_values(name, expected, actual):
+def compare_values(name, expected, actual, rel_tol=5e-2):
     print('Comparing {0}: Expected = {1} ; Actual = {2}'.format(name, expected, actual))
-    if expected != actual:
+    if math.isclose(expected, actual, rel_tol=rel_tol):
+        return True
+    else:
         error('Mismatch on {0}'.format(name))
         return False
-    else:
-        return True
 
 
 def accuracy_checker(log, run_dir, expected_results):
-- 
GitLab