@@ -3,11 +3,9 @@ class Pytorch < Formula
33
44 desc "Tensors and dynamic neural networks"
55 homepage "https://pytorch.org/"
6- url "https://github.com/pytorch/pytorch.git" ,
7- tag : "v2.1.0" ,
8- revision : "7bcf7da3a268b435777fe87c7794c382f444e86d"
6+ url "https://github.com/pytorch/pytorch/releases/download/v2.1.2/pytorch-v2.1.2.tar.gz"
7+ sha256 "85effbcce037bffa290aea775c9a4bad5f769cb229583450c40055501ee1acd7"
98 license "BSD-3-Clause"
10- revision 1
119
1210 livecheck do
1311 url :stable
@@ -42,6 +40,7 @@ class Pytorch < Formula
4240 depends_on "python-sympy"
4341 depends_on "python-typing-extensions"
4442 depends_on "pyyaml"
43+ depends_on "sleef"
4544
4645 on_macos do
4746 depends_on "libomp"
@@ -55,45 +54,37 @@ class Pytorch < Formula
5554 end
5655
5756 def install
58- python_exe = Formula [ "[email protected] " ] . opt_libexec /
"bin/python" 59- args = %W[
60- -GNinja
61- -DBLAS=OpenBLAS
62- -DBUILD_CUSTOM_PROTOBUF=OFF
63- -DBUILD_PYTHON=ON
64- -DCMAKE_CXX_COMPILER=#{ ENV . cxx }
65- -DCMAKE_C_COMPILER=#{ ENV . cc }
66- -DPYTHON_EXECUTABLE=#{ python_exe }
67- -DUSE_CUDA=OFF
68- -DUSE_DISTRIBUTED=ON
69- -DUSE_METAL=OFF
70- -DUSE_MKLDNN=OFF
71- -DUSE_NNPACK=OFF
72- -DUSE_OPENMP=ON
73- -DUSE_SYSTEM_EIGEN_INSTALL=ON
74- -DUSE_SYSTEM_PYBIND11=ON
75- ]
76- args << "-DUSE_MPS=ON" if OS . mac?
77-
78- ENV [ "LDFLAGS" ] = "-L#{ buildpath } /build/lib"
79-
80- # Update references to shared libraries
81- inreplace "torch/__init__.py" do |s |
82- s . sub! ( /here = os.path.abspath\( __file__\) / , "here = \" #{ lib } \" " )
83- s . sub! ( "get_file_path('torch', 'bin', 'torch_shm_manager')" , "\" #{ bin } /torch_shm_manager\" " )
84- end
85-
86- inreplace "torch/utils/cpp_extension.py" , "_TORCH_PATH = os.path.dirname(os.path.dirname(_HERE))" ,
87- "_TORCH_PATH = \" #{ opt_prefix } \" "
88-
89- system "cmake" , "-B" , "build" , "-S" , "." , *std_cmake_args , *args
57+ python3 = "python3.11"
58+
59+ ENV [ "ATEN_NO_TEST" ] = "ON"
60+ ENV [ "BLAS" ] = "OpenBLAS"
61+ ENV [ "BUILD_CUSTOM_PROTOBUF" ] = "OFF"
62+ ENV [ "BUILD_PYTHON" ] = "ON"
63+ ENV [ "BUILD_TEST" ] = "OFF"
64+ ENV [ "PYTHON_EXECUTABLE" ] = which ( python3 )
65+ ENV [ "USE_CUDA" ] = "OFF"
66+ ENV [ "USE_DISTRIBUTED" ] = "ON"
67+ ENV [ "USE_METAL" ] = "OFF"
68+ ENV [ "USE_MKLDNN" ] = "OFF"
69+ ENV [ "USE_NNPACK" ] = "OFF"
70+ ENV [ "USE_OPENMP" ] = "ON"
71+ ENV [ "USE_SYSTEM_EIGEN_INSTALL" ] = "ON"
72+ ENV [ "USE_SYSTEM_PYBIND11" ] = "ON"
73+ ENV [ "USE_SYSTEM_SLEEF" ] = "ON"
74+ ENV [ "USE_MPS" ] = "ON" if OS . mac?
9075
9176 # Avoid references to Homebrew shims
92- inreplace "build/ caffe2/core/macros.h" , Superenv . shims_path / ENV . cxx , ENV . cxx
77+ inreplace "caffe2/core/macros.h.in " , "${CMAKE_CXX_COMPILER}" , ENV . cxx
9378
94- venv = virtualenv_create ( libexec , " python3.11" )
79+ venv = virtualenv_create ( libexec , python3 )
9580 venv . pip_install resources
9681 venv . pip_install_and_link ( buildpath , build_isolation : false )
82+
83+ # Expose C++ API
84+ torch = libexec /Language ::Python . site_packages ( python3 ) /"torch"
85+ include . install_symlink ( torch /"include" ) . children
86+ lib . install_symlink ( torch /"lib" ) . children
87+ ( share /"cmake" ) . install_symlink ( torch /"share/cmake" ) . children
9788 end
9889
9990 test do
0 commit comments