Skip to content

Commit 43fd961

Browse files
titaiwangmsCopilot
andauthored
Integrate ONNX 1.22.0 (opset 27) — issue #28752 (#28754)
### Integrate ONNX 1.22.0rc1 (opset 27) Resolves #28752. Pin: `onnx/onnx@bc3be77bec2f628788796dff60819186bacf49df` (VERSION_NUMBER `1.22.0rc1`). ONNX **1.21.0 → 1.22.0rc1**. Max ai.onnx opset **26 → 27**. IR version **unchanged (13 / `0x0D`)**. This is the **RC validation phase** of an incremental integration (same strategy as the ONNX 1.21 bump, #27601). The formal `v1.22.0` GitHub release is still a **draft** (no git tag yet), so re-pinning to the released tag is deferred to **Phase 2** (see Follow-ups). Landing the RC now validates ONNX 1.22 against ORT before ONNX publishes the formal release. --- ### Update — ONNX 1.22.0 **FINAL** re-pin + rebase onto `upstream/main` + closes #28969 ONNX published the formal **`v1.22.0`** GitHub release, so this PR is re-pinned **rc2 → FINAL** (`onnx/onnx@v1.22.0`) — the Phase-2 step deferred in the rc1 description below. The branch was also **rebased onto `upstream/main`** to pick up the intervening optimizer/opset-26 work. The released tag tarball is a different asset hash than the RCs, so the vcpkg MS-internal asset mirror was re-seeded for the final tag (otherwise `--use_vcpkg` legs 404). **Also closes #28969** (WebGPU binary-elementwise broadcast `SIZE_MAX` underflow). ONNX 1.22's expanded-Attention reference tests exposed a latent WebGPU bug where a broadcast shape computed `dim - 1` on a zero/unit dimension and underflowed to `SIZE_MAX`; the fix is included here and the previously-skipped reference tests are re-enabled. **Opset-27 `*CurrentOpset` test handling.** ONNX 1.22.0 FINAL ships `DomainToVersionRange` **map-max 27** while the last *released* opset is **26**, so **opset 27 stays under development** for the whole 1.22 cycle. Strict legs (the default, or `ALLOW_RELEASED_ONNX_OPSET_ONLY=1`) therefore throw *"Opset 27 under development"* at model load on every `*CurrentOpset` fusion test that builds at the max opset. These tests now load with per-model `ModelOptions{/*allow_released_opsets_only*/ false, /*strict_shape_type_inference*/ false}`, extending the existing `38f17243b` / GatherToSlice precedent to the rest of the `*CurrentOpset` suite. This is **leg-agnostic** (exercises opset 27 on every CI leg, not just the relaxed ones) and **preserves opset coverage** (vs. `GTEST_SKIP`). Each call site is annotated with a one-line WHY + tracking issue (#28966) so the relaxation can be removed once opset 27 is released. `Resolves #28752` (unchanged). Closes #28969. ### Update — ONNX 1.22.0rc2 re-pin + ConvTranspose conforms to ONNX `output_shape` spec Since the original rc1 description below, this PR was re-pinned **rc1 → rc2** (`onnx/onnx@b124e0188a`, `VERSION_NUMBER 1.22.0rc2`) to pick up the upstream Xcode/iOS CMake fix (onnx#8056). rc2 also carries onnx#8051, which tightened `convTransposeShapeInference` to reject an `output_shape`/`output_padding` whose size does not match the number of spatial dimensions (per the ONNX spec clarification onnx#5400). **ONNX Runtime now conforms to that spec** instead of patching ONNX to preserve a non-standard form. **⚠️ Breaking change — ConvTranspose `output_shape` now follows the ONNX spec (spatial dimensions only).** ORT previously also accepted a non-standard `rank + 2` form that included batch and channel, i.e. `(N, C, H, W)`. As of ONNX 1.22, a `rank + 2` `output_shape` on a ConvTranspose whose input has a **statically-known rank** is rejected at `Graph::Resolve` with *"Attribute output_shape has incorrect size"*. **Migration:** specify `output_shape` with spatial dimensions only — e.g. `{1, 1, 1, 14}` → `{1, 14}` (batch and channel are always inferred from the input and weight, so results are identical; the kernel ignores `N, C`). Models whose ConvTranspose input has a **dynamic/unknown rank are unaffected** — ONNX skips the size check and ORT computes the same result (covered by the new `ConvTranspose_RankPlus2_OutputShape_DynamicRankInput_Runtime` test). **Patch inventory — supersedes "2 files, 3 hunks" below.** `cmake/patches/onnx/onnx.patch` (and its byte-identical `binskim.patch` mirror) carries **only** the `ONNX_MINIMAL_BUILD` option hunk and the GroupNormalization-18 `.Deprecate()` removal — **no ConvTranspose hunks**. rc2's strict shape-inference check is kept as-is; ORT's own test models were conformed to the spec. The upstream archive hash, `deps.txt`, `portfile.cmake`, `vcpkg.json`, and the submodule pin are unchanged. **Additional rc2 test conform.** rc2 also tightened `convPoolShapeInference` to reject `Conv` inputs with rank < 3 (*"Input tensor must have at least 3 dimensions"*). The hand-authored model in `onnxruntime/test/python/quantization/test_op_split.py` declared a spec-invalid rank-2 `Conv` input/weight; it was conformed to a valid NCHW shape (`[6, 3]` → `[1, 1, 6, 3]`, weight → `[2, 1, 1, 1]`), keeping the quantized-Split graph and expected outputs identical. No ORT source change. > This note should also seed the GitHub Release notes for the ONNX 1.22 / opset 27 milestone and the squash-commit message. --- ### What changed (29 files) **Version plumbing** - `cmake/deps.txt` — onnx archive URL → rc1 commit zip + SHA1 `421e5a9afb6c41a54696e424e5b9a3796aab6821`. - `cmake/external/onnx` — submodule → `bc3be77b`. - `cmake/vcpkg-ports/onnx/portfile.cmake` — `REF` commit form + tar.gz SHA512 `e0c526f5…3ce467`. - `cmake/vcpkg-ports/onnx/vcpkg.json` — `version-semver` `1.22.0`, `port-version` 0. - `cmake/patches/onnx/onnx.patch` + `cmake/vcpkg-ports/onnx/binskim.patch` — **byte-identical** rebase onto 1.22 (2 files, 3 hunks): kept the `ONNX_MINIMAL_BUILD` option (restructured for 1.22's new `onnx_core` OBJECT-lib / `add_subdirectory(onnx)` layout) and the GroupNormalization-18 `.Deprecate()` removal; **dropped** the `Utils.cmake` protobuf-warnings hunk (already merged upstream in 1.22). **Opset-27 op enablement (Range)** - `onnxruntime/core/providers/cpu/generator/range.cc` — split into versioned `[11, 26]` + a new unversioned `27` registration. The opset-27 kernel natively supports the existing common numeric types (float/double/int16/int32/int64). **fp16 Range is covered** via ONNX's Range-27 **function body**, which ORT expands into primitive ops at partition time. **bf16 Range is deferred to that same function expansion** — there is no native bf16 kernel, and its bf16 reference node test (`test_range_bfloat16_type_positive_delta`, base + `_expanded`) is not exercised by the Python/numpy ONNX backend series, whose harness cannot materialize bf16 (`Numpy_type 256`); a native fp16/bf16 kernel + `stash_type` handling is a follow-up (efficiency, not correctness). - `onnxruntime/core/providers/cpu/cpu_execution_provider.cc` — versioned the Range forward-declare + `BuildKernelCreateInfo` entries and added the opset-27 registration. - **CUDA Range** — same versioned `[11, 26]` + opset-27 split as CPU (`onnxruntime/core/providers/cuda/generator/range.cc` + `cuda_execution_provider.cc`); GPU-verified locally: `onnx_test_runner -e cuda` 8/8 opset-27 Range node tests pass, native Range-27 placed on CUDAExecutionProvider (fp16/bf16 via function expansion). **Optimizer / EP opset ceilings** - `…/transpose_optimization/optimizer_api.h` — `kMaxSupportedOpset` **26 → 27**. - `coreml`/`nnapi`/`vsinpu`/`webnn` `base_op_builder.h` — `GetMaxSupportedOpSet()` **25 → 27** (upper guard only; per-op support checks still gate — these EPs gain no new kernels here). **Fusion updates** - `onnxruntime/core/optimizer/gather_fusion.cc` — GatherToSlice Range version list `{1,11}` → `{1,11,27}`. - `onnxruntime/core/optimizer/embed_layer_norm_fusion.cc` — add `27` to the two Range path-matchers (`parent_path_3/4`) so embedding fusion still matches opset-27 models. - `onnxruntime/test/optimizer/graph_transform_test.cc` — new opset-27 GatherToSliceFusion test. **Requirements (7 bumped)** - All 7 CI `requirements.txt` → `onnx==1.22.0rc1` (rc1 wheel is on PyPI). The 3 transformers pins remain frozen at `1.18.0` (unrelated to this bump; intentionally untouched). **Generated docs / test data** - `js/web/docs/webgl-operators.md` — regenerated. - `docs/OperatorKernels.md` — **surgical** edit: CPU EP **and** CUDA EP Range rows (`27+` + `[11, 26]` continuation each); see caveats. - `onnxruntime/test/testdata/onnx_backend_test_series_filters.jsonc` — **comment-only**: documents why no opset-27 CPU exclusions are needed (all opset-27 node tests pass via function expansion). **Docs** - `.agents/skills/onnx-opset-bump-checklist/SKILL.md` — new reusable checklist skill distilled from this integration. Now also documents the "bump **all** execution providers together" tradition (CPU + CUDA + JS/DML assessment in one pass) so future opset bumps don't ship a partial EP set. --- ### Validation (CPU EP + CUDA EP, Linux x64) - Full build ✅ - `--minimal_build extended` build ✅ (validates the rebased `ONNX_MINIMAL_BUILD` patch hunk independently of the vcpkg mirror path) - `onnxruntime_test_all` ✅ — **1595 passed / 0 failed** - `onnx_test_runner -e cpu` on the ONNX 1.22 opset-27 node tests ✅ — **62/62 pass** via ONNX function-body expansion (run with `ALLOW_RELEASED_ONNX_OPSET_ONLY=0`), including CausalConvWithState, LinearAttention, and fp16/bf16 Range — despite no native kernels for them. - **CUDA EP (H100):** built `--use_cuda` clean in both **Debug** and **RelWithDebInfo** ✅; `onnx_test_runner -e cuda` on the opset-27 Range node tests ✅ — **8/8 pass**, with native Range-27 placed on CUDAExecutionProvider (no CPU fallback) and fp16/bf16 covered via function-body expansion. --- ### Standing caveats (please read before reviewing) 1. **CUDA EP now locally verified for Range; other GPU EPs/ops still CI-only.** The CUDA EP was built and the opset-27 **Range** node tests run locally on an H100 (8/8 pass). DML and the remaining GPU EPs/ops were **not** exercised here. Function-body expansion is EP-agnostic, so other opset-27 models are expected to run on those EPs too, but broader GPU coverage remains a CI/follow-up item. 2. **`OperatorKernels.md` updated surgically** (CPU Range row only). A CPU-only *full* regen would destructively wipe the CUDA/DML/other-EP sections (the generator only emits rows for the EPs in the built module). A correct multi-EP regen needs a build per EP and is a follow-up. 3. **Opset 27 is "under development"** in ONNX's released-versions map. ORT's load-time validation rejects opset-27 models unless `ALLOW_RELEASED_ONNX_OPSET_ONLY=0` (ORT CI already sets this). The opset-27 **schemas are always compiled in from the submodule** regardless — this gate only affects model load-time acceptance, not schema availability. 4. **EP `GetMaxSupportedOpSet` jumped 25 → 27** (skips 26). This is an *upper* guard only; raising it merely lets opset-26/27 nodes reach the per-op support checks that still gate correctness. No regression — it also retroactively un-caps opset-26 for these EPs. 5. **iOS/macOS Xcode framework build is currently broken by an upstream ONNX CMake regression** (the `onnx_core` OBJECT-library split in onnx/onnx#7733 reintroduced the Xcode breakage originally fixed by onnx/onnx#7515 for onnx/onnx#7514). This is **NOT** caused by this opset bump. Tracked upstream at [onnx/onnx#8053](onnx/onnx#8053). Non-Xcode builds (Linux/Windows/Android/WASM) and all CPU/CUDA validation are unaffected. This resolves at the **Phase 2** formal `v1.22.0` re-pin once ONNX ships the fix. --- ### Follow-ups (explicitly NOT in this PR) - **GPU/multi-EP coverage:** run opset-27 CUDA/DML node tests; regenerate `OperatorKernels.md` across all EPs. - **JS EP Range** `[11, 26]` + `27` split (currently registered open-ended at `11`; mirror the CPU/CUDA versioned split). - **DML Range opset-27 assessment** (DML uses its own `REG_INFO` registration system — assess whether an opset-27 entry is needed). - **WebGPU EP Range** opset-27 split — `range.cc` registers `Range` `.SinceVersion(11)` open-ended, so it already claims opset-27 Range; only the new bf16 type is unsupported and falls back via the `T` type-constraint (function expansion). Mirror the CPU/CUDA versioned `[11, 26]` + `27` split. - **Native kernels:** implement CPU (and EP) `CausalConvWithState` and `LinearAttention` kernels, and a native fp16/bf16 + `stash_type` Range-27 kernel (replace today's function-expansion path with efficient kernels). - **Phase 2 — formal `v1.22.0` re-pin:** re-pin `deps.txt`/submodule/portfile/requirements to the released tag once ONNX publishes it (currently blocked on ONNX tagging the release); upload the tag tarball to the vcpkg mirror. **This also restores the iOS/macOS Xcode framework build** once the upstream onnx OBJECT-library Xcode regression (caveat 5) is resolved and re-pinned. - **Tooling:** fix the pre-existing crash in `find_optimizer_opset_version_updates_required.py` (placeholder `ver` parsed as int) so it can be relied on for future bumps. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent cbb7457 commit 43fd961

