@@ -600,7 +600,7 @@ HOSTDEVICE inline bool operator>=(const float16& a, const float16& b) {
600
600
601
601
// Arithmetic operators for float16 on ARMv8.2-A CPU
602
602
#elif defined(PADDLE_WITH_NATIVE_FP16)
603
- HOST inline float16 operator +(const float16& a, const float16& b) {
603
+ inline float16 operator +(const float16& a, const float16& b) {
604
604
float16 res;
605
605
asm volatile (
606
606
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -616,7 +616,7 @@ HOST inline float16 operator+(const float16& a, const float16& b) {
616
616
return res;
617
617
}
618
618
619
- HOST inline float16 operator -(const float16& a, const float16& b) {
619
+ inline float16 operator -(const float16& a, const float16& b) {
620
620
float16 res;
621
621
asm volatile (
622
622
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -632,7 +632,7 @@ HOST inline float16 operator-(const float16& a, const float16& b) {
632
632
return res;
633
633
}
634
634
635
- HOST inline float16 operator *(const float16& a, const float16& b) {
635
+ inline float16 operator *(const float16& a, const float16& b) {
636
636
float16 res;
637
637
asm volatile (
638
638
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -648,7 +648,7 @@ HOST inline float16 operator*(const float16& a, const float16& b) {
648
648
return res;
649
649
}
650
650
651
- HOST inline float16 operator /(const float16& a, const float16& b) {
651
+ inline float16 operator /(const float16& a, const float16& b) {
652
652
float16 res;
653
653
asm volatile (
654
654
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -664,7 +664,7 @@ HOST inline float16 operator/(const float16& a, const float16& b) {
664
664
return res;
665
665
}
666
666
667
- HOST inline float16 operator -(const float16& a) {
667
+ inline float16 operator -(const float16& a) {
668
668
float16 res;
669
669
asm volatile (
670
670
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -679,27 +679,27 @@ HOST inline float16 operator-(const float16& a) {
679
679
return res;
680
680
}
681
681
682
- HOST inline float16& operator +=(float16& a, const float16& b) {
682
+ inline float16& operator +=(float16& a, const float16& b) {
683
683
a = a + b;
684
684
return a;
685
685
}
686
686
687
- HOST inline float16& operator -=(float16& a, const float16& b) {
687
+ inline float16& operator -=(float16& a, const float16& b) {
688
688
a = a - b;
689
689
return a;
690
690
}
691
691
692
- HOST inline float16& operator *=(float16& a, const float16& b) {
692
+ inline float16& operator *=(float16& a, const float16& b) {
693
693
a = a * b;
694
694
return a;
695
695
}
696
696
697
- HOST inline float16& operator /=(float16& a, const float16& b) {
697
+ inline float16& operator /=(float16& a, const float16& b) {
698
698
a = a / b;
699
699
return a;
700
700
}
701
701
702
- HOST inline bool operator ==(const float16& a, const float16& b) {
702
+ inline bool operator ==(const float16& a, const float16& b) {
703
703
uint16_t res;
704
704
asm volatile (
705
705
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -715,11 +715,9 @@ HOST inline bool operator==(const float16& a, const float16& b) {
715
715
return (res & 0xffff ) != 0 ;
716
716
}
717
717
718
- HOST inline bool operator !=(const float16& a, const float16& b) {
719
- return !(a == b);
720
- }
718
+ inline bool operator !=(const float16& a, const float16& b) { return !(a == b); }
721
719
722
- HOST inline bool operator <(const float16& a, const float16& b) {
720
+ inline bool operator <(const float16& a, const float16& b) {
723
721
uint16_t res;
724
722
asm volatile (
725
723
" ld1 {v1.h}[0], [%[a_ptr]]\n "
@@ -735,7 +733,7 @@ HOST inline bool operator<(const float16& a, const float16& b) {
735
733
return (res & 0xffff ) != 0 ;
736
734
}
737
735
738
- HOST inline bool operator <=(const float16& a, const float16& b) {
736
+ inline bool operator <=(const float16& a, const float16& b) {
739
737
uint16_t res;
740
738
asm volatile (
741
739
" ld1 {v1.h}[0], [%[a_ptr]]\n "
@@ -751,7 +749,7 @@ HOST inline bool operator<=(const float16& a, const float16& b) {
751
749
return (res & 0xffff ) != 0 ;
752
750
}
753
751
754
- HOST inline bool operator >(const float16& a, const float16& b) {
752
+ inline bool operator >(const float16& a, const float16& b) {
755
753
uint16_t res;
756
754
asm volatile (
757
755
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -767,7 +765,7 @@ HOST inline bool operator>(const float16& a, const float16& b) {
767
765
return (res & 0xffff ) != 0 ;
768
766
}
769
767
770
- HOST inline bool operator >=(const float16& a, const float16& b) {
768
+ inline bool operator >=(const float16& a, const float16& b) {
771
769
uint16_t res;
772
770
asm volatile (
773
771
" ld1 {v0.h}[0], [%[a_ptr]]\n "
@@ -785,69 +783,69 @@ HOST inline bool operator>=(const float16& a, const float16& b) {
785
783
786
784
// Arithmetic operators for float16, software emulated on other CPU
787
785
#else
788
- HOST inline float16 operator +(const float16& a, const float16& b) {
786
+ inline float16 operator +(const float16& a, const float16& b) {
789
787
return float16 (float (a) + float (b));
790
788
}
791
789
792
- HOST inline float16 operator -(const float16& a, const float16& b) {
790
+ inline float16 operator -(const float16& a, const float16& b) {
793
791
return float16 (float (a) - float (b));
794
792
}
795
793
796
- HOST inline float16 operator *(const float16& a, const float16& b) {
794
+ inline float16 operator *(const float16& a, const float16& b) {
797
795
return float16 (float (a) * float (b));
798
796
}
799
797
800
- HOST inline float16 operator /(const float16& a, const float16& b) {
798
+ inline float16 operator /(const float16& a, const float16& b) {
801
799
return float16 (float (a) / float (b));
802
800
}
803
801
804
- HOST inline float16 operator -(const float16& a) {
802
+ inline float16 operator -(const float16& a) {
805
803
float16 res;
806
804
res.x = a.x ^ 0x8000 ;
807
805
return res;
808
806
}
809
807
810
- HOST inline float16& operator +=(float16& a, const float16& b) {
808
+ inline float16& operator +=(float16& a, const float16& b) {
811
809
a = float16 (float (a) + float (b));
812
810
return a;
813
811
}
814
812
815
- HOST inline float16& operator -=(float16& a, const float16& b) {
813
+ inline float16& operator -=(float16& a, const float16& b) {
816
814
a = float16 (float (a) - float (b));
817
815
return a;
818
816
}
819
817
820
- HOST inline float16& operator *=(float16& a, const float16& b) {
818
+ inline float16& operator *=(float16& a, const float16& b) {
821
819
a = float16 (float (a) * float (b));
822
820
return a;
823
821
}
824
822
825
- HOST inline float16& operator /=(float16& a, const float16& b) {
823
+ inline float16& operator /=(float16& a, const float16& b) {
826
824
a = float16 (float (a) / float (b));
827
825
return a;
828
826
}
829
827
830
- HOST inline bool operator ==(const float16& a, const float16& b) {
828
+ inline bool operator ==(const float16& a, const float16& b) {
831
829
return float (a) == float (b);
832
830
}
833
831
834
- HOST inline bool operator !=(const float16& a, const float16& b) {
832
+ inline bool operator !=(const float16& a, const float16& b) {
835
833
return float (a) != float (b);
836
834
}
837
835
838
- HOST inline bool operator <(const float16& a, const float16& b) {
836
+ inline bool operator <(const float16& a, const float16& b) {
839
837
return float (a) < float (b);
840
838
}
841
839
842
- HOST inline bool operator <=(const float16& a, const float16& b) {
840
+ inline bool operator <=(const float16& a, const float16& b) {
843
841
return float (a) <= float (b);
844
842
}
845
843
846
- HOST inline bool operator >(const float16& a, const float16& b) {
844
+ inline bool operator >(const float16& a, const float16& b) {
847
845
return float (a) > float (b);
848
846
}
849
847
850
- HOST inline bool operator >=(const float16& a, const float16& b) {
848
+ inline bool operator >=(const float16& a, const float16& b) {
851
849
return float (a) >= float (b);
852
850
}
853
851
#endif
0 commit comments