Eigen  3.4.90 (git rev 5a9f66fb35d03a4da9ef8976e67a61b30aa16dcf)
 
Loading...
Searching...
No Matches
arch/NEON/UnaryFunctors.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_NEON_UNARY_FUNCTORS_H
9#define EIGEN_NEON_UNARY_FUNCTORS_H
10
11// IWYU pragma: private
12#include "../../InternalHeaderCheck.h"
13
14namespace Eigen {
15
16namespace internal {
17
18#if EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
22template <>
23struct scalar_logistic_op<Eigen::half> {
24 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half operator()(const Eigen::half& x) const {
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
30 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half packetOp(const Eigen::half& x) const { return this->operator()(x); }
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
44template <>
45struct 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
Namespace containing all symbols from the Eigen library.
Definition Core:137