Commit adb2add
committed
Round gaussian_blur outputs before OpenCV reference compare.
OpenCV ground truth in gaussian_blur_opencv_results.pt is uint8 (discrete
gray levels). torchvision returns float blur values, so compare rounded
outputs to match integer reference semantics at atol=1.0.
Example (small image, kernel [3, 5], sigma 0.8, channel 0 at (9, 0)):
- OpenCV uint8 reference: 62
- OpenCV float / torchvision fp32: ~61.05 (already within atol=1 vs 62)
- torchvision fp16 on ROCm raw: ~60.94 -> |62 - 60.94| = 1.0625 fails atol=1.0
- after round: 61 -> |62 - 61| = 1.0 passes
Use round, not a bare .to(torch.uint8) on float outputs: PyTorch truncates
float-to-uint8 (60.9375 -> 60), which gives |62 - 60| = 2.0 and fails.
round(out) is enough here and keeps assert_close aligned with true_out
dtype (.to(tensor) leaves float refs as float).
All test_gaussian_blur cases that hit the reference pass with round + atol=1.0.1 parent 0fba2e8 commit adb2add
1 file changed
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1053 | 1053 | | |
1054 | 1054 | | |
1055 | 1055 | | |
1056 | | - | |
| 1056 | + | |
| 1057 | + | |
1057 | 1058 | | |
1058 | 1059 | | |
1059 | 1060 | | |
| |||
0 commit comments