51 lines
1.7 KiB
Ruby
51 lines
1.7 KiB
Ruby
class Libtensorflow < Formula
|
|
desc "C interface for Google's OS library for Machine Intelligence"
|
|
homepage "https://www.tensorflow.org/"
|
|
url "https://github.com/tensorflow/tensorflow/archive/v1.0.1.tar.gz"
|
|
sha256 "deea3c65e0703da96d9c3f1162e464c51d37659dd129396af134e9e8f1ea8c05"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "0f92ebdc243573a77c1cf0584b68a5c4dd155360d85b960f1aba87139d18373e" => :sierra
|
|
sha256 "f92bad9c13d39fb1b814db84e8dbbaf9672f05c9ba327c069db9b608b2e173e4" => :el_capitan
|
|
sha256 "86d31c16d7c5dc239f5a8fbdb48a3b3f281bccc79a271f792a994e41effe5a23" => :yosemite
|
|
end
|
|
|
|
depends_on "bazel" => :build
|
|
|
|
def install
|
|
ENV["PYTHON_BIN_PATH"] = which("python").to_s
|
|
ENV["CC_OPT_FLAGS"] = "-march=native"
|
|
ENV["TF_NEED_JEMALLOC"] = "1"
|
|
ENV["TF_NEED_GCP"] = "0"
|
|
ENV["TF_NEED_HDFS"] = "0"
|
|
ENV["TF_ENABLE_XLA"] = "0"
|
|
ENV["USE_DEFAULT_PYTHON_LIB_PATH"] = "1"
|
|
ENV["TF_NEED_OPENCL"] = "0"
|
|
ENV["TF_NEED_CUDA"] = "0"
|
|
system "./configure"
|
|
|
|
system "bazel", "build", "--compilation_mode=opt", "--copt=-march=native", "tensorflow:libtensorflow.so"
|
|
lib.install "bazel-bin/tensorflow/libtensorflow.so"
|
|
(include/"tensorflow/c").install "tensorflow/c/c_api.h"
|
|
(lib/"pkgconfig/tensorflow.pc").write <<-EOS.undent
|
|
Name: tensorflow
|
|
Description: Tensorflow library
|
|
Version: #{version}
|
|
Libs: -L#{lib} -ltensorflow
|
|
Cflags: -I#{include}
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<-EOS.undent
|
|
#include <stdio.h>
|
|
#include <tensorflow/c/c_api.h>
|
|
int main() {
|
|
printf("%s", TF_Version());
|
|
}
|
|
EOS
|
|
system ENV.cc, "-L#{lib}", "-ltensorflow", "-o", "test_tf", "test.c"
|
|
assert_equal version, shell_output("./test_tf")
|
|
end
|
|
end
|