Skip to content

Conversation

@jgibson2
Copy link
Contributor

@jgibson2 jgibson2 commented Dec 2, 2025

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_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.

Copilot AI review requested due to automatic review settings December 2, 2025 19:03
@pytorch-bot
Copy link

pytorch-bot bot commented Dec 2, 2025

🔗 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 Failures

As of commit f77c27d with merge base c00d726 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 2, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jgibson2
Copy link
Contributor Author

jgibson2 commented Dec 2, 2025

@pytorchbot label "release notes: ops & kernels"

@pytorch-bot pytorch-bot bot added the release notes: ops & kernels Changes to the opset and any new / changed kernel implementations label Dec 2, 2025
Copilot AI review requested due to automatic review settings December 2, 2025 20:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI review requested due to automatic review settings December 3, 2025 16:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot AI review requested due to automatic review settings December 3, 2025 16:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jgibson2 jgibson2 requested a review from Copilot December 3, 2025 19:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jgibson2 jgibson2 changed the title grid_sample_2d_out Portable Kernel Implementation grid_sampler_2d_out Portable Kernel Implementation Dec 4, 2025
@manuelcandales manuelcandales merged commit 8944db4 into pytorch:main Dec 4, 2025
141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: ops & kernels Changes to the opset and any new / changed kernel implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement portable kernel: grid_sampler_2d.out

2 participants