@@ -15,8 +15,6 @@ limitations under the License. */
15
15
#pragma once
16
16
17
17
#include < cstdint>
18
- #include < istream>
19
- #include < ostream>
20
18
21
19
#include < cuda.h>
22
20
#include " unsupported/Eigen/CXX11/Tensor"
@@ -117,7 +115,8 @@ struct PADDLE_ALIGN(2) float16 {
117
115
// float16_t is an alias for __fp16 in arm_fp16.h,
118
116
// which is included in arm_neon.h.
119
117
PADDLE_HOSTDEVICE inline float16 (const float16_t & h) {
120
- x = *reinterpret_cast <uint16_t *>(&h);
118
+ float16_t tmp = h;
119
+ x = *reinterpret_cast <uint16_t *>(&tmp);
121
120
}
122
121
#endif
123
122
@@ -197,7 +196,8 @@ struct PADDLE_ALIGN(2) float16 {
197
196
#if defined(PADDLE_NEON) && defined(PADDLE_ARM_FP16) && \
198
197
(PADDLE_GNUC_VER >= 61 || PADDLE_CLANG_VER >= 34 )
199
198
PADDLE_HOSTDEVICE inline float16& operator =(const float16_t & rhs) {
200
- x = *reinterpret_cast <uint16_t *>(&rhs);
199
+ float16_t tmp = rhs;
200
+ x = *reinterpret_cast <uint16_t *>(&tmp);
201
201
return *this ;
202
202
}
203
203
#endif
@@ -460,23 +460,37 @@ __host__ inline bool operator!=(const float16& a, const float16& b) {
460
460
return !(a == b);
461
461
}
462
462
463
- #ifdef PADDLE_NEON_64
464
463
__host__ inline bool operator <(const float16& a, const float16& b) {
464
+ #ifdef PADDLE_NEON_64
465
465
return static_cast <bool >(vclth_f16 (float16_t (a), float16_t (b)));
466
+ #else
467
+ return float (a) < float (b);
468
+ #endif // PADDLE_NEON_64
466
469
}
467
470
468
471
__host__ inline bool operator <=(const float16& a, const float16& b) {
472
+ #ifdef PADDLE_NEON_64
469
473
return static_cast <bool >(vcleh_f16 (float16_t (a), float16_t (b)));
474
+ #else
475
+ return float (a) <= float (b);
476
+ #endif // PADDLE_NEON_64
470
477
}
471
478
472
479
__host__ inline bool operator >(const float16& a, const float16& b) {
480
+ #ifdef PADDLE_NEON_64
473
481
return static_cast <bool >(vcgth_f16 (float16_t (a), float16_t (b)));
482
+ #else
483
+ return float (a) > float (b);
484
+ #endif // PADDLE_NEON_64
474
485
}
475
486
476
487
__host__ inline bool operator >=(const float16& a, const float16& b) {
488
+ #ifdef PADDLE_NEON_64
477
489
return static_cast <bool >(vcgeh_f16 (float16_t (a), float16_t (b)));
478
- }
490
+ #else
491
+ return float (a) >= float (b);
479
492
#endif // PADDLE_NEON_64
493
+ }
480
494
481
495
#else // Software emulation on other cpu
482
496
PADDLE_HOSTDEVICE inline float16 operator +(const float16& a, const float16& b) {
0 commit comments