Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnnxToTorch lowering resize op (cherry-picks from upstream) (CR-1196776) #168

Merged
merged 12 commits into from
Jun 7, 2024

Conversation

mgehre-amd
Copy link
Collaborator

@mgehre-amd mgehre-amd commented Jun 6, 2024

This are the commits from upstream required to lower onnx.Resize to linalg.
In addition, I fixed the default nearest_mode to be round_prefer_floor as specified by ONNX, and implemented coordTfMode half_pixel.

aldesilv and others added 5 commits June 6, 2024 15:41
nod-ai/SHARK-ModelDev#358
adds a lowering from onnx to linalg for bilinear and nearest resize with
support for using scales or sizes to get resize shape. uses coordinate
transform half pixel for bilinear mode and asymmetrical for nearest
mode. See
https://github.com/onnx/onnx/blob/main/docs/Operators.md#Resize. Added
two passes -- one for bilinear and the other for nearest.
…ering (llvm#3351)

Addresses [Shark-Turbine

Related tracker [Shark-Turbine

Related onnx.Resize issues [Shark-Turbine
The old lowering only had logic for 2d (i.e. images). this patch allows
interpolation for n spatial dims, which is required for some 3d vision
models such as

- onnx/models/pytorch-3dunet_vaiq_int8

which successfully compiles and runs with this patch.
Updates:

- some unsupported modes are now going to report a match failure for
unsupported coordinate transformation modes.
- fixes a bug that was introduced in the last patch for resize (my
bad...)
- uses actual x and y coordinates for computing weights in bilinear
interpolation (rather than eps modified values)
- slightly simplifies the bilinear interpolation payload for readability
and performance
- passes coordinate transformation mode information from an onnx.Resize
op to the mode string for the aten._interpolate op. This allows us to
perform custom logic in the torch->linalg lowering to support
onnx.Resize options without losing the default behaviors of the
interpolate op.
@mgehre-amd mgehre-amd changed the title OnnxToTorch lowering resize op cherry-picks from upstream OnnxToTorch lowering resize op (cherry-picks from upstream) (CR-1196776) Jun 6, 2024
@mgehre-amd mgehre-amd changed the base branch from release_rai_1_2 to matthias.enable_ci June 7, 2024 13:18
Base automatically changed from matthias.enable_ci to release_rai_1_2 June 7, 2024 13:37
@mgehre-amd mgehre-amd merged commit ccfc8b3 into release_rai_1_2 Jun 7, 2024
2 checks passed
@mgehre-amd mgehre-amd deleted the matthias.onnx_resize branch June 7, 2024 15:18
@mgehre-amd mgehre-amd restored the matthias.onnx_resize branch June 7, 2024 15:18
@mgehre-amd mgehre-amd mentioned this pull request Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants