Skip to content

Commit

Permalink
Corrected Python class used for tests SimilarTensorFixp
Browse files Browse the repository at this point in the history
It was not computing the right difference when using unsigned datatype
  • Loading branch information
christophe0606 committed May 27, 2024
1 parent 1b3694e commit 52002df
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Testing/board/scripts/details/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit 52002df

Please sign in to comment.