File tree 5 files changed +38
-3
lines changed
5 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ option(FBGEMM_BUILD_TESTS "Build fbgemm unit tests" ON)
105
105
option (FBGEMM_BUILD_BENCHMARKS "Build fbgemm benchmarks" ON )
106
106
option (FBGEMM_BUILD_DOCS "Build fbgemm documentation" OFF )
107
107
option (FBGEMM_BUILD_FBGEMM_GPU "Build fbgemm_gpu library" OFF )
108
+ option (DISABLE_FBGEMM_AUTOVEC "Disable FBGEMM Autovec" OFF )
108
109
109
110
if (FBGEMM_BUILD_TESTS)
110
111
enable_testing ()
@@ -422,3 +423,11 @@ endif()
422
423
if (FBGEMM_BUILD_FBGEMM_GPU)
423
424
add_subdirectory (fbgemm_gpu)
424
425
endif ()
426
+
427
+ if (HAVE_GNU_F2H_IEEE)
428
+ add_definitions (-DHAVE_GNU_F2H_IEEE)
429
+ endif ()
430
+
431
+ if (DISABLE_FBGEMM_AUTOVEC)
432
+ add_definitions (-DDISABLE_FBGEMM_AUTOVEC)
433
+ endif ()
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the BSD-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+
8
+ ################################################################################
9
+ # Finds and sets GNU_FH2_IEEE compilation flags
10
+ ################################################################################
11
+
12
+ INCLUDE (CheckCXXSourceCompiles)
13
+
14
+ CHECK_CXX_SOURCE_COMPILES("
15
+ #include <arm_neon.h>
16
+ int main() {
17
+ float f = 1.0f;
18
+ uint16_t h = __gnu_f2h_ieee(f);
19
+ return 0;
20
+ }
21
+ " HAVE_GNU_F2H_IEEE)
Original file line number Diff line number Diff line change 10
10
11
11
set (fbgemm_sources_normal
12
12
"${FBGEMM} /src/EmbeddingSpMDM.cc"
13
- "${FBGEMM} /src/EmbeddingSpMDMAutovec.cc"
14
13
"${FBGEMM} /src/EmbeddingSpMDMNBit.cc"
15
14
"${FBGEMM} /src/QuantUtils.cc"
16
15
"${FBGEMM} /src/RefImplementations.cc"
17
16
"${FBGEMM} /src/RowWiseSparseAdagradFused.cc"
18
17
"${FBGEMM} /src/SparseAdagrad.cc"
19
18
"${FBGEMM} /src/Utils.cc" )
20
19
20
+ if (NOT DISABLE_FBGEMM_AUTOVEC)
21
+ list (APPEND fbgemm_sources_normal "${FBGEMM} /src/EmbeddingSpMDMAutovec.cc" )
22
+ endif ()
23
+
21
24
set (fbgemm_sources_avx2
22
25
"${FBGEMM} /src/EmbeddingSpMDMAvx2.cc"
23
26
"${FBGEMM} /src/QuantUtilsAvx2.cc" )
Original file line number Diff line number Diff line change @@ -287,7 +287,7 @@ inline float cpu_half2float_ref(const float16 h) {
287
287
// Same as the previous function, but use the built-in fp16 to fp32
288
288
// conversion provided by the compiler
289
289
inline float cpu_half2float (const float16 h) {
290
- #ifdef HAS_NATIVE_FP16_TYPE
290
+ #if defined( HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
291
291
__fp16 h_fp16;
292
292
std::memcpy (&h_fp16, &h, sizeof (__fp16));
293
293
return h_fp16;
@@ -297,7 +297,7 @@ inline float cpu_half2float(const float16 h) {
297
297
}
298
298
299
299
inline float16 cpu_float2half (const float f) {
300
- #ifdef HAS_NATIVE_FP16_TYPE
300
+ #if defined( HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
301
301
__fp16 h = f;
302
302
float16 res;
303
303
std::memcpy (&res, &h, sizeof (__fp16));
Original file line number Diff line number Diff line change 14
14
15
15
#include " fbgemm/FbgemmEmbedding.h"
16
16
17
+ #ifndef DISABLE_FBGEMM_AUTOVEC
17
18
#define FBGEMM_AUTOVEC_AVAILABLE
19
+ #endif
18
20
19
21
namespace fbgemm {
20
22
You can’t perform that action at this time.
0 commit comments