11 #ifndef EIGEN_TYPE_CASTING_ALTIVEC_H
12 #define EIGEN_TYPE_CASTING_ALTIVEC_H
14 #include "../../InternalHeaderCheck.h"
20 struct type_casting_traits<float, int> {
29 struct type_casting_traits<int, float> {
38 struct type_casting_traits<bfloat16, unsigned short int> {
47 struct type_casting_traits<unsigned short int, bfloat16> {
82 if(vec_any_gt(int_even, p4ui_low_mask)){
83 overflow_selector = vec_cmpgt(int_even, p4ui_low_mask);
84 low_even = vec_sel(low_even, p4ui_low_mask, overflow_selector);
86 if(vec_any_gt(int_odd, p4ui_low_mask)){
87 overflow_selector = vec_cmpgt(int_odd, p4ui_low_mask);
88 low_odd = vec_sel(low_even, p4ui_low_mask, overflow_selector);
91 return pmerge(low_even, low_odd);
99 Packet4ui int_odd = plogical_shift_right<16>(int_cast);
106 struct type_casting_traits<
bfloat16, float> {
117 return reinterpret_cast<Packet4f>(vec_mergeh(
a.m_val, z));
119 return reinterpret_cast<Packet4f>(vec_mergeh(z,
a.m_val));
124 struct type_casting_traits<float,
bfloat16> {
144 #ifdef EIGEN_VECTORIZE_VSX
153 #if EIGEN_GNUC_STRICT_AT_LEAST(7,1,0)
154 return vec_cts(
x, 0);
157 memcpy(tmp, &
x,
sizeof(tmp));
158 Packet2l l = {
static_cast<long long>(tmp[0]),
159 static_cast<long long>(tmp[1]) };
166 unsigned long long tmp[2];
167 memcpy(tmp, &
x,
sizeof(tmp));
168 Packet2d d = {
static_cast<double>(tmp[0]),
169 static_cast<double>(tmp[1]) };
Packet8bf F32ToBf16(Packet4f p4f)
Packet8bf pcast< Packet8us, Packet8bf >(const Packet8us &a)
Packet4f Bf16ToF32Even(const Packet8bf &bf)
Packet4f preinterpret< Packet4f, Packet4i >(const Packet4i &a)
EIGEN_ALWAYS_INLINE Packet8us pmerge(Packet4ui even, Packet4ui odd)
__vector unsigned short int Packet8us
static EIGEN_DECLARE_CONST_FAST_Packet4ui(SIGN, 0x80000000u)
Packet4i pcast< Packet4f, Packet4i >(const Packet4f &a)
__vector unsigned int Packet4ui
__vector __bool int Packet4bi
eigen_packet_wrapper< __vector unsigned short int, 0 > Packet8bf
Packet4f pcast< Packet4ui, Packet4f >(const Packet4ui &a)
Packet4f pcast< Packet4i, Packet4f >(const Packet4i &a)
Packet8us pset1< Packet8us >(const unsigned short int &from)
Packet4i preinterpret< Packet4i, Packet4f >(const Packet4f &a)
Packet4f Bf16ToF32Odd(const Packet8bf &bf)
Packet4f pcast< Packet8bf, Packet4f >(const Packet8bf &a)
Packet4ui pcast< Packet4f, Packet4ui >(const Packet4f &a)
Packet8bf F32ToBf16Both(Packet4f lo, Packet4f hi)
Packet4ui pand< Packet4ui >(const Packet4ui &a, const Packet4ui &b)
Packet8us pcast< Packet8bf, Packet8us >(const Packet8bf &a)
Packet8bf pcast< Packet4f, Packet8bf >(const Packet4f &a, const Packet4f &b)