agentleFS
onnxonnx/onnx-mlir/AGENTS.md

onnx-mlir

AGENTS.md1.1k starsChanged 9 days agoApache-2.0View on GitHub

onnx-mlir compiles ONNX models to native code using MLIR and LLVM. A model is imported into the ONNX dialect, transformed (shape inference, constant propagation, decompositions), and lowered. The main path goes through the Krnl dialect, then Affine/SCF/MemRef and LLVM. Other paths start from the same ONNX dialect: - Linalg: --use-linalg-path replaces Krnl for selected ops (--linalg-ops). - StableHLO and TOSA: conversion passes in src/Conversion/ONNXToStablehlo/ and ONNXToTOSA/, run through onnx-mlir-opt. StableHLO is built when ONNX_MLIR_ENABLE_STABLEHLO is on, which is the default.…

Trending

Quiet since December.about the whole repository

Dec 2025: 1 mentionJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the onnx/onnx-mlir repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about onnx/onnx-mlir

The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 22

Talked about on GitHub (22 times).

On GitHub · 22

17 more on GitHub

The file

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep changes focused on the task, and don't reformat or refactor unrelated code.

    line 91

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md
<!--- SPDX-License-Identifier: Apache-2.0 -->

onnx-mlir

onnx-mlir compiles ONNX models to native code using MLIR and LLVM. A model is imported into the ONNX dialect, transformed (shape inference, constant propagation, decompositions), and lowered. The main path goes through the Krnl dialect, then Affine/SCF/MemRef and LLVM. Other paths start from the same ONNX dialect:

  • Linalg: --use-linalg-path replaces Krnl for selected ops (--linalg-ops).
  • StableHLO and TOSA: conversion passes in src/Conversion/ONNXToStablehlo/ and ONNXToTOSA/, run through onnx-mlir-opt. StableHLO is built when ONNX_MLIR_ENABLE_STABLEHLO is on, which is the default.
  • NNPA (IBM Z): the accelerator lowers supported ops through the ZHigh and ZLow dialects (src/Accelerators/NNPA/).

Where things are

  • src/Builder/: ONNX model importer
  • src/Dialect/ONNX/, src/Dialect/Krnl/: dialects, ops, shape inference
  • src/Dialect/ONNX/Transforms/, src/Transform/: ONNX-level and Krnl-level passes
  • src/Conversion/: lowerings (ONNXToKrnl/, KrnlToAffine/, KrnlToLLVM/, ...)
  • src/Accelerators/NNPA/: NNPA accelerator
  • src/Compiler/: driver and options (CompilerOptions.cpp)
  • src/Runtime/: runtime library and Python/Java bindings
  • src/Tools/: onnx-mlir-opt and other tools
  • test/mlir/: lit tests; test/backend/: ONNX backend tests; test/numerical/: numerical tests
  • utils/: scripts (gen_onnx_mlir.py, fixLitTest.py, GroundLitTest.py, ...)
  • third_party/: vendored submodules, not modified here

Build and test

onnx-mlir builds against a specific LLVM commit, the one in utils/clone-mlir.sh. Full setup is in docs/BuildOnLinuxOSX.md; NNPA builds add -DONNX_MLIR_ACCELERATORS=NNPA. From an existing build/ directory:

cmake --build .                                  # build; binaries in <Config>/bin
cmake --build . --target check-onnx-lit          # lit tests, required for every change
llvm-lit -v test/mlir/onnx/<file>.mlir           # one lit test (path relative to build/)
cmake --build . --target check-onnx-backend      # ONNX backend tests
TEST_CASE_BY_USER=<test_name> cmake --build . --target check-onnx-backend
cmake --build . --target check-onnx-numerical    # numerical tests

llvm-lit is in the LLVM build's bin/ directory. Other targets and environment variables are in docs/Testing.md.

A lit test's CHECK lines only confirm that the output has a given shape, not that it is correct. When adding or changing a lowering or pass, ground each case by running it with utils/GroundLitTest.py before recording the CHECK lines; see docs/GroundedLitTests.md.

Style

  • C++: LLVM coding standards, formatted with clang-format using the repository's .clang-format. CI checks src/.
  • Python: formatted with black, which CI also checks.
  • Project-specific rules are in CODING_PRACTICE.md and the coding-conventions skill.

Generated files: do not edit by hand

  • src/Dialect/ONNX/ONNXOps.td.inc: edit utils/gen_onnx_mlir.py, then regenerate with make OMONNXOpsIncTranslation and commit the output (docs/ImportONNXDefs.md).
  • docs/Dialects/*.md: regenerate with make onnx-mlir-docs.
  • docs/SupportedONNXOps-*.md: generated by utils/documentOps.py.
  • .agents/skills/: exported from a knowledge base; see its README.

Skills

Task guides live in .agents/skills/, one SKILL.md per task: adding ONNX ops (dialect, lowering, end to end), passes, op fusion, grounded lit tests, debugging compilation, NNPA performance, and LLVM upgrades. onnx-mlir-internals and nnpa-internals hold background reference pages. Load the skill that matches the task before starting.

Contribution rules

These come from CONTRIBUTING.md, which follows the LLVM AI Tool Use Policy:

  • A human must approve every commit, PR, and comment. Never push, open a PR, or post on GitHub on your own.
  • Commits need a DCO sign-off (git commit -s). Note substantial AI help with an Assisted-by: <tool> trailer or in the PR description.
  • Keep changes focused on the task, and don't reformat or refactor unrelated code.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.