Home / Class/ _pooling_same_mode_padding_lr Class — pytorch Architecture

_pooling_same_mode_padding_lr Class — pytorch Architecture

Architecture documentation for the _pooling_same_mode_padding_lr class in Pool.h from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/native/Pool.h lines 90–107

template <typename T>
std::pair<T, T> _pooling_same_mode_padding_lr(
    T inputSize, T kernelSize, T stride, T dilation) {
  // NOTE: with strides, the output shape is ceil(inputSize/stride)
  auto total_padding = T(dilation) * (kernelSize - 1);

  // Prefer symmetric padding if possible
  if (stride > 2 && (total_padding % 2 == 1)) {
    // The floor in the output size calculation gives us a little wiggle room
    auto wiggle_room = inputSize % stride - 1;
    if (wiggle_room > 0) {
      total_padding = total_padding - 1;
    }
  }

  auto left = total_padding / 2;
  return {left, total_padding - left};
}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free