aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/arch/Default/BFloat16.h
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-12-03 22:31:44 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-12-03 22:31:44 +0000
commit4d91519a9be061da5d300079fca17dd0b9328050 (patch)
tree5546a7f478049ce24d8f69f20ad018d6a63ec807 /Eigen/src/Core/arch/Default/BFloat16.h
parent25d8ae7465e6430bc2dc7f65800332932d3bb774 (diff)
Add log2() operator to Eigen
Diffstat (limited to 'Eigen/src/Core/arch/Default/BFloat16.h')
-rw-r--r--Eigen/src/Core/arch/Default/BFloat16.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h
index 351f451a3..616dcf667 100644
--- a/Eigen/src/Core/arch/Default/BFloat16.h
+++ b/Eigen/src/Core/arch/Default/BFloat16.h
@@ -512,6 +512,9 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log1p(const bfloat16& a) {
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log10(const bfloat16& a) {
return bfloat16(::log10f(float(a)));
}
+EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log2(const bfloat16& a) {
+ return bfloat16(static_cast<float>(M_LOG2E) * ::logf(float(a)));
+}
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sqrt(const bfloat16& a) {
return bfloat16(::sqrtf(float(a)));
}