Validate Conv bias size - #32160
Open
Akshay Sonawane (apsonawane) wants to merge 1 commit into
Open
Conversation
Copilot started reviewing on behalf of
Akshay Sonawane (apsonawane)
August 18, 2026 22:57
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds CPU Conv bias validation to prevent invalid rank or channel counts.
Changes:
- Validates that bias is 1-D with one value per output channel.
- Adds a failure test for incorrect bias size.
- Rank-validation coverage is still missing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
onnxruntime/core/providers/cpu/nn/conv.cc |
Adds bias validation to Conv compute paths. |
onnxruntime/test/providers/cpu/nn/conv_op_test.cc |
Tests rejection of incorrect bias size. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| OpTester test("Conv", 22); | ||
| test.AddInput<float>("X", {1, 1, 1, 1}, {1.0f}); | ||
| test.AddInput<float>("W", {4, 1, 1, 1}, std::vector<float>(4, 0.0f)); | ||
| test.AddInput<float>("B", {1}, {0.0f}); |
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 18, 2026 23:03
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 Conv operator by adding explicit checks for the bias tensor shape and size, and adds a new unit test to verify this behavior. The main changes are as follows:
Input validation improvements:
Conv<T>::Compute(and the float specialization) to ensure that the bias tensorB, if provided, is a 1D tensor whose size matches the number of output channels (M). If not, an informative error message is returned. [1] [2]Testing enhancements:
Conv2D_InvalidBiasSizeinconv_op_test.ccto verify that the Conv operator correctly fails when the bias tensor does not have the expected size, ensuring the new validation logic works as intended.