Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libtorch 1.10.0 and torchvision 1.11.1 #88950

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Formula/libtorch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ class Libtorch < Formula
desc "Tensors and dynamic neural networks"
homepage "https://pytorch.org/"
url "https://github.com/pytorch/pytorch.git",
tag: "v1.9.1",
revision: "dfbd030854359207cb3040b864614affeace11ce"
tag: "v1.10.0",
revision: "36449ea93134574c2a22b87baad3de0bf8d64d42"
license "BSD-3-Clause"

livecheck do
Expand All @@ -32,8 +32,8 @@ class Libtorch < Formula
depends_on "pybind11"

resource "PyYAML" do
url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz"
sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"
url "https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz"
sha256 "68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"
end

resource "typing-extensions" do
Expand All @@ -49,14 +49,16 @@ def install
-DBUILD_CUSTOM_PROTOBUF=OFF
-DBUILD_PYTHON=OFF
-DPYTHON_EXECUTABLE=#{buildpath}/venv/bin/python
-Dpybind11_PREFER_third_party=OFF
-DUSE_CUDA=OFF
-DUSE_METAL=OFF
-DUSE_MKLDNN=OFF
-DUSE_NNPACK=OFF
-DUSE_OPENMP=OFF
-DUSE_SYSTEM_EIGEN_INSTALL=ON
-DUSE_SYSTEM_PYBIND11=ON
]
# Remove when https://github.com/pytorch/pytorch/issues/67974 is addressed
args << "-DUSE_SYSTEM_BIND11=ON"

mkdir "build" do
system "cmake", "..", *std_cmake_args, *args
Expand Down
20 changes: 15 additions & 5 deletions Formula/torchvision.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class Torchvision < Formula
desc "Datasets, transforms, and models for computer vision"
homepage "https://github.com/pytorch/vision"
url "https://github.com/pytorch/vision/archive/refs/tags/v0.10.1.tar.gz"
sha256 "4d595cf0214c8adc817f8e3cd0043a027b52b481e05d67b04f4947fcb43d4277"
url "https://github.com/pytorch/vision/archive/refs/tags/v0.11.1.tar.gz"
sha256 "32a06ccf755e4d75006ce03701f207652747a63dbfdf65f0f20a1b6f93a2e834"
license "BSD-3-Clause"

bottle do
Expand Down Expand Up @@ -31,13 +31,23 @@ def install
end

test do
cp pkgshare/"examples/cpp/hello_world/main.cpp", testpath
(testpath/"test.cpp").write <<~EOS
#include <assert.h>
#include <torch/script.h>
#include <torch/torch.h>
#include <torchvision/vision.h>

int main() {
auto& ops = torch::jit::getAllOperatorsFor(torch::jit::Symbol::fromQualString("torchvision::nms"));
assert(ops.size() == 1);
}
EOS
libtorch = Formula["libtorch"]
system ENV.cxx, "-std=c++14", "main.cpp", "-o", "test",
system ENV.cxx, "-std=c++14", "test.cpp", "-o", "test",
"-I#{libtorch.opt_include}",
"-I#{libtorch.opt_include}/torch/csrc/api/include",
"-L#{libtorch.opt_lib}", "-ltorch", "-ltorch_cpu", "-lc10",
"-L#{lib}", "-ltorchvision"
assert_match "[1, 1000]", shell_output("./test")
system "./test"
end
end