Skip to content

Commit 182da95

Browse files
committed
small fix
1 parent f2bbbb2 commit 182da95

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

paddle/fluid/platform/float16.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,20 +490,23 @@ HOSTDEVICE inline float16 operator+(const float16& a, const float16& b) {
490490
return float16(__hadd(half(a), half(b)));
491491
#else
492492
return float16(float(a) + float(b));
493+
#endif
493494
}
494495

495496
HOSTDEVICE inline float16 operator-(const float16& a, const float16& b) {
496497
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
497498
return float16(__hsub(half(a), half(b)));
498499
#else
499500
return float16(float(a) - float(b));
501+
#endif
500502
}
501503

502504
HOSTDEVICE inline float16 operator*(const float16& a, const float16& b) {
503505
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
504506
return float16(__hmul(half(a), half(b)));
505507
#else
506508
return float16(float(a) * float(b));
509+
#endif
507510
}
508511

509512
HOSTDEVICE inline float16 operator/(const float16& a, const float16& b) {
@@ -514,6 +517,7 @@ HOSTDEVICE inline float16 operator/(const float16& a, const float16& b) {
514517
return float16(num / denom);
515518
#else
516519
return float16(float(a) / float(b));
520+
#endif
517521
}
518522

519523
HOSTDEVICE inline float16 operator-(const float16& a) {
@@ -523,6 +527,7 @@ HOSTDEVICE inline float16 operator-(const float16& a) {
523527
float16 res;
524528
res.x = a.x ^ 0x8000;
525529
return res;
530+
#endif
526531
}
527532

528533
HOSTDEVICE inline float16& operator+=(float16& a, const float16& b) {
@@ -550,41 +555,47 @@ HOSTDEVICE inline bool operator==(const float16& a, const float16& b) {
550555
return __heq(half(a), half(b));
551556
#else
552557
return float(a) == float(b);
558+
#endif
553559
}
554560

555561
HOSTDEVICE inline bool operator!=(const float16& a, const float16& b) {
556562
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
557563
return __hne(half(a), half(b));
558564
#else
559565
return float(a) != float(b);
566+
#endif
560567
}
561568

562569
HOSTDEVICE inline bool operator<(const float16& a, const float16& b) {
563570
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
564571
return __hlt(half(a), half(b));
565572
#else
566573
return float(a) < float(b);
574+
#endif
567575
}
568576

569577
HOSTDEVICE inline bool operator<=(const float16& a, const float16& b) {
570578
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
571579
return __hle(half(a), half(b));
572580
#else
573581
return float(a) <= float(b);
582+
#endif
574583
}
575584

576585
HOSTDEVICE inline bool operator>(const float16& a, const float16& b) {
577586
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
578587
return __hgt(half(a), half(b));
579588
#else
580589
return float(a) > float(b);
590+
#endif
581591
}
582592

583593
HOSTDEVICE inline bool operator>=(const float16& a, const float16& b) {
584594
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
585595
return __hge(half(a), half(b));
586596
#else
587597
return float(a) >= float(b);
598+
#endif
588599
}
589600

590601
// Arithmetic operators for float16 on ARMv8.2-A CPU

0 commit comments

Comments
 (0)