Skip to content

Commit b78ffe7

Browse files
author
Roy Li
committed
fix nits
1 parent 9445ca4 commit b78ffe7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

aten/src/THNN/generic/VolumetricMaxUnpooling.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,16 @@ static void THNN_(VolumetricMaxUnpooling_updateOutput_frame)(
7575
real *input_p_k = input_p + k * iT * iH * iW;
7676
THIndex_t *ind_p_k = ind_p + k * iT * iH * iW;
7777

78-
int ti, i, j;
78+
int t, i, j, index;
7979
THIndex_t maxp;
80-
for (ti = 0; ti < iT; ti++)
80+
for (t = 0; t < iT; t++)
8181
{
8282
for (i = 0; i < iH; i++)
8383
{
8484
for (j = 0; j < iW; j++)
8585
{
86-
maxp = ind_p_k[ti * iH * iW + i * iW + j] - TH_INDEX_BASE; /* retrieve position of max */
86+
index = t * iH * iW + i * iW + j;
87+
maxp = ind_p_k[index] - TH_INDEX_BASE; /* retrieve position of max */
8788
if (maxp < 0 || maxp >= oT * oW * oH)
8889
{
8990
#pragma omp critical
@@ -92,7 +93,7 @@ static void THNN_(VolumetricMaxUnpooling_updateOutput_frame)(
9293
error_index = maxp;
9394
}
9495
} else {
95-
output_p_k[maxp] = input_p_k[ti * iH * iW + i * iW + j]; /* update output */
96+
output_p_k[maxp] = input_p_k[index]; /* update output */
9697
}
9798
}
9899
}
@@ -222,20 +223,21 @@ static void THNN_(VolumetricMaxUnpooling_updateGradInput_frame)(
222223
real *gradOutput_p_k = gradOutput_p + k * oT * oH * oW;
223224
THIndex_t *ind_p_k = ind_p + k * iT * iH * iW;
224225

225-
int ti, i, j;
226+
int t, i, j, index;
226227
THIndex_t maxp;
227-
for (ti = 0; ti < iT; ti++)
228+
for (t = 0; t < iT; t++)
228229
{
229230
for (i = 0; i < iH; i++)
230231
{
231232
for (j = 0; j < iW; j++)
232233
{
233-
maxp = ind_p_k[ti * iH * iW + i * iW + j] - TH_INDEX_BASE; /* retrieve position of max */
234+
index = t * iH * iW + i * iW + j;
235+
maxp = ind_p_k[index] - TH_INDEX_BASE; /* retrieve position of max */
234236
if (maxp < 0 || maxp >= oT * oH * oW)
235237
{
236238
THError("invalid max index %ld, oT= %d, oW= %d, oH= %d", maxp, oT, oW, oH);
237239
}
238-
gradInput_p_k[ti * iH * iW + i * iW + j] = gradOutput_p_k[maxp]; /* update gradient */
240+
gradInput_p_k[index] = gradOutput_p_k[maxp]; /* update gradient */
239241
}
240242
}
241243
}

0 commit comments

Comments
 (0)