Skip to content
Permalink
Browse files
fixed possible memleak: issue 143
  • Loading branch information
nitslp-ri committed Sep 8, 2020
1 parent ff5cd0f commit d75aea01786563d22c8489142f4c1bcc5acc602b
Showing 1 changed file with 2 additions and 5 deletions.
@@ -806,16 +806,15 @@ void dnn_calc_outprob(HMMWork *wrk)
#ifdef _OPENMP
#pragma omp parallel num_threads(dnn->num_threads)
{
int n = 0;
int hidx, i;
float *lsrc, *dst;
DNNLayer *h;
int id = omp_get_thread_num();
int j;

dst = dnn->work[n];
lsrc = src;
for (hidx = 0; hidx < dnn->hnum; hidx++) {
dst = dnn->work[hidx];
h = &(dnn->h[hidx]);
(*dnn->subfunc)(dst + h->begin[id] , lsrc, h->w + h->begin[id] * h->in, h->b + h->begin[id], h->end[id] - h->begin[id], h->in, dnn->accum + id * 8);
for (j = h->begin[id] ; j < h->end[id]; j++) {
@@ -828,23 +827,21 @@ void dnn_calc_outprob(HMMWork *wrk)
}
#pragma omp barrier
lsrc = dst;
dst = dnn->work[++n];
}
/* compute output layer */
(*dnn->subfunc)(wrk->last_cache + dnn->o.begin[id] , lsrc, dnn->o.w + dnn->o.begin[id] * dnn->o.in, dnn->o.b + dnn->o.begin[id], dnn->o.end[id] - dnn->o.begin[id], dnn->o.in, dnn->accum + id * 8);
}

#else /* ~_OPENMP */

dst = dnn->work[n];
for (hidx = 0; hidx < dnn->hnum; hidx++) {
dst = dnn->work[hidx];
h = &(dnn->h[hidx]);
(*dnn->subfunc)(dst, src, h->w, h->b, h->out, h->in, dnn->accum);
for (i = 0; i < h->out; i++) {
dst[i] = logistic_func(dst[i]);
}
src = dst;
dst = dnn->work[++n];
}
/* compute output layer */
(*dnn->subfunc)(wrk->last_cache, src, dnn->o.w, dnn->o.b, dnn->o.out, dnn->o.in, dnn->accum);

0 comments on commit d75aea0

Please sign in to comment.