2
0

xmake.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package("onednn")
  2. set_homepage("https://oneapi-src.github.io/oneDNN/")
  3. set_description("oneAPI Deep Neural Network Library")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/oneapi-src/oneDNN/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/oneapi-src/oneDNN.git")
  7. add_versions("v3.4", "1044dc3655d18de921c98dfc61ad7f65799ba5e897063d4a56d291394e12dcf5")
  8. add_versions("v3.3.4", "e291fa4702f4bcfa6c8c23cb5b6599f0fefa8f23bc08edb9e15ddc5254ab7843")
  9. add_versions("v2.5.4", "a463ab05129e3e307333ff49d637568fa6ae1fb81742f40918b618e8ef714987")
  10. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"})
  11. add_configs("cpu_runtime", {description = "Defines the threading runtime for CPU engines.", default = "seq", type = "string", values = {"none", "omp", "tbb", "seq", "threadpool", "dpcpp"}})
  12. add_configs("gpu_runtime", {description = "Defines the offload runtime for GPU engines.", default = "none", type = "string", values = {"none", "ocl", "dpcpp"}})
  13. add_deps("cmake")
  14. on_load("windows|x64", "macosx|x86_64", "linux|x86_64", function (package)
  15. local cpu_runtime = package:config("cpu_runtime")
  16. if cpu_runtime == "omp" then
  17. package:add("deps", "openmp")
  18. elseif cpu_runtime == "tbb" then
  19. package:add("deps", "tbb")
  20. end
  21. local gpu_runtime = package:config("gpu_runtime")
  22. if gpu_runtime == "ocl" then
  23. package:add("deps", "opencl")
  24. end
  25. end)
  26. on_install("windows|x64", "macosx|x86_64", "linux|x86_64", function (package)
  27. local configs = {"-DDNNL_BUILD_TESTS=OFF", "-DDNNL_BUILD_EXAMPLES=OFF"}
  28. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  29. table.insert(configs, "-DDNNL_LIBRARY_TYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
  30. import("package.tools.cmake").install(package, configs)
  31. end)
  32. on_test(function (package)
  33. assert(package:check_cxxsnippets({test = [[
  34. #include "oneapi/dnnl/dnnl.hpp"
  35. void test() {
  36. dnnl::engine eng(dnnl::engine::kind::cpu, 0);
  37. }
  38. ]]}, {configs = {languages = "c++14"}}))
  39. end)