aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Elsing <david.elsing@posteo.net>2024-03-23 22:04:58 +0000
committerLudovic Courtès <ludo@gnu.org>2024-06-18 11:43:46 +0200
commitca63ef4f5b62bd6b3adcee6e9f00d69be3e26398 (patch)
tree2722bf4da7019e690398334c1991eb947acb9e65
parentc45b370385e35a9d6444b16017cf08c97e1463ae (diff)
downloadguix-ca63ef4f5b62bd6b3adcee6e9f00d69be3e26398.tar.gz
guix-ca63ef4f5b62bd6b3adcee6e9f00d69be3e26398.zip
gnu: Add fbgemm.
* gnu/packages/machine-learning.scm (fbgemm): New variable. * gnu/packages/patches/fbgemm-use-system-libraries.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/machine-learning.scm34
-rw-r--r--gnu/packages/patches/fbgemm-use-system-libraries.patch62
3 files changed, 97 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 5a1665326e..3b3d6b6bfa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1202,6 +1202,7 @@ dist_patch_DATA = \
%D%/packages/patches/fasthenry-spUtils.patch \
%D%/packages/patches/fasthenry-spSolve.patch \
%D%/packages/patches/fasthenry-spFactor.patch \
+ %D%/packages/patches/fbgemm-use-system-libraries.patch \
%D%/packages/patches/fbreader-curl-7.62.patch \
%D%/packages/patches/fbreader-fix-icon.patch \
%D%/packages/patches/feedbackd-use-system-gmobile.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index ddeb9a166a..837ff7df11 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -4115,6 +4115,40 @@ TensorFlow.js, PyTorch, and MediaPipe.")
"-DXNNPACK_BUILD_TESTS=FALSE" ;FIXME: see below
"-DXNNPACK_BUILD_BENCHMARKS=FALSE"))))))
+;; Warning: This package requires AVX2 or AVX-512 instructions.
+(define-public fbgemm
+ (package
+ (name "fbgemm")
+ (version "0.6.0")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/pytorch/fbgemm")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "0mw30v55aicqdbh3xwfj9p8f38nw70ks5cxiwpgwjsk0dylah9rf"))
+ (patches (search-patches "fbgemm-use-system-libraries.patch"))
+ (modules '((guix build utils)))
+ (snippet
+ '(delete-file-recursively "third_party"))))
+ (build-system cmake-build-system)
+ (arguments
+ (list
+ #:configure-flags
+ ''("-DFBGEMM_LIBRARY_TYPE=shared")
+ ;; Tests require AVX2 or AVX-512 instructions
+ #:tests? #f))
+ (inputs (list asmjit cpuinfo))
+ (native-inputs (list pkg-config python googletest))
+ (home-page "https://github.com/pytorch/fbgemm")
+ (synopsis "Facebook GEneral Matrix Multiplication")
+ (description "Low-precision, high-performance matrix-matrix
+multiplications and convolution library for server-side inference.")
+ (supported-systems '("x86_64-linux"))
+ (license license:bsd-3)))
+
(define-public tensorpipe
(let ((commit "bb1473a4b38b18268e8693044afdb8635bc8351b")
(revision "0"))
diff --git a/gnu/packages/patches/fbgemm-use-system-libraries.patch b/gnu/packages/patches/fbgemm-use-system-libraries.patch
new file mode 100644
index 0000000000..456bc3021c
--- /dev/null
+++ b/gnu/packages/patches/fbgemm-use-system-libraries.patch
@@ -0,0 +1,62 @@
+Use the asmjit and cpuinfo packages.
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 134523e..b88b0e7 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -235,7 +235,7 @@ message(WARNING "CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}")
+ message(WARNING "CMAKE_CXX_FLAGS_RELEASE is ${CMAKE_CXX_FLAGS_RELEASE}")
+ message(WARNING "==========")
+
+-if(NOT TARGET asmjit)
++if(FALSE)
+ #Download asmjit from github if ASMJIT_SRC_DIR is not specified.
+ if(NOT DEFINED ASMJIT_SRC_DIR)
+ set(ASMJIT_SRC_DIR "${FBGEMM_SOURCE_DIR}/third_party/asmjit"
+@@ -264,7 +264,7 @@ if(NOT TARGET asmjit)
+ endif()
+ endif()
+
+-if(NOT TARGET cpuinfo)
++if(FALSE)
+ #Download cpuinfo from github if CPUINFO_SOURCE_DIR is not specified.
+ if(NOT DEFINED CPUINFO_SOURCE_DIR)
+ set(CPUINFO_SOURCE_DIR "${FBGEMM_SOURCE_DIR}/third_party/cpuinfo"
+@@ -340,9 +340,12 @@ target_include_directories(fbgemm BEFORE
+ target_link_libraries(fbgemm
+ $<BUILD_INTERFACE:asmjit>
+ $<BUILD_INTERFACE:cpuinfo>)
+-add_dependencies(fbgemm
+- asmjit
+- cpuinfo)
++
++find_package(asmjit)
++find_package(PkgConfig REQUIRED)
++pkg_check_modules(libcpuinfo REQUIRED IMPORTED_TARGET libcpuinfo)
++
++target_link_libraries(fbgemm asmjit::asmjit PkgConfig::libcpuinfo)
+
+ if(OpenMP_FOUND)
+ target_link_libraries(fbgemm OpenMP::OpenMP_CXX)
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index 2cffddf..bd4d409 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -14,7 +14,7 @@ set(CMAKE_C_STANDARD 11)
+ set(CMAKE_C_EXTENSIONS OFF)
+ set(CMAKE_C_STANDARD_REQUIRED ON)
+
+-if(FBGEMM_BUILD_TESTS AND NOT TARGET gtest)
++if(FALSE)
+ #Download Googletest framework from github if
+ #GOOGLETEST_SOURCE_DIR is not specified.
+ if(NOT DEFINED GOOGLETEST_SOURCE_DIR)
+@@ -78,7 +78,7 @@ macro(add_gtest TESTNAME)
+ target_link_libraries(${TESTNAME} ${OpenMP_CXX_LIBRARIES})
+ endif()
+
+- add_dependencies(${TESTNAME} gtest fbgemm)
++ add_dependencies(${TESTNAME} fbgemm)
+ add_test(${TESTNAME} ${TESTNAME})
+ set_target_properties(${TESTNAME} PROPERTIES FOLDER test)
+ endmacro()