Skip to content

Commit 0dfc2a5

Browse files
authored
[circle-mlir] Prevent division by zero in PEIR calculation (#14842)
This commit adds a check to set PEIR to 0 when INTERVAL is 0, ensuring that division by zero is avoided. ONE-DCO-1.0-Signed-off-by: ragmani <ragmani0216@gmail.com>
1 parent f9a1c47 commit 0dfc2a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

circle-mlir/circle-mlir/tools-test/onnx2circle-value-test/util_validation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ def get_peir_from(baseline_output, target_output):
1919
PEIR = 0
2020
else:
2121
INTERVAL = baseline_max - baseline_min
22-
PEIR = PEAK_ERROR / INTERVAL
22+
if INTERVAL == 0:
23+
# Set to infinity because INTERVAL is zero
24+
PEIR = np.inf
25+
else:
26+
PEIR = PEAK_ERROR / INTERVAL
2327

2428
PEIR_res = '{:.4f}'.format(PEIR) if PEIR <= 1.0 else '> 1'
2529

0 commit comments

Comments
 (0)