Address parameter validation across all EPs for Convo kernels#28142
Address parameter validation across all EPs for Convo kernels#28142yuslepukhin merged 14 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes stride/dilation validation for convolution/pooling-family operators across CPU, CoreML, and DML execution providers, and updates/extends tests to cover the new validation behavior.
Changes:
- Added explicit “> 0” validation for stride/dilation attributes in CPU conv/pool/unpool/col2im paths.
- Added equivalent validation in CoreML builders and DML OperatorAuthorHelper (including a new formatted validation macro).
- Updated CPU unit tests: removed DML-based whole-test skips, adjusted excluded EP lists, and added negative tests to ensure invalid stride/dilation values are rejected.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/test/providers/cpu/nn/pool_op_test.cc | Removes DML skip blocks, adjusts excluded EPs, and adds failure tests for invalid pool strides/dilations (plus DML-specific variants). |
| onnxruntime/test/providers/cpu/nn/conv_op_test.cc | Refactors to std:: types, adds invalid stride/dilation tests (and DML-specific variants), and includes DML default provider helpers. |
| onnxruntime/core/providers/dml/OperatorAuthorHelper/OperatorHelper.cpp | Adds runtime validation that DML stride/dilation values are strictly positive. |
| onnxruntime/core/providers/dml/OperatorAuthorHelper/Common.h | Introduces ML_CHECK_VALID_ARGUMENT_MSG macro to throw formatted invalid-argument errors. |
| onnxruntime/core/providers/dml/DmlExecutionProvider/src/ErrorHandling.h | Adds ORT_THROW_HR_MSG macro and minor whitespace fixes in macros. |
| onnxruntime/core/providers/cpu/tensor/col2im.h | Enforces positive strides/dilations during kernel construction. |
| onnxruntime/core/providers/cpu/nn/unpool.h | Enforces positive strides for MaxUnpool. |
| onnxruntime/core/providers/cpu/nn/pool_attributes.h | Enforces positive strides/dilations in pool attribute parsing/validation. |
| onnxruntime/core/providers/cpu/nn/conv_attributes.h | Enforces positive strides/dilations in conv attribute parsing/validation. |
| onnxruntime/core/providers/coreml/builders/impl/pool_op_builder.cc | Adds positive-stride validation for CoreML pooling builder. |
| onnxruntime/core/providers/coreml/builders/impl/conv_op_builder.cc | Adds positive stride/dilation validation for CoreML convolution builder. |
💡 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 12 out of 12 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…crosoft/onnxruntime into yuslepukhin/convo_msrc_113157
vraspar
left a comment
There was a problem hiding this comment.
Nit: DML Col2ImHelper appears to be missing the new stride/dilation positivity validation.
KernelHelper::InitializeKernelAndShapes now validates stride/dilation > 0 for Conv/Pool, and CPU col2im.h was similarly updated — but Col2ImHelper::Initialize (~line 1872-1891) still only checks attribute vector lengths after reading Dilations and Strides. Those values then flow directly into DML_FOLD_OPERATOR_DESC via DmlOperatorCol2Im.
Since DML Col2Im uses its own helper path (not the CPU Col2Im kernel), the CPU-side validation won't cover it. Additionally, because these are downcast into uint32_t via DowncastDimensions, a negative ONNX attribute value would wrap to a large unsigned value rather than failing cleanly.
Could we add the same ML_CHECK_VALID_ARGUMENT_MSG(... > 0, ...) checks here for consistency?
This pull request introduces consistent validation checks across ONNX Runtime's CPU, CoreML, and DML providers to ensure that all stride and dilation values are strictly positive for convolution, pooling, and related operators. It also updates the DML error handling macros and re-enables previously skipped DML tests now that validation is enforced. Minor test refactoring was performed for clarity and consistency.
Validation and Error Handling Improvements
conv,pool,unpool,col2im) to enforce that all stride and dilation values are positive, improving robustness and error reporting. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]Test Suite Updates
MaxPooltests, which were previously skipped due to invalid stride/dilation values, and removed unnecessary test skips. [1] [2] [3] [4] [5]vectorwithstd::vectorin test attribute declarations for clarity and consistency. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]using namespace std;directive from the test file.These changes improve input validation, error diagnostics, and ensure more reliable cross-provider behavior for stride and dilation attributes.