Fix/pool negative pad validation - #32076
Open
Akshay Sonawane (apsonawane) wants to merge 2 commits into
Open
Conversation
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 14, 2026 00:35
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
August 14, 2026 00:36
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR strengthens pooling padding validation across the CPU provider and MLAS to reject negative pad values (when auto_pad is not set), and adds targeted unit tests to ensure invalid configurations fail early with clear errors.
Changes:
- Add
PoolAttributesvalidation to enforce non-negativepadswhenauto_pad == NOTSET. - Add an MLAS-layer guard that throws
std::invalid_argumentwhen any padding value is negative. - Add unit tests covering both the ORT MaxPool operator path and the MLAS
MlasPoolbackend.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| onnxruntime/test/providers/cpu/nn/pool_op_test.cc | Adds regression tests ensuring negative pads are rejected at the ORT op level and (when exceptions are enabled) at the MLAS level. |
| onnxruntime/core/providers/cpu/nn/pool_attributes.h | Enforces non-negative pads for explicit padding to prevent invalid pooling configurations from reaching execution. |
| onnxruntime/core/mlas/lib/pooling.cpp | Adds a low-level validation check to reject negative padding values before MLAS pooling proceeds. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // Graph::Resolve() and reach kernel construction where our ORT_ENFORCE checks fire. | ||
| // Exclude compiling EPs (TRT, QNN) and EPs with their own validation (DML) that produce | ||
| // different error messages. | ||
| TEST(PoolTest, MaxPool_NegativePad) { |
Ti-Tai Wang (titaiwangms)
approved these changes
Aug 14, 2026
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.
This pull request strengthens validation for padding values in pooling operations to ensure they are non-negative, preventing invalid configurations and potential runtime errors. It also adds unit tests to verify that negative padding values are correctly rejected, both at the ONNX operator level and in the underlying MLAS pooling implementation.
Validation improvements:
pool_attributes.hto enforce that all padding values (pads) are non-negative whenauto_padis not set, raising an error if this condition is violated.pooling.cppto throw astd::invalid_argumentexception if any padding value is negative, providing an additional safeguard at the MLAS pooling layer.Testing enhancements:
pool_op_test.ccto verify that negative padding values cause the expected errors, both for the ONNX MaxPool operator and for the MLAS pooling backend.