text
stringlengths
0
2.2M
scalar_t *input_p,
scalar_t *output_p,
int64_t *indz_p,
int64_t nslices,
int64_t itime,
int64_t iwidth,
int64_t iheight,
int64_t otime,
int64_t owidth,
int64_t oheight,
int kT,
int kW,
int kH,
int dT,
int dW,
int dH,
int pT,
int pW,
int pH,
int dilationT,
int dilationW,
int dilationH)
{
at::parallel_for(0, nslices, 0, [&](int64_t start, int64_t end) {
for (const auto k : c10::irange(start, end)) {
/* loop over output */
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
int64_t i, j, ti;
scalar_t *ip = input_p + k * itime * iwidth * iheight;
for (ti = 0; ti < otime; ti++)
{
for (i = 0; i < oheight; i++)
{
for (j = 0; j < owidth; j++)
{
/* local pointers */
int64_t start_t = ti * dT - pT;
int64_t start_h = i * dH - pH;
int64_t start_w = j * dW - pW;
int64_t end_t = std::min(start_t + (kT - 1) * dilationT + 1, itime);
int64_t end_h = std::min(start_h + (kH - 1) * dilationH + 1, iheight);
int64_t end_w = std::min(start_w + (kW - 1) * dilationW + 1, iwidth);
while(start_t < 0)
start_t += dilationT;
while(start_h < 0)
start_h += dilationH;
while(start_w < 0)
start_w += dilationW;
scalar_t *op = output_p + k * otime * owidth * oheight
+ ti * owidth * oheight + i * owidth + j;
int64_t *indzp = indz_p + k * otime * owidth * oheight
+ ti * owidth * oheight + i * owidth + j;
/* compute local max: */
int64_t maxindex = start_t * iwidth * iheight + start_h * iwidth + start_w;
scalar_t maxval = -std::numeric_limits<scalar_t>::infinity();
for (int64_t z = start_t; z < end_t; z += dilationT)
{
for (int64_t y = start_h; y < end_h; y += dilationH)
{
for (int64_t x = start_w; x < end_w; x += dilationW)
{
int64_t index = z * iwidth * iheight + y * iwidth + x;
scalar_t val = ip[index];
if ((val > maxval) || std::isnan(val))
{
maxval = val;
maxindex = index;
}
}
}
}
// store location of max
*indzp = maxindex;
/* set output to local max */
*op = maxval;
}
}
}
}
});
}
template <typename scalar_t>
static void max_pool3d_with_indices_out_frame(
scalar_t *input_data,
scalar_t *output_data,
int64_t *indices_data,
int64_t nbatch,
int64_t nslices,
int64_t istride, int64_t ostride,
int64_t itime, int64_t iwidth, int64_t iheight,
int64_t otime, int64_t owidth, int64_t oheight,