grid_sampler_2d_out Portable Kernel Implementation#16051
grid_sampler_2d_out Portable Kernel Implementation#16051manuelcandales merged 11 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16051
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f77c27d with merge base c00d726 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Pull request overview
This PR implements a portable kernel for the grid_sampler_2d operation in ExecuTorch, enabling 2D grid sampling with support for multiple interpolation modes (bilinear, nearest, bicubic), padding modes (zeros, border, reflection), and the align_corners parameter.
Key changes:
- Added complete implementation of grid_sampler_2d kernel with bilinear, nearest, and bicubic interpolation
- Created utility functions for coordinate transformation and bounds checking
- Added comprehensive test suites comparing ExecuTorch implementation against PyTorch reference
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| kernels/portable/cpu/op_grid_sampler_2d.cpp | Main kernel implementation with three interpolation modes |
| kernels/portable/cpu/util/grid_sampler_2d_util.h | Utility functions for coordinate transformations and cubic interpolation |
| kernels/portable/cpu/util/grid_sampler_2d_util.cpp | Argument validation and output tensor resizing logic |
| kernels/portable/functions.yaml | Registration of grid_sampler_2d.out operation |
| kernels/portable/test/op_grid_sampler_2d_test.py | Unit tests comparing against PyTorch reference implementation |
| kernels/portable/test/test_grid_sampler_2d_executorch.py | End-to-end tests via ExecuTorch runtime |
| kernels/portable/test/register_ops_aot_for_test.cpp | Test wrapper for AOT compilation |
| kernels/portable/test/targets.bzl | Build configuration for new test |
| kernels/portable/test/TARGETS | Dependency addition for grid_sampler_2d |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@pytorchbot label "release notes: ops & kernels" |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
### Summary Adds grid_sample_2d_out portable kernels. Fixes pytorch#11328 Release notes: ops & kernels ### Test plan I was unable to get the internal tests using `torch.et_test` to build. However, I did add a fairly comprehensive test suite in kernels/portable/test/op_grid_sampler_2d_test.py which compares the exported operation results to torch.nn.functional.grid_sample operations. Note that there are _some_ differences in how the implementations handle nan, inf, and -inf values; however, all the tests using real numbers pass. --------- Co-authored-by: John Gibson <jgibson@Johns-MacBook-Pro.local> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Adds grid_sample_2d_out portable kernels.
Fixes #11328
Release notes: ops & kernels
Test plan
I was unable to get the internal tests using
torch.et_testto build. However, I did add a fairly comprehensive test suite in kernels/portable/test/op_grid_sampler_2d_test.py which compares the exported operation results to torch.nn.functional.grid_sample operations. Note that there are some differences in how the implementations handle nan, inf, and -inf values; however, all the tests using real numbers pass.