Home / Class/ update_to Class — pytorch Architecture

update_to Class — pytorch Architecture

Architecture documentation for the update_to class in DistributionTemplates.h from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/native/DistributionTemplates.h lines 59–74

template<typename scalar_t>
int64_t update_to(int64_t to) {
  static_assert(
    std::is_floating_point_v<scalar_t> ||
    std::is_same_v<scalar_t, at::Half> ||
    std::is_same_v<scalar_t, at::BFloat16>, "scalar_t must be floating-point type");
  const auto to_minus_1 = static_cast<int64_t>(static_cast<scalar_t>(to - 1));
  if (to_minus_1 >= to) {
    int64_t to_ = std::abs(to - 1);
    int n = 0;
    while (to_ >>= 1) ++n;
    // NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult)
    to = to_minus_1 - (1LL << (n - std::numeric_limits<scalar_t>::digits + 1));
  }
  return to;
}

Analyze Your Own Codebase

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

Try Supermodel Free