@@ -490,20 +490,23 @@ HOSTDEVICE inline float16 operator+(const float16& a, const float16& b) {
490
490
return float16 (__hadd (half (a), half (b)));
491
491
#else
492
492
return float16 (float (a) + float (b));
493
+ #endif
493
494
}
494
495
495
496
HOSTDEVICE inline float16 operator -(const float16& a, const float16& b) {
496
497
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
497
498
return float16 (__hsub (half (a), half (b)));
498
499
#else
499
500
return float16 (float (a) - float (b));
501
+ #endif
500
502
}
501
503
502
504
HOSTDEVICE inline float16 operator *(const float16& a, const float16& b) {
503
505
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
504
506
return float16 (__hmul (half (a), half (b)));
505
507
#else
506
508
return float16 (float (a) * float (b));
509
+ #endif
507
510
}
508
511
509
512
HOSTDEVICE inline float16 operator /(const float16& a, const float16& b) {
@@ -514,6 +517,7 @@ HOSTDEVICE inline float16 operator/(const float16& a, const float16& b) {
514
517
return float16 (num / denom);
515
518
#else
516
519
return float16 (float (a) / float (b));
520
+ #endif
517
521
}
518
522
519
523
HOSTDEVICE inline float16 operator -(const float16& a) {
@@ -523,6 +527,7 @@ HOSTDEVICE inline float16 operator-(const float16& a) {
523
527
float16 res;
524
528
res.x = a.x ^ 0x8000 ;
525
529
return res;
530
+ #endif
526
531
}
527
532
528
533
HOSTDEVICE inline float16& operator +=(float16& a, const float16& b) {
@@ -550,41 +555,47 @@ HOSTDEVICE inline bool operator==(const float16& a, const float16& b) {
550
555
return __heq (half (a), half (b));
551
556
#else
552
557
return float (a) == float (b);
558
+ #endif
553
559
}
554
560
555
561
HOSTDEVICE inline bool operator !=(const float16& a, const float16& b) {
556
562
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
557
563
return __hne (half (a), half (b));
558
564
#else
559
565
return float (a) != float (b);
566
+ #endif
560
567
}
561
568
562
569
HOSTDEVICE inline bool operator <(const float16& a, const float16& b) {
563
570
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
564
571
return __hlt (half (a), half (b));
565
572
#else
566
573
return float (a) < float (b);
574
+ #endif
567
575
}
568
576
569
577
HOSTDEVICE inline bool operator <=(const float16& a, const float16& b) {
570
578
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
571
579
return __hle (half (a), half (b));
572
580
#else
573
581
return float (a) <= float (b);
582
+ #endif
574
583
}
575
584
576
585
HOSTDEVICE inline bool operator >(const float16& a, const float16& b) {
577
586
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
578
587
return __hgt (half (a), half (b));
579
588
#else
580
589
return float (a) > float (b);
590
+ #endif
581
591
}
582
592
583
593
HOSTDEVICE inline bool operator >=(const float16& a, const float16& b) {
584
594
#if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
585
595
return __hge (half (a), half (b));
586
596
#else
587
597
return float (a) >= float (b);
598
+ #endif
588
599
}
589
600
590
601
// Arithmetic operators for float16 on ARMv8.2-A CPU
0 commit comments