-
Notifications
You must be signed in to change notification settings - Fork 0
31 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class LibtorchPrebuildAT19 < Formula
desc "Tensors and dynamic neural networks"
homepage "https://pytorch.org/"
url "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.9.0.zip"
sha256 "5343b311201b1bd8e010ce613baedf4e5bf31dd098e1ac550b3c21f3192a4aad"
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++14", "-L#{lib}", "-ltorch", "-ltorch_cpu", "-lc10", "test.cpp", "-o", "test"
system "./test"
end
end