Skip to content

Commit 4dc4f72

Browse files
committed
onnxsim: carry forward riscv64 patches to 0.8.1
Nightly version bump omitted the patches/onnxsim/<version> directory for 0.8.1, so the build's unconditional `git apply .../*.patch` step failed with "No such file or directory" before any build/test ran. Copied forward the same patch set from 0.7.3 (unchanged since then).
1 parent 3096be6 commit 4dc4f72

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Ludovic Henry <git@ludovic.dev>
3+
Date: Thu, 24 Sep 2026 00:00:00 +0000
4+
Subject: [PATCH] tests: pin ir_version in test_profiling's _foldable_model
5+
6+
Every other test file that builds an onnx.ModelProto by hand pins
7+
ir_version explicitly (test_python_api.py, test_function_rewriter.py,
8+
test_constant_fold_determinism.py, etc. all pass ir_version=... to
9+
helper.make_model()). test_profiling.py's _foldable_model() is the one
10+
holdout: it calls helper.make_model(graph, opset_imports=[...]) with no
11+
ir_version, so the model is stamped with whatever onnx.IR_VERSION the
12+
currently installed onnx package defines.
13+
14+
onnxsim statically links a vendored onnx (via the onnx-optimizer git
15+
submodule, frozen at a pinned commit) into its C++ core, and that
16+
core's checker enforces its own, older notion of the max supported IR
17+
version. Once the *installed* onnx package (an unpinned "onnx" runtime
18+
dependency in pyproject.toml) is newer than whatever onnx-optimizer's
19+
submodule was pinned to at release time, every one of
20+
_foldable_model()'s callers in this file fails identically:
21+
22+
RuntimeError: Your model ir_version 14 is higher than the
23+
checker's (13).
24+
25+
before reaching any of what the test actually means to check (the
26+
profiler's spans, the OrtSession nesting, the env var save/restore).
27+
This is a real ambient-versioning gap, not a riscv64-only symptom: the
28+
same break reproduces on any platform the moment pip resolves an onnx
29+
release newer than the vendored submodule tolerates, which is exactly
30+
why every sibling test file already pins ir_version defensively -
31+
test_profiling.py just missed doing the same for its one hand-built
32+
model.
33+
34+
Match the existing convention used throughout the suite (ir_version=10
35+
regardless of opset) so the fixture stays valid across the wide range
36+
of onnx versions the unpinned runtime dependency can resolve to.
37+
38+
Upstream-Status: To upstream [no push/issue access to onnxsim/onnxsim from this environment - only riseproject-dev/python-wheels is attached; the fix is a one-line ir_version pin matching every sibling test file's existing convention]
39+
40+
Signed-off-by: Ludovic Henry <git@ludovic.dev>
41+
---
42+
diff --git a/tests/test_profiling.py b/tests/test_profiling.py
43+
--- a/tests/test_profiling.py
44+
+++ b/tests/test_profiling.py
45+
@@ -29,7 +29,18 @@
46+
x = helper.make_tensor_value_info("x", TensorProto.FLOAT, [1, 4])
47+
y = helper.make_tensor_value_info("y", TensorProto.FLOAT, [1, 4])
48+
graph = helper.make_graph([add_const, add_x], "g", [x], [y], [a, b])
49+
- model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 17)])
50+
+ model = helper.make_model(
51+
+ graph,
52+
+ opset_imports=[helper.make_opsetid("", 17)],
53+
+ # Pin ir_version like every other model-building test in this suite
54+
+ # already does (test_python_api.py, test_function_rewriter.py, etc.):
55+
+ # onnx.helper.make_model() otherwise stamps the installed onnx package's
56+
+ # current onnx.IR_VERSION, which floats upward with each onnx release and
57+
+ # can exceed what the vendored onnx-optimizer/onnx submodule's checker
58+
+ # (frozen at a pinned commit) accepts, e.g. "Your model ir_version 14 is
59+
+ # higher than the checker's (13)" once a newer onnx is installed.
60+
+ ir_version=10,
61+
+ )
62+
onnx.checker.check_model(model)
63+
return model
64+

0 commit comments

Comments
 (0)