Contributing to IREE

We'd love to accept your patches and contributions to this project.

This file covers the policies that apply to every contributor. The Contributing guide on the website contains the same text and adds details for maintainers and frequent contributors, such as commit access and CI configuration.

Getting in touch

Please file issues or reach out on any of these channels before doing substantial work; this will ensure that others don‘t duplicate the work and that there’s a chance to discuss any design issues.

Developer policies

Code of conduct

This project follows the LF Projects code of conduct.

Project governance

IREE is a sandbox-stage project of the LF AI & Data Foundation. Technical oversight of the project is the responsibility of its Technical Steering Committee (TSC), as set out in the IREE Technical Charter.

As provided for in section 2.b of the charter, the voting members of the TSC are:

  • Maximilian Bartel (@maxbartel), RooflineAI — Chairperson
  • Tobias Fuchs (@devtbi), RooflineAI
  • Artem Gindinson (@AGindinson), RooflineAI
  • Stella Laurenzo (@stellaraccident), AMD
  • Christopher McGirr (@chrsmcgrr), RooflineAI
  • Stefan Schuermans (@schuermans-roofline), RooflineAI
  • Jelle Schuhmacher (@jschuhmacher), RooflineAI
  • Ben Vanik (@benvanik), AMD

See MAINTAINERS.md for how the TSC operates. TSC meetings are open to everyone.

Developer Certificate of Origin

Contributors must certify that they wrote or otherwise have the right to submit the code they are contributing to the project, by agreeing to the Developer Certificate of Origin (DCO).

Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Signing is enforced by the DCO GitHub App (see also the dcoapp/app repository).

The DCO check requires that all commits included in pull requests either are cryptographically signed by a member of the repository's organization or include a Signed-off-by message as a git trailer. Frequent contributors can sign their commits cryptographically.

Adding Signed-off-by to commits

This requires less setup and is suitable for first time contributors.

Contributors sign-off their agreement by adding a Signed-off-by line to commit messages:

This is my commit message

Signed-off-by: Random J Developer <random@developer.example.org>
  • Git will automatically append this message if you use the -s option:

    git commit -s -m 'This is my commit message'
    
  • Users of Visual Studio Code can add "git.alwaysSignOff": true, in their settings

  • See .git/hooks/prepare-commit-msg.sample for how to automatically add this using a git hook

Coding policies

Coding style guidelines

Our formatting rules are enforced by language-specific formatters like clang-format for C++ and black for Python. In addition to formatting, we follow these coding standards:

Compiler

The C++ compiler portion of the project follows the MLIR style guide based on the LLVM coding standards. We also follow the recommendations of the LLVM Programmer's Manual.

IREE deviates from the MLIR style guide in the following ways:

  • We use braces with single-line if statements and loops.
  • We allow for static functions in anonymous namespaces to avoid repeatedly reopening/closing namespaces.
  • Pass declarations in TableGen (.td) files should use a Pass suffix (e.g., def FooBarPass), while the corresponding implementation file should not include the Pass suffix (e.g., FooBar.cpp, not FooBarPass.cpp).

Runtime

Most of the code style is derived from the Google Style Guides for the appropriate language.

Other

For code outside of the compiler/ and runtime/ subdirectories, follow the style used in existing files.

Formatting and Linting

We use pre-commit to run assorted formatters and lint checks. The configuration file at .pre-commit-config.yaml defines which “hooks” run.

Improvements to code structure and clarity are welcome but please file issues to track such work first. Pure style changes are unlikely to be accepted unless they are applied consistently across the project.

Testing policy

With few exceptions, features should be accompanied by automated tests.

We use a mix of in-tree and out-of-tree unit and integration tests. For more information about the types of tests used across the project, refer to the testing guide.

GitHub policies

Code reviews

All submissions, including submissions by maintainers, require review. We use GitHub pull requests (PRs) for this purpose. Consult GitHub Help for more information on using pull requests.

  • Please keep PRs small (focused on a single issue or feature) to make reviews and later culprit-finding easier.
    • You may see trusted core contributors bending above rule for project maintenance and major subsystem renovation. If you feel like the rules aren't working for a certain situation, please ask as we bias towards pragmatism for cases that require it.
  • We require review comments to be addressed before merging, even when there is an approval from another reviewer. Unless stated otherwise, we treat request for changes as blocking. Reviewers may indicate that some comments requesting changes are optional (commonly by prefixing them with ‘nit’ or ‘optional’) -- use your best engineering judgement to decide whether to follow these suggestions or not.
  • If there are new comments requesting changes after a PR was merged, these comments should be addressed as well, either through follow-up discussion or code changes. Small issues may be fixed forward, but reviewers may also ask for your PR to be reverted. This is not a sign that your PR was faulty -- we prefer to err on the side of caution and reverting allows more time for design discussion.

