From 52002dfc301855d9161aa7fba974d5fb6e252983 Mon Sep 17 00:00:00 2001 From: Christophe Favergeon Date: Mon, 27 May 2024 14:09:51 +0200 Subject: [PATCH] Corrected Python class used for tests SimilarTensorFixp It was not computing the right difference when using unsigned datatype --- Testing/board/scripts/details/testing.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Testing/board/scripts/details/testing.py b/Testing/board/scripts/details/testing.py index 6ef4378..38e57ca 100644 --- a/Testing/board/scripts/details/testing.py +++ b/Testing/board/scripts/details/testing.py @@ -96,7 +96,21 @@ def __init__(self,t=0): def __call__(self,ref,result): for s,d in zip(ref,result): - diff = np.abs(s.tensor-d.tensor) + st = s.tensor + dt = d.tensor + # Cast to signed so that the difference below is giving + # the right value + if st.dtype == np.uint8: + st = st.astype(dtype=np.int16) + dt = dt.astype(dtype=np.int16) + if st.dtype == np.uint16: + st = st.astype(dtype=np.int32) + dt = dt.astype(dtype=np.int32) + if st.dtype == np.uint32: + st = st.astype(dtype=np.int64) + dt = dt.astype(dtype=np.int64) + + diff = np.abs(st-dt) errorVal = np.max(diff) if errorVal > self._t: self.add_error(f"Different tensors. Max error = {errorVal}")