mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-05 04:17:53 +00:00
Fix math domain error with log10 (#12841)
fix math domain error with log10
This commit is contained in:
parent
8cedafe250
commit
9ad5b95e4f
1 changed files with 5 additions and 3 deletions
|
|
@ -343,9 +343,11 @@ def compute_signal_to_quantization_noice_ratio(
|
|||
left = numpy.concatenate(xlist).flatten()
|
||||
right = numpy.concatenate(ylist).flatten()
|
||||
|
||||
Ps = numpy.linalg.norm(left)
|
||||
Pn = numpy.linalg.norm(left - right) + numpy.finfo("float").eps
|
||||
return 20 * math.log10(Ps / Pn)
|
||||
epsilon = numpy.finfo("float").eps
|
||||
tensor_norm = max(numpy.linalg.norm(left), epsilon)
|
||||
diff_norm = max(numpy.linalg.norm(left - right), epsilon)
|
||||
res = tensor_norm / diff_norm
|
||||
return 20 * math.log10(res)
|
||||
|
||||
|
||||
def compute_weight_error(
|
||||
|
|
|
|||
Loading…
Reference in a new issue