Commit 0aa847f9 authored by Scott Thornton's avatar Scott Thornton
Browse files

refactored loops in im2col

parent c1241216
...@@ -177,26 +177,20 @@ struct cpu_im2col ...@@ -177,26 +177,20 @@ struct cpu_im2col
// compute linear index for output // compute linear index for output
std::size_t ldx = ioutput * col_width + joutput; std::size_t ldx = ioutput * col_width + joutput;
std::size_t p = 0; std::size_t p = 0;
for(std::size_t c = 0; c < channels; c++) dfor(channels, kernel_h, kernel_w)(
{ [&](std::size_t c, std::size_t koffset, std::size_t loffset) {
for(int koffset = -kdiv2_h; koffset <= kdiv2_h; koffset++) int idx = iinput + koffset - kdiv2_h;
{ int jdx = jinput + loffset - kdiv2_w;
for(int loffset = -kdiv2_w; loffset <= kdiv2_w; loffset++) if((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width))
{ {
int idx = iinput + koffset; col[ldx * ksize + p] = input[c * npixels + idx * width + jdx];
int jdx = jinput + loffset;
if((idx >= 0) && (idx < height) && (jdx >= 0) && (jdx < width))
{
col[ldx * ksize + p] = input[c * npixels + idx * width + jdx];
}
else
{
col[ldx * ksize + p] = 0;
}
p++;
} }
} else
} {
col[ldx * ksize + p] = 0;
}
p++;
});
} }
} }
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment