Skip to content

Address parameter validation across all EPs for Convo kernels#28142

Merged
yuslepukhin merged 14 commits intomainfrom
yuslepukhin/convo_msrc_113157
Apr 23, 2026
Merged

Address parameter validation across all EPs for Convo kernels#28142
yuslepukhin merged 14 commits intomainfrom
yuslepukhin/convo_msrc_113157

Conversation

@yuslepukhin
Copy link
Copy Markdown
Member

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

  • Added explicit checks in CPU, CoreML, and DML operator implementations (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]
  • Introduced new error handling macros for DML to support formatted error messages and consistent validation checks. [1] [2]

Test Suite Updates

  • Re-enabled DML execution provider in several MaxPool tests, which were previously skipped due to invalid stride/dilation values, and removed unnecessary test skips. [1] [2] [3] [4] [5]
  • Replaced vector with std::vector in test attribute declarations for clarity and consistency. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]
  • Removed an unused 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.

Copy link
Copy Markdown
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 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.

Comment thread onnxruntime/core/providers/dml/OperatorAuthorHelper/Common.h
Copy link
Copy Markdown
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 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.

Comment thread onnxruntime/test/providers/cpu/nn/pool_op_test.cc
Comment thread onnxruntime/test/providers/cpu/nn/conv_op_test.cc
Comment thread onnxruntime/test/providers/cpu/nn/pool_op_test.cc
Comment thread onnxruntime/core/providers/coreml/builders/impl/conv_op_builder.cc Outdated
Comment thread onnxruntime/core/providers/coreml/builders/impl/pool_op_builder.cc
Copy link
Copy Markdown
Contributor

@vraspar vraspar left a comment

Choose a reason for hiding this comment

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

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?

Comment thread .vscode/settings.json Outdated
@yuslepukhin yuslepukhin requested a review from vraspar April 22, 2026 17:30
@yuslepukhin yuslepukhin enabled auto-merge (squash) April 22, 2026 23:33
@yuslepukhin yuslepukhin merged commit 9ec5c19 into main Apr 23, 2026
90 of 91 checks passed
@yuslepukhin yuslepukhin deleted the yuslepukhin/convo_msrc_113157 branch April 23, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants