Home / Class/ update_from Class — pytorch Architecture

update_from Class — pytorch Architecture

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

Entity Profile

Source Code

aten/src/ATen/native/DistributionTemplates.h lines 42–57

template<typename scalar_t>
int64_t update_from(int64_t from) {
  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 from_plus_1 = static_cast<int64_t>(static_cast<scalar_t>(from + 1));
  if (from_plus_1 < from) {
    int64_t from_ = std::abs(from + 1);
    int n = 0;
    while (from_ >>= 1) ++n;
    // NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult)
    from = from_plus_1 + (1LL << (n - std::numeric_limits<scalar_t>::digits + 1));
  }
  return from;
}

Analyze Your Own Codebase

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

Try Supermodel Free