[XLA] Fix precision in lgamma once and for all.
Fix two bugs in our lgamma implementation. - We were losing precision when computing pi * x for x = 1 - ?, resulting in incorrect values for lgamma for x = <negative integer> - ?. Fixed by computing pi * (1 - x) instead. This works because we're passing this to sin, which is symmetric around the line Y=0.5, and x was already normalized to be in range [0,1]. - We were overflowing to infinity when computing the first term of x * log(y) - y for large values x and y. Compute this instead as (x - y/log(y)) * log(y). PiperOrigin-RevId: 235268279
Loading
Please sign in to comment