onnxruntime
AGENTS.md22k starsChanged 3 months agoMITView on GitHub
This file contains repository-wide guidance for coding agents. See Extending Agent Coding Guidance when adding or updating guidance. Before implementing or reviewing changes, inspect .github/instructions/**/*.instructions.md and parse each file's applyTo scope. Apply every instruction whose scope matches any target or changed path. Unless explicitly stated otherwise, matching instructions apply to both implementation and review. Repository skills are available in .github/skills. Load each skill whose description matches the requested task, subsystem, or behavior. For code reviews, follow the /code-review skill in…
Trending
Less talk lately.about the whole repository
Who's talking about microsoft/onnxruntime
- A Hacker News story“ONNX Runtime merges WebGPU backend”Hacker News · Apr 24, 2023 · 178 points
- immich-app/immich“feat(ml): introduce support of onnxruntime-rocm for AMD GPU”GitHub · Jul 12, 2024 · 28 reactions
- Unstructured-IO/unstructured“feat/numpy_2”GitHub · Oct 1, 2024 · 17 reactions
- microsoft/vcpkg“[onnxruntime] new ports for microsoft/onnxruntime v1.23.2”GitHub · Feb 19, 2024 · 17 reactions
- huggingface/transformers.js“Can GPU acceleration be used when using this library in a node.js environment?”GitHub · Feb 7, 2024 · 17 reactions
The biggest 5 of 39 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 39
Talked about on GitHub, Hacker News, Bluesky and the web (39 times).
On GitHub · 32
- Jul 12, 2024feat(ml): introduce support of onnxruntime-rocm for AMD GPU — immich-app/immich28 reactions · 58 comments
- Oct 1, 2024feat/numpy_2 — Unstructured-IO/unstructured17 reactions · 10 comments
- Feb 19, 2024[onnxruntime] new ports for microsoft/onnxruntime v1.23.2 — microsoft/vcpkg17 reactions · 80 comments
- Feb 7, 2024Can GPU acceleration be used when using this library in a node.js environment? — huggingface/transformers.js17 reactions · 6 comments
- Jan 21, 2024FAQ/GUIDE: I've figured out why CUDA isn't available in Insightface! — cubiq/ComfyUI_IPAdapter_plus17 reactions · 14 comments
27 more on GitHub
- Jan 8, 2020[request] some of most relevant c++ libraries in github (by number of stars) — conan-io/conan-center-index16 reactions · 132 comments
- Jun 18, 2024feat: add support for custom ai models | Pipeline API RFC — supabase/edge-runtime14 reactions · 18 comments
- Mar 16, 2021Add support for anchor tags — lycheeverse/lychee13 reactions · 39 comments
- May 14, 2024wanted: microsoft/onnxruntime — bazelbuild/bazel-central-registry11 reactions · 3 comments
- Mar 6, 2021[request] onnxruntime/1.7.1 — conan-io/conan-center-index11 reactions · 11 comments
- Nov 13, 2025Getting wrong .NET version — actions/setup-dotnet10 reactions · 18 comments
- May 8, 2025Enable Android 16 KB page size support — microsoft/onnxruntime-extensions9 reactions · 14 comments
- Apr 11, 2024Expose onnxruntime session options (intra_op_num_threads) — deepinsight/insightface9 reactions
- Sep 16, 2020Exporting the pytorch grid_sample operator to ONNX opset version 9 is not supported — pytorch/pytorch7 reactions · 1 comment
- Dec 29, 2023wasm does not work on node right now with multiple threads — huggingface/transformers.js6 reactions · 3 comments
- Mar 22, 2022Define layer normalization as a function — onnx/onnx6 reactions
- Dec 2, 2020[onnxruntime] Add new port — microsoft/vcpkg6 reactions · 28 comments
- Jul 28, 2026(partially) fix #23462: configure onnxruntime to stop VRAM usage from growing — immich-app/immich5 reactions · 4 comments
- Jul 23, 2024windows 10 installation tutorial (win10 安装教程) — warmshao/FasterLivePortrait5 reactions · 1 comment
- Nov 30, 2023[ROCm] TunableOp — pytorch/pytorch5 reactions · 31 comments
- Apr 15, 2025[DO NOT SUBMIT] Model cache POC — shiyi9801/chromium4 reactions · 2 comments
- Nov 19, 2024GafferML — GafferHQ/gaffer4 reactions · 3 comments
- Apr 15, 2026Add support for q1, q1f16, q2, q2f16 data types — huggingface/transformers.js3 reactions · 1 comment
- Dec 26, 2025onnx and onnxruntime bump versions (fixed onnx dependency with shared=True) — conan-io/conan-center-index3 reactions
- Nov 4, 2025python3Packages.rapidocr-onnxruntime: fix aarch64-linux build — NixOS/nixpkgs3 reactions · 7 comments
- Feb 26, 2025introduce "--webnn-ort-ov-gpu-precision" to specify gpu precision — shiyi9801/chromium3 reactions · 1 comment
- Feb 4, 2025Add: WASM Emscripten example — pykeio/ort3 reactions · 33 comments
- Feb 1, 2025Object mask — darktable-org/darktable3 reactions · 5 comments
- Sep 23, 2024C, C++, and Python API for Adapters (Multi-LoRA and others) — microsoft/onnxruntime-genai3 reactions
- Dec 12, 2023relax protobuf restriction — microsoft/onnxconverter-common3 reactions · 12 comments
- Apr 1, 2023onnxruntime: add 1.14.1 — conan-io/conan-center-index3 reactions · 36 comments
- Jan 14, 2022Add Col2Im operator — onnx/onnx3 reactions · 21 comments
On Hacker News · 5
- Apr 24, 2023ONNX Runtime merges WebGPU backend178 points · 35 comments
- Jan 19, 2020ONNX Runtime: cross-platform, high performance scoring engine for ML models8 points · 1 comment
- Sep 26, 2025ONNX Runtime v1.23.0 Released4 points
- Dec 11, 2020ONNX Runtime v1.6.0 Release1 point
- Oct 31, 2019Microsoft collects telemetry in onnxruntime Python module1 point
On Bluesky · 1
- Aug 22, 2026📦 microsoft / onnxruntime ⭐ 21,420 (+5) 🗒 C++ ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator — @github-trending.bsky.social1 likes and repost
On the web · 1
- Oct 21, 2026microsoft/onnxruntime - GitHub Explorer — ghe.derekchia.com
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- code-reviewSkill
- contrib-op-shape-inference-memory-safetySkill
- cuda-attention-kernel-patternsSkill
- cuda-cutlass-fmha-incremental-rebuildSkill
- onnx-opset-bump-checklistSkill
- ort-buildSkill
- ort-ciSkill
- ort-lintSkill
- ort-release-notesSkill
- ort-testSkill
- ort-transformers-gpu-pytestSkill
- python-kwargs-setattr-securitySkill
- webgpu-local-testingSkill
- workspace-estimation-shared-headerSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 5 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Before implementing or reviewing changes, inspect .github/instructions//*.instructions.md and parse each file's applyTo scope.
- Distinctive: line 59
Keep code comments concise.
- Very specific: line 83
Use these instead of std::vector / std::unordered_map:
- Very specific: line 90
Use reserve() not resize().
- Very specific: line 96
Prefer gsl::span<const T> over const std::vector<T>& for input parameters
- Very specific: line 97
Prefer std::string_view by value over const std::string&
- Very specific: line 108
Don't use else after return
- Very specific: line 109
Avoid long (ambiguous width) — use int64_t for dimensions, size_t for counts
- Very specific: line 125
If a virtual environment already exists (e.g., .venv/), activate it rather than creating a new one.
- Distinctive: line 129
Follow Google Python Style Guide (extension of PEP 8)
- Very specific: line 133
Test framework: unittest (preferred) with pytest as runner
- Distinctive: line 141
All strings are UTF-8 encoded
- Very specific: line 142
Use int64_t for dimensions, size_t for counts and memory sizes
- Distinctive: line 148
Keep PRs small (aim for ≤10 files.
- Distinctive: line 149
All changes must have unit tests, unless documentation-only or already adequately covered
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Instructions for ONNX Runtime
This file contains repository-wide guidance for coding agents. See Extending Agent Coding Guidance when adding or updating guidance.
Path-Scoped Instructions
Before implementing or reviewing changes, inspect .github/instructions/**/*.instructions.md and parse each file's
applyTo scope. Apply every instruction whose scope matches any target or changed path. Unless explicitly stated
otherwise, matching instructions apply to both implementation and review.
Agent Skills
Repository skills are available in .github/skills. Load each skill whose description matches the
requested task, subsystem, or behavior.
For code reviews, follow the /code-review skill in addition to relevant domain skills and matching path-scoped
instructions.
Build, Test, and Lint
See the /ort-build, /ort-test, and /ort-lint skills for detailed instructions.
CI
See the /ort-ci skill for triggering, re-running, and unblocking CI checks on a pull request (GitHub Actions, Azure
Pipelines, Python format, and license/cla).
Architecture Overview
ONNX Runtime is a cross-platform inference and training engine for ONNX models. The core pipeline is: Load model → Build graph → Optimize graph → Partition across Execution Providers → Execute.
Key layers (onnxruntime/core/)
graph/— ONNX model/graph IR.Modelwraps aGraphofNodes.GraphViewerprovides read-only traversal.optimizer/— Graph transformations (fusion, elimination, constant folding, layout transforms). Organized by optimization level (Level1–Level4).framework/— Execution machinery:OpKernel,Tensor,KernelRegistry, allocators, executors.session/—InferenceSession:Load()→Initialize()(optimize + assign kernels) →Run().providers/— Execution Provider (EP) implementations. Each EP implementsIExecutionProvider. CPU EP is the default fallback. 20+ EPs exist (CUDA, TensorRT, DirectML, CoreML, OpenVINO, WebGPU, QNN, etc.).common/— Utilities, status/error types, logging, threading.platform/— OS abstraction (file I/O, threading).
Contrib ops (onnxruntime/contrib_ops/)
Custom operators not in the ONNX standard, organized by EP (cpu/, cuda/, js/, webgpu/). Each EP has its own contrib kernel registration file (e.g., cpu_contrib_kernels.cc, cuda_contrib_kernels.cc, js_contrib_kernels.cc, webgpu_contrib_kernels.cc).
Training (orttraining/)
Training-specific code (gradient ops, loss functions, optimizers, TrainingSession) layered on top of the inference framework.
Language bindings
csharp/, java/, js/, objectivec/, rust/ — each wraps the C API (include/onnxruntime/core/session/onnxruntime_c_api.h).
General Code Conventions
Code Comments
Keep code comments concise. Add a comment only when it explains rationale, an invariant, a constraint, or subtle behavior that is not clear from the immediate context. Do not narrate obvious code or document the sequence of approaches taken to reach the current implementation; that history belongs in the pull request or commit message when relevant.
C++ Conventions
Style: Google C++ Style with modifications. Max line length 120 (aim for 80). See docs/Coding_Conventions_and_Standards.md for full details.
Error handling
Functions that can fail return onnxruntime::common::Status. Key macros from core/common/common.h:
ORT_RETURN_IF_ERROR(expr)— early-return ifexprreturns non-OK StatusORT_THROW_IF_ERROR(expr)— throw ifexprreturns non-OK StatusORT_RETURN_IF(cond, ...)/ORT_RETURN_IF_NOT(cond, ...)— conditional early-return with messageORT_ENFORCE(cond, ...)— assert-like; throwsOnnxRuntimeExceptionon failureORT_MAKE_STATUS(category, code, ...)— construct a Status object
Exceptions may be disabled in a build, in which case, the throwing macros will call abort() instead.
At the C API boundary, use API_IMPL_BEGIN / API_IMPL_END to catch exceptions — C++ exceptions must never cross the C API boundary.
Container types
Use these instead of std::vector / std::unordered_map:
InlinedVector<T>— small-buffer-optimized vector (64 bytes inline)InlinedHashSet<T>,InlinedHashMap<K,V>— flat hash containersNodeHashSet<T>,NodeHashMap<K,V>— when pointer stability is neededTensorShapeVector— for shape dimensions
Use reserve() not resize(). Do not use absl:: directly — use the ORT typedefs.
Other conventions
#pragma oncefor header guardsORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVEfor new classes until copy/move is proven necessary- Prefer
gsl::span<const T>overconst std::vector<T>&for input parameters - Prefer
std::string_viewby value overconst std::string& SafeInt<size_t>(fromcore/common/safeint.h) for memory size arithmetic- Signed vs unsigned on negative-capable differences. Any expression of the form
a - bthat can be negative (an offset or remaining-budget computed from counts, e.g.num_keys - num_queries) must be stored and compared using a signed type (int32_t/int64_t), and any unsigned operand must bestatic_castto signed before the subtraction/comparison. An unsigned result silently wraps to a huge value (~4.29e9foruint32_t), which can permanently satisfy or skip a relational guard with no crash and no warning — a correct-looking-but-wrong result. Concrete ORT instance + the exact fix sites: CUTLASS FMHAcausal_diagonal_offset, see thecuda-attention-kernel-patternsskill §12. - Don't use
elseafterreturn - Avoid
long(ambiguous width) — useint64_tfor dimensions,size_tfor counts using namespaceallowed in limited scope but never at global scope in headersstd::make_unique()for heap allocations; preferstd::optionaloverunique_ptrfor optional/delayed construction
Python
Virtual environment
Build and test processes may install Python packages. Create and activate an isolated virtual environment first:
python -m venv .venv # one-time setup
source .venv/bin/activate # Linux/macOS
.\.venv\Scripts\Activate.ps1 # Windows (PowerShell)If a virtual environment already exists (e.g., .venv/), activate it rather than creating a new one.
Conventions
- Follow Google Python Style Guide (extension of PEP 8)
- Max line length: 120 characters
- Formatter: ruff (configured in
pyproject.toml) - Static type checking: pyright/pylance
- Test framework:
unittest(preferred) withpytestas runner
C API Conventions
The main public C API header is include/onnxruntime/core/session/onnxruntime_c_api.h. Other public headers are in include/onnxruntime/core/session/ and orttraining/orttraining/training_api/include/.
- Functions that may fail return
OrtStatus*(nullptron success); release/cleanup functions returnvoid - Object lifecycle:
OrtCreateXxx/OrtReleaseXxx - All strings are UTF-8 encoded
- Use
int64_tfor dimensions,size_tfor counts and memory sizes - APIs requiring allocation take an
OrtAllocator*parameter - Failed calls must not modify out-parameters
PR Guidelines
- Keep PRs small (aim for ≤10 files; separate cosmetic changes from functional ones)
- All changes must have unit tests, unless documentation-only or already adequately covered
- Build and test locally on at least one platform before submitting
- PR author is responsible for merging after approval
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

