Skip to content

Commit 6f5142a

Browse files
committed
Update onnxruntime to 1.17.1
1 parent f2ff599 commit 6f5142a

File tree

3 files changed

+104
-82
lines changed

3 files changed

+104
-82
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[[rules]]
2-
version = '== 1.14.1'
3-
patch = 'onnxruntime-1.14.1.patch'
2+
version = '== 1.17.1'
3+
patch = 'onnxruntime-1.17.1.patch'
44
dist-type = 'sdist'
55

66
[[add-sources]]
7-
version = '1.14.1'
8-
url = 'https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.14.1.tar.gz'
7+
version = '1.17.1'
8+
url = 'https://github.com/microsoft/onnxruntime/archive/refs/tags/v1.17.1.tar.gz'

graalpython/lib-graalpython/patches/onnxruntime/onnxruntime-1.14.1.patch

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
2+
index 94d650f..62ffee7 100644
3+
--- a/cmake/CMakeLists.txt
4+
+++ b/cmake/CMakeLists.txt
5+
@@ -54,6 +54,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
6+
enable_testing()
7+
include(Dart)
8+
9+
+set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-error=array-bounds -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict -Wno-error=unused-but-set-variable -Wno-error=overloaded-virtual")
10+
+
11+
if (NOT CMAKE_BUILD_TYPE)
12+
message(STATUS "Build type not set - using RelWithDebInfo")
13+
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo MinSizeRel." FORCE)
14+
diff --git a/onnxruntime_build_backend.py b/onnxruntime_build_backend.py
15+
new file mode 100644
16+
index 0000000..dac866e
17+
--- /dev/null
18+
+++ b/onnxruntime_build_backend.py
19+
@@ -0,0 +1,52 @@
20+
+import os
21+
+import re
22+
+import sys
23+
+import tarfile
24+
+import subprocess
25+
+import tempfile
26+
+import shutil
27+
+from pathlib import Path
28+
+
29+
+
30+
+def build_sdist(sdist_directory, config_settings=None):
31+
+ nv = 'onnxruntime-1.17.1'
32+
+ srcdir = Path(__file__).parent
33+
+ archive_path = Path(sdist_directory) / f'{nv}.tar.gz'
34+
+
35+
+ def tarfilter(info):
36+
+ if re.match(r'\./(?:.git|venv|[^-/]+-venv|dist)', info.name):
37+
+ return None
38+
+ info.name = f'./{nv}/{info.name}'
39+
+ return info
40+
+
41+
+ with tarfile.open(archive_path, 'w:gz') as tar:
42+
+ tar.add('.', filter=tarfilter)
43+
+ return archive_path.name
44+
+
45+
+
46+
+def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
47+
+ wheel_directory = Path(wheel_directory).absolute()
48+
+ builddir = Path('build/Release')
49+
+ parallel = os.environ.get('CMAKE_BUILD_PARALLEL_LEVEL', os.cpu_count())
50+
+ build_cmd = [
51+
+ sys.executable,
52+
+ 'tools/ci_build/build.py',
53+
+ '--build_dir', 'build',
54+
+ '--build_wheel',
55+
+ '--skip_submodule_sync',
56+
+ '--skip_tests',
57+
+ '--config', 'Release',
58+
+ '--enable_pybind',
59+
+ '--parallel', str(parallel),
60+
+ ]
61+
+ subprocess.check_call(build_cmd)
62+
+ if sys.implementation.name == 'graalpy':
63+
+ # The cmake build downloads a bunch of sources that need to be patched
64+
+ subprocess.check_call([sys.executable, '-m', 'autopatch_capi', '.'])
65+
+ # Rerun to rebuild the patched sources
66+
+ subprocess.check_call(build_cmd)
67+
+ wheels = list((builddir / 'dist').glob('*.whl'))
68+
+ assert len(wheels) == 1, f"Expected 1 wheel, found {len(wheels)}"
69+
+ wheel = wheels[0]
70+
+ shutil.copyfile(wheel, wheel_directory / wheel.name)
71+
+ return str(wheel.name)
72+
diff --git a/pyproject.toml b/pyproject.toml
73+
index 97515cb..143790d 100644
74+
--- a/pyproject.toml
75+
+++ b/pyproject.toml
76+
@@ -1,3 +1,8 @@
77+
+[build-system]
78+
+requires = ["setuptools >= 40.6.0", "wheel", "packaging", "numpy>=1.24.2"]
79+
+build-backend = "onnxruntime_build_backend"
80+
+backend-path = ["."]
81+
+
82+
[tool.black]
83+
line-length = 120
84+
# NOTE: Do not extend the exclude list. Edit .lintrunner.toml instead
85+
diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py
86+
index 31f242c..300211b 100644
87+
--- a/tools/ci_build/build.py
88+
+++ b/tools/ci_build/build.py
89+
@@ -1266,6 +1266,11 @@ def generate_build_tree(
90+
"-Ddml_EXTERNAL_PROJECT=ON",
91+
]
92+
93+
+ if not args.test:
94+
+ cmake_args += [
95+
+ "-Donnxruntime_BUILD_UNIT_TESTS=OFF",
96+
+ ]
97+
+
98+
if args.use_gdk:
99+
cmake_args += [
100+
"-DCMAKE_TOOLCHAIN_FILE=" + os.path.join(source_dir, "cmake", "gdk_toolchain.cmake"),

0 commit comments

Comments
 (0)