xmake.lua 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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", {submodules = false})
  7. add_versions("v1.2.0", "f679c3a9d0b0b1511122dca39c553b52d1fbf23c563f897d8218746a087f8bed")
  8. add_versions("v1.1.2", "15f89d724a00ce2f82ea7c1782e3fdc5c472d0ad37698498c0f419cc4924d8c8")
  9. add_versions("v1.1.0", "ca55019d6b75952a14c64aed0b6b90df06b21196a1152ab97c385964cc996a30")
  10. add_versions("v0.8.0", "f754dbc6becf8ece0474872c4e797445b55c21799c1f1d219470c0c5818207dd")
  11. add_versions("v0.7.0", "c51ac26bc0aa8fef7e80631c4abdd3a7c33d1a097359cef9b008bf9e1203c071")
  12. add_patches(">=1.1.0", "patches/1.1.0/dep-unbundle.patch", "c1c4f6cc5d319d827959c70396a2dade6a0c7aa4db9c42f2b29ac76634949b6f")
  13. add_patches("0.8.0", "patches/0.8.0/dep-unbundle.patch", "505ccda3b12ec519cb0732352b223862b3470c207e03e84889b977cbdc1d9aae")
  14. add_patches("0.7.0", "patches/0.7.0/dep-unbundle.patch", "f3117ff728989146d5ab0c370fe410c73459091f65cae5f6b304e5637889fb8f")
  15. if is_plat("windows") then
  16. add_patches("0.8.0", "patches/0.8.0/msvc-omp.patch", "d4a7830e40a476ffdeda00d2f7901a7db6e7950392ff672144d5e9f3c37ced2f")
  17. end
  18. -- need libtorch
  19. add_configs("gpu", {description = "Build fbgemm_gpu library", default = false, type = "boolean"})
  20. add_configs("cpu", {description = "Build FBGEMM_GPU without GPU support", default = false, type = "boolean"})
  21. add_configs("rocm", {description = "Build FBGEMM_GPU for ROCm", default = false, type = "boolean"})
  22. add_deps("cmake", "python", {kind = "binary"})
  23. add_deps("asmjit", "cpuinfo", "openmp")
  24. -- mingw support: https://github.com/pytorch/FBGEMM/pull/2114
  25. -- arm support: https://github.com/pytorch/FBGEMM/issues/2074
  26. on_install("windows|x64", "linux|x86_64", "macosx|x86_64", function (package)
  27. if not package:config("shared") then
  28. package:add("defines", "FBGEMM_STATIC")
  29. end
  30. io.replace("CMakeLists.txt", "-Werror", "", {plain = true})
  31. local configs = {"-DFBGEMM_BUILD_TESTS=OFF", "-DFBGEMM_BUILD_BENCHMARKS=OFF"}
  32. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  33. table.insert(configs, "-DFBGEMM_LIBRARY_TYPE=" .. (package:config("shared") and "shared" or "static"))
  34. if package:config("asan") then
  35. table.insert(configs, "-DUSE_SANITIZER=address")
  36. end
  37. table.insert(configs, "-DFBGEMM_BUILD_FBGEMM_GPU=" .. (package:config("gpu") and "ON" or "OFF"))
  38. table.insert(configs, "-DFBGEMM_CPU_ONLY=" .. (package:config("cpu") and "ON" or "OFF"))
  39. table.insert(configs, "-DUSE_ROCM=" .. (package:config("rocm") and "ON" or "OFF"))
  40. local opt = {packagedeps = {"asmjit", "cpuinfo"}}
  41. if package:has_tool("cxx", "cl") then
  42. opt.cxflags = "/bigobj"
  43. end
  44. import("package.tools.cmake").install(package, configs, opt)
  45. end)
  46. on_test(function (package)
  47. assert(package:check_cxxsnippets({test = [[
  48. void test() {
  49. fbgemm::Xor128();
  50. }
  51. ]]}, {configs = {languages = "c++20"}, includes = "fbgemm/QuantUtilsAvx2.h"}))
  52. end)