Skip to content

Commit

Permalink
Add libtorch-2.3 for arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
junjihashimoto committed Apr 30, 2024
1 parent f515aaa commit 3cc33a4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class LibtorchPrebuildAT23 < Formula
desc "Tensors and dynamic neural networks"
homepage "https://pytorch.org/"
url "https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.3.0.zip"
sha256 "ff86ea62ac24a27bba31490d95a8fab6beab8aab5abe72978300568c49bf2150"
license "BSD-3-Clause"

def install
system "bash", "-c", "cd include/torch; for i in csrc/api/include/torch/* ; do ln -s $i ;done"
system "bash", "-c", "install -d #{include}"
system "bash", "-c", "install -d #{lib}"
system "bash", "-c", "install -d #{share}"
system "bash", "-c", "cp -a include/* #{include}"
system "bash", "-c", "cp -a lib/* #{lib}"
system "bash", "-c", "cp -a share/* #{share}"
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++17", "-L#{lib}", "-ltorch", "-ltorch_cpu", "-lc10", "test.cpp", "-o", "test"
system "./test"
end
end

0 comments on commit 3cc33a4

Please sign in to comment.