-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibtorch-prebuild.rb
31 lines (28 loc) · 1.05 KB
/
libtorch-prebuild.rb
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 LibtorchPrebuild < Formula
desc "Tensors and dynamic neural networks"
homepage "https://pytorch.org/"
url "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.7.0.zip"
sha256 "2dccb83f1beb16ef3129d9f7af5abafb2f5d9220d0c7da8fde3531bd4ef0e655"
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