Skip to content

Commit 789799b

Browse files
larryliu0820Mengwei Liu
and
Mengwei Liu
authored
Add code structure and a few other links to CONTRIBUTING.md (#9793)
As titled. This PR mainly adds the mapping between our code structure to the documentations/tutorials. Also a few other touch-ups. cc @mergennachin @byjlw --------- Co-authored-by: Mengwei Liu <[email protected]>
1 parent 5e9e9d1 commit 789799b

File tree

3 files changed

+104
-58
lines changed

3 files changed

+104
-58
lines changed

CONTRIBUTING.md

+92-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,95 @@ Set up your environment by following the instructions at
99
https://pytorch.org/executorch/stable/getting-started-setup.html to clone
1010
the repo and install the necessary requirements.
1111

12+
Refer to this [document](https://pytorch.org/executorch/main/using-executorch-building-from-source.html) to build ExecuTorch from source.
13+
14+
### Dev Setup for Android
15+
For Android, please refer to the [Android documentation](docs/source/using-executorch-android.md).
16+
17+
### Dev Setup for Apple
18+
For Apple, please refer to the [iOS documentation](docs/source/using-executorch-ios.md).
19+
&nbsp;
20+
21+
## Codebase structure
22+
23+
<pre>
24+
25+
executorch
26+
├── <a href="backends">backends</a> - Backend delegate implementations for various hardware targets. Each backend uses partitioner to split the graph into subgraphs that can be executed on specific hardware, quantizer to optimize model precision, and runtime components to execute the graph on target hardware. For details refer to the <a href="docs/source/backend-delegates-integration.md">backend documentation</a> and the <a href="docs/source/using-executorch-export.md">Export and Lowering tutorial</a> for more information.
27+
│ ├── <a href="backends/apple">apple</a> - Apple-specific backends.
28+
│ │ ├── <a href="backends/apple/coreml">coreml</a> - CoreML backend for Apple devices. See <a href="docs/source/backends-coreml.md">doc</a>.
29+
│ │ └── <a href="backends/apple/mps">mps</a> - Metal Performance Shaders backend for Apple devices. See <a href="docs/source/backends-mps.md">doc</a>.
30+
│ ├── <a href="backends/arm">arm</a> - ARM architecture backends. See <a href="docs/source/backends-arm-ethos-u.md">doc</a>.
31+
│ ├── <a href="backends/cadence">cadence</a> - Cadence-specific backends. See <a href="docs/source/backends-cadence.md">doc</a>.
32+
│ ├── <a href="backends/example">example</a> - Example backend implementations.
33+
│ ├── <a href="backends/mediatek">mediatek</a> - MediaTek-specific backends. See <a href="docs/source/backends-mediatek.md">doc</a>.
34+
│ ├── <a href="backends/openvino">openvino</a> - OpenVINO backend for Intel hardware.
35+
│ ├── <a href="backends/qualcomm">qualcomm</a> - Qualcomm-specific backends. See <a href="docs/source/backends-qualcomm.md">doc</a>.
36+
│ ├── <a href="backends/transforms">transforms</a> - Transformations for backend optimization.
37+
│ ├── <a href="backends/vulkan">vulkan</a> - Vulkan backend for cross-platform GPU support. See <a href="docs/source/backends-vulkan.md">doc</a>.
38+
│ └── <a href="backends/xnnpack">xnnpack</a> - XNNPACK backend for optimized neural network operations. See <a href="docs/source/backends-xnnpack.md">doc</a>.
39+
├── <a href="codegen">codegen</a> - Tooling to autogenerate bindings between kernels and the runtime.
40+
├── <a href="configurations">configurations</a> - Configuration files.
41+
├── <a href="devtools">devtools</a> - Model profiling, debugging, and inspection. Please refer to the <a href="docs/source/devtools-overview.md">tools documentation</a> for more information.
42+
│ ├── <a href="devtools/bundled_program">bundled_program</a> - a tool for validating ExecuTorch model. See <a href="docs/source/bundled-io.md">doc</a>.
43+
│ ├── <a href="devtools/etdump">etdump</a> - ETDump - a format for saving profiling and debugging data from runtime. See <a href="docs/source/etdump.md">doc</a>.
44+
│ ├── <a href="devtools/etrecord">etrecord</a> - ETRecord - AOT debug artifact for ExecuTorch. See <a href="https://pytorch.org/executorch/main/etrecord.html">doc</a>.
45+
│ ├── <a href="devtools/inspector">inspector</a> - Python API to inspect ETDump and ETRecord. See <a href="https://pytorch.org/executorch/main/model-inspector.html">doc</a>.
46+
│ └── <a href="devtools/visualization">visualization</a> - Visualization tools for representing model structure and performance metrics.
47+
├── <a href="docs">docs</a> - Static docs tooling and documentation source files.
48+
├── <a href="examples">examples</a> - Examples of various user flows, such as model export, delegates, and runtime execution.
49+
├── <a href="exir">exir</a> - Ahead-of-time library: model capture and lowering APIs. EXport Intermediate Representation (EXIR) is a format for representing the result of <a href="https://pytorch.org/docs/main/export.ir_spec.html">torch.export</a>. This directory contains utilities and passes for lowering the EXIR graphs into different <a href="/docs/source/ir-exir.md">dialects</a> and eventually suitable to run on target hardware.
50+
│ ├── <a href="exir/_serialize">_serialize</a> - Serialize final export artifact.
51+
│ ├── <a href="exir/backend">backend</a> - Backend delegate ahead of time APIs.
52+
│ ├── <a href="exir/capture">capture</a> - Program capture.
53+
│ ├── <a href="exir/dialects">dialects</a> - Op sets for various dialects in the export process. Please refer to the <a href="/docs/source/ir-exir.md">EXIR spec</a> and the <a href="/docs/source/compiler-backend-dialect.md">backend dialect</a> doc for more details.
54+
│ ├── <a href="exir/emit">emit</a> - Conversion from ExportedProgram to ExecuTorch execution instructions.
55+
│ ├── <a href="exir/operator">operator</a> - Operator node manipulation utilities.
56+
│ ├── <a href="exir/passes">passes</a> - Built-in compiler passes.
57+
│ ├── <a href="exir/program">program</a> - Export artifacts.
58+
│ ├── <a href="exir/serde">serde</a> - Graph module serialization/deserialization.
59+
│ ├── <a href="exir/verification">verification</a> - IR verification.
60+
├── <a href="extension">extension</a> - Extensions built on top of the runtime.
61+
│ ├── <a href="extension/android">android</a> - ExecuTorch wrappers for Android apps. Please refer to the <a href="docs/source/using-executorch-android.md">Android documentation</a> and <a href="https://pytorch.org/executorch/main/javadoc/">Javadoc</a> for more information.
62+
│ ├── <a href="extension/apple">apple</a> - ExecuTorch wrappers for iOS apps. Please refer to the <a href="docs/source/using-executorch-ios.md">iOS documentation</a> and <a href="https://pytorch.org/executorch/stable/apple-runtime.html">how to integrate into Apple platform</a> for more information.
63+
│ ├── <a href="extension/aten_util">aten_util</a> - Converts to and from PyTorch ATen types.
64+
│ ├── <a href="extension/data_loader">data_loader</a> - 1st party data loader implementations.
65+
│ ├── <a href="extension/evalue_util">evalue_util</a> - Helpers for working with EValue objects.
66+
│ ├── <a href="extension/gguf_util">gguf_util</a> - Tools to convert from the GGUF format.
67+
│ ├── <a href="extension/kernel_util">kernel_util</a> - Helpers for registering kernels.
68+
│ ├── <a href="extension/llm">llm</a> - Library to run LLM on ExecuTorch including common optimization passes, runtime C++ components. Please refer to the <a href="docs/source/llm/getting-started.md">LLM documentation</a> for more information.
69+
│ ├── <a href="extension/memory_allocator">memory_allocator</a> - 1st party memory allocator implementations.
70+
│ ├── <a href="extension/module">module</a> - A simplified C++ wrapper for the runtime. An abstraction that deserializes and executes an ExecuTorch artifact (.pte file). Refer to the <a href="docs/source/extension-module.md">module documentation</a> for more information.
71+
│ ├── <a href="extension/parallel">parallel</a> - C++ threadpool integration.
72+
│ ├── <a href="extension/pybindings">pybindings</a> - Python API for executorch runtime. This is powering up the <a href="https://pytorch.org/executorch/main/runtime-python-api-reference.html">runtime Python API</a> for ExecuTorch.
73+
│ ├── <a href="extension/pytree">pytree</a> - C++ and Python flattening and unflattening lib for pytrees.
74+
│ ├── <a href="extension/runner_util">runner_util</a> - Helpers for writing C++ PTE-execution tools.
75+
│ ├── <a href="extension/tensor">tensor</a> - Tensor maker and <code>TensorPtr</code>, details in <a href="/docs/source/extension-tensor.md">this documentation</a>. For how to use <code>TensorPtr</code> and <code>Module</code>, please refer to the <a href="/docs/source/using-executorch-cpp.md">"Using ExecuTorch with C++"</a> doc.
76+
│ ├── <a href="extension/testing_util">testing_util</a> - Helpers for writing C++ tests.
77+
│ ├── <a href="extension/threadpool">threadpool</a> - Threadpool.
78+
│ └── <a href="extension/training">training</a> - Experimental libraries for on-device training.
79+
├── <a href="kernels">kernels</a> - 1st party kernel implementations.
80+
│ ├── <a href="kernels/aten">aten</a> - ATen kernel implementations.
81+
│ ├── <a href="kernels/optimized">optimized</a> - Optimized kernel implementations.
82+
│ ├── <a href="kernels/portable">portable</a> - Reference implementations of ATen operators.
83+
│ ├── <a href="kernels/prim_ops">prim_ops</a> - Special ops used in executorch runtime for control flow and symbolic primitives.
84+
│ └── <a href="kernels/quantized">quantized</a> - Quantized kernel implementations.
85+
├── <a href="profiler">profiler</a> - Utilities for profiling runtime execution.
86+
├── <a href="runtime">runtime</a> - Core C++ runtime. These components are used to execute the ExecuTorch program. Please refer to the <a href="docs/source/runtime-overview.md">runtime documentation</a> for more information.
87+
│ ├── <a href="runtime/backend">backend</a> - Backend delegate runtime APIs.
88+
│ ├── <a href="runtime/core">core</a> - Core structures used across all levels of the runtime. Basic components such as <code>Tensor</code>, <code>EValue</code>, <code>Error</code> and <code>Result</code> etc.
89+
│ ├── <a href="runtime/executor">executor</a> - Model loading, initialization, and execution. Runtime components that execute the ExecuTorch program, such as <code>Program</code>, <code>Method</code>. Refer to the <a href="https://pytorch.org/executorch/main/executorch-runtime-api-reference.html">runtime API documentation</a> for more information.
90+
│ ├── <a href="runtime/kernel">kernel</a> - Kernel registration and management.
91+
│ └── <a href="runtime/platform">platform</a> - Layer between architecture specific code and portable C++.
92+
├── <a href="schema">schema</a> - ExecuTorch PTE file format flatbuffer schemas.
93+
├── <a href="scripts">scripts</a> - Utility scripts for building libs, size management, dependency management, etc.
94+
├── <a href="shim">shim</a> - Compatibility layer between OSS and Internal builds.
95+
├── <a href="test">test</a> - Broad scoped end-to-end tests.
96+
├── <a href="third-party">third-party</a> - Third-party dependencies.
97+
├── <a href="tools">tools</a> - Tools for building ExecuTorch from source, for different built tools (CMake, Buck).
98+
└── <a href="util">util</a> - Various helpers and scripts.
99+
</pre>
100+
12101
&nbsp;
13102

14103
## Contributing workflow
@@ -221,7 +310,7 @@ CI is run automatically on all pull requests. However, if you want to run tests
221310

222311
- The `sh test/build_size_test.sh` script will compile the C++runtime along with portable kernels.
223312
- The `test/run_oss_cpp_tests.sh` script will build and run C++ tests locally
224-
- Running `pytest` from the root directory will run Python tests locally.
313+
- Running `pytest` from the root directory will run Python tests locally. Make sure to run this after finishing [Dev Install](#dev-install).
225314

226315
### Writing Tests
227316
To help keep code quality high, ExecuTorch uses a combination of unit tests and
@@ -279,7 +368,8 @@ for basics.
279368
- Good title: "Add XYZ method to ABC"
280369
- Give the PR a clear and thorough description. Don't just describe what the PR
281370
does: the diff will do that. Explain *why* you are making this change, in a
282-
way that will make sense to someone years from now.
371+
way that will make sense to someone years from now. If the PR is a bug fix,
372+
include the issue number at the beginning of the description: "Fixes #1234"
283373
- Explain how you have tested your changes by including repeatable instructions for
284374
testing the PR.
285375
- If you added tests, this can be as simple as the command you used to run the

README.md

+1-56
Original file line numberDiff line numberDiff line change
@@ -65,62 +65,7 @@ We welcome contributions. To get started review the [guidelines](CONTRIBUTING.md
6565

6666
## Directory Structure
6767

68-
```
69-
executorch
70-
├── backends # Backend delegate implementations.
71-
├── codegen # Tooling to autogenerate bindings between kernels and the runtime.
72-
├── configurations
73-
├── docs # Static docs tooling.
74-
├── examples # Examples of various user flows, such as model export, delegates, and runtime execution.
75-
├── exir # Ahead-of-time library: model capture and lowering APIs.
76-
| ├── _serialize # Serialize final export artifact.
77-
| ├── backend # Backend delegate ahead of time APIs
78-
| ├── capture # Program capture.
79-
| ├── dialects # Op sets for various dialects in the export process.
80-
| ├── emit # Conversion from ExportedProgram to ExecuTorch execution instructions.
81-
| ├── operator # Operator node manipulation utilities.
82-
| ├── passes # Built-in compiler passes.
83-
| ├── program # Export artifacts.
84-
| ├── serde # Graph module serialization/deserialization.
85-
| ├── verification # IR verification.
86-
├── extension # Extensions built on top of the runtime.
87-
| ├── android # ExecuTorch wrappers for Android apps.
88-
| ├── apple # ExecuTorch wrappers for iOS apps.
89-
| ├── aten_util # Converts to and from PyTorch ATen types.
90-
| ├── data_loader # 1st party data loader implementations.
91-
| ├── evalue_util # Helpers for working with EValue objects.
92-
| ├── gguf_util # Tools to convert from the GGUF format.
93-
| ├── kernel_util # Helpers for registering kernels.
94-
| ├── memory_allocator # 1st party memory allocator implementations.
95-
| ├── module # A simplified C++ wrapper for the runtime.
96-
| ├── parallel # C++ threadpool integration.
97-
| ├── pybindings # Python API for executorch runtime.
98-
| ├── pytree # C++ and Python flattening and unflattening lib for pytrees.
99-
| ├── runner_util # Helpers for writing C++ PTE-execution tools.
100-
| ├── testing_util # Helpers for writing C++ tests.
101-
| ├── training # Experimental libraries for on-device training
102-
├── kernels # 1st party kernel implementations.
103-
| ├── aten
104-
| ├── optimized
105-
| ├── portable # Reference implementations of ATen operators.
106-
| ├── prim_ops # Special ops used in executorch runtime for control flow and symbolic primitives.
107-
| ├── quantized
108-
├── profiler # Utilities for profiling runtime execution.
109-
├── runtime # Core C++ runtime.
110-
| ├── backend # Backend delegate runtime APIs.
111-
| ├── core # Core structures used across all levels of the runtime.
112-
| ├── executor # Model loading, initialization, and execution.
113-
| ├── kernel # Kernel registration and management.
114-
| ├── platform # Layer between architecture specific code and portable C++.
115-
├── schema # ExecuTorch PTE file format flatbuffer schemas.
116-
├── scripts # Utility scripts for building libs, size management, dependency management, etc.
117-
├── tools # Development tool management.
118-
├── devtools # Model profiling, debugging, and introspection.
119-
├── shim # Compatibility layer between OSS and Internal builds
120-
├── test # Broad scoped end-to-end tests.
121-
├── third-party # Third-party dependencies.
122-
├── util # Various helpers and scripts.
123-
```
68+
Please refer to the [Codebase structure](CONTRIBUTING.md#codebase-structure) section of the [Contributing Guidelines](CONTRIBUTING.md) for more details.
12469

12570
## License
12671
ExecuTorch is BSD licensed, as found in the LICENSE file.

docs/source/using-executorch-building-from-source.md

+11
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,17 @@ Or alternatively, [install conda on your machine](https://conda.io/projects/cond
8888
pip install -e .
8989
```
9090

91+
If C++ files are being modified, you will still have to reinstall ExecuTorch from source.
92+
93+
> **_WARNING:_**
94+
> Some modules can't be imported directly in editable mode. This is a known [issue](https://github.com/pytorch/executorch/issues/9558) and we are actively working on a fix for this. To workaround this:
95+
> ```bash
96+
> # This will fail
97+
> python -c "from executorch.exir import CaptureConfig"
98+
> # But this will succeed
99+
> python -c "from executorch.exir.capture import CaptureConfig"
100+
> ```
101+
91102
> **_NOTE:_** Cleaning the build system
92103
>
93104
> When fetching a new version of the upstream repo (via `git fetch` or `git

0 commit comments

Comments
 (0)