Files
wehub-resource-sync 5cbd3f29e3
clang-tidy / clang-tidy (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Copilot Setup Steps / copilot-setup-steps (push) Waiting to run
Lint / Validate SBOM (push) Waiting to run
Lint / Enforce style (push) Waiting to run
CI / Test windows-2022, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test windows-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test windows-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test windows-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14, Internal, debug=1, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=1, onnx_ml=1, autogen=1 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=0, autogen=0 (push) Waiting to run
CI / Test macos-latest, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test macos-latest, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test macos-latest, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14, External, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.10, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
CI / Test ubuntu-24.04, 3.14t, Internal, debug=0, unity_build=0, onnx_ml=1, autogen=0 (push) Waiting to run
Generate and publish ONNX docs / build (push) Waiting to run
Generate and publish ONNX docs / deploy (push) Blocked by required conditions
Pixi CI / Install and lint (ubuntu-24.04-arm) (push) Waiting to run
Pixi CI / Install and lint (windows-2022) (push) Waiting to run
Pixi CI / Xcode generator build (push) Waiting to run
Pixi CI / Install and test (macos-latest, default) (push) Waiting to run
Pixi CI / Install and test (ubuntu-24.04-arm, default) (push) Waiting to run
Pixi CI / Install and test (ubuntu-latest, default) (push) Waiting to run
Pixi CI / Install and test (windows-2022, default) (push) Waiting to run
Pixi CI / Install and test (macos-latest, oldies) (push) Waiting to run
Pixi CI / Install and test (ubuntu-24.04-arm, oldies) (push) Waiting to run
Pixi CI / Install and test (ubuntu-latest, oldies) (push) Waiting to run
Pixi CI / Install and test (windows-2022, oldies) (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Fuzz / Run fuzz harnesses (${{ github.event_name == 'schedule' && 'nightly' || 'smoke' }}) (push) Has been cancelled
Create Releases / call-mac (push) Has been cancelled
Create Releases / call-linux (push) Has been cancelled
Create Releases / call-sdist (push) Has been cancelled
Create Releases / call-win (push) Has been cancelled
Create Releases / call-pyodide (push) Has been cancelled
Windows_No_Exception_CI / build (x64, 3.10) (push) Has been cancelled
Check URLs / build (push) Has been cancelled
Create Releases / Attest CI build artifacts (push) Has been cancelled
Create Releases / Check for Publish release build to pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to test.pypi-weekly (push) Has been cancelled
Create Releases / Check for Publish release build to test.pypi (rc-candidates) (push) Has been cancelled
Create Releases / Publish release build to test.pypi (push) Has been cancelled
Create Releases / Check for Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish preview build to pypi-weekly (push) Has been cancelled
Create Releases / Publish release build to pypi (push) Has been cancelled
Create Releases / test source distribution (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:41:19 +08:00

3.6 KiB

CLAUDE.md — ONNX Project Guide

ONNX (Open Neural Network Exchange) — open-source standard format for AI models. Python + C++ codebase using protobuf for serialization. Builds and runs on Linux, macOS, and Windows — keep all three platforms in mind when making changes.

Also follow the shared AI assistant guidelines in .github/copilot-instructions.md.

Project Norms

  • Follow the ONNX Code of Conduct. All generated code, comments, commit messages, and PR descriptions must be professional, welcoming, and free of hostile, discriminatory, or demeaning language.
  • ONNX is an open standard — changes to operator definitions, proto schemas, or the IR spec affect the entire ML ecosystem. Be conservative and deliberate with spec-level changes.
  • Stay vendor-neutral. Do not favor any specific framework, runtime, or hardware in code or comments.
  • Preserve backward compatibility. Breaking changes to the spec or public API have outsized impact across the ecosystem.
  • Match existing code patterns and conventions — read surrounding code before making changes.
  • Keep PRs focused. Do not bundle unrelated changes or refactor code outside the scope of the task.
  • New operators must follow the process in docs/AddNewOp.md.

Build

pip install -e . -v                        # Development install
ONNX_BUILD_TESTS=1 pip install -e . -v     # With C++ tests

Pure Python changes take effect immediately in editable installs. C++ changes require rebuild.

Testing

pytest                                      # All Python tests

# C++ tests (build with ONNX_BUILD_TESTS=1 first)
# Linux/macOS:
LD_LIBRARY_PATH=./.setuptools-cmake-build/ .setuptools-cmake-build/onnx_gtests
# Windows:
.setuptools-cmake-build\Release\onnx_gtests.exe

Tests live in onnx/test/ with *_test.py naming.

Linting

lintrunner init    # First-time setup
lintrunner         # Lint changed files
lintrunner -a      # Auto-fix

Runs ruff, mypy, clang-format, editorconfig-checker, and a namespace checker.

Code Conventions

  • All Python files require from __future__ import annotations
  • No relative imports — use absolute imports from onnx
  • Copyright header on all files: # Copyright (c) ONNX Project Contributors + # SPDX-License-Identifier: Apache-2.0
  • DCO sign-off required on all commits (git commit -s)

Auto-Generated Files (Do Not Edit)

Edit the source, then regenerate. CI verifies these are up to date.

Generated files Source of truth Regenerate with
docs/Operators.md, docs/Changelog.md, docs/TestCoverage.md Op schemas in onnx/defs/ python onnx/defs/gen_doc.py
onnx/*_pb2.py, onnx/*_pb.h, onnx/onnx_data.proto onnx/onnx.in.proto, onnx/onnx-ml.in.proto python onnx/gen_proto.py
onnx/backend/test/data/ node tests Op schemas + reference impl python onnx/backend/test/stat_coverage.py

Edit .in.proto files, not .proto files. When adding/changing operator schemas, run all three scripts.

C++/Python Boundary

Core validation (checker), shape inference, and version conversion are C++ exposed via nanobind (onnx_cpp2py_export/). Operator schemas are defined in C++ under onnx/defs/. Helper utilities, reference implementation, parser, and compose are pure Python.

ONNX_ML flag (on by default): controls traditional ML types (sequences, maps, sparse tensors). When enabled, builds use onnx-ml.in.proto instead of onnx.in.proto.

Build artifacts go to .setuptools-cmake-build/.