File tree Expand file tree Collapse file tree 5 files changed +38
-3
lines changed Expand file tree Collapse file tree 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)
105105option (FBGEMM_BUILD_BENCHMARKS "Build fbgemm benchmarks" ON )
106106option (FBGEMM_BUILD_DOCS "Build fbgemm documentation" OFF )
107107option (FBGEMM_BUILD_FBGEMM_GPU "Build fbgemm_gpu library" OFF )
108+ option (DISABLE_FBGEMM_AUTOVEC "Disable FBGEMM Autovec" OFF )
108109
109110if (FBGEMM_BUILD_TESTS)
110111 enable_testing ()
@@ -422,3 +423,11 @@ endif()
422423if (FBGEMM_BUILD_FBGEMM_GPU)
423424 add_subdirectory (fbgemm_gpu)
424425endif ()
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 1010
1111set (fbgemm_sources_normal
1212 "${FBGEMM} /src/EmbeddingSpMDM.cc"
13- "${FBGEMM} /src/EmbeddingSpMDMAutovec.cc"
1413 "${FBGEMM} /src/EmbeddingSpMDMNBit.cc"
1514 "${FBGEMM} /src/QuantUtils.cc"
1615 "${FBGEMM} /src/RefImplementations.cc"
1716 "${FBGEMM} /src/RowWiseSparseAdagradFused.cc"
1817 "${FBGEMM} /src/SparseAdagrad.cc"
1918 "${FBGEMM} /src/Utils.cc" )
2019
20+ if (NOT DISABLE_FBGEMM_AUTOVEC)
21+ list (APPEND fbgemm_sources_normal "${FBGEMM} /src/EmbeddingSpMDMAutovec.cc" )
22+ endif ()
23+
2124set (fbgemm_sources_avx2
2225 "${FBGEMM} /src/EmbeddingSpMDMAvx2.cc"
2326 "${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) {
287287// Same as the previous function, but use the built-in fp16 to fp32
288288// conversion provided by the compiler
289289inline float cpu_half2float (const float16 h) {
290- #ifdef HAS_NATIVE_FP16_TYPE
290+ #if defined( HAS_NATIVE_FP16_TYPE) && defined(HAVE_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
299299inline float16 cpu_float2half (const float f) {
300- #ifdef HAS_NATIVE_FP16_TYPE
300+ #if defined( HAS_NATIVE_FP16_TYPE) && defined(HAVE_GNU_F2H_IEEE)
301301 __fp16 h = f;
302302 float16 res;
303303 std::memcpy (&res, &h, sizeof (__fp16));
Original file line number Diff line number Diff line change 1414
1515#include " fbgemm/FbgemmEmbedding.h"
1616
17+ #ifndef DISABLE_FBGEMM_AUTOVEC
1718#define FBGEMM_AUTOVEC_AVAILABLE
19+ #endif
1820
1921namespace fbgemm {
2022
You can’t perform that action at this time.
0 commit comments