Repository navigation
Conversation
Resize-18 can adjust the requested sizes to preserve the input aspect ratio (not_larger / not_smaller). The frontend read every other Resize attribute but dropped this one, so an imported model used the raw sizes and produced a stretched output. Apply the policy when sizes are given: compute the scale over the affected axes (all axes by default), take the min/max, and round each output dimension half-up like the ONNX reference. Add an ONNX Runtime checked test covering not_larger, not_smaller and stretch.
This branch has not been deployed
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.
Fixes #20842
Problem
Resize-18
keep_aspect_ratio_policyadjusts the requestedsizesto preserve the input aspect ratio. The frontend read the other Resize attributes but not this one, so the raw sizes were used and the output was stretched.Reported example: input spatial
(2, 4), requestedsizesspatial(1, 3):not_larger: ONNX Runtime returns shape(1, 1, 1, 2)with values[1, 3]; TVM returned(1, 1, 1, 3)with[1, 2, 4].not_smaller: ONNX Runtime keeps(1, 1, 2, 4)(the batch/channel scales participate, so the max is 1).stretch(default): unchanged.Change
_apply_keep_aspect_ratio_policy: when the policy is notstretchandsizesis given, compute the per-axis scales over the affected axes (axesattribute, or all axes by default), take the min/max, and round each output dimension half-up like the ONNX reference implementation.test_resize_keep_aspect_ratio_policy, checked against ONNX Runtime fornot_larger,not_smallerandstretch.Validation
pytest tests/python/relax/test_frontend_onnx.py -k resizepasses (12 tests), and the reported input matches ONNX Runtime for all three policies.