[ICM CXX] Address Pad kernel shortcomings#26864
Merged
yuslepukhin merged 29 commits intomainfrom Jan 8, 2026
Merged
Conversation
…nxruntime into yuslepukhin/pad_rce
This reverts commit 96a6045.
…expected. [ FAILED ] PadOpTest/0.Pad_Constant_DimWithZeroInput, where TypeParam = float [ FAILED ] PadOpTest/1.Pad_Constant_DimWithZeroInput, where TypeParam = double
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses shortcomings in the Pad kernel implementation across CPU and CUDA providers, with a focus on improving robustness, safety, and edge case handling for padding operations.
Key Changes:
- Enhanced integer overflow protection using SafeInt throughout CPU and CUDA Pad implementations
- Added validation for edge cases including zero-extent dimensions and reflect mode constraints
- Introduced new comprehensive test cases for edge conditions, negative padding, and mixed-sign padding scenarios
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/test/testdata/test_pad_rce.py | Python script to generate ONNX model for RCE (Remote Code Execution) testing with dynamic pad inputs |
| onnxruntime/test/testdata/test_pad_rce.onnx | Generated ONNX model artifact for pad RCE testing |
| onnxruntime/test/providers/cpu/tensor/pad_test.cc | Updated test exclusions for DML provider, added extensive new tests for edge cases, negative padding, and various pad modes |
| onnxruntime/core/providers/cuda/tensor/pad.h | Minor update with copyright header duplication issue |
| onnxruntime/core/providers/cuda/tensor/pad.cc | Enhanced type safety (int32_t→size_t), added SafeInt usage, improved edge case handling for zero extents and reflect mode |
| onnxruntime/core/providers/cuda/cuda_utils.cu | Added Fill template specialization for bool type |
| onnxruntime/core/providers/cpu/tensor/padbase.h | Added helper functions for flattening validation and element coverage checking |
| onnxruntime/core/providers/cpu/tensor/pad.cc | Introduced OutputSink debug wrapper, enhanced SafeInt usage, improved validation for zero extents and reflect mode, conditional flattening logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tianleiwu
reviewed
Jan 6, 2026
Contributor
tianleiwu
left a comment
There was a problem hiding this comment.
The code and comprehensive tests looks good.
OutputSink only checks boundary in debug build. Is there use case that need bounds check in release build?
Some CI pipeline failed. Please take a look.
fs-eire
reviewed
Jan 6, 2026
tianleiwu
previously approved these changes
Jan 6, 2026
edgchen1
reviewed
Jan 7, 2026
edgchen1
reviewed
Jan 7, 2026
edgchen1
approved these changes
Jan 8, 2026
tianleiwu
approved these changes
Jan 8, 2026
alex-spacemit
pushed a commit
to spacemit-com/onnxruntime
that referenced
this pull request
Jan 20, 2026
### Description Address OOB reads and writes issues. ### Motivation and Context microsoft#11828 microsoft#13332 See also this: onnx/onnx#4294
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
Address OOB reads and writes issues.
Motivation and Context
#11828
#13332
See also this: onnx/onnx#4294