cpu_pixel_unshuffle Class — pytorch Architecture
Architecture documentation for the cpu_pixel_unshuffle class in PixelShuffleKernel.cpp from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/cpu/PixelShuffleKernel.cpp lines 113–152
template <typename scalar_t>
void cpu_pixel_unshuffle(
TensorBase& output,
const TensorBase& input,
int64_t downscale_factor) {
auto input_data = input.const_data_ptr<scalar_t>();
auto output_data = output.data_ptr<scalar_t>();
// [(B1...Bn), C, H, W] => [N, C, H, W]
int64_t sub_channels = input.size(-3);
int64_t height = input.size(-2) / downscale_factor;
int64_t width = input.size(-1) / downscale_factor;
int64_t channels = sub_channels * downscale_factor * downscale_factor;
int64_t numel = input.numel();
int64_t nbatch = numel / (channels * height * width);
int64_t S = downscale_factor;
// input strides
int64_t stride_n = channels * height * width;
int64_t stride_c = height * S * width * S;
int64_t stride_h = S * width * S;
int64_t stride_s1 = width * S;
int64_t stride_w = S;
int64_t stride_s2 = 1;
// input tensor shape of [n, c, h, s1, w, s2]
// output tensor shape of [n, c, s1, s2, h, w]
at::parallel_for(0, numel, 0, [&](int64_t begin, int64_t end) {
int64_t n{0}, c{0}, s1{0}, s2{0}, h{0}, w{0};
data_index_init(begin, n, nbatch, c, sub_channels, s1, S, s2, S, h, height, w, width);
for (const auto i : c10::irange(begin, end)) {
int64_t input_offset = n * stride_n + c * stride_c + h * stride_h +
s1 * stride_s1 + w * stride_w + s2 * stride_s2;
output_data[i] = c10::load(&input_data[input_offset]);
data_index_step(n, nbatch, c, sub_channels, s1, S, s2, S, h, height, w, width);
}
});
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free