fix(rpp): Fix normalize to apply per-sample mean/stddev for caller-supplied params - #12002
Open
sruthi0107 wants to merge 1 commit into
Open
fix(rpp): Fix normalize to apply per-sample mean/stddev for caller-supplied params#12002sruthi0107 wants to merge 1 commit into
sruthi0107 wants to merge 1 commit into
Conversation
…upplied When both statistics are caller-supplied, the per-sample stride into meanTensor/stdDevTensor was zeroed (HOST: maxSize = 0; HIP: maxParamVolume = 0), so every sample read sample 0's parameter block instead of its own. The partial-compute modes already stride per sample and match the reference on both backends, so per-sample is the intended layout and the both-supplied path was the outlier. HOST: drop the maxSize zeroing in both entry points and convert the whole batchSize * maxSize stddev array (previously only sample 0's block was converted to the scale / stddev multiplier form, which was masked by the broadcast). HIP: drop the maxParamVolume zeroing; the kernel already derives scale / stddev at point of use, so per-sample indexing is enough. Fixes cms0 on both backends (HIP F32/F16 fully green; HOST 2D/4D/F16 green). HOST 3D cms0 remains red due to a separate 3D reduction defect tracked in its own issue.
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
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
Normalize processes a batch of samples, and each sample has its own mean and stddev. Internally it locates a sample's parameters with a per-sample stride (
meanTensor + batchCount * maxSize). When the caller supplies both mean and stddev, that stride was set to zero, so every sample read sample 0's values and the whole batch was normalized with sample 0's mean and stddev. The modes where the kernel computes one statistic (cms1: mean computed; cms2: stddev computed) already stride per sample and match the reference on both backends, so per-sample is the intended layout. The both-supplied mode (cms0) was the outlier.Issue
JIRA ID : AICV-222
Technical Details
Remove the stride zeroing on both backends so each sample reads its own parameters again.
maxSize = 0in both entry points (f32/f32 and generic). The supplied stddev also gets converted to thescale / stddevmultiplier form in a one-time loop; that loop only covered sample 0 before (safe only because of the broadcast), so it now runs over the wholebatchSize * maxSizearray.maxParamVolume = 0. No conversion loop is needed here — the kernel computesscale / stddevat the point of use, so restoring the stride is enough.Test Plan
Ran the normalize correctness filters from the GoogleTest suite:
rpp_tests --gtest_filter='*NormalizeTest*cms0*'.Test Result