Round gaussian_blur outputs before OpenCV reference compare. - #9579
Open
dnikolaev-amd wants to merge 1 commit into
Open
Round gaussian_blur outputs before OpenCV reference compare.#9579dnikolaev-amd wants to merge 1 commit into
dnikolaev-amd wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9579
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Author
|
Hi @NicolasHug, |
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.
dnikolaev-amd
force-pushed
the
fix/gaussian-blur-round-before-compare
branch
from
August 11, 2026 15:03
a1b559b to
adb2add
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenCV ground truth in
gaussian_blur_opencv_results.ptisuint8(discrete levels). torchvision returnsfloatblur values, so compare rounded outputs to match integer reference semantics atatol=1.0Fixes AssertionError at
torch.testing.assert_close(out, true_out, rtol=0.0, atol=1.0, msg=f"{ksize}, {sigma}")if a small numerical noise (1ULP) occurs.Example:
Use
round, not a bare.to(torch.uint8)on float outputs: PyTorch truncates float-to-uint8 (60.9375 -> 60), which gives|62 - 60| = 2.0and fails.round(out)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.0Fixes AssertionError on ROCm:
As a replacement for #9509
cc @jeffdaily @jithunnair-amd