[CPU][x64] Fix i8/u8 SquaredDifference returning zeros in Snippets #39683
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 328 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #39683"
general
weight: 0.35
v-Golubev
Details:
- On x64, an
i8/u8SquaredDifferencereturned zeros. For example,SquaredDifference([7, 3, 1, 5], [2, 0, 6, 5])withi8inputs gives[0, 0, 0, 0]instead of[25, 9, 25, 0].i16andi32are correct, because those run through theEltwisenode, whilei8/u8run as a SnippetsSubgraph(jit_avx2_i8).- Snippets converts the 8-bit inputs to
i32for this emitter, but the node constructor ofjit_squared_difference_emitterignored the node and kept the defaultf32execution precision, so it ransubps/mulpson integer data. It now takes the precision from the node throughget_arithmetic_binary_exec_precision(), as the other arithmetic emitters (and the comparison emitters since #39444) do. ARM64 and RISC-V already do this.- In
EltwiseChainTestwith parameter inputs, the first operation used the first parameter for both of its inputs, the last parameter was unused, and all inputs were generated with the same seed. ASquaredDifferencein the chain therefore always computed(x - x)^2 = 0and could not catch this. The parameters are now paired as for constant inputs (the first one starts the chain, the next ones are the second inputs), and each input gets its own seed.- New x64 instance
smoke_EltwiseChain_SquaredDifference_8bit:i8andu8over all chain shapes. The inputs are in[10, 20), so the result stays in the 8-bit range.Validation:
Run on Windows with an Intel Core i5-12450HX (AVX2, no AVX-512), using a local Release build.
- New instance: all 18 cases fail without the change to
jit_eltwise_emitters.cppand pass with it. Also passes withONEDNN_MAX_CPU_ISA=SSE41and under Intel SDE-spr(AVX-512).- All
EltwiseChainsuites with the test changes: 267/267 pass (249/249 without the emitter change, apart from the 18 new cases).-
ov_cpu_func_testsfiltered to eltwise tests: 7132 ran, 4794 passed, 2338 skipped by configuration, 0 failed. Filtered to Snippets and SquaredDifference tests: 6570 ran, 3920 passed, 2650 skipped, 0 failed.Found while comparing the CPU plugin with constant folding and numpy on small integer inputs. The same comparison showed that an
i8/u8Clampwith fractional bounds (e.g. min 1.5) uses 1 instead of 2 on x64 whilei32is correct; that is left for a separate change.Tickets:
- N/A
AI Assistance:
- AI assistance used: yes
- An AI coding agent was used to find the issue with a differential test, trace the cause, write the fix and test, and draft this description.
- Validation performed: the local build, tests and ISA checks listed above, run on my machine.