[MIOpen] fix bn fwd training edge case#2193
Closed
bghimireamd wants to merge 9 commits into
Closed
Conversation
JonathanLichtnerAMD
approved these changes
Nov 10, 2025
Contributor
JonathanLichtnerAMD
left a comment
There was a problem hiding this comment.
LGTM but could we add a test for this?
EnricoDeg
reviewed
Nov 11, 2025
…m/rocm-libraries into users/bghimire/fix_bn_variance_issue
Contributor
|
LGTM |
Contributor
Author
|
Closing: Test case N=1,H=1,W=1 is invalid for training mode (PyTorch rejects with "Expected more than 1 value per channel when training"). Proper fix is API-level input validation, not kernel changes. Will address in separate PR. |
1 task
bghimireamd
added a commit
that referenced
this pull request
Dec 5, 2025
## Motivation
Adds validation in both hipDNN frontend and MIOpen to reject batch norm
forward training and backward shapes where N × spatial_dimensions ≤ 1
(e.g., {1, 256, 1, 1}).
## Technical Details
This supersedes the [closed kernel-level
approach](#2193) .
## Test Plan
This prevents undefined behavior, aligns with PyTorch, and includes 22
hipDNN frontend tests. Invalid test cases removed from backend fixtures.
## Test Result
<!-- Briefly summarize test outcomes. -->
## Submission Checklist
- [ ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
assistant-librarian Bot
pushed a commit
to ROCm/MIOpen
that referenced
this pull request
Dec 5, 2025
[MIOpen] [HipDNN] [ALMIOPEN-493] Handle Batch norm invalid cases (#3030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation Adds validation in both hipDNN frontend and MIOpen to reject batch norm forward training and backward shapes where N × spatial_dimensions ≤ 1 (e.g., {1, 256, 1, 1}). ## Technical Details This supersedes the [closed kernel-level approach](ROCm/rocm-libraries#2193) . ## Test Plan This prevents undefined behavior, aligns with PyTorch, and includes 22 hipDNN frontend tests. Invalid test cases removed from backend fixtures. ## Test Result <!-- Briefly summarize test outcomes. --> ## Submission Checklist - [ ] Look over the contributing guidelines at https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
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.
Motivation
./bin/MIOpenDriver bnorm -n 1 -c 256 -H 1 -W 1 -m 1 --forw 1 -b 0 -r 1 -s 1 --layout NCHWThis edge case was causing issue ( hardcode variance to zero for single samples). This PR is to fix this edge case.
Technical Details
Test Plan
Test Result
Submission Checklist