Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
arch/NEON/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
14namespace Eigen {
15
16namespace internal {
17
18EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet2f)
19EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_FLOAT(Packet4f)
20
21#if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
22template <>
23EIGEN_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
28template <>
29EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Packet8hf ptanh<Packet8hf>(const Packet8hf& x) {
30 // Convert each 4 halfs 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
36BF16_PACKET_FUNCTION(Packet4f, Packet4bf, psin)
37BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pcos)
38BF16_PACKET_FUNCTION(Packet4f, Packet4bf, plog)
39BF16_PACKET_FUNCTION(Packet4f, Packet4bf, pexp)
40BF16_PACKET_FUNCTION(Packet4f, Packet4bf, ptanh)
41
42template <>
43EIGEN_STRONG_INLINE Packet4bf pfrexp(const Packet4bf& a, Packet4bf& exponent) {
44 Packet4f fexponent;
45 const Packet4bf out = F32ToBf16(pfrexp<Packet4f>(Bf16ToF32(a), fexponent));
46 exponent = F32ToBf16(fexponent);
47 return out;
48}
49
50template <>
51EIGEN_STRONG_INLINE Packet4bf pldexp(const Packet4bf& a, const Packet4bf& exponent) {
52 return F32ToBf16(pldexp<Packet4f>(Bf16ToF32(a), Bf16ToF32(exponent)));
53}
54
55//---------- double ----------
56
57#if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG
58
59EIGEN_INSTANTIATE_GENERIC_MATH_FUNCS_DOUBLE(Packet2d)
60
61#endif
62
63} // end namespace internal
64
65} // end namespace Eigen
66
67#endif // EIGEN_MATH_FUNCTIONS_NEON_H
Namespace containing all symbols from the Eigen library.
Definition Core:137