_igam_helper_fac Class — pytorch Architecture
Architecture documentation for the _igam_helper_fac class in Math.h from the pytorch codebase.
Entity Profile
Source Code
aten/src/ATen/native/Math.h lines 620–652
template <typename scalar_t>
static scalar_t _igam_helper_fac(scalar_t a, scalar_t x) {
// compute x^a * exp(-a) / gamma(a)
// corrected from (15) and (16) in [igam2] by replacing exp(x - a) with
// exp(a - x).
scalar_t ax, fac, res, num, numfac;
static scalar_t MAXLOG = std::is_same_v<scalar_t,double> ?
7.09782712893383996843E2 : 88.72283905206835;
static scalar_t EXP1 = 2.718281828459045;
static scalar_t lanczos_g = 6.024680040776729583740234375;
if (std::fabs(a - x) > 0.4 * std::fabs(a)) {
ax = a * std::log(x) - x - std::lgamma(a);
if (ax < -MAXLOG) {
return 0.0;
}
return std::exp(ax);
}
fac = a + lanczos_g - 0.5;
res = std::sqrt(fac / EXP1) / lanczos_sum_expg_scaled(a);
if ((a < 200) && (x < 200)) {
res *= std::exp(a - x) * std::pow(x / fac, a);
}
else {
num = x - a - lanczos_g + 0.5;
numfac = num / fac;
res *= std::exp(a * (std::log1p(numfac) - numfac) + x * (0.5 - lanczos_g) / fac);
}
return res;
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free