unfolded2d_acc Class — pytorch Architecture
Architecture documentation for the unfolded2d_acc class in Unfold2d.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/cpu/Unfold2d.cpp lines 36–113
template <typename scalar_t>
void unfolded2d_acc(
scalar_t* finput_data,
scalar_t* input_data,
int64_t kH,
int64_t kW,
int64_t dH,
int64_t dW,
int64_t padH,
int64_t padW,
int64_t n_input_plane,
int64_t input_height,
int64_t input_width,
int64_t output_height,
int64_t output_width) {
at::parallel_for(0, n_input_plane, 0, [&](int64_t start, int64_t end) {
for (const auto nip : c10::irange(start, end)) {
for (int64_t kh = 0; kh < kH; kh++) {
for (int64_t kw = 0; kw < kW; kw++) {
scalar_t* src = finput_data +
nip * ((size_t)kH * kW * output_height * output_width) +
kh * ((size_t)kW * output_height * output_width) +
kw * ((size_t)output_height * output_width);
scalar_t* dst =
input_data + nip * ((size_t)input_height * input_width);
if (padW > 0 || padH > 0) {
for (int64_t y = 0; y < output_height; y++) {
auto iy = y * dH - padH + kh;
if (iy < 0 || iy >= input_height) {
} else {
if (dW == 1) {
auto ix = 0 - padW + kw;
auto lpad = std::max<int64_t>(0, padW - kw);
auto rpad = std::max<int64_t>(0, padW - (kW - kw - 1));
scalar_t* dst_slice =
dst + (size_t)iy * input_width + ix + lpad;
cadd(
dst_slice,
dst_slice,
src + (size_t)y * output_width + lpad,
output_width - lpad - rpad);
} else {
for (int64_t x = 0; x < output_width; x++) {
auto ix = x * dW - padW + kw;
if (ix < 0 || ix >= input_width) {
} else {
scalar_t* dst_slice = dst + (size_t)iy * input_width + ix;
*dst_slice = *dst_slice + src[(size_t)y * output_width + x];
}
}
}
}
}
} else {
for (int64_t y = 0; y < output_height; y++) {
auto iy = y * dH + kh;
auto ix = 0 + kw;
if (dW == 1) {
scalar_t* dst_slice = dst + (size_t)iy * input_width + ix;
cadd(
dst_slice,
dst_slice,
src + (size_t)y * output_width,
output_width);
} else {
for (int64_t x = 0; x < output_width; x++) {
scalar_t* dst_slice =
dst + (size_t)iy * input_width + ix + x * dW;
*dst_slice = *dst_slice + src[(size_t)y * output_width + x];
}
}
}
}
}
}
}
});
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free