GitHub Actions workflows

We use GitHub Actions to automatically build and test various parts of the project.

  • Most presubmit workflows will only run automatically on PRs if you are a project collaborator. Otherwise a maintainer must approve workflow runs. If you are sending code changes to the project, please request commit access, so that these can run automatically.
  • It is generally expected that PRs will only be merged when all checks are passing. In some cases, pre-existing failures may be bypassed by a maintainer.

Some workflows only run on commits after they are merged. See CI behavior manipulation to learn how to customize this behavior.

Pull request descriptions

PRs are squash-merged, so the PR title and description become the commit message, and the commit messages on the PR branch are discarded. Write them for someone reading git log or bisecting a regression later, and update them when the PR changes during review.

Title: a short, imperative summary of what changes and, if it fits, why, prefixed with the affected area, for example [CI] Bump iree-test-suites to fix sharktank test failure. Keep it under 72 characters. Avoid ambiguous titles like “Fix bug” or “Fix CI”.

Description: start with why, then what.

  1. Why: The most important part of a PR description. Explain the underlying motivation of the PR. Why did you create it and what is the use-case this enables or fixes. Be concise. Depending on the change, this covers:
    • for a bug fix, the symptom, its impact, and the issue or failing run
    • for a regression fix, also the commit or PR that introduced it
    • for a feature, the missing capability and what it is used for
    • for a refactor, the current limitation
    • for a performance change, the bottleneck, with numbers
    • for a revert or reland, what broke or what was fixed since, and the original PR
  2. Change: what the PR does and why this approach. The diff shows the details. For refactors, state “No functional change intended”. For small PRs, one sentence is enough.
  3. If relevant:
    • results: before/after numbers for performance, memory, or size changes, and how they were measured
    • trade-offs: known shortcomings, costs, or side effects
    • testing: only tests that CI does not cover
    • review notes: where reviewers should start in large PRs
  4. Trailers at the end: Fixes #1234 for issues that the PR resolves, Depends on #1234 for PRs that it builds on, CI trailers such as ci-extra:, and Assisted-by: for AI tools.

Keep the description concise and self-contained: links add context but do not replace an explanation, and they must be public. Leave out restatements of the diff, implementation details that belong in code comments, review history, and @-mentions, which notify people again on every cherry-pick. A description that keeps growing is a sign that the PR should be split. Small changes need one or two sentences; longer descriptions can use headings such as ## Why, ## Change, and ## Results.

See also:

Merging approved changes

After review and presubmit checks, PRs should typically be merged using “squash and merge”.

  • The squashed commit summary should match the PR title and the commit description should match the PR body (this is the default behavior). Accordingly, please write these as you would a helpful commit message (see Pull request descriptions).

It is assumed that the PR author will merge their change unless they ask someone else to merge it for them (e.g. because they don't have write access yet).

AI tool use

We adopt the LLVM AI Tool Use Policy and require all AI-assisted contributions (Pull Requests, issues, design proposals) to be reviewed and understood by the author(s).

The key points include:

  1. “Contributors must read and review all LLM-generated code or text before they ask other project members to review it.”
  2. “Contributors are expected to be transparent and label contributions that contain substantial amounts of tool-generated content.” This can be done with the Assisted-by: tool-name or the Co-authored-by: tool-name tool@email trailer in PR descriptions.
  3. “To ensure sufficient self review and understanding of the work, it is strongly recommended that contributors write PR descriptions themselves (if needed, using tools for translation or copy-editing).” This also extends to code documentation, issue descriptions, and design proposals.
  4. “Contributors are responsible for ensuring that they have the right to contribute code under the terms of our license, [...]. Using AI tools to regenerate copyrighted material does not remove the copyright, and contributors are responsible for ensuring that such material does not appear in their contributions.”

We extend the LLVM policy with an exception for AI bot-authored contributions (e.g., updating dependencies, fixing build script, etc.); bot account may create Pull Requests as long as the bot maintainers ensure they are first in line and primarily responsible for reviewing those contributions.