Validate NCHWc reorder channel layout - #32552
Open
Akshay Sonawane (apsonawane) wants to merge 1 commit into
Open
Validate NCHWc reorder channel layout#32552Akshay Sonawane (apsonawane) wants to merge 1 commit into
Akshay Sonawane (apsonawane) wants to merge 1 commit into
Conversation
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
September 10, 2026 21:00
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
September 10, 2026 21:01
View session
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The test does not cover the newly added excessive-padding rejection condition.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Strengthens NCHWc ReorderOutput channel-layout validation.
Changes:
- Validates block alignment and requested channel count.
- Adds a rejection test for unaligned input channels.
File summaries
| File | Description |
|---|---|
onnxruntime/contrib_ops/cpu/nchwc_ops.cc |
Enforces valid NCHWc channel padding. |
onnxruntime/test/contrib_ops/nchwc_ops_test.cc |
Tests rejection of unaligned channels. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+13
to
+31
| TEST(NchwcOpsTest, ReorderOutputRejectsUnalignedInputChannels) { | ||
| const int64_t block_size = static_cast<int64_t>(MlasNchwcGetBlockSize()); | ||
| if (block_size <= 1) { | ||
| GTEST_SKIP() << "NCHWc blocking is not enabled on this platform."; | ||
| } | ||
|
|
||
| const int64_t input_channels = block_size - 1; | ||
| OpTester test("ReorderOutput", 1, kMSNchwcDomain); | ||
| test.AddAttribute("channels", int64_t{1}); | ||
| test.AddAttribute("channels_last", int64_t{0}); | ||
| test.AddInput<float>("X", {1, input_channels, 2, 2}, | ||
| std::vector<float>(static_cast<size_t>(input_channels) * 4, 0.0f)); | ||
| test.AddOutput<float>("Y", {1, 1, 2, 2}, {0.0f, 0.0f, 0.0f, 0.0f}); | ||
|
|
||
| test.Config(OpTester::ExpectResult::kExpectFailure, | ||
| "Input channels must match the NCHWc block-aligned channel count.") | ||
| .ConfigEp(DefaultCpuExecutionProvider()) | ||
| .RunWithConfig(); | ||
| } |
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 in the
ReorderOutputoperator for NCHWc tensors and adds a new unit test to ensure correct error handling for misaligned input channels. The main focus is to enforce stricter requirements on input channel alignment and to verify this behavior with automated testing.Operator input validation improvements:
ReorderOutput::Computeinnchwc_ops.ccto enforce that the input channel count is a multiple of the NCHWc block size, and that the number of channels requested is properly aligned. The error message was also improved for clarity.Testing enhancements:
ReorderOutputRejectsUnalignedInputChannelsinnchwc_ops_test.ccto verify that the operator correctly rejects inputs where the channel count is not NCHWc block-aligned, ensuring that the stricter validation is covered.