Skip to content

Commit

Permalink
Merge pull request AlexeyAB#6564 from bouncyphoton/master
Browse files Browse the repository at this point in the history
Improve model loading performance for detect
  • Loading branch information
AlexeyAB authored Aug 29, 2020
2 parents 05dee78 + 519fc8b commit ae27c16
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1240,12 +1240,14 @@ void fuse_conv_batchnorm(network net)
{
l->biases[f] = l->biases[f] - (double)l->scales[f] * l->rolling_mean[f] / (sqrt((double)l->rolling_variance[f] + .00001));

double precomputed = l->scales[f] / (sqrt((double)l->rolling_variance[f] + .00001));

const size_t filter_size = l->size*l->size*l->c / l->groups;
int i;
for (i = 0; i < filter_size; ++i) {
int w_index = f*filter_size + i;

l->weights[w_index] = (double)l->weights[w_index] * l->scales[f] / (sqrt((double)l->rolling_variance[f] + .00001));
l->weights[w_index] *= precomputed;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void *xcalloc(size_t nmemb, size_t size) {
if(!ptr) {
calloc_error();
}
memset(ptr, 0, nmemb * size);
return ptr;
}

Expand Down

0 comments on commit ae27c16

Please sign in to comment.