arch/NEON/MathFunctions.h
Go to the documentation of this file.
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 #include "../../InternalHeaderCheck.h"
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
19 
20 #if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
21 template <>
22 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC
23 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
30 Packet8hf ptanh<Packet8hf>(const Packet8hf& x) {
31  // Convert each 4 halfs to float, call the float ptanh, and then convert back.
32  return vcombine_f16(
33  vcvt_f16_f32(ptanh<Packet4f>(vcvt_f32_f16(vget_low_f16(x)))),
34  vcvt_f16_f32(ptanh<Packet4f>(vcvt_high_f32_f16(x))));
35 }
36 #endif // EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
37 
43 
44 template <>
45 EIGEN_STRONG_INLINE Packet4bf pfrexp(const Packet4bf& a, Packet4bf& exponent) {
46  Packet4f fexponent;
47  const Packet4bf out = F32ToBf16(pfrexp<Packet4f>(Bf16ToF32(a), fexponent));
48  exponent = F32ToBf16(fexponent);
49  return out;
50 }
51 
52 template <>
53 EIGEN_STRONG_INLINE Packet4bf pldexp(const Packet4bf& a, const Packet4bf& exponent) {
54  return F32ToBf16(pldexp<Packet4f>(Bf16ToF32(a), Bf16ToF32(exponent)));
55 }
56 
57 //---------- double ----------
58 
59 #if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG
60 
62 
63 #endif
64 
65 } // end namespace internal
66 
67 } // end namespace Eigen
68 
69 #endif // EIGEN_MATH_FUNCTIONS_NEON_H
#define BF16_PACKET_FUNCTION(PACKET_F, PACKET_BF16, METHOD)
Definition: BFloat16.h:33
#define EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_DOUBLE(PACKET)
#define EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(PACKET)
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
Packet8bf F32ToBf16(Packet4f p4f)
eigen_packet_wrapper< uint16x4_t, 19 > Packet4bf
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet plog(const Packet &a)
Packet4f pldexp< Packet4f >(const Packet4f &a, const Packet4f &exponent)
Packet8f Bf16ToF32(const Packet8bf &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pexp(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet pcos(const Packet &a)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin(const Packet &a)
Packet8h pfrexp(const Packet8h &a, Packet8h &exponent)
EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet4f ptanh< Packet4f >(const Packet4f &_x)
EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet ptanh(const Packet &a)
Packet4f pfrexp< Packet4f >(const Packet4f &a, Packet4f &exponent)
Packet8h pldexp(const Packet8h &a, const Packet8h &exponent)
float32x2_t Packet2f
__vector float Packet4f
: InteropHeaders
Definition: Core:139