Skip to content
Snippets Groups Projects
Commit 59c4412d authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Improved average pooling precision

parent 8ecdc264
No related branches found
Tags v0.4.0
2 merge requests!50version 0.2.0,!45Improved scheduling
Pipeline #42677 failed
......@@ -49,12 +49,12 @@ void GlobalAveragePoolingImpl_cpu_forward_kernel(
for (DimSize_t channel = 0; channel < dims[1]; ++channel) {
const I *filter_start = std::next(
input, (batch * in_batch_nb_elems) + (channel * in_channel_nb_elems));
I sum = 0;
I mean = 0;
for (size_t i = 0; i < in_channel_nb_elems; ++i) {
sum += filter_start[i];
// Single pass numerically stable mean, using the fmaf
mean = fmaf(filter_start[i] - mean, 1.0f/(i+1), mean);
}
output[batch * out_batch_nb_elems + channel] =
sum / static_cast<I>(in_channel_nb_elems);
output[batch * out_batch_nb_elems + channel] = mean;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment