Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions projects/rpp/src/modules/tensor/cpu/kernel/normalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,11 @@ RppStatus normalize_f32_f32_host_tensor(Rpp32f* srcPtr, RpptGenericDescPtr srcGe
}

if (!computeMeanStddev) {
for (Rpp32u i = 0; i < maxSize; i++)
// Both mean and stddev are caller-supplied, one parameter block per sample. Convert the
// supplied stddev to the (scale / stddev) multiplier form across the whole batch and keep
// the per-sample stride (do not zero maxSize) so each sample reads its own parameters.
for (Rpp32u i = 0; i < maxSize * batchSize; i++)
stdDevTensorPtr[i] = (!stdDevTensorPtr[i]) ? 1.0f : scale / stdDevTensorPtr[i];
maxSize = 0;
}

std::atomic<RppStatus> axisMaskStatus{RPP_SUCCESS};
Expand Down Expand Up @@ -743,9 +745,11 @@ RppStatus normalize_generic_host_tensor(T1* srcPtr, RpptGenericDescPtr srcGeneri
maxSize = std::max(maxSize, size);
}
if (!computeMeanStddev) {
for (Rpp32u i = 0; i < maxSize; i++)
// Both mean and stddev are caller-supplied, one parameter block per sample. Convert the
// supplied stddev to the (scale / stddev) multiplier form across the whole batch and keep
// the per-sample stride (do not zero maxSize) so each sample reads its own parameters.
for (Rpp32u i = 0; i < maxSize * batchSize; i++)
stdDevTensorPtr[i] = (!stdDevTensorPtr[i]) ? 1.0f : scale / stdDevTensorPtr[i];
maxSize = 0;
}

omp_set_dynamic(0);
Expand Down
4 changes: 3 additions & 1 deletion projects/rpp/src/modules/tensor/hip/kernel/normalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,9 @@ RppStatus hip_exec_normalize_tensor(T* srcPtr, RpptGenericDescPtr srcGenericDesc
bool computeStdDev =
computeMeanStddev & 2; // if 1st bit in computeMeanStddev is set, computeStdDev is set to
// true. Otherwise it is set to false
if ((!computeMean) && (!computeStdDev)) maxParamVolume = 0;
// maxParamVolume is the per-sample stride into meanTensor/stdDevTensor (paramIndex =
// id_z * maxParamVolume). It must stay per-sample even when both statistics are supplied, so
// that each sample reads its own parameter block instead of sample 0's.

// Zero-initialize the mean and standard deviation tensors
if (computeMean)
Expand Down
Loading