xmake.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package("fbgemm")
  2. set_homepage("https://github.com/pytorch/FBGEMM")
  3. set_description("FB (Facebook) + GEMM (General Matrix-Matrix Multiplication) - https://code.fb.com/ml-applications/fbgemm/")
  4. set_license("BSD")
  5. add_urls("https://github.com/pytorch/FBGEMM/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/pytorch/FBGEMM.git")
  7. add_versions("v0.7.0", "c51ac26bc0aa8fef7e80631c4abdd3a7c33d1a097359cef9b008bf9e1203c071")
  8. add_patches("0.7.0", "patches/0.7.0/dep-unbundle.patch", "f3117ff728989146d5ab0c370fe410c73459091f65cae5f6b304e5637889fb8f")
  9. -- need libtorch
  10. add_configs("gpu", {description = "Build fbgemm_gpu library", default = false, type = "boolean"})
  11. add_configs("cpu", {description = "Build FBGEMM_GPU without GPU support", default = false, type = "boolean"})
  12. add_configs("rocm", {description = "Build FBGEMM_GPU for ROCm", default = false, type = "boolean"})
  13. add_deps("cmake", "python", {kind = "binary"})
  14. add_deps("asmjit", "cpuinfo", "openmp")
  15. -- mingw support: https://github.com/pytorch/FBGEMM/pull/2114
  16. -- arm support: https://github.com/pytorch/FBGEMM/issues/2074
  17. on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package)
  18. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  19. if not package:config("shared") then
  20. package:add("defines", "FBGEMM_STATIC")
  21. end
  22. local configs = {"-DFBGEMM_BUILD_TESTS=OFF", "-DFBGEMM_BUILD_BENCHMARKS=OFF"}
  23. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  24. table.insert(configs, "-DFBGEMM_LIBRARY_TYPE=" .. (package:config("shared") and "shared" or "static"))
  25. table.insert(configs, "-DFBGEMM_BUILD_FBGEMM_GPU=" .. (package:config("gpu") and "ON" or "OFF"))
  26. table.insert(configs, "-DFBGEMM_CPU_ONLY=" .. (package:config("cpu") and "ON" or "OFF"))
  27. table.insert(configs, "-DUSE_ROCM=" .. (package:config("rocm") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs, {packagedeps = {"asmjit", "cpuinfo"}})
  29. end)
  30. on_test(function (package)
  31. assert(package:check_cxxsnippets({test = [[
  32. void test() {
  33. fbgemm::Xor128();
  34. }
  35. ]]}, {configs = {languages = "c++20"}, includes = "fbgemm/QuantUtilsAvx2.h"}))
  36. end)