Skip to content

Commit 033f872

Browse files
gchalumpfacebook-github-bot
authored andcommitted
Fix use __fp16 by default (#4257)
Summary: Pull Request resolved: #4257 X-link: facebookresearch/FBGEMM#1335 HAVE_GNU_F2H_IEEE was flag introduced to check if this function exist for OSS. And previously use as a default flag to enable `__fp16` which makes `__fb16` disable by default. This diff enable __fp16 by default, and disable it with explicit flag. Reviewed By: q10 Differential Revision: D75975271 fbshipit-source-id: d617a3e8c17e63bcbf2bb4361a1fa93c25c9a2fd
1 parent 44810e8 commit 033f872

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,6 @@ if(FBGEMM_BUILD_FBGEMM_GPU)
431431
add_subdirectory(fbgemm_gpu)
432432
endif()
433433

434-
if(HAVE_GNU_F2H_IEEE)
435-
add_definitions(-DHAVE_GNU_F2H_IEEE)
434+
if(NOT HAVE_GNU_F2H_IEEE)
435+
add_definitions(-DMISSING_GNU_F2H_IEEE)
436436
endif()

include/fbgemm/FloatConversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ inline float cpu_half2float_ref(const float16 h) {
287287
// Same as the previous function, but use the built-in fp16 to fp32
288288
// conversion provided by the compiler
289289
inline float cpu_half2float(const float16 h) {
290-
#if defined(HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
290+
#if defined(HAS_NATIVE_FP16_TYPE) && not defined(MISSING_GNU_F2H_IEEE)
291291
__fp16 h_fp16;
292292
std::memcpy(&h_fp16, &h, sizeof(__fp16));
293293
return h_fp16;
@@ -297,7 +297,7 @@ inline float cpu_half2float(const float16 h) {
297297
}
298298

299299
inline float16 cpu_float2half(const float f) {
300-
#if defined(HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
300+
#if defined(HAS_NATIVE_FP16_TYPE) && not defined(MISSING_GNU_F2H_IEEE)
301301
__fp16 h = f;
302302
float16 res;
303303
std::memcpy(&res, &h, sizeof(__fp16));

0 commit comments

Comments
 (0)