Skip to content

Commit 5b57d07

Browse files
committed
onnxruntime 1.20.0
1 parent f028adb commit 5b57d07

File tree

1 file changed

+63
-11
lines changed

1 file changed

+63
-11
lines changed

Formula/o/onnxruntime.rb

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ class Onnxruntime < Formula
22
desc "Cross-platform, high performance scoring engine for ML models"
33
homepage "https://github.com/microsoft/onnxruntime"
44
url "https://github.com/microsoft/onnxruntime.git",
5-
tag: "v1.17.1",
6-
revision: "8f5c79cb63f09ef1302e85081093a3fe4da1bc7d"
5+
tag: "v1.20.0",
6+
revision: "c4fb724e810bb496165b9015c77f402727392933"
77
license "MIT"
88

99
livecheck do
@@ -21,21 +21,74 @@ class Onnxruntime < Formula
2121
sha256 cellar: :any_skip_relocation, x86_64_linux: "dde778dd1564940af7b2116cba7d4c8b45b4d6e335c78620cf97b1e1e6a688b1"
2222
end
2323

24+
depends_on "boost" => :build
2425
depends_on "cmake" => :build
25-
depends_on "[email protected]" => :build
26+
depends_on "cpp-gsl" => :build
27+
depends_on "flatbuffers" => :build # NOTE: links to static library
28+
depends_on "howard-hinnant-date" => :build
29+
depends_on "nlohmann-json" => :build
30+
depends_on "nsync" => :build # NOTE: links to static library
31+
depends_on "[email protected]" => :build
32+
depends_on "safeint" => :build
33+
depends_on "abseil"
34+
depends_on "protobuf@21" # https://github.com/microsoft/onnxruntime/issues/21308
35+
depends_on "re2"
2636

27-
fails_with gcc: "5" # GCC version < 7 is no longer supported
37+
# Need newer than stable `eigen` after https://github.com/microsoft/onnxruntime/pull/21492
38+
# element_wise_ops.cc:708:32: error: no matching member function for call to 'min'
39+
#
40+
# https://github.com/microsoft/onnxruntime/blob/v#{version}/cmake/deps.txt#L25
41+
resource "eigen" do
42+
url "https://gitlab.com/libeigen/eigen/-/archive/e7248b26a1ed53fa030c5c459f7ea095dfd276ac/eigen-e7248b26a1ed53fa030c5c459f7ea095dfd276ac.tar.bz2"
43+
sha256 "a3f1724de1dc7e7f74fbcc206ffcaeba27fd89b37dc71f9c31e505634d0c1634"
44+
end
45+
46+
# https://github.com/microsoft/onnxruntime/blob/v#{version}/cmake/deps.txt#L52
47+
resource "pytorch_cpuinfo" do
48+
url "https://github.com/pytorch/cpuinfo/archive/ca678952a9a8eaa6de112d154e8e104b22f9ab3f.tar.gz"
49+
sha256 "c8f43b307fa7d911d88fec05448161eb1949c3fc0cb62f3a7a2c61928cdf2e9b"
50+
end
51+
52+
# TODO: Consider making separate formula
53+
resource "onnx" do
54+
url "https://github.com/onnx/onnx/archive/refs/tags/v1.17.0.tar.gz"
55+
sha256 "8d5e983c36037003615e5a02d36b18fc286541bf52de1a78f6cf9f32005a820e"
56+
end
2857

2958
def install
30-
cmake_args = %W[
31-
-Donnxruntime_RUN_ONNX_TESTS=OFF
32-
-Donnxruntime_GENERATE_TEST_REPORTS=OFF
33-
-DPYTHON_EXECUTABLE=#{which("python3.12")}
59+
python3 = which("python3.13")
60+
61+
# Workaround to use brew `nsync`. Remove in future release with
62+
# https://github.com/microsoft/onnxruntime/commit/88676e62b966add2cc144a4e7d8ae1dbda1148e8
63+
inreplace "cmake/external/onnxruntime_external_deps.cmake" do |s|
64+
s.gsub!(/ NAMES nsync unofficial-nsync$/, " NAMES nsync_cpp")
65+
s.gsub!(/\bunofficial::nsync::nsync_cpp\b/, "nsync_cpp")
66+
end
67+
68+
resources.each do |r|
69+
(buildpath/"build/_deps/#{r.name}-src").install r
70+
end
71+
72+
args = %W[
73+
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
74+
-DFETCHCONTENT_FULLY_DISCONNECTED=ON
75+
-DFETCHCONTENT_SOURCE_DIR_PYTORCH_CLOG=#{buildpath}/build/_deps/pytorch_cpuinfo-src
76+
-DFETCHCONTENT_TRY_FIND_PACKAGE_MODE=ALWAYS
77+
-DPYTHON_EXECUTABLE=#{python3}
78+
-DONNX_CUSTOM_PROTOC_EXECUTABLE=#{Formula["protobuf@21"].opt_bin}/protoc
3479
-Donnxruntime_BUILD_SHARED_LIB=ON
3580
-Donnxruntime_BUILD_UNIT_TESTS=OFF
81+
-Donnxruntime_GENERATE_TEST_REPORTS=OFF
82+
-Donnxruntime_RUN_ONNX_TESTS=OFF
83+
-Donnxruntime_USE_FULL_PROTOBUF=ON
3684
]
3785

38-
system "cmake", "-S", "cmake", "-B", "build", *cmake_args, *std_cmake_args
86+
# Regenerate C++ bindings to use newer `flatbuffers`
87+
flatc = Formula["flatbuffers"].opt_bin/"flatc"
88+
system python3, "onnxruntime/core/flatbuffers/schema/compile_schema.py", "--flatc", flatc
89+
system python3, "onnxruntime/lora/adapter_format/compile_schema.py", "--flatc", flatc
90+
91+
system "cmake", "-S", "cmake", "-B", "build", *args, *std_cmake_args
3992
system "cmake", "--build", "build"
4093
system "cmake", "--install", "build"
4194
end
@@ -50,8 +103,7 @@ def install
50103
return 0;
51104
}
52105
C
53-
system ENV.cc, "-I#{include}", testpath/"test.c",
54-
"-L#{lib}", "-lonnxruntime", "-o", testpath/"test"
106+
system ENV.cc, "-I#{include}", "test.c", "-L#{lib}", "-lonnxruntime", "-o", "test"
55107
assert_equal version, shell_output("./test").strip
56108
end
57109
end

0 commit comments

Comments
 (0)