Checkin to fix bugs in math functions.

This change fixes the following bugs that were discovered while debuggnig TF unit test failures (cwise_ops_test)

1. __hisinf and __hisnan routines
   Both had incorrect implementations.

2. abs
   A "long long" (64bit int) version was missing, resulting in the 32bit version being used for 64bit ints (which resulted in incorrect results, when the value passed in was outside the 32bit int range)

3. lgamma
  We seemed to have a custom version for the 'double' datatype (which was giving incorrect results). Replaced it with a call to the 'double' version of the underlying 'hc::precision_math::lgamma'


[ROCm/hip commit: af586bbbf2]
Цей коміт міститься в:
Deven Desai
2018-04-24 18:10:07 +00:00
джерело 31ddd40442
коміт 16d2b986aa
3 змінених файлів з 21 додано та 16 видалено
+4 -8
Переглянути файл
@@ -56,6 +56,9 @@ __device__ float expm1f(float x) { return hc::precise_math::expm1f(x); }
__device__ int abs(int x) {
return x >= 0 ? x : -x; // TODO - optimize with OCML
}
__device__ long long abs(long long x) {
return x >= 0 ? x : -x;
}
__device__ float fabsf(float x) { return hc::precise_math::fabsf(x); }
__device__ float fdimf(float x, float y) { return hc::precise_math::fdimf(x, y); }
__device__ float fdividef(float x, float y) { return x / y; }
@@ -220,14 +223,7 @@ __device__ double j0(double x) { return __hip_j0(x); }
__device__ double j1(double x) { return __hip_j1(x); }
__device__ double jn(int n, double x) { return __hip_jn(n, x); }
__device__ double ldexp(double x, int exp) { return hc::precise_math::ldexp(x, exp); }
__device__ double lgamma(double x) {
double val = 0.0;
double y = x - 1;
while (y > 0) {
val += log(y--);
}
return val;
}
__device__ double lgamma(double x) { return hc::precise_math::lgamma(x); }
__device__ long long int llrint(double x) {
long long int y = hc::precise_math::round(x);
return y;