update openblas and add faiss (#402)

* update openblas

* add faiss
pull/405/head
Hoildkv 4 years ago committed by GitHub
parent ee232186b0
commit ce4ae04271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      packages/f/faiss/xmake.lua
  2. 22
      packages/l/libtorch/xmake.lua
  3. 15
      packages/o/openblas/xmake.lua

@ -0,0 +1,34 @@
package("faiss")
set_homepage("https://github.com/facebookresearch/faiss/")
set_description("A library for efficient similarity search and clustering of dense vectors.")
set_license("MIT")
add_urls("https://github.com/facebookresearch/faiss/archive/refs/tags/$(version).tar.gz",
"https://github.com/facebookresearch/faiss.git")
add_versions("v1.7.0", "f86d346ac9f409ee30abe37e52f6cce366b7f60d3924d65719f40aa07ceb4bec")
add_deps("cmake")
add_deps("cuda", {system = true, optional = true})
add_deps("mkl", "cuda", {system = true, optional = true})
if is_plat("linux") then
add_syslinks("pthread")
end
on_load("windows|x64", "linux", function (package)
if not find_package("mkl") then
package:add("deps", "openblas")
end
end)
on_install("windows|x64", "linux", function (package)
io.replace("CMakeLists.txt", "add_subdirectory(demos)", "", {plain = true})
io.replace("CMakeLists.txt", "add_subdirectory(tutorial/cpp)", "", {plain = true})
local configs = {"-DFAISS_ENABLE_PYTHON=OFF", "-DBUILD_TESTING=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DFAISS_ENABLE_GPU=" .. (package:dep("cuda"):exists() and "ON" or "OFF"))
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cxxtypes("faiss::MultiIndexQuantizer", {configs = {languages = "c++11"}, includes = "faiss/IndexPQ.h"}))
end)

@ -74,11 +74,8 @@ package("libtorch")
io.replace("third_party/fbgemm/CMakeLists.txt", "PRIVATE FBGEMM_STATIC", "PUBLIC FBGEMM_STATIC", {plain = true})
io.replace("third_party/protobuf/cmake/install.cmake", "install%(DIRECTORY.-%)", "")
io.replace("third_party/ideep/mkl-dnn/src/CMakeLists.txt", "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}", "${CMAKE_INSTALL_LIBDIR}", {plain = true})
if package:is_plat("windows") then
io.replace("cmake/Modules/FindOpenBLAS.cmake", "NAMES openblas PATHS", "NAMES libopenblas PATHS", {plain = true})
if package:config("vs_runtime"):startswith("MD") then
io.replace("third_party/fbgemm/CMakeLists.txt", "MT", "MD", {plain = true})
end
if package:is_plat("windows") and package:config("vs_runtime"):startswith("MD") then
io.replace("third_party/fbgemm/CMakeLists.txt", "MT", "MD", {plain = true})
end
-- prepare python
@ -92,11 +89,11 @@ package("libtorch")
end
-- prepare for installation
local extracfg = {}
local opt = {}
if package:config("ninja") then
extracfg.cmake_generator = "Ninja"
opt.cmake_generator = "Ninja"
end
local envs = cmake.buildenvs(package, extracfg)
local envs = cmake.buildenvs(package, opt)
if not package:is_plat("macosx") then
if package:dep("mkl"):exists() then
table.insert(configs, "-DBLAS=MKL")
@ -110,9 +107,11 @@ package("libtorch")
envs.libuv_ROOT = package:dep("libuv"):installdir()
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DCAFFE2_USE_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
extracfg.envs = envs
cmake.install(package, configs, extracfg)
if package:is_plat("windows") then
table.insert(configs, "-DCAFFE2_USE_MSVC_STATIC_RUNTIME=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
end
opt.envs = envs
cmake.install(package, configs, opt)
end)
on_test(function (package)
@ -124,4 +123,3 @@ package("libtorch")
}
]]}, {configs = {languages = "c++14"}, includes = "torch/torch.h"}))
end)

@ -8,25 +8,28 @@ package("openblas")
add_urls("https://github.com/xianyi/OpenBLAS/releases/download/v$(version)/OpenBLAS-$(version)-x64.zip")
add_versions("0.3.12", "f1d231594365d5c7f2c625f9d8bd4eeea4f7b748675a95301d3cb2c0aa118e26")
add_versions("0.3.13", "85cacd71dec9bc1e1168a8463fd0aa29a31f449b4583ed3a1c689a56df8eae29")
add_versions("0.3.15", "afc029572a84820596fe81f1faeb909ada5bab27d091285fdd80bc2a8231f4a6")
elseif is_arch("x86") then
add_urls("https://github.com/xianyi/OpenBLAS/releases/download/v$(version)/OpenBLAS-$(version)-x86.zip")
add_versions("0.3.15", "bcde933737b477813eaac290de5cb8756d3b42199e8ef5f44b23ae5f06fe0834")
end
else
add_urls("https://github.com/xianyi/OpenBLAS/releases/download/v$(version)/OpenBLAS-$(version).tar.gz")
add_versions("0.3.12", "65a7d3a4010a4e3bd5c0baa41a234797cd3a1735449a4a5902129152601dc57b")
add_versions("0.3.13", "79197543b17cc314b7e43f7a33148c308b0807cd6381ee77f77e15acf3e6459e")
add_versions("0.3.15", "30a99dec977594b387a17f49904523e6bc8dd88bd247266e83485803759e4bbe")
add_configs("with_fortran", {description="Compile with fortran enabled.", default = true, type = "boolean"})
end
if is_plat("linux") then
add_syslinks("pthread")
elseif is_plat("windows") then
add_links("libopenblas")
end
on_install("windows|x64", function (package)
os.cp("bin", package:installdir())
os.cp("include", package:installdir())
os.cp("lib", package:installdir())
on_install("windows", function (package)
os.mv(path.join("bin", "libopenblas.dll"), path.join(package:installdir("bin"), "openblas.dll"))
os.mv("include", package:installdir())
os.mv(path.join("lib", "libopenblas.lib"), path.join(package:installdir("lib"), "openblas.lib"))
package:addenv("PATH", "bin")
end)

Loading…
Cancel
Save