xmake.lua 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package("onnxruntime")
  2. set_homepage("https://www.onnxruntime.ai")
  3. set_description("ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator")
  4. set_license("MIT")
  5. add_configs("gpu", {description = "Enable GPU supports on windows|x64", default = false, type = "boolean"})
  6. if is_plat("windows") then
  7. if is_arch("x64") then
  8. set_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-win-x64-$(version).zip")
  9. add_versions("1.11.1", "1f127b9d41f445a2d03356c86c125cb79dc3e66d391872c9babe6b444a51a93d")
  10. elseif is_arch("x86") then
  11. set_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-win-x86-$(version).zip")
  12. add_versions("1.11.1", "734ee4b76a17c466d5a5e628c27c38eccaf512e0228237cfc3d7a0a408986d1c")
  13. end
  14. elseif is_plat("linux") then
  15. if is_arch("x86_64") then
  16. set_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-linux-x64-$(version).tgz")
  17. add_versions("1.11.1", "ddc03b5ae325c675ff76a6f18786ce7d310be6eb6f320087f7a0e9228115f24d")
  18. elseif is_arch("arm64") then
  19. set_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-linux-aarch64-$(version).tgz")
  20. add_versions("1.11.1", "bb9ca658a6a0acc7b9e4288647277a9ce9d86b063a2403a51d5c0d2e4df43603")
  21. end
  22. elseif is_plat("macosx") then
  23. if is_arch("x86_64") then
  24. add_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-osx-x86_64-$(version).tgz")
  25. add_versions("1.11.1", "872e4413d73382db14e892112a0ee319746420f7f3a38121038a2845a97e7b5b")
  26. elseif is_arch("arm64") then
  27. add_urls("https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-osx-arm64-$(version).tgz")
  28. add_versions("1.11.1", "dc70af1424f173d57477ecf902d4bf4a2d3a110167089037e3866ac2bf3182e3")
  29. end
  30. end
  31. on_load(function (package)
  32. if package:config("gpu") then
  33. package:add("deps", "cuda", {configs = {utils = {"cudart", "nvrtc"}}})
  34. local versions = package:get("versions")
  35. if package:is_plat("windows") and package:is_arch("x64") then
  36. versions["1.11.1"] = "a9a10e76fbb4351d4103a4d46dc37690075901ef3bb7304dfa138820c42c547b"
  37. package:set("urls", "https://github.com/microsoft/onnxruntime/releases/download/v$(version)/onnxruntime-win-x64-gpu-$(version).zip")
  38. end
  39. package:set("versions", versions)
  40. end
  41. end)
  42. on_install("windows", "linux|arm64", "linux|x86_64", "macosx", function (package)
  43. os.cp("*", package:installdir())
  44. end)
  45. on_test(function (package)
  46. assert(package:check_cxxsnippets({test = [[
  47. #include <array>
  48. void test() {
  49. std::array<float, 2> data = {0.0f, 0.0f};
  50. std::array<std::int64_t, 1> shape{2};
  51. Ort::Env env;
  52. auto memory_info = Ort::MemoryInfo::CreateCpu(OrtDeviceAllocator, OrtMemTypeCPU);
  53. auto tensor = Ort::Value::CreateTensor<float>(memory_info, data.data(), data.size(), shape.data(), shape.size());
  54. }
  55. ]]}, {configs = {languages = "c++17"}, includes = "onnxruntime_cxx_api.h"}))
  56. end)