$darkmode
Eigen  5.0.1-dev
MathFunctions.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // This Source Code Form is subject to the terms of the Mozilla
5 // Public License v. 2.0. If a copy of the MPL was not distributed
6 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 
8 #ifndef EIGEN_MATH_FUNCTIONS_NEON_H
9 #define EIGEN_MATH_FUNCTIONS_NEON_H
10 
11 // IWYU pragma: private
12 #include "../../InternalHeaderCheck.h"
13 
14 namespace Eigen {
15 
16 namespace internal {
17 
18 EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet2f)
19 EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet4f)
20 
21 #if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
22 template <>
23 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Packet4hf ptanh<Packet4hf>(const Packet4hf& x) {
24  // Convert to float, call the float ptanh, and then convert back.
25  return vcvt_f16_f32(ptanh<Packet4f>(vcvt_f32_f16(x)));
26 }
27 
28 template <>
29 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Packet8hf ptanh<Packet8hf>(const Packet8hf& x) {
30  // Convert each 4 half types to float, call the float ptanh, and then convert back.
31  return vcombine_f16(vcvt_f16_f32(ptanh<Packet4f>(vcvt_f32_f16(vget_low_f16(x)))),
32  vcvt_f16_f32(ptanh<Packet4f>(vcvt_high_f32_f16(x))));
33 }
34 #endif // EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
35 
36 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, psin)
37 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pcos)
38 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, plog)
39 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pexp)
40 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pexp2)
41 BF16_PACKET_FUNCTION(Packet4f, Packet4bf, ptanh)
42 
43 template <>
44 EIGEN_STRONG_INLINE Packet4bf pfrexp(const Packet4bf& a, Packet4bf& exponent) {
45  Packet4f fexponent;
46  const Packet4bf out = F32ToBf16(pfrexp<Packet4f>(Bf16ToF32(a), fexponent));
47  exponent = F32ToBf16(fexponent);
48  return out;
49 }
50 
51 template <>
52 EIGEN_STRONG_INLINE Packet4bf pldexp(const Packet4bf& a, const Packet4bf& exponent) {
53  return F32ToBf16(pldexp<Packet4f>(Bf16ToF32(a), Bf16ToF32(exponent)));
54 }
55 
56 //---------- double ----------
57 
58 #if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG
59 
60 EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_DOUBLE(Packet2d)
61 
62 #endif
63 
64 } // end namespace internal
65 
66 } // end namespace Eigen
67 
68 #endif // EIGEN_MATH_FUNCTIONS_NEON_H
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1