10 #ifndef EIGEN_TYPE_CASTING_GPU_H
11 #define EIGEN_TYPE_CASTING_GPU_H
17 #if (defined(EIGEN_HAS_CUDA_FP16) && defined(EIGEN_CUDA_ARCH) && EIGEN_CUDA_ARCH >= 300) || \
18 (defined(EIGEN_HAS_HIP_FP16) && defined(EIGEN_HIP_DEVICE_COMPILE))
22 struct type_casting_traits<
Eigen::half,
float> {
31 float2
r1 = __half22float2(
a);
32 float2
r2 = __half22float2(
b);
33 return make_float4(
r1.x,
r1.y,
r2.x,
r2.y);
39 half2* r_alias=
reinterpret_cast<half2*
>(&r);
40 r_alias[0]=__floats2half2_rn(
a.x,
a.y);
41 r_alias[1]=__floats2half2_rn(
a.z,
a.w);
42 r_alias[2]=__floats2half2_rn(
b.x,
b.y);
43 r_alias[3]=__floats2half2_rn(
b.z,
b.w);
48 struct type_casting_traits<
float,
Eigen::half> {
59 const half2* a_alias=
reinterpret_cast<const half2*
>(&
a);
60 float2
r1 = __half22float2(a_alias[0]);
61 float2
r2 = __half22float2(a_alias[1]);
62 r.x=
static_cast<float>(
r1.x);
63 r.y=
static_cast<float>(
r1.y);
64 r.z=
static_cast<float>(
r2.x);
65 r.w=
static_cast<float>(
r2.y);
71 return __floats2half2_rn(
a.x,
a.y);
80 #endif // EIGEN_TYPE_CASTING_GPU_H