Validate NCHWc convolution layouts - #32557
Open
Akshay Sonawane (apsonawane) wants to merge 1 commit into
Open
Conversation
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
September 10, 2026 22:53
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Newly added rank, channel, and overflow validation paths lack test coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Strengthens NCHWc convolution validation and adds failure-path tests.
Changes:
- Validates ranks, groups, channels, blocked layouts, overflow, and bias shape.
- Adds tests for invalid groups, layouts, and biases.
File summaries
| File | Description |
|---|---|
onnxruntime/contrib_ops/cpu/nchwc_ops.cc |
Adds runtime validation. |
onnxruntime/test/contrib_ops/nchwc_ops_test.cc |
Tests selected invalid configurations. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+164
to
+165
| ORT_RETURN_IF_NOT(X_shape.NumDimensions() == 4 && W_shape.NumDimensions() == 4, | ||
| "NCHWc Conv input and filter must be rank 4."); |
Comment on lines
+169
to
+172
| ORT_RETURN_IF_NOT(input_channels_per_group > 0 && output_channels > 0, | ||
| "NCHWc Conv input and output channels must be greater than 0."); | ||
| ORT_RETURN_IF_NOT(input_channels_per_group <= std::numeric_limits<int64_t>::max() / conv_attrs_.group, | ||
| "NCHWc Conv input channels per group is too large."); |
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 input validation for the NCHWc convolution operator and adds comprehensive unit tests to ensure invalid configurations are properly rejected. The main changes are improved error checking in the operator implementation and a new test suite covering various invalid input scenarios.
Input validation improvements:
NchwcConv::Computeto check for valid group count, input/filter tensor ranks, positive channel sizes, channel size overflow, and correct blocked layout alignment. Also checks that the bias tensor (if present) is 1D and matches the number of output channels.#include <limits>to support overflow checks in the validation logic.Testing:
nchwc_ops_test.cc, with unit tests that verify the operator correctly rejects various invalid input and filter shapes, group values, and bias tensor configurations.