vacu9708 commented on issue #17997:
URL: https://github.com/apache/tvm/issues/17997#issuecomment-2903014765

   Below is how I tested.
   ```python
   ref_np = ref_output.numpy().astype('float32')
   opt_np = opt_mod_output.numpy().astype('float32')
   
   # absolute difference
   diff = np.abs(ref_np - opt_np)
   # 1 ULP at each ref element
   ulp = np.abs(np.spacing(ref_np))
   # allow up to N ULP
   N = 1
   mask = diff > (N * ulp)
   
   if mask.any():
       bad = np.argwhere(mask)
       print(f"{len(bad)} elements differ by more than {N} ULP:")
       for idx in bad[:10]:
           i = tuple(idx)
           print(f" idx={i}: ref={ref_np[i]:.8e}, opt={opt_np[i]:.8e}, "
                 f"diff={diff[i]:.8e}, 1ULP@ref={ulp[i]:.8e}")
       if len(bad) > 10:
           print(f" …and {len(bad)-10} more")
   else:
       print(f"All values within {N} ULP of reference.")
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to