Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the robustness of the CPU AffineGrid kernel by adding stricter shape validation and expanding unit tests to verify failures on invalid inputs.
Changes:
- Added explicit validation for
theta/sizebatch consistency and expectedthetashapes for 2D/3D cases. - Improved type safety in base-grid generation by using templated Eigen vector types rather than hardcoded
float. - Added negative unit tests covering invalid dimensions, invalid
sizelengths, batch mismatches, and invalidthetashapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| onnxruntime/core/providers/cpu/tensor/affine_grid.cc | Adds stricter input validation and improves type correctness in grid generation. |
| onnxruntime/test/providers/cpu/tensor/affine_grid_test.cc | Adds unit tests to ensure invalid inputs fail with expected error messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Description
This pull request improves the robustness and correctness of the
AffineGridoperator in ONNX Runtime by adding stricter input validation and updating the implementation for better type safety. It also introduces comprehensive unit tests to verify error handling for invalid inputs.Input validation enhancements
affine_grid.ccto ensure that the batch dimension insizematches the batch dimension intheta, and thatthetahas the correct shape for both 2D ([N, 2, 3]) and 3D ([N, 3, 4]) cases. This prevents silent errors due to shape mismatches. [1] [2]Type safety and code clarity improvements
Tfor Eigen vector creation, replacing hardcodedfloattypes. This ensures correct behavior for different data types and improves code clarity. [1] [2]Test coverage improvements
affine_grid_test.ccto validate input shape checks, including cases for incorrect tensor dimensions, mismatched batch sizes, and invalidsizelengths. These tests ensure that the operator fails gracefully with informative error messages when given invalid inputs.Code cleanup
affine_grid.ccto tidy up the codebase.