diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed1e2b30323..82076c2727d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,6 +9,95 @@ 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. +Refer to this [document](https://pytorch.org/executorch/main/using-executorch-building-from-source.html) to build ExecuTorch from source. + +### Dev Setup for Android +For Android, please refer to the [Android documentation](docs/source/using-executorch-android.md). + +### Dev Setup for Apple +For Apple, please refer to the [iOS documentation](docs/source/using-executorch-ios.md). +  + +## Codebase structure + +
+
+executorch
+├── backends - 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 backend documentation and the Export and Lowering tutorial for more information.
+│   ├── apple - Apple-specific backends.
+│   │   ├── coreml - CoreML backend for Apple devices. See doc.
+│   │   └── mps - Metal Performance Shaders backend for Apple devices. See doc.
+│   ├── arm - ARM architecture backends. See doc.
+│   ├── cadence - Cadence-specific backends. See doc.
+│   ├── example - Example backend implementations.
+│   ├── mediatek - MediaTek-specific backends. See doc.
+│   ├── openvino - OpenVINO backend for Intel hardware.
+│   ├── qualcomm - Qualcomm-specific backends. See doc.
+│   ├── transforms - Transformations for backend optimization.
+│   ├── vulkan - Vulkan backend for cross-platform GPU support. See doc.
+│   └── xnnpack - XNNPACK backend for optimized neural network operations. See doc.
+├── codegen - Tooling to autogenerate bindings between kernels and the runtime.
+├── configurations - Configuration files.
+├── devtools - Model profiling, debugging, and inspection. Please refer to the tools documentation for more information.
+│   ├── bundled_program - a tool for validating ExecuTorch model. See doc.
+│   ├── etdump - ETDump - a format for saving profiling and debugging data from runtime. See doc.
+│   ├── etrecord - ETRecord - AOT debug artifact for ExecuTorch. See doc.
+│   ├── inspector - Python API to inspect ETDump and ETRecord. See doc.
+│   └── visualization - Visualization tools for representing model structure and performance metrics.
+├── docs - Static docs tooling and documentation source files.
+├── examples - Examples of various user flows, such as model export, delegates, and runtime execution.
+├── exir - Ahead-of-time library: model capture and lowering APIs. EXport Intermediate Representation (EXIR) is a format for representing the result of torch.export. This directory contains utilities and passes for lowering the EXIR graphs into different dialects and eventually suitable to run on target hardware.
+│   ├── _serialize - Serialize final export artifact.
+│   ├── backend - Backend delegate ahead of time APIs.
+│   ├── capture - Program capture.
+│   ├── dialects - Op sets for various dialects in the export process. Please refer to the EXIR spec and the backend dialect doc for more details.
+│   ├── emit - Conversion from ExportedProgram to ExecuTorch execution instructions.
+│   ├── operator - Operator node manipulation utilities.
+│   ├── passes - Built-in compiler passes.
+│   ├── program - Export artifacts.
+│   ├── serde - Graph module serialization/deserialization.
+│   ├── verification - IR verification.
+├── extension - Extensions built on top of the runtime.
+│   ├── android - ExecuTorch wrappers for Android apps. Please refer to the Android documentation and Javadoc for more information.
+│   ├── apple - ExecuTorch wrappers for iOS apps. Please refer to the iOS documentation and how to integrate into Apple platform for more information.
+│   ├── aten_util - Converts to and from PyTorch ATen types.
+│   ├── data_loader - 1st party data loader implementations.
+│   ├── evalue_util - Helpers for working with EValue objects.
+│   ├── gguf_util - Tools to convert from the GGUF format.
+│   ├── kernel_util - Helpers for registering kernels.
+│   ├── llm - Library to run LLM on ExecuTorch including common optimization passes, runtime C++ components. Please refer to the LLM documentation for more information.
+│   ├── memory_allocator - 1st party memory allocator implementations.
+│   ├── module - A simplified C++ wrapper for the runtime. An abstraction that deserializes and executes an ExecuTorch artifact (.pte file). Refer to the module documentation for more information.
+│   ├── parallel - C++ threadpool integration.
+│   ├── pybindings - Python API for executorch runtime. This is powering up the runtime Python API for ExecuTorch.
+│   ├── pytree - C++ and Python flattening and unflattening lib for pytrees.
+│   ├── runner_util - Helpers for writing C++ PTE-execution tools.
+│   ├── tensor - Tensor maker and TensorPtr, details in this documentation. For how to use TensorPtr and Module, please refer to the "Using ExecuTorch with C++" doc.
+│   ├── testing_util - Helpers for writing C++ tests.
+│   ├── threadpool - Threadpool.
+│   └── training - Experimental libraries for on-device training.
+├── kernels - 1st party kernel implementations.
+│   ├── aten - ATen kernel implementations.
+│   ├── optimized - Optimized kernel implementations.
+│   ├── portable - Reference implementations of ATen operators.
+│   ├── prim_ops - Special ops used in executorch runtime for control flow and symbolic primitives.
+│   └── quantized - Quantized kernel implementations.
+├── profiler - Utilities for profiling runtime execution.
+├── runtime - Core C++ runtime. These components are used to execute the ExecuTorch program. Please refer to the runtime documentation for more information.
+│   ├── backend - Backend delegate runtime APIs.
+│   ├── core - Core structures used across all levels of the runtime. Basic components such as Tensor, EValue, Error and Result etc.
+│   ├── executor - Model loading, initialization, and execution. Runtime components that execute the ExecuTorch program, such as Program, Method. Refer to the runtime API documentation for more information.
+│   ├── kernel - Kernel registration and management.
+│   └── platform - Layer between architecture specific code and portable C++.
+├── schema - ExecuTorch PTE file format flatbuffer schemas.
+├── scripts - Utility scripts for building libs, size management, dependency management, etc.
+├── shim - Compatibility layer between OSS and Internal builds.
+├── test - Broad scoped end-to-end tests.
+├── third-party - Third-party dependencies.
+├── tools - Tools for building ExecuTorch from source, for different built tools (CMake, Buck).
+└── util - Various helpers and scripts.
+
+   ## Contributing workflow @@ -221,7 +310,7 @@ CI is run automatically on all pull requests. However, if you want to run tests - The `sh test/build_size_test.sh` script will compile the C++runtime along with portable kernels. - The `test/run_oss_cpp_tests.sh` script will build and run C++ tests locally -- Running `pytest` from the root directory will run Python tests locally. +- Running `pytest` from the root directory will run Python tests locally. Make sure to run this after finishing [Dev Install](#dev-install). ### Writing Tests To help keep code quality high, ExecuTorch uses a combination of unit tests and @@ -279,7 +368,8 @@ for basics. - Good title: "Add XYZ method to ABC" - Give the PR a clear and thorough description. Don't just describe what the PR does: the diff will do that. Explain *why* you are making this change, in a - way that will make sense to someone years from now. + way that will make sense to someone years from now. If the PR is a bug fix, + include the issue number at the beginning of the description: "Fixes #1234" - Explain how you have tested your changes by including repeatable instructions for testing the PR. - If you added tests, this can be as simple as the command you used to run the diff --git a/README.md b/README.md index dd1fafe715b..d60220bae85 100644 --- a/README.md +++ b/README.md @@ -65,62 +65,7 @@ We welcome contributions. To get started review the [guidelines](CONTRIBUTING.md ## Directory Structure -``` -executorch -├── backends # Backend delegate implementations. -├── codegen # Tooling to autogenerate bindings between kernels and the runtime. -├── configurations -├── docs # Static docs tooling. -├── examples # Examples of various user flows, such as model export, delegates, and runtime execution. -├── exir # Ahead-of-time library: model capture and lowering APIs. -| ├── _serialize # Serialize final export artifact. -| ├── backend # Backend delegate ahead of time APIs -| ├── capture # Program capture. -| ├── dialects # Op sets for various dialects in the export process. -| ├── emit # Conversion from ExportedProgram to ExecuTorch execution instructions. -| ├── operator # Operator node manipulation utilities. -| ├── passes # Built-in compiler passes. -| ├── program # Export artifacts. -| ├── serde # Graph module serialization/deserialization. -| ├── verification # IR verification. -├── extension # Extensions built on top of the runtime. -| ├── android # ExecuTorch wrappers for Android apps. -| ├── apple # ExecuTorch wrappers for iOS apps. -| ├── aten_util # Converts to and from PyTorch ATen types. -| ├── data_loader # 1st party data loader implementations. -| ├── evalue_util # Helpers for working with EValue objects. -| ├── gguf_util # Tools to convert from the GGUF format. -| ├── kernel_util # Helpers for registering kernels. -| ├── memory_allocator # 1st party memory allocator implementations. -| ├── module # A simplified C++ wrapper for the runtime. -| ├── parallel # C++ threadpool integration. -| ├── pybindings # Python API for executorch runtime. -| ├── pytree # C++ and Python flattening and unflattening lib for pytrees. -| ├── runner_util # Helpers for writing C++ PTE-execution tools. -| ├── testing_util # Helpers for writing C++ tests. -| ├── training # Experimental libraries for on-device training -├── kernels # 1st party kernel implementations. -| ├── aten -| ├── optimized -| ├── portable # Reference implementations of ATen operators. -| ├── prim_ops # Special ops used in executorch runtime for control flow and symbolic primitives. -| ├── quantized -├── profiler # Utilities for profiling runtime execution. -├── runtime # Core C++ runtime. -| ├── backend # Backend delegate runtime APIs. -| ├── core # Core structures used across all levels of the runtime. -| ├── executor # Model loading, initialization, and execution. -| ├── kernel # Kernel registration and management. -| ├── platform # Layer between architecture specific code and portable C++. -├── schema # ExecuTorch PTE file format flatbuffer schemas. -├── scripts # Utility scripts for building libs, size management, dependency management, etc. -├── tools # Development tool management. -├── devtools # Model profiling, debugging, and introspection. -├── shim # Compatibility layer between OSS and Internal builds -├── test # Broad scoped end-to-end tests. -├── third-party # Third-party dependencies. -├── util # Various helpers and scripts. -``` +Please refer to the [Codebase structure](CONTRIBUTING.md#codebase-structure) section of the [Contributing Guidelines](CONTRIBUTING.md) for more details. ## License ExecuTorch is BSD licensed, as found in the LICENSE file. diff --git a/docs/source/using-executorch-building-from-source.md b/docs/source/using-executorch-building-from-source.md index 10024ff1457..f676d73165c 100644 --- a/docs/source/using-executorch-building-from-source.md +++ b/docs/source/using-executorch-building-from-source.md @@ -92,6 +92,17 @@ portability details. pip install -e . ``` + If C++ files are being modified, you will still have to reinstall ExecuTorch from source. + +> **_WARNING:_** +> 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: +> ```bash +> # This will fail +> python -c "from executorch.exir import CaptureConfig" +> # But this will succeed +> python -c "from executorch.exir.capture import CaptureConfig" +> ``` + > **_NOTE:_** Cleaning the build system > > When fetching a new version of the upstream repo (via `git fetch` or `git