-
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 LibtorchPrebuildAT16 < Formula
desc "Tensors and dynamic neural networks"
homepage "https://pytorch.org/"
url "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.6.0.zip"
sha256 "e1140bed7bd56c26638bae28aebbdf68e588a9fae92c6684645bcdd996e4183c"
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