@@ -3,26 +3,23 @@ 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
1412 regex ( /^v?(\d +(?:\. \d +)+)$/i )
1513 end
1614
1715 bottle do
18- rebuild 1
19- sha256 cellar : :any , arm64_sonoma : "1e04904eefe2362abf5bb2a7b268bc918c7e15644fc44e484f52dab5e9bc7265"
20- sha256 cellar : :any , arm64_ventura : "596151cc5e64e57b03fe2a25305a302bf421e9b128fce82e45731a637c2c54d3"
21- sha256 cellar : :any , arm64_monterey : "91650359defe1da8775fc260b3e481214a46b3b7ec79efab32f97a314ea95e91"
22- sha256 cellar : :any , sonoma : "4db1789590deeb347ffb1bcea8bb36e0d9049437b0fb48fffc28855724cbe0c1"
23- sha256 cellar : :any , ventura : "6175ae382a2dad45844a60081670cb2569d8ec7f26dfba57062ce3e084e2d1d3"
24- sha256 cellar : :any , monterey : "3b8654206fcf0872831f73e84911e22f8b297a8be12ea59b5ca7586ac5828ee0"
25- sha256 cellar : :any_skip_relocation , x86_64_linux : "16355062ead50b480b29ec1db4d4cccce737beb7a0ec807c2e44d497e740ef19"
16+ sha256 cellar : :any , arm64_sonoma : "3b79d89656fc777cfa460fbd40b09a2ddfe21b640e4303a94b1b24827cd83e59"
17+ sha256 cellar : :any , arm64_ventura : "3129d0ce0efd548db5ab330c2a1289d8e0f7cd4fd271b43601a487e283775ded"
18+ sha256 cellar : :any , arm64_monterey : "954d33258bc02d4c2372aa4c870ed3de605e3040ebaa3fbd86079ca0548f4811"
19+ sha256 cellar : :any , sonoma : "b3ce62639d92a479e0ad7f19d3624a049dfafb292a58bdee7122ba65ae4d871a"
20+ sha256 cellar : :any , ventura : "7c54cdba347cdb15dcee5abada6b68065160f6a8c19a8f23052957dc1619222e"
21+ sha256 cellar : :any , monterey : "7bb1edf65c33f0642855e26a017d0d98e7c71655b92eccc79838536f12d9ed1d"
22+ sha256 cellar : :any_skip_relocation , x86_64_linux : "8812cf061f0ec26410ae3ddf592734e0a0672fbc324d0748e65025559c6a9630"
2623 end
2724
2825 depends_on "cmake" => :build
@@ -42,6 +39,7 @@ class Pytorch < Formula
4239 depends_on "python-sympy"
4340 depends_on "python-typing-extensions"
4441 depends_on "pyyaml"
42+ depends_on "sleef"
4543
4644 on_macos do
4745 depends_on "libomp"
@@ -55,45 +53,37 @@ class Pytorch < Formula
5553 end
5654
5755 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
56+ python3 = "python3.11"
57+
58+ ENV [ "ATEN_NO_TEST" ] = "ON"
59+ ENV [ "BLAS" ] = "OpenBLAS"
60+ ENV [ "BUILD_CUSTOM_PROTOBUF" ] = "OFF"
61+ ENV [ "BUILD_PYTHON" ] = "ON"
62+ ENV [ "BUILD_TEST" ] = "OFF"
63+ ENV [ "PYTHON_EXECUTABLE" ] = which ( python3 )
64+ ENV [ "USE_CUDA" ] = "OFF"
65+ ENV [ "USE_DISTRIBUTED" ] = "ON"
66+ ENV [ "USE_METAL" ] = "OFF"
67+ ENV [ "USE_MKLDNN" ] = "OFF"
68+ ENV [ "USE_NNPACK" ] = "OFF"
69+ ENV [ "USE_OPENMP" ] = "ON"
70+ ENV [ "USE_SYSTEM_EIGEN_INSTALL" ] = "ON"
71+ ENV [ "USE_SYSTEM_PYBIND11" ] = "ON"
72+ ENV [ "USE_SYSTEM_SLEEF" ] = "ON"
73+ ENV [ "USE_MPS" ] = "ON" if OS . mac?
9074
9175 # Avoid references to Homebrew shims
92- inreplace "build/ caffe2/core/macros.h" , Superenv . shims_path / ENV . cxx , ENV . cxx
76+ inreplace "caffe2/core/macros.h.in " , "${CMAKE_CXX_COMPILER}" , ENV . cxx
9377
94- venv = virtualenv_create ( libexec , " python3.11" )
78+ venv = virtualenv_create ( libexec , python3 )
9579 venv . pip_install resources
9680 venv . pip_install_and_link ( buildpath , build_isolation : false )
81+
82+ # Expose C++ API
83+ torch = libexec /Language ::Python . site_packages ( python3 ) /"torch"
84+ include . install_symlink ( torch /"include" ) . children
85+ lib . install_symlink ( torch /"lib" ) . children
86+ ( share /"cmake" ) . install_symlink ( torch /"share/cmake" ) . children
9787 end
9888
9989 test do
0 commit comments