Skip to content

Commit

Permalink
THVector_(add) -> THVector_(adds)
Browse files Browse the repository at this point in the history
  • Loading branch information
soumith committed Feb 28, 2017
1 parent 2d269a9 commit 80429ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
8 changes: 5 additions & 3 deletions generic/TemporalRowConvolution.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ static void THNN_(unfolded_acc_row)(

ix = (long long)(kw);
if (dW == 1) {
THVector_(add)(dst + (size_t)(ix), src, 1, nOutputFrame);
real *dst_slice = dst + (size_t)(ix);
THVector_(cadd)(dst_slice, dst_slice, src, 1, nOutputFrame);
} else {
for (x = 0; x < nOutputFrame; x++) {
THVector_(add)(dst + (size_t)(ix + x * dW),
src + (size_t)(x), 1, 1);
real *dst_slice = dst + (size_t)(ix + x * dW);
THVector_(cadd)(dst_slice, dst_slice,
src + (size_t)(x), 1, 1);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions generic/VolumetricConvolutionMM.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ static void THNN_(unfolded_acc_vol)(
}
else
{
THVector_(add)(dst+it*inputHeight*inputWidth+iy*inputWidth+ix, src+t*outputHeight*outputWidth+y*outputWidth+x, 1, 1);
real *dst_slice = dst+it*inputHeight*inputWidth+iy*inputWidth+ix;
THVector_(cadd)(dst_slice, dst_slice, src+t*outputHeight*outputWidth+y*outputWidth+x, 1, 1);
}
}
}
Expand All @@ -169,7 +170,8 @@ static void THNN_(unfolded_acc_vol)(
for(x = 0; x < outputWidth; x++)
{
ix = x*dW + kw;
THVector_(add)(dst+it*inputHeight*inputWidth+iy*inputWidth+ix, src+t*outputHeight*outputWidth+y*outputWidth+x, 1, 1);
real *dst_slice = dst+it*inputHeight*inputWidth+iy*inputWidth+ix;
THVector_(cadd)(dst_slice, dst_slice, src+t*outputHeight*outputWidth+y*outputWidth+x, 1, 1);
}
}
}
Expand Down
22 changes: 14 additions & 8 deletions generic/unfold.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ void THNN_(unfolded_acc)(
ix = (long long)(0 - padW + kw);
lpad = fmaxf(0,(int)(padW-kw));
rpad = fmaxf(0,(int)(padW-(kW-kw-1)));
THVector_(add)(dst+(size_t)(iy*inputWidth+ix+lpad), src+(size_t)(y*outputWidth+lpad), 1, outputWidth - lpad - rpad); /* note: THVector_add could handle 1 value better */
real *dst_slice = dst+(size_t)(iy*inputWidth+ix+lpad);
THVector_(cadd)(dst_slice, dst_slice, src+(size_t)(y*outputWidth+lpad), 1, outputWidth - lpad - rpad); /* note: THVector_add could handle 1 value better */
}
else{
for (x=0; x<outputWidth; x++){
ix = (long long)(x*dW - padW + kw);
if (ix < 0 || ix >= inputWidth){
}else
THVector_(add)(dst+(size_t)(iy*inputWidth+ix), src+(size_t)(y*outputWidth+x), 1, 1);
}else{
real *dst_slice = dst+(size_t)(iy*inputWidth+ix);
THVector_(cadd)(dst_slice, dst_slice, src+(size_t)(y*outputWidth+x), 1, 1);
}
}
}
}
Expand All @@ -68,11 +71,14 @@ void THNN_(unfolded_acc)(
for(y = 0; y < outputHeight; y++) {
iy = (long long)(y*dH + kh);
ix = (long long)(0 + kw);
if (dW == 1 )
THVector_(add)(dst+(size_t)(iy*inputWidth+ix), src+(size_t)(y*outputWidth), 1, outputWidth); /* note: THVector_add could handle 1 value better */
else{
for(x = 0; x < outputWidth; x++)
THVector_(add)(dst+(size_t)(iy*inputWidth+ix+x*dW), src+(size_t)(y*outputWidth+x), 1, 1);
if (dW == 1 ) {
real *dst_slice = dst+(size_t)(iy*inputWidth+ix);
THVector_(cadd)(dst_slice, dst_slice, src+(size_t)(y*outputWidth), 1, outputWidth); /* note: THVector_add could handle 1 value better */
}else{
for(x = 0; x < outputWidth; x++) {
real *dst_slice = dst+(size_t)(iy*inputWidth+ix+x*dW);
THVector_(cadd)(dst_slice, dst_slice, src+(size_t)(y*outputWidth+x), 1, 1);
}
}
}
}
Expand Down

0 comments on commit 80429ad

Please sign in to comment.