Fixed for-loop var initialization for OpenMP, for Contrastive-loss

This commit is contained in:
AlexeyAB 2021-07-27 18:43:40 +03:00
parent d669680879
commit f5007cd0d4
1 changed files with 7 additions and 6 deletions

View File

@ -498,17 +498,18 @@ void forward_contrastive_layer(contrastive_layer l, network_state state)
// calc deltas
int bd = 0;
#pragma omp parallel for
for (b = 0; b < l.batch; ++b) {
for (n = 0; n < l.n; ++n) {
for (h = 0; h < l.h; ++h) {
for (w = 0; w < l.w; ++w)
for (bd = 0; bd < l.batch; ++bd) {
for (int nd = 0; nd < l.n; ++nd) {
for (int hd = 0; hd < l.h; ++hd) {
for (int wd = 0; wd < l.w; ++wd)
{
const int z_index = b*l.n*l.h*l.w + n*l.h*l.w + h*l.w + w;
const int z_index = bd*l.n*l.h*l.w + nd*l.h*l.w + hd*l.w + wd;
const size_t step = l.batch*l.n*l.h*l.w;
if (l.labels[z_index] < 0) continue;
const int delta_index = b*l.embedding_size*l.n*l.h*l.w + n*l.embedding_size*l.h*l.w + h*l.w + w;
const int delta_index = bd*l.embedding_size*l.n*l.h*l.w + nd*l.embedding_size*l.h*l.w + hd*l.w + wd;
const int wh = l.w*l.h;
if (l.detection) {