@@ -10,23 +10,24 @@ package("libtorch")
1010 add_versions (" v1.8.2" , " e0495a7aa104471d95dc85a1b8f6473fbcc427a8" )
1111 add_versions (" v1.9.0" , " d69c22dd61a2f006dcfe1e3ea8468a3ecaf931aa" )
1212 add_versions (" v1.9.1" , " dfbd030854359207cb3040b864614affeace11ce" )
13+ add_versions (" v1.11.0" , " bc2c6edaf163b1a1330e37a6e34caf8c553e4755" )
1314
1415 add_patches (" 1.9.x" , path.join (os.scriptdir (), " patches" , " 1.9.0" , " gcc11.patch" ), " 4191bb3296f18f040c230d7c5364fb160871962d6278e4ae0f8bc481f27d8e4b" )
16+ add_patches (" 1.11.0" , path.join (os.scriptdir (), " patches" , " 1.11.0" , " gcc11.patch" ), " 1404b0bc6ce7433ecdc59d3412e3d9ed507bb5fd2cd59134a254d7d4a8d73012" )
1517
1618 add_configs (" python" , {description = " Build python interface." , default = false , type = " boolean" })
17- add_configs (" ninja" , {description = " Use ninja as build tool." , default = true , type = " boolean" })
19+ add_configs (" cuda" , {description = " Enable CUDA support." , default = false , type = " boolean" })
20+ add_configs (" ninja" , {description = " Use ninja as build tool." , default = false , type = " boolean" })
21+ add_configs (" blas" , {description = " Set BLAS vendor." , default = " openblas" , type = " string" , values = {" mkl" , " openblas" , " eigen" }})
1822 if not is_plat (" macosx" ) then
19- add_configs (" blas " , {description = " Set BLAS vendor ." , default = " openblas " , type = " string " , values = { " mkl " , " openblas " } })
23+ add_configs (" distributed " , {description = " Enable distributed support ." , default = false , type = " boolean " })
2024 end
2125
2226 add_deps (" cmake" )
23- add_deps (" python 3.x" , {kind = " binary" , system = false })
24- add_deps (" libuv" )
25- add_deps (" cuda" , {optional = true , configs = {utils = {" nvrtc" , " cudnn" , " cufft" , " curand" , " cublas" , " cudart_static" }}})
26- add_deps (" nvtx" , {optional = true , system = true })
27+ add_deps (" python 3.x" , {kind = " binary" })
28+
2729 add_includedirs (" include" )
2830 add_includedirs (" include/torch/csrc/api/include" )
29-
3031 if is_plat (" linux" ) then
3132 add_syslinks (" rt" )
3233 end
@@ -40,6 +41,13 @@ package("libtorch")
4041 if package :config (" ninja" ) then
4142 package :add (" deps" , " ninja" )
4243 end
44+ if package :config (" cuda" ) then
45+ package :add (" deps" , " cuda" , {configs = {utils = {" nvrtc" , " cudnn" , " cufft" , " curand" , " cublas" , " cudart_static" }}})
46+ package :add (" deps" , " nvtx" )
47+ end
48+ if package :config (" distributed" ) then
49+ package :add (" deps" , " libuv" )
50+ end
4351 if not package :is_plat (" macosx" ) and package :config (" blas" ) then
4452 package :add (" deps" , package :config (" blas" ))
4553 end
@@ -56,13 +64,12 @@ package("libtorch")
5664 end
5765
5866 -- tackle link flags
59- local has_cuda = package :dep (" cuda" ):exists () and package :dep (" nvtx" ):exists ()
6067 local libnames = {" torch" , " torch_cpu" }
61- if has_cuda then
68+ if package : config ( " cuda " ) then
6269 table.insert (libnames , " torch_cuda" )
6370 end
6471 table.insert (libnames , " c10" )
65- if has_cuda then
72+ if package : config ( " cuda " ) then
6673 table.insert (libnames , " c10_cuda" )
6774 end
6875 local suffix = " "
@@ -82,11 +89,10 @@ package("libtorch")
8289 end
8390 end
8491 if not package :config (" shared" ) then
85- for _ , lib in ipairs ({" nnpack" , " pytorch_qnnpack" , " qnnpack" , " XNNPACK" , " caffe2_protos" , " protobuf-lite" , " protobuf" , " protoc" , " onnx" , " onnx_proto" , " foxi_loader" , " pthreadpool" , " eigen_blas" , " fbgemm" , " cpuinfo" , " clog" , " dnnl" , " mkldnn" , " sleef" , " asmjit" , " fmt" }) do
92+ for _ , lib in ipairs ({" nnpack" , " pytorch_qnnpack" , " qnnpack" , " XNNPACK" , " caffe2_protos" , " protobuf-lite" , " protobuf" , " protoc" , " onnx" , " onnx_proto" , " foxi_loader" , " pthreadpool" , " eigen_blas" , " fbgemm" , " cpuinfo" , " clog" , " dnnl" , " mkldnn" , " sleef" , " asmjit" , " fmt" , " kineto " }) do
8693 package :add (" links" , lib )
8794 end
8895 end
89- package :add (" links" , " kineto" )
9096
9197 -- some patches to the third-party cmake files
9298 io .replace (" third_party/fbgemm/CMakeLists.txt" , " PRIVATE FBGEMM_STATIC" , " PUBLIC FBGEMM_STATIC" , {plain = true })
@@ -97,7 +103,9 @@ package("libtorch")
97103
98104 -- prepare python
99105 os .vrun (" python -m pip install typing_extensions pyyaml" )
100- local configs = {" -DUSE_MPI=OFF" , " -DCMAKE_INSTALL_LIBDIR=lib" }
106+ local configs = {" -DUSE_MPI=OFF" ,
107+ " -DCMAKE_INSTALL_LIBDIR=lib" ,
108+ " -DATEN_NO_TEST=ON" }
101109 if package :config (" python" ) then
102110 table.insert (configs , " -DBUILD_PYTHON=ON" )
103111 os .vrun (" python -m pip install numpy" )
@@ -116,11 +124,17 @@ package("libtorch")
116124 elseif package :config (" blas" ) == " openblas" then
117125 table.insert (configs , " -DBLAS=OpenBLAS" )
118126 envs .OpenBLAS_HOME = package :dep (" openblas" ):installdir ()
127+ elseif package :config (" blas" ) == " eigen" then
128+ table.insert (configs , " -DBLAS=Eigen" )
119129 end
120130 end
121- envs .libuv_ROOT = package :dep (" libuv" ):installdir ()
131+ if package :config (" distributed" ) then
132+ envs .libuv_ROOT = package :dep (" libuv" ):installdir ()
133+ end
122134 table.insert (configs , " -DCMAKE_BUILD_TYPE=" .. (package :debug () and " Debug" or " Release" ))
123135 table.insert (configs , " -DBUILD_SHARED_LIBS=" .. (package :config (" shared" ) and " ON" or " OFF" ))
136+ table.insert (configs , " -DUSE_CUDA=" .. (package :config (" cuda" ) and " ON" or " OFF" ))
137+ table.insert (configs , " -DUSE_DISTRIBUTED=" .. (package :config (" distributed" ) and " ON" or " OFF" ))
124138 if package :is_plat (" windows" ) then
125139 table.insert (configs , " -DCAFFE2_USE_MSVC_STATIC_RUNTIME=" .. (package :config (" vs_runtime" ):startswith (" MT" ) and " ON" or " OFF" ))
126140 end
0 commit comments