Thank you for your interest in contributing to ExecuTorch! We want to make it easy to contribute to this project.
Set up your environment by following the instructions at https://pytorch.org/executorch/stable/getting-started-setup.html to clone the repo and install the necessary requirements.
We actively welcome your pull requests (PRs).
main in your forked repo, with a name describing the work you're completing; e.g., add-feature-x.pytorch/executorch Github repo using the instructions below.
We use GitHub issues to track public bugs and feature requests. Ensure that the issue title is clear and descriptive, and that the description has sufficient instructions to be able to reproduce the issue.
Meta has a bounty program for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
We'd love your help closing out open issues in the Github repo.
actionable or good first issue label that is not currently assigned to anyone.actionable, please comment on the issue to ask about its status and wait for a response.#1234 in the PR description details (the first comment in the PR conversation thread).
Goal: Encourage standards that make it easier to read, edit, maintain, and debug the ExecuTorch code.
We use lintrunner to help make sure the code follows our standards. Set it up with:
pip install lintrunner==0.11.0 pip install lintrunner-adapters==0.11.0 lintrunner init
Then run lintrunner from the root of the repo to see its suggestions, or run lintrunner -a to automatically apply the suggestions.
ExecuTorch Python code follows the style used by the PyTorch core project.
ExecuTorch code uses the Google C++ Style, with modifications.
Rationale: Google style is close to the C++ style used by PyTorch core, although PyTorch core does not explicitly document its C++ style. Google style is well documented, and has exceptional tooling support.
Modifications to the Google C++ style, to make it closer to the code in PyTorch core:
lower_snake_case(). This follows the convention that PyTorch core inherited from its namesake Python, and is the biggest modification to the Google C++ style.lower_snake_case.cpp (not .cc, and not PascalCase.cpp). This follows the most common pattern in PyTorch core.#pragma once instead of manual include guards. This follows the most common pattern in PyTorch core.<angle brackets>, not "double quotes". This ensures that headers are included using the compiler's include path, and not relative to the local file.//** ... */ (multi-line) or /// ... (single line), with @-style parameters like @param, @retval. Public APIs must be documented in the .h files that declare them.TODO(#123): <description>, rather than a username. A task can manage much-more-nuanced information, and can change ownership as people leave and join the project.See the rest of this file for other portability- and efficiency-related modifications to the Google C++ style guide.
See also Portable C++ Programming for detailed advice.
C++17.
Rationale: This is a compromise between being compatible with older, proprietary toolchains, and having access to relatively modern C++ features.
Restricted usage of the C++ standard library.
Rationale: ExecuTorch is intended to be portable to bare-metal systems that lack certain features, like dynamic memory, threading, and locking, required by parts of the standard library. It is also intended to be as small as possible, and some convenient stdlib features may grow the binary size unacceptably.
Generally, do not instantiate types that allocate memory under the hood, like std::vector or std::string. Do not call new, malloc() or mmap(); do not use iostreams; do not operate on files.
However, it is convenient and portable (and sometimes necessary) to use static standard library concepts like std::move, or metaprogramming helpers like std::is_floating_point<>. Pure code like <cmath> and <cstring> is fine, as long as you stay away from functions that allocate memory (like strdup()).
It is also allowed (and sometimes necessary) to use “placement new”, but be careful to also manually destroy objects initialized in this way.
Exceptions: Do not use.
Threads, thread_local, locking: Do not use, except in optional libraries that must work with threading
RTTI, dynamic_cast, and <typeid>: Do not use.
dynamic_cast and friends, so it’s better to reduce the binary size.Templates and template metaprogramming: Be careful and avoid if possible.
ArrayRef<T>, or code that handles multiple ScalarType types), but for the most part avoid them if possible.
To help keep code quality high, ExecuTorch uses a combination of unit tests and end-to-end (e2e) tests. If you add a new feature or fix a bug, please add tests to ensure that the feature/fix works properly and continues to work properly.
Most directories in the repo already contain test files. In many cases, you can add a test to an existing file, and the existing CI jobs will run it will run automatically. If you do this, please take a look at the CI job logs to ensure that it did actually run.
If it‘s not clear how to add a test for your PR, take a look at the blame for the code you’re modifying and find an author who has more context. Ask them for their help in the PR comments.
TODO: Explain how to run tests locally without needing to push and wait for CI.
See https://hud.pytorch.org/hud/pytorch/executorch/main for the current state of the CI (continuous integration) jobs. If main is broken, consider rebasing your PR onto the viable/strict branch, which points to the most recent all-green commit.
ExecuTorch documents its APIs using inline code comments: doc strings for Python, and Doxygen comments for C++. When modifying or adding an API, be sure to modify or add documentation to the interfaces that you change. If the API doesn't have inline documentation yet, please help improve the code by adding documentation and describing the rest of the piece you modified.
Also search for references to the API you modified under docs/source to see if any docs need to be modified to reflect your changes; these are the files that are published on https://pytorch.org/executorch. If you are adding a new API, look for places in the docs that would benefit from talking about that API, or even create a new document for it. A job on the PR will give you a link to a website preview based on your changes.
This repo uses Github pull requests (PRs) to stage and review code before merging it into the main branch. See the Github docs for basics.
pytorch/executorch. Most people do not have permission to push a branch directoy to the upstream repo.main branch as the base.git log.Release notes: runtime: changes related to the core runtime which loads the program methods, initializes delegates, and runs the lowered graph.Release notes: exir: changes to any internal representations, such as any edge-related dialects. Also any changes to passes that may modify the exir, such as memory planning.Release notes: quantization: changes to quantization.Release notes: ops & kernels: changes to the opset and any new / changed kernel implementations.Release notes: api: changes to public facing apis (any interfaces, pybinded runtime methods, etc.).Release notes: backends: changes to any of the backend delegates.Release notes: build: changes related to the build system, including major dependency upgrades, notable build flags, optimizations, etc.Release notes: devtools: changes to any of ExecuTorch's developer tools, for example the debugger & profiler.Release notes: examples: changes to any code under examples/.Release notes: misc: anything notable that doesn't belong in the above categories.main branch of the repo is consistent, maintainable, and of high quality.main CI jobs are broken, we will only merge PRs that fix the broken jobs until all critical jobs are fixed.
By contributing to ExecuTorch, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Meta's open source projects.
Complete your CLA here: https://code.facebook.com/cla