-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
OpenVINO Version
2024.6.0
Operating System
Ubuntu 20.04 (LTS)
Device used for inference
CPU
Framework
None
Model used
No response
Issue description
I have identified a behavior divergence between OpenVINO and standard NumPy arithmetic regarding uint8 subtraction underflow.
When performing subtraction A - B where A < B using uint8 data types:
NumPy (Oracle) performs modular arithmetic (wrap-around). Result: (3 - 4) mod 256 = 255.
OpenVINO (CPU) performs saturation arithmetic. Result: max(0, 3 - 4) = 0.
While saturation is common in image processing, the standard Subtract operator in generic computational graphs typically expects standard integer arithmetic (wrap-around) unless specified as a specific "QLinear" or "Saturated" op. This inconsistency causes accuracy drops when porting models that rely on bitwise/integer arithmetic logic.
Step-by-step reproduction
Construct a minimal OpenVINO graph with two uint8 Inputs and a Subtract node.
Feed inputs A=3 and B=4.
Compare the OpenVINO inference result with NumPy.
Relevant log output
--- Reproducing uint8 Sub Arithmetic Underflow (Saturation) BUG ---
Input A (uint8): 3
Input B (uint8): 4
--- Oracle (Numpy) Calculation ---
np.uint8(3) - np.uint8(4) = 255
--- OpenVINO Calculation ---
OpenVINO Sub(3, 4) = 0
--- Conclusion ---
Oracle (Expected, Wrap-around): 255
OpenVINO (Actual): 0
✅ BUG REPRODUCED!
Oracle (uint8) 3 - 4 = 255 (Wrap-around)
OpenVINO (uint8) 3 - 4 = 0 (Saturation)
This matches the reported behavior: Oracle: 255 vs OpenVINO: 0Issue submission checklist
- I'm reporting an issue. It's not a question.
- I checked the problem with the documentation, FAQ, open issues, Stack Overflow, etc., and have not found a solution.
- There is reproducer code and related data files such as images, videos, models, etc.