11 #ifndef EIGEN_GENERIC_TYPE_CASTING_H 12 #define EIGEN_GENERIC_TYPE_CASTING_H 19 struct scalar_cast_op<float,
Eigen::half> {
20 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
21 typedef Eigen::half result_type;
22 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half operator() (
const float& a)
const {
23 #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 24 (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 25 return __float2half(a);
27 return Eigen::half(a);
33 struct functor_traits<scalar_cast_op<float,
Eigen::half> >
34 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
38 struct scalar_cast_op<int,
Eigen::half> {
39 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
40 typedef Eigen::half result_type;
41 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half operator() (
const int& a)
const {
42 #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 43 (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 44 return __float2half(static_cast<float>(a));
46 return Eigen::half(static_cast<float>(a));
52 struct functor_traits<scalar_cast_op<int,
Eigen::half> >
53 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
57 struct scalar_cast_op<
Eigen::half, float> {
58 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
59 typedef float result_type;
60 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
float operator() (
const Eigen::half& a)
const {
61 #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \ 62 (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE)) 63 return __half2float(a);
65 return static_cast<float>(a);
71 struct functor_traits<scalar_cast_op<
Eigen::half, float> >
72 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
76 struct scalar_cast_op<float,
Eigen::bfloat16> {
77 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
78 typedef Eigen::bfloat16 result_type;
79 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::bfloat16 operator() (
const float& a)
const {
80 return Eigen::bfloat16(a);
85 struct functor_traits<scalar_cast_op<float,
Eigen::bfloat16> >
86 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
90 struct scalar_cast_op<int,
Eigen::bfloat16> {
91 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
92 typedef Eigen::bfloat16 result_type;
93 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::bfloat16 operator() (
const int& a)
const {
94 return Eigen::bfloat16(static_cast<float>(a));
99 struct functor_traits<scalar_cast_op<int,
Eigen::bfloat16> >
100 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
104 struct scalar_cast_op<
Eigen::bfloat16, float> {
105 EIGEN_EMPTY_STRUCT_CTOR(scalar_cast_op)
106 typedef float result_type;
107 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
float operator() (
const Eigen::bfloat16& a)
const {
108 return static_cast<float>(a);
113 struct functor_traits<scalar_cast_op<
Eigen::bfloat16, float> >
114 {
enum { Cost = NumTraits<float>::AddCost, PacketAccess =
false }; };
120 #endif // EIGEN_GENERIC_TYPE_CASTING_H Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: Eigen_Colamd.h:50