diff options
author | 2016-03-29 09:20:36 -0700 | |
---|---|---|
committer | 2016-03-29 09:20:36 -0700 | |
commit | e02b784ec3c4f1932d7b4c3805c2fc56e35f8c3f (patch) | |
tree | 62764029bad1064aa1df857496c1a75aa3d68d9a /Eigen/src/Core/arch/CUDA/Half.h | |
parent | c38295f0a03edcd9f8325fcb08484eb579b7841f (diff) |
Added support for standard mathematical functions and trancendentals(such as exp, log, abs, ...) on fp16
Diffstat (limited to 'Eigen/src/Core/arch/CUDA/Half.h')
-rw-r--r-- | Eigen/src/Core/arch/CUDA/Half.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/Eigen/src/Core/arch/CUDA/Half.h b/Eigen/src/Core/arch/CUDA/Half.h index 61131828f..6c412159c 100644 --- a/Eigen/src/Core/arch/CUDA/Half.h +++ b/Eigen/src/Core/arch/CUDA/Half.h @@ -361,9 +361,6 @@ static inline EIGEN_HALF_CUDA_H bool (isnan)(const Eigen::half& a) { } // end namespace Eigen // Standard mathematical functions and trancendentals. - -namespace std { - static inline EIGEN_DEVICE_FUNC Eigen::half abs(const Eigen::half& a) { Eigen::half result; result.x = a.x & 0x7FFF; @@ -375,6 +372,36 @@ static inline EIGEN_DEVICE_FUNC Eigen::half exp(const Eigen::half& a) { static inline EIGEN_DEVICE_FUNC Eigen::half log(const Eigen::half& a) { return Eigen::half(::logf(float(a))); } +static inline EIGEN_DEVICE_FUNC Eigen::half sqrt(const Eigen::half& a) { + return Eigen::half(::sqrtf(float(a))); +} +static inline EIGEN_DEVICE_FUNC Eigen::half floor(const Eigen::half& a) { + return Eigen::half(::floorf(float(a))); +} +static inline EIGEN_DEVICE_FUNC Eigen::half ceil(const Eigen::half& a) { + return Eigen::half(::ceilf(float(a))); +} +static inline EIGEN_DEVICE_FUNC bool (isnan)(const Eigen::half& a) { + return (Eigen::numext::isnan)(a); +} +static inline EIGEN_DEVICE_FUNC bool (isinf)(const Eigen::half& a) { + return (Eigen::numext::isinf)(a); +} +static inline EIGEN_DEVICE_FUNC bool (isfinite)(const Eigen::half& a) { + return !(Eigen::numext::isinf)(a) && !(Eigen::numext::isnan)(a); +} + + +namespace std { + +// Import the standard mathematical functions and trancendentals into the +// into the std namespace. +using ::abs; +using ::exp; +using ::log; +using ::sqrt; +using ::floor; +using ::ceil; } // end namespace std |