arch/NEON/UnaryFunctors.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_NEON_UNARY_FUNCTORS_H
9 #define EIGEN_NEON_UNARY_FUNCTORS_H
10 
11 // IWYU pragma: private
12 #include "../../InternalHeaderCheck.h"
13 
14 namespace Eigen {
15 
16 namespace internal {
17 
18 #if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
22 template <>
23 struct scalar_logistic_op<Eigen::half> {
25  // Convert to float and call scalar_logistic_op<float>.
26  const scalar_logistic_op<float> float_op;
27  return Eigen::half(float_op(float(x)));
28  }
29 
31 
32  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet4hf packetOp(const Packet4hf& x) const {
33  const scalar_logistic_op<float> float_op;
34  return vcvt_f16_f32(float_op.packetOp(vcvt_f32_f16(x)));
35  }
36 
37  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet8hf packetOp(const Packet8hf& x) const {
38  const scalar_logistic_op<float> float_op;
39  return vcombine_f16(vcvt_f16_f32(float_op.packetOp(vcvt_f32_f16(vget_low_f16(x)))),
40  vcvt_f16_f32(float_op.packetOp(vcvt_high_f32_f16(x))));
41  }
42 };
43 
44 template <>
45 struct functor_traits<scalar_logistic_op<Eigen::half>> {
46  enum {
47  Cost = functor_traits<scalar_logistic_op<float>>::Cost,
48  PacketAccess = functor_traits<scalar_logistic_op<float>>::PacketAccess,
49  };
50 };
51 #endif // EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
52 
53 } // end namespace internal
54 
55 } // end namespace Eigen
56 
57 #endif // EIGEN_NEON_UNARY_FUNCTORS_H
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:892
#define EIGEN_STRONG_INLINE
Definition: Macros.h:834
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Definition: Eigen_Colamd.h:49
list x
Definition: plotDoE.py:28
Definition: Half.h:139
@ PacketAccess
Definition: XprHelper.h:206
@ Cost
Definition: XprHelper.h:206
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(const T &x) const
Definition: functors/UnaryFunctors.h:1189
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet &x) const
Definition: functors/UnaryFunctors.h:1192