File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,16 +99,18 @@ GPUARRAY_PUBLIC void gpuarray_elemwise_collapse(unsigned int n,
9999 size_t * dim , ssize_t * * strs );
100100
101101
102+ typedef struct _ga_half_t { uint16_t h ; } ga_half_t ;
103+
102104/* code strongly inspired from
103105 https://github.com/numpy/numpy/blob/master/numpy/core/src/npymath/halffloat.c#L246 */
104106
105- static inline half_t ga_float2half (float f ) {
107+ static inline ga_half_t ga_float2half (float f ) {
106108 union {
107109 float f ;
108110 uint32_t bits ;
109111 } bf ;
110112 union {
111- half_t h ;
113+ ga_half_t h ;
112114 uint16_t bits ;
113115 } bh ;
114116
Original file line number Diff line number Diff line change @@ -129,20 +129,20 @@ START_TEST(test_float2half) {
129129 65520.f ,
130130 };
131131 const ga_half_t h [] = {
132- 0x0001u , /* 2e-24 */
133- 0x0000u , /* 0 */
134- 0x0000u , /* 0 */
135- 0x3c01u , /* 1.0 + 2e-10 */
136- 0x3c00u , /* 1.0 */
137- 0x7bffu , /* 65504 */
138- 0x7c00u , /* Inf */
132+ { 0x0001u } , /* 2e-24 */
133+ { 0x0000u } , /* 0 */
134+ { 0x0000u } , /* 0 */
135+ { 0x3c01u } , /* 1.0 + 2e-10 */
136+ { 0x3c00u } , /* 1.0 */
137+ { 0x7bffu } , /* 65504 */
138+ { 0x7c00u } , /* Inf */
139139 };
140140 unsigned int i ;
141141 ga_half_t hr ;
142142
143143 for (i = 0 ; i < sizeof (f )/sizeof (f [0 ]); i ++ ) {
144144 hr = ga_float2half (f [i ]);
145- ck_assert_int_eq (hr , h [i ]);
145+ ck_assert_int_eq (hr . h , h [i ]. h );
146146 }
147147}
148148END_TEST
You can’t perform that action at this time.
0 commit comments