Skip to content

Commit f8dd690

Browse files
committed
onnxruntime 1.20.0
1 parent 61a22e4 commit f8dd690

File tree

1 file changed

+81
-11
lines changed

1 file changed

+81
-11
lines changed

Formula/o/onnxruntime.rb

Lines changed: 81 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,78 @@ 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 "[email protected]" => :build
31+
depends_on "safeint" => :build
32+
depends_on "abseil"
33+
depends_on "nsync"
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
57+
58+
# Fix build on Linux
59+
# TODO: Upstream if it works
60+
patch :DATA
2861

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

38-
system "cmake", "-S", "cmake", "-B", "build", *cmake_args, *std_cmake_args
90+
# Regenerate C++ bindings to use newer `flatbuffers`
91+
flatc = Formula["flatbuffers"].opt_bin/"flatc"
92+
system python3, "onnxruntime/core/flatbuffers/schema/compile_schema.py", "--flatc", flatc
93+
system python3, "onnxruntime/lora/adapter_format/compile_schema.py", "--flatc", flatc
94+
95+
system "cmake", "-S", "cmake", "-B", "build", *args, *std_cmake_args
3996
system "cmake", "--build", "build"
4097
system "cmake", "--install", "build"
4198
end
@@ -50,8 +107,21 @@ def install
50107
return 0;
51108
}
52109
C
53-
system ENV.cc, "-I#{include}", testpath/"test.c",
54-
"-L#{lib}", "-lonnxruntime", "-o", testpath/"test"
110+
system ENV.cc, "-I#{include}", "test.c", "-L#{lib}", "-lonnxruntime", "-o", "test"
55111
assert_equal version, shell_output("./test").strip
56112
end
57113
end
114+
115+
__END__
116+
diff --git a/onnxruntime/core/optimizer/transpose_optimization/onnx_transpose_optimization.cc b/onnxruntime/core/optimizer/transpose_optimization/onnx_transpose_optimization.cc
117+
index 470838d36e..81a842eb87 100644
118+
--- a/onnxruntime/core/optimizer/transpose_optimization/onnx_transpose_optimization.cc
119+
+++ b/onnxruntime/core/optimizer/transpose_optimization/onnx_transpose_optimization.cc
120+
@@ -5,6 +5,7 @@
121+
122+
#include <algorithm>
123+
#include <cassert>
124+
+#include <cstring>
125+
#include <iostream>
126+
#include <memory>
127+
#include <unordered_map>

0 commit comments

Comments
 (0)