80 lines
2.4 KiB
Ruby
80 lines
2.4 KiB
Ruby
class Libtorch < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Tensors and dynamic neural networks"
|
|
homepage "https://pytorch.org/"
|
|
url "https://github.com/pytorch/pytorch.git",
|
|
tag: "v1.6.0",
|
|
revision: "b31f58de6fa8bbda5353b3c77d9be4914399724d"
|
|
license "BSD-3-Clause"
|
|
revision 1
|
|
|
|
livecheck do
|
|
url "https://github.com/pytorch/pytorch/releases/latest"
|
|
regex(%r{href=.*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "639c902bc29a3d3bc3da276a36d2ca4a1b652c3500544a959e8854ff8bbb3d94" => :catalina
|
|
sha256 "19826ceb6d2fb187fa62581e59eac8119c62a9848b26165db5a90782e6cd2e52" => :mojave
|
|
sha256 "7e8b575d15988304e31d00eeaedc2cc463fda10a12192ae598e3c7b28f70a6a3" => :high_sierra
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "python@3.8" => :build
|
|
depends_on "eigen"
|
|
depends_on "libomp"
|
|
depends_on "libyaml"
|
|
depends_on "protobuf"
|
|
depends_on "pybind11"
|
|
|
|
resource "PyYAML" do
|
|
url "https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz"
|
|
sha256 "b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"
|
|
end
|
|
|
|
resource "typing" do
|
|
url "https://files.pythonhosted.org/packages/05/d9/6eebe19d46bd05360c9a9aae822e67a80f9242aabbfc58b641b957546607/typing-3.7.4.3.tar.gz"
|
|
sha256 "1187fb9c82fd670d10aa07bbb6cfcfe4bdda42d6fab8d5134f04e8c4d0b71cc9"
|
|
end
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec, Formula["python@3.8"].opt_bin/"python3")
|
|
venv.pip_install resources
|
|
|
|
args = %W[
|
|
-DBUILD_CUSTOM_PROTOBUF=OFF
|
|
-DBUILD_PYTHON=OFF
|
|
-DPYTHON_EXECUTABLE=#{libexec}/bin/python
|
|
-Dpybind11_PREFER_third_party=OFF
|
|
-DUSE_CUDA=OFF
|
|
-DUSE_METAL=OFF
|
|
-DUSE_MKLDNN=OFF
|
|
-DUSE_NNPACK=OFF
|
|
-DUSE_SYSTEM_EIGEN_INSTALL=ON
|
|
]
|
|
|
|
mkdir "build" do
|
|
system "cmake", "..", *std_cmake_args, *args
|
|
system "make"
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <torch/torch.h>
|
|
#include <iostream>
|
|
|
|
int main() {
|
|
torch::Tensor tensor = torch::rand({2, 3});
|
|
std::cout << tensor << std::endl;
|
|
}
|
|
EOS
|
|
system ENV.cxx, "-std=c++14", "-L#{lib}", "-ltorch", "-ltorch_cpu", "-lc10",
|
|
"-I#{include}/torch/csrc/api/include", "test.cpp", "-o", "test"
|
|
system "./test"
|
|
end
|
|
end
|