File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,12 +118,42 @@ START_TEST(test_elemwise_collapse) {
118118}
119119END_TEST
120120
121+ START_TEST (test_float2half ) {
122+ const float f [] = {
123+ 2.9831426e-08f ,
124+ 2e-25f ,
125+ 2e-26f ,
126+ 1.0005035f ,
127+ 1.0002441f ,
128+ 65519.f ,
129+ 65520.f ,
130+ };
131+ 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 */
139+ };
140+ unsigned int i ;
141+ ga_half_t hr ;
142+
143+ for (i = 0 ; i < sizeof (f )/sizeof (f [0 ]); i ++ ) {
144+ hr = ga_float2half (f [i ]);
145+ ck_assert_int_eq (hr , h [i ]);
146+ }
147+ }
148+ END_TEST
149+
121150Suite * get_suite (void ) {
122151 Suite * s = suite_create ("util" );
123152 TCase * tc = tcase_create ("All" );
124153 tcase_add_test (tc , test_register_type );
125154 tcase_add_test (tc , test_type_flags );
126155 tcase_add_test (tc , test_elemwise_collapse );
156+ tcase_add_test (tc , test_float2half );
127157 suite_add_tcase (s , tc );
128158 return s ;
129159}
You can’t perform that action at this time.
0 commit comments