Commit 10247def authored by Justin Lebar's avatar Justin Lebar Committed by TensorFlower Gardener
Browse files

[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
parent e9678fd3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment