Share box conversion kernels between ops and transforms v2 - #9651
Open
YeonwooSung wants to merge 1 commit into
Open
Share box conversion kernels between ops and transforms v2#9651YeonwooSung wants to merge 1 commit into
YeonwooSung wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9651
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. |
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.
ops.box_convertandF.convert_bounding_box_formatboth converted boxes, but the arithmetic lived in two places. This keeps the kernels intorchvision/ops/_box_convert.pyand has transforms v2 call them.What is now shared
ops/_box_convert.py(_box_*helpers plus_half_wh).ops.box_convertuses those helpers directly, including new first-classxywh ↔ cxcywhkernels instead of a two-step trip throughxyxy.convert_bounding_box_formatcalls the same kernels for the arithmetic.xyxy → cxcywh(andxywh → cxcywh) use overflow-safeorigin + size/2instead of(x1 + x2) / 2or(x1 * 2 + width) / 2. This does not fight Avoid overflow in box center conversion #9641; it uses the same safer form.Backward compatibility
ops.box_convertis still out-of-place, still JIT-scriptable, and still true-divides (integer inputs may promote to float).inplace=Trueand still keeps integer dtype via floor-div on thexyxy/xywh → cxcywhpaths.CXCYWH → XYWHstill recomputesw/hafter truncation so it matches the two-step v2 path (PR Fix CXCYWH to XYXY conversion for integer bounding boxes #9322 / issue Incorrect BoundingBoxes format conversion CXCYWH -> XYXY #8887).opsdoes not importtransforms.Tests
ops.box_convertandF.convert_bounding_box_formatare checked to agree on float32/float64 forxyxy/xywh/cxcywhpairs.Fixes #9387