xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.3.4", "e291fa4702f4bcfa6c8c23cb5b6599f0fefa8f23bc08edb9e15ddc5254ab7843")
  8. add_versions("v2.5.4", "a463ab05129e3e307333ff49d637568fa6ae1fb81742f40918b618e8ef714987")
  9. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"})
  10. add_configs("cpu_runtime", {description = "Defines the threading runtime for CPU engines.", default = "seq", type = "string", values = {"none", "omp", "tbb", "seq", "threadpool", "dpcpp"}})
  11. add_configs("gpu_runtime", {description = "Defines the offload runtime for GPU engines.", default = "none", type = "string", values = {"none", "ocl", "dpcpp"}})
  12. add_deps("cmake")
  13. on_load("windows|x64", "macosx|x86_64", "linux|x86_64", function (package)
  14. local cpu_runtime = package:config("cpu_runtime")
  15. if cpu_runtime == "omp" then
  16. package:add("deps", "openmp")
  17. elseif cpu_runtime == "tbb" then
  18. package:add("deps", "tbb")
  19. end
  20. local gpu_runtime = package:config("gpu_runtime")
  21. if gpu_runtime == "ocl" then
  22. package:add("deps", "opencl")
  23. end
  24. end)
  25. on_install("windows|x64", "macosx|x86_64", "linux|x86_64", function (package)
  26. local configs = {"-DDNNL_BUILD_TESTS=OFF", "-DDNNL_BUILD_EXAMPLES=OFF"}
  27. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  28. table.insert(configs, "-DDNNL_LIBRARY_TYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
  29. import("package.tools.cmake").install(package, configs)
  30. end)
  31. on_test(function (package)
  32. assert(package:check_cxxsnippets({test = [[
  33. #include "oneapi/dnnl/dnnl.hpp"
  34. void test() {
  35. dnnl::engine eng(dnnl::engine::kind::cpu, 0);
  36. }
  37. ]]}, {configs = {languages = "c++14"}}))
  38. end)