46 files changed

Lines changed: 1336 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/onnx-opset-bump-checklist/SKILL.md

Lines changed: 557 additions & 0 deletions
Large diffs are not rendered by default.

.agents/skills/ort-build/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ You do **not** need `--update` when only modifying existing `.cc`/`.h` files —
6565
| `--build_wheel` | Build the Python wheel package |
6666
| `--use_cuda` | Enable CUDA EP. Requires `--cuda_home`/`--cudnn_home` or `CUDA_HOME`/`CUDNN_HOME` env vars. On Windows, only `cuda_home`/`CUDA_HOME` is validated. |
6767
| `--target T` | Build a specific CMake target (requires `--build`; e.g., `onnxruntime_common`, `onnxruntime_test_all`) |
68+
| `--use_webgpu` | Enable WebGPU EP. To run its tests locally on Linux without a GPU, see the `webgpu-local-testing` skill. |
6869
| `--build_dir` | Build output directory |
6970

7071
## Build output path

.agents/skills/ort-test/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ Python test naming convention: `test_<method>_<expected_behavior>_[when_<conditi
7979
- **Redirect test output to a file** (e.g., `> test_output.txt 2>&1`) — output can be large.
8080
- For C++ tests, verify the build directory exists and a prior build completed before running.
8181
- Use `--gtest_filter` to run a targeted subset when the full suite takes too long.
82+
- **Running WebGPU tests locally on Linux without a GPU** — WebGPU op tests build into `onnxruntime_provider_test` and can run against a software Vulkan adapter (Mesa lavapipe). See the `webgpu-local-testing` skill.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
name: webgpu-local-testing
3+
description: Build and run ONNX Runtime WebGPU provider tests on Linux WITHOUT a real GPU, using a software Vulkan adapter (Mesa lavapipe). Use when you need to exercise WebGPU EP kernels off-Mac — the Linux webgpu CI leg is build-only, so software Vulkan is how you actually run WebGPU correctness tests locally. SCOPE: lavapipe only validates host-side enforce/shape bugs and MatMul-free kernels; any graph containing MatMul (including the expanded-Attention node tests) crashes lavapipe and runs ONLY on macOS-arm64 Metal, which is the source of truth for those. Covers install (dnf on Azure Linux), the --use_webgpu build flag, the onnxruntime_provider_test target, VK_ICD_FILENAMES, and the lavapipe MatMul crash gotcha.
4+
---
5+
6+
# Running ONNX Runtime WebGPU Tests Locally on Linux (No GPU)
7+
8+
Reusable knowledge for exercising the **WebGPU execution provider** on a Linux box
9+
with no physical GPU.
10+
11+
> **Scope**: Linux ORT WebGPU only. macOS uses the Metal backend and a real GPU;
12+
> this skill is the off-Mac story for running WebGPU EP kernels in CI-less dev loops.
13+
14+
## 1. Why software Vulkan is enough
15+
16+
On Linux, ORT's WebGPU EP runs on **Dawn** with the **Vulkan** backend. Vulkan does
17+
not require a hardware GPU — **Mesa lavapipe** is a software (CPU) Vulkan adapter that
18+
Dawn enumerates like any other device. For **EP correctness tests** this is sufficient
19+
because:
20+
21+
- Many host-side validation paths (shape/broadcast checks, `ORT_ENFORCE`s) fire
22+
**before** any shader is dispatched. E.g. the WebGPU broadcast `ORT_ENFORCE` runs
23+
host-side, so the failure is observable on a software adapter without ever touching
24+
the GPU.
25+
- Element-wise and broadcasting kernels that do dispatch run correctly (if slowly) on
26+
lavapipe, so their numeric output can be validated against the CPU reference.
27+
28+
You are trading speed for not needing hardware. It is **not** a substitute for a real
29+
GPU on perf-sensitive or driver-specific paths — but for kernel correctness it is the
30+
practical local loop.
31+
32+
> **Scope — what lavapipe can and cannot validate.** Software Vulkan covers (a)
33+
> **host-side** failures (shape/broadcast `ORT_ENFORCE`s that fire *before* any shader
34+
> dispatch) and (b) **MatMul-free** kernels that dispatch. It does **NOT** cover any
35+
> graph that contains a **MatMul** — the MatMul family crashes lavapipe's LLVM JIT (see
36+
> §5). This explicitly includes the motivating expanded-Attention node tests
37+
> (`test_attention_4d_softcap_neginf_mask_expanded`): they decompose to
38+
> `softmax(Q·Kᵀ + bias)·V`, which **contains MatMuls**, so they **cannot run on
39+
> lavapipe**. For those, **macOS-arm64 Metal is the source of truth**. Concretely, the
40+
> #28969 WebGPU broadcast-underflow fix was validated on lavapipe via a standalone
41+
> Add-broadcast `OpTester` proxy (a host-side enforce/shape path) — **NOT** via the
42+
> expanded-Attention node test. **Never** run lavapipe green and conclude an
43+
> Attention/MatMul fix is validated off-Mac.
44+
45+
## 2. Install the software Vulkan stack (Azure Linux — use `dnf`, NOT `apt`)
46+
47+
```bash
48+
dnf install -y mesa-vulkan-drivers vulkan-loader
49+
# optional, for sanity-checking the adapter:
50+
dnf install -y vulkan-tools && vulkaninfo | head
51+
```
52+
53+
`mesa-vulkan-drivers` provides lavapipe; `vulkan-loader` provides the ICD loader.
54+
The lavapipe ICD manifest lands at `/usr/share/vulkan/icd.d/lvp_icd.<arch>.json`
55+
`lvp_icd.x86_64.json` on x86_64, `lvp_icd.aarch64.json` on arm64. The examples below
56+
use the x86_64 name; substitute your arch, or glob it:
57+
`VK_ICD_FILENAMES=$(echo /usr/share/vulkan/icd.d/lvp_icd.*.json)`.
58+
59+
## 3. Build with `--use_webgpu`
60+
61+
```bash
62+
./build.sh --config Release --parallel --use_webgpu
63+
```
64+
65+
See the `ort-build` skill for general build phases and flags.
66+
67+
## 4. Run the WebGPU provider tests
68+
69+
WebGPU operator/kernel tests are **provider op tests** — they build into the
70+
`onnxruntime_provider_test` target (**NOT** `onnxruntime_test_all`; see the `ort-test`
71+
skill for the executable taxonomy). Point the Vulkan loader at the lavapipe ICD and
72+
select a subset with `--gtest_filter`:
73+
74+
```bash
75+
cd build/Linux/Release
76+
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
77+
./onnxruntime_provider_test --gtest_filter="*WebGPU*"
78+
```
79+
80+
`VK_ICD_FILENAMES` forces Vulkan to load **only** lavapipe, so the run is
81+
deterministic regardless of what else is installed.
82+
83+
## 5. Gotcha: lavapipe crashes on the MatMul family
84+
85+
`MathOpTest.MatMulFloatType` (and other MatMul-family tests) crash lavapipe with:
86+
87+
```
88+
LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations
89+
```
90+
91+
This is a **pre-existing limitation of software Vulkan (Mesa lavapipe's LLVM JIT)**,
92+
not an ORT bug. **Exclude the MatMul family** from broad lavapipe runs:
93+
94+
```bash
95+
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
96+
./onnxruntime_provider_test --gtest_filter="*WebGPU*:-*MatMul*"
97+
```
98+
99+
## 6. Why this matters: the Linux webgpu CI leg is build-only
100+
101+
The Linux webgpu CI leg (`py-linux-webgpu-stage.yml`) **only builds** — it does not run
102+
WebGPU kernels. A green Linux webgpu leg therefore does **not** mean any WebGPU test
103+
actually executed. The macOS-arm64 webgpu leg is the only CI leg that runs WebGPU
104+
backend node tests. So a local lavapipe run is the practical way to **actually exercise
105+
WebGPU kernels off-Mac** before you push.
106+
107+
But mind the §1 scope: lavapipe covers host-side enforce/shape paths and **MatMul-free**
108+
kernels only. Any **MatMul-containing** graph — including the expanded-Attention node
109+
tests (`test_attention_4d_softcap_neginf_mask_expanded`) — crashes lavapipe and runs
110+
**only** on the macOS-arm64 Metal leg, which is the source of truth for those. A green
111+
lavapipe run never validates a MatMul/Attention fix off-Mac.

cmake/deps.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ microsoft_gsl;https://github.com/microsoft/GSL/archive/refs/tags/v4.2.1.zip;1094
3434
microsoft_wil;https://github.com/microsoft/wil/archive/refs/tags/v1.0.250325.1.zip;826c8bd47c2258ec61b8b218e031e5b33d27f761
3535
mimalloc;https://github.com/microsoft/mimalloc/archive/refs/tags/v2.1.1.zip;d5ee7d34223d0567892db5179849939c8769dc41
3636
mp11;https://github.com/boostorg/mp11/archive/refs/tags/boost-1.82.0.zip;9bc9e01dffb64d9e0773b2e44d2f22c51aace063
37-
onnx;https://github.com/onnx/onnx/archive/refs/tags/v1.21.0.zip;321d4acc807c8e0fb0bbcc0424a143dffde1e846
37+
# ONNX pinned to the 1.22.0 final release (tag v1.22.0). rc2->final changed only CI
38+
# workflow yml + VERSION_NUMBER (no operator-schema, opset, or testdata change), so it is
39+
# pure version plumbing. The 7 CI requirements.txt files are pinned to onnx==1.22.0 (now on PyPI).
40+
onnx;https://github.com/onnx/onnx/archive/refs/tags/v1.22.0.zip;2b2cd58ac7a26df5371266149e0c76776330cdf1
3841
# Use the latest commit of 10.9-GA
3942
onnx_tensorrt;https://github.com/onnx/onnx-tensorrt/archive/d5dce67db7c2e64b07e055571f5ec06f7f254de2.zip;01114d3b67650857281fa50faa2e412130a63b69
4043
protobuf;https://github.com/protocolbuffers/protobuf/archive/refs/tags/v21.12.zip;7cf2733949036c7d52fda017badcab093fe73bfa

cmake/external/onnx

Submodule onnx updated 978 files

cmake/patches/onnx/onnx.patch

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,44 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 044996e..ded7e39 100644
2+
index 791e24b..5f861a1 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -53,6 +53,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
6-
option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
5+
@@ -46,6 +46,7 @@ option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
76
option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for ONNX operator schemas." OFF)
87
option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
8+
option(ONNX_PYODIDE_BUILD "Build ONNX for Pyodide/Emscripten (wasm32)." OFF)
99
+option(ONNX_MINIMAL_BUILD "Build only essential ONNX components" OFF)
1010
option(ONNX_INSTALL "Install ONNX targets, headers, and CMake config files" ON)
1111
if(WIN32)
12-
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime" OFF)
13-
@@ -399,14 +400,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14-
onnx/onnx-operators.in.proto
15-
onnx/onnx-data.in.proto)
16-
17-
-file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
18-
-file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
19-
- "${ONNX_ROOT}/onnx/test/cpp/*.cc"
20-
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
21-
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
22-
-list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
23-
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
24-
-list(APPEND ONNX_SRCS ${__tmp_srcs})
12+
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime. Ignored if CMAKE_MSVC_RUNTIME_LIBRARY is defined." OFF)
13+
@@ -515,7 +516,22 @@ add_dependencies(onnx_proto onnx_proto_gen)
14+
# Core library. Hand-written sources come from target_sources(onnx ...) in the
15+
# subdirectories; the protobuf objects are pulled in from onnx_proto.
16+
add_library(onnx $<TARGET_OBJECTS:onnx_proto>)
17+
-add_subdirectory(onnx)
2518
+if(ONNX_MINIMAL_BUILD)
2619
+ message(STATUS "Configuring ONNX minimal build")
27-
+ set(ONNX_SRCS
28-
+ "${ONNX_ROOT}/onnx/common/common.h"
29-
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.h"
30-
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.cc"
20+
+ # ORT's minimal/WebAssembly builds only need ONNX's type utilities and the
21+
+ # generated protobuf sources (linked via onnx_proto above); skip pulling in
22+
+ # the full operator/schema sources via add_subdirectory(onnx).
23+
+ target_sources(onnx PRIVATE
24+
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.cc"
3125
+ )
3226
+ # Ensure ONNX_ML is treated as ON for minimal build consistency with ORT's file
3327
+ set(ONNX_ML ON CACHE BOOL "Enable traditional ML API." FORCE)
3428
+ # Minimal build doesn't need Python or tests
3529
+ set(ONNX_BUILD_PYTHON OFF CACHE BOOL "Build Python binaries" FORCE)
3630
+ set(ONNX_BUILD_TESTS OFF CACHE BOOL "Build ONNX C++ APIs Tests" FORCE)
3731
+else()
38-
+ file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
39-
+ file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
40-
+ "${ONNX_ROOT}/onnx/test/cpp/*.cc"
41-
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
42-
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
43-
+ list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
44-
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
45-
+ list(APPEND ONNX_SRCS ${__tmp_srcs})
32+
+ add_subdirectory(onnx)
4633
+endif()
47-
48-
set(LINKED_PROTOBUF_TARGET protobuf::libprotobuf)
49-
if(ONNX_USE_LITE_PROTO)
50-
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
51-
index 1987edd..04b3088 100644
52-
--- a/cmake/Utils.cmake
53-
+++ b/cmake/Utils.cmake
54-
@@ -103,18 +103,7 @@ endfunction()
55-
56-
function(add_onnx_compile_options target)
57-
if(MSVC)
58-
- # For disabling Protobuf related warnings
59-
- set(protobuf_warnings
60-
- /wd4146 # unary minus operator applied to unsigned type, result still
61-
- # unsigned
62-
- /wd4244 # 'argument': conversion from 'google::protobuf::uint64' to
63-
- # 'int', possible loss of data
64-
- /wd4267 # Conversion from 'size_t' to 'int', possible loss of data
65-
- /wd4141 # 'inline': used more than once
66-
- /wd4047 # '=': 'uintptr_t' differs in levels of indirection from 'void *'
67-
- )
68-
add_msvc_runtime_flag(${target})
69-
- target_compile_options(${target} PUBLIC ${protobuf_warnings})
70-
if(ONNX_WERROR)
71-
target_compile_options(${target} PRIVATE "/WX")
72-
endif()
34+
add_dependencies(onnx onnx_proto)
35+
set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET hidden)
36+
add_onnx_global_defines(onnx)
7337
diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
74-
index a6a8a83..153da87 100644
38+
index 3887169..8432613 100644
7539
--- a/onnx/defs/nn/old.cc
7640
+++ b/onnx/defs/nn/old.cc
77-
@@ -4026,7 +4026,6 @@ ONNX_OPERATOR_SET_SCHEMA(
41+
@@ -4078,7 +4078,6 @@ ONNX_OPERATOR_SET_SCHEMA(
7842
GroupNormalization,
7943
18,
8044
OpSchema()

cmake/vcpkg-ports/onnx/binskim.patch

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,44 @@
11
diff --git a/CMakeLists.txt b/CMakeLists.txt
2-
index 044996e..ded7e39 100644
2+
index 791e24b..5f861a1 100644
33
--- a/CMakeLists.txt
44
+++ b/CMakeLists.txt
5-
@@ -53,6 +53,7 @@ option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
6-
option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
5+
@@ -46,6 +46,7 @@ option(ONNX_DISABLE_EXCEPTIONS "Disable exception handling." OFF)
76
option(ONNX_DISABLE_STATIC_REGISTRATION "Disable static registration for ONNX operator schemas." OFF)
87
option(ONNX_USE_UNITY_BUILD "Enable Unity (Jumbo) build for" OFF)
8+
option(ONNX_PYODIDE_BUILD "Build ONNX for Pyodide/Emscripten (wasm32)." OFF)
99
+option(ONNX_MINIMAL_BUILD "Build only essential ONNX components" OFF)
1010
option(ONNX_INSTALL "Install ONNX targets, headers, and CMake config files" ON)
1111
if(WIN32)
12-
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime" OFF)
13-
@@ -399,14 +400,28 @@ relative_protobuf_generate_cpp(ONNX_PROTO_SRCS
14-
onnx/onnx-operators.in.proto
15-
onnx/onnx-data.in.proto)
16-
17-
-file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
18-
-file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
19-
- "${ONNX_ROOT}/onnx/test/cpp/*.cc"
20-
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
21-
- "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
22-
-list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
23-
-list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
24-
-list(APPEND ONNX_SRCS ${__tmp_srcs})
12+
option(ONNX_USE_MSVC_STATIC_RUNTIME "Build with MSVC static runtime. Ignored if CMAKE_MSVC_RUNTIME_LIBRARY is defined." OFF)
13+
@@ -515,7 +516,22 @@ add_dependencies(onnx_proto onnx_proto_gen)
14+
# Core library. Hand-written sources come from target_sources(onnx ...) in the
15+
# subdirectories; the protobuf objects are pulled in from onnx_proto.
16+
add_library(onnx $<TARGET_OBJECTS:onnx_proto>)
17+
-add_subdirectory(onnx)
2518
+if(ONNX_MINIMAL_BUILD)
2619
+ message(STATUS "Configuring ONNX minimal build")
27-
+ set(ONNX_SRCS
28-
+ "${ONNX_ROOT}/onnx/common/common.h"
29-
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.h"
30-
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.cc"
20+
+ # ORT's minimal/WebAssembly builds only need ONNX's type utilities and the
21+
+ # generated protobuf sources (linked via onnx_proto above); skip pulling in
22+
+ # the full operator/schema sources via add_subdirectory(onnx).
23+
+ target_sources(onnx PRIVATE
24+
+ "${ONNX_ROOT}/onnx/defs/data_type_utils.cc"
3125
+ )
3226
+ # Ensure ONNX_ML is treated as ON for minimal build consistency with ORT's file
3327
+ set(ONNX_ML ON CACHE BOOL "Enable traditional ML API." FORCE)
3428
+ # Minimal build doesn't need Python or tests
3529
+ set(ONNX_BUILD_PYTHON OFF CACHE BOOL "Build Python binaries" FORCE)
3630
+ set(ONNX_BUILD_TESTS OFF CACHE BOOL "Build ONNX C++ APIs Tests" FORCE)
3731
+else()
38-
+ file(GLOB_RECURSE __tmp_srcs "${ONNX_ROOT}/onnx/*.h" "${ONNX_ROOT}/onnx/*.cc")
39-
+ file(GLOB_RECURSE onnx_gtests_src "${ONNX_ROOT}/onnx/test/cpp/*.h"
40-
+ "${ONNX_ROOT}/onnx/test/cpp/*.cc"
41-
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.cc"
42-
+ "${ONNX_ROOT}/onnx/backend/test/cpp/*.h")
43-
+ list(REMOVE_ITEM __tmp_srcs "${ONNX_ROOT}/onnx/cpp2py_export.cc")
44-
+ list(REMOVE_ITEM __tmp_srcs ${onnx_gtests_src} "${ONNX_ROOT}/onnx/test/cmake/main.cc")
45-
+ list(APPEND ONNX_SRCS ${__tmp_srcs})
32+
+ add_subdirectory(onnx)
4633
+endif()
47-
48-
set(LINKED_PROTOBUF_TARGET protobuf::libprotobuf)
49-
if(ONNX_USE_LITE_PROTO)
50-
diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake
51-
index 1987edd..04b3088 100644
52-
--- a/cmake/Utils.cmake
53-
+++ b/cmake/Utils.cmake
54-
@@ -103,18 +103,7 @@ endfunction()
55-
56-
function(add_onnx_compile_options target)
57-
if(MSVC)
58-
- # For disabling Protobuf related warnings
59-
- set(protobuf_warnings
60-
- /wd4146 # unary minus operator applied to unsigned type, result still
61-
- # unsigned
62-
- /wd4244 # 'argument': conversion from 'google::protobuf::uint64' to
63-
- # 'int', possible loss of data
64-
- /wd4267 # Conversion from 'size_t' to 'int', possible loss of data
65-
- /wd4141 # 'inline': used more than once
66-
- /wd4047 # '=': 'uintptr_t' differs in levels of indirection from 'void *'
67-
- )
68-
add_msvc_runtime_flag(${target})
69-
- target_compile_options(${target} PUBLIC ${protobuf_warnings})
70-
if(ONNX_WERROR)
71-
target_compile_options(${target} PRIVATE "/WX")
72-
endif()
34+
add_dependencies(onnx onnx_proto)
35+
set_target_properties(onnx PROPERTIES CXX_VISIBILITY_PRESET hidden)
36+
add_onnx_global_defines(onnx)
7337
diff --git a/onnx/defs/nn/old.cc b/onnx/defs/nn/old.cc
74-
index a6a8a83..153da87 100644
38+
index 3887169..8432613 100644
7539
--- a/onnx/defs/nn/old.cc
7640
+++ b/onnx/defs/nn/old.cc
77-
@@ -4026,7 +4026,6 @@ ONNX_OPERATOR_SET_SCHEMA(
41+
@@ -4078,7 +4078,6 @@ ONNX_OPERATOR_SET_SCHEMA(
7842
GroupNormalization,
7943
18,
8044
OpSchema()

cmake/vcpkg-ports/onnx/portfile.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
33
vcpkg_from_github(
44
OUT_SOURCE_PATH SOURCE_PATH
55
REPO onnx/onnx
6-
REF "v${VERSION}"
7-
SHA512 3cee4c0fbc9e260e360a62a59e324e0b127a5749f958e0704989b407a4c1179c637ef86e41a406e7868537a62a11a821e3433005eb0725f979145f8d514926bd
6+
REF "v1.22.0"
7+
SHA512 13fafff073a8e0bcf67fd06195da979c3c6273b3f5fdd25f5e5c39ad6af20eefe107f13dc73d52b6021e986d87401e46121e00bba8fbd09f098334e34f78462f
88
PATCHES
99
fix-cmakelists.patch
1010
fix-dependency-protobuf.patch

cmake/vcpkg-ports/onnx/vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "onnx",
3-
"version-semver": "1.21.0",
3+
"version-semver": "1.22.0",
44
"port-version": 0,
55
"description": "Open standard for machine learning interoperability",
66
"homepage": "https://onnx.ai",

0 commit comments

Comments
 (0)