Skip to content

Commit fa411c1

Browse files
gchalumpfacebook-github-bot
authored andcommitted
Remove fbgemm autovec (#4123)
Summary: DO NOT LAND Testing PyTorch CI without fbgemm autovec Differential Revision: D74747522
1 parent fd1c41b commit fa411c1

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ option(FBGEMM_BUILD_TESTS "Build fbgemm unit tests" ON)
105105
option(FBGEMM_BUILD_BENCHMARKS "Build fbgemm benchmarks" ON)
106106
option(FBGEMM_BUILD_DOCS "Build fbgemm documentation" OFF)
107107
option(FBGEMM_BUILD_FBGEMM_GPU "Build fbgemm_gpu library" OFF)
108+
option(DISABLE_FBGEMM_AUTOVEC "Disable FBGEMM Autovec" OFF)
108109

109110
if(FBGEMM_BUILD_TESTS)
110111
enable_testing()
@@ -422,3 +423,11 @@ endif()
422423
if(FBGEMM_BUILD_FBGEMM_GPU)
423424
add_subdirectory(fbgemm_gpu)
424425
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()

cmake/modules/FindGnuH2fIeee.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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)

fbgemm_gpu/cmake/Fbgemm.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010

1111
set(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+
2124
set(fbgemm_sources_avx2
2225
"${FBGEMM}/src/EmbeddingSpMDMAvx2.cc"
2326
"${FBGEMM}/src/QuantUtilsAvx2.cc")

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-
#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

299299
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)
301301
__fp16 h = f;
302302
float16 res;
303303
std::memcpy(&res, &h, sizeof(__fp16));

src/EmbeddingSpMDMAutovec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
#include "fbgemm/FbgemmEmbedding.h"
1616

17+
#ifndef DISABLE_FBGEMM_AUTOVEC
1718
#define FBGEMM_AUTOVEC_AVAILABLE
19+
#endif
1820

1921
namespace fbgemm {
2022

0 commit comments

Comments
 (0)