Skip to content

Commit f9699e4

Browse files
authored
Merge branch 'pytorch:main' into main
2 parents 111b8eb + a704b2b commit f9699e4

File tree

154 files changed

+3036
-474
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3036
-474
lines changed

.ci/docker/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Docker images for Executorch CI
1+
# Docker images for ExecuTorch CI
22

33
This directory contains everything needed to build the Docker images
4-
that are used in Executorch CI. The content of this directory are copied
4+
that are used in ExecuTorch CI. The content of this directory are copied
55
from PyTorch CI https://github.com/pytorch/pytorch/tree/main/.ci/docker.
66
It also uses the same directory structure as PyTorch.
77

.ci/docker/conda-env-ci.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# TODO: We might need to update this to install flatbuffers from the pinned commit
2-
# in fbcode/executorch/third-party/flatbuffers.submodule.txt
3-
flatbuffers=2.0.0
41
cmake=3.22.1

.ci/scripts/gather_test_models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"ic4": "linux.12xlarge",
2424
"resnet50": "linux.12xlarge",
2525
# This one causes timeout on smaller runner, the root cause is unclear (T161064121)
26+
"dl3": "linux.12xlarge",
2627
"emformer_join": "linux.12xlarge",
2728
}
2829

.ci/scripts/setup-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ fi
2020

2121
# As Linux job is running inside a Docker container, all of its dependencies
2222
# have already been installed
23+
install_flatc_from_source
2324
install_executorch
2425
build_executorch_runner "${BUILD_TOOL}"

.ci/scripts/setup-macos.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,6 @@ install_buck
8080
install_conda
8181
install_pip_dependencies
8282
print_cmake_info
83+
install_flatc_from_source
8384
install_executorch
8485
build_executorch_runner "${BUILD_TOOL}"

.ci/scripts/utils.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ install_executorch() {
2727
install_conda() {
2828
pushd .ci/docker || return
2929
# Install conda dependencies like flatbuffer
30-
conda install --file conda-env-ci.txt
30+
conda install -y --file conda-env-ci.txt
3131
popd || return
3232
}
3333

@@ -49,6 +49,25 @@ install_pip_dependencies() {
4949
popd || return
5050
}
5151

52+
install_flatc_from_source() {
53+
# NB: This function could be used to install flatbuffer from source
54+
pushd third-party/flatbuffers || return
55+
56+
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
57+
if [ "$(uname)" == "Darwin" ]; then
58+
CMAKE_JOBS=$(( $(sysctl -n hw.ncpu) - 1 ))
59+
else
60+
CMAKE_JOBS=$(( $(nproc) - 1 ))
61+
fi
62+
cmake --build . -j "${CMAKE_JOBS}"
63+
64+
# Copy the flatc binary to conda path
65+
EXEC_PATH=$(dirname "$(which python)")
66+
cp flatc "${EXEC_PATH}"
67+
68+
popd || return
69+
}
70+
5271
build_executorch_runner_buck2() {
5372
# Build executorch runtime with retry as this step is flaky on macos CI
5473
retry buck2 build //examples/executor_runner:executor_runner

.github/workflows/_unittest.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
jobs:
1616
linux:
1717
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
18+
strategy:
19+
matrix:
20+
include:
21+
- build-tool: buck2
1822
with:
1923
runner: linux.2xlarge
2024
docker-image: ${{ inputs.docker-image }}
@@ -28,8 +32,10 @@ jobs:
2832
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2933
conda activate "${CONDA_ENV}"
3034
31-
# Just need to install executorch, everything else has been setup
32-
pip install .
35+
BUILD_TOOL=${{ matrix.build-tool }}
36+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
37+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
38+
3339
# Run pytest with coverage
3440
pytest -n auto --cov=./ --cov-report=xml
3541
@@ -53,8 +59,6 @@ jobs:
5359
# Setup MacOS dependencies as there is no Docker support on MacOS atm
5460
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
5561
56-
# Just need to install executorch, everything else has been setup
57-
pip install .
5862
# Run pytest with coverage
5963
pytest -n auto --cov=./ --cov-report=xml
6064
# Run gtest

.github/workflows/doc-build.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,33 @@ on:
1616
jobs:
1717
build:
1818
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
19+
strategy:
20+
matrix:
21+
include:
22+
- build-tool: buck2
1923
with:
2024
job-name: Build doc
2125
runner: linux.2xlarge
2226
docker-image: executorch-ubuntu-22.04-clang12
23-
fetch-depth: 0
2427
submodules: 'true'
2528
repository: pytorch/executorch
2629
upload-artifact: docs
27-
2830
script: |
29-
# Set up Environment Variables
30-
PYTHON_VERSION=3.10
31-
export PATH="/opt/conda/envs/py_${PYTHON_VERSION}/bin:${PATH}"
31+
# The generic Linux job chooses to use base env, not the one setup by the image
32+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
33+
conda activate "${CONDA_ENV}"
34+
35+
BUILD_TOOL=${{ matrix.build-tool }}
36+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
37+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
3238
3339
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
3440
export CHANNEL=test
3541
else
3642
export CHANNEL=nightly
3743
fi
3844
39-
set -ex
40-
set +u
45+
set -eux
4146
4247
# Build docset:
4348
cd docs
@@ -48,7 +53,6 @@ jobs:
4853
4954
# Sometimes the artifact directory already contains an "html" subdir.
5055
rm -rf "${RUNNER_ARTIFACT_DIR}/html"
51-
5256
mv docs/_build/html "${RUNNER_ARTIFACT_DIR}"
5357
5458
# Enable preview later. Previews are available publicly

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ jobs:
130130
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
131131
script: |
132132
WORKSPACE=$(pwd)
133-
134133
pushd "${WORKSPACE}/pytorch/executorch"
135134
136135
BUILD_TOOL=${{ matrix.build-tool }}
137136
# Setup MacOS dependencies as there is no Docker support on MacOS atm
138137
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
138+
139139
# Build and test custom ops
140140
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
141141
popd
@@ -179,12 +179,12 @@ jobs:
179179
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
180180
script: |
181181
WORKSPACE=$(pwd)
182-
183182
pushd "${WORKSPACE}/pytorch/executorch"
184183
185184
BUILD_TOOL=${{ matrix.build-tool }}
186185
# Setup MacOS dependencies as there is no Docker support on MacOS atm
187186
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
187+
188188
# Build and test selective build
189189
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
190190
popd

.lintrunner.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,34 @@ init_command = [
122122
'--dry-run={{DRYRUN}}',
123123
'--requirement=requirements-lintrunner.txt',
124124
]
125+
126+
[[linter]]
127+
code = 'ETCAPITAL'
128+
include_patterns = [
129+
'**/*.py',
130+
'**/*.pyi',
131+
'**/*.h',
132+
'**/*.cpp',
133+
'**/*.md',
134+
'**/*.rst',
135+
]
136+
exclude_patterns = [
137+
'third-party/**',
138+
'**/third-party/**',
139+
]
140+
command = [
141+
'python',
142+
'-m',
143+
'lintrunner_adapters',
144+
'run',
145+
'grep_linter',
146+
'--pattern= Executorch\W+',
147+
'--linter-name=ExecuTorchCapitalization',
148+
'--error-name=Incorrect capitalization for ExecuTorch',
149+
"""--error-description=
150+
Please use ExecuTorch with capital T for consistency.
151+
https://fburl.com/workplace/nsx6hib2
152+
""",
153+
'--',
154+
'@{{PATHSFILE}}',
155+
]

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ must work with threading**
113113
## For Delegate Authors
114114

115115
* Use [this](/docs/website/docs/contributors/delegates.md)
116-
guide when integrating your delegate with Executorch.
116+
guide when integrating your delegate with ExecuTorch.
117117

118118
* Refer to [this](/docs/website/docs/contributors/delegates_and_dependencies.md)
119119
set of guidelines when including a 3p depenency for your delegate.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ Compared to the legacy Lite Interpreter, there are some major benefits:
3939

4040
- [Setting up ExecuTorch from GitHub](/docs/website/docs/tutorials/00_setting_up_executorch.md)
4141
- (Optional) [Building with CMake](/docs/website/docs/tutorials/cmake_build_system.md)
42-
- [Exporting to Executorch](/docs/website/docs/tutorials/exporting_to_executorch.md)
42+
- [Exporting to ExecuTorch](/docs/website/docs/tutorials/exporting_to_executorch.md)
4343
- [EXIR Spec](/docs/website/docs/ir_spec/00_exir.md)
4444
- [Exporting manual](/docs/website/docs/export/00_export_manual.md)
4545
- [Quantization](/docs/website/docs/tutorials/quantization_flow.md)
4646
- [Delegate to a backend](/docs/website/docs/tutorials/backend_delegate.md)
4747
- [Profiling](/docs/website/docs/tutorials/profiling.md)
48-
- [Executorch Google Colab](https://colab.research.google.com/drive/1m8iU4y7CRVelnnolK3ThS2l2gBo7QnAP#scrollTo=1o2t3LlYJQY5)
48+
- [ExecuTorch Google Colab](https://colab.research.google.com/drive/1m8iU4y7CRVelnnolK3ThS2l2gBo7QnAP#scrollTo=1o2t3LlYJQY5)
4949

5050
## Directory Structure [WIP]
5151

@@ -67,7 +67,7 @@ executorch
6767
| ├── backend # Backend delegate ahead of time APIs
6868
| ├── capture # Program capture.
6969
| ├── dialects # Op sets for various dialects in the export process.
70-
| ├── emit # Conversion from ExportedProgram to Executorch execution instructions.
70+
| ├── emit # Conversion from ExportedProgram to ExecuTorch execution instructions.
7171
| ├── program # Export artifacts.
7272
| ├── serialize # Serialize final export artifact.
7373
├── extension # Extensions built on top of the runtime.
@@ -90,7 +90,7 @@ executorch
9090
| ├── executor # Model loading, initalization, and execution.
9191
| ├── kernel # Kernel registration and management.
9292
| ├── platform # Layer between architecture specific code and user calls.
93-
├── schema # Executorch program definition, TODO move under serialization/
93+
├── schema # ExecuTorch program definition, TODO move under serialization/
9494
├── scripts # Utility scripts for size management, dependency management, etc.
9595
├── sdk # Model profiling, debugging, and introspection: NOT READY YET FOR OSS USE
9696
├── shim # Compatibility layer between OSS and Internal builds

backends/arm/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Executorch Arm/TOSA Delegate
1+
# ExecuTorch Arm/TOSA Delegate
22

3-
This subtree contains the Arm Delegate implementation for Executorch.
3+
This subtree contains the Arm Delegate implementation for ExecuTorch.
44

55
This delegate is structured to, over time, support a number of different Arm devices
66
through an AoT flow which targets multiple Arm IP using the TOSA standard.

backends/tosa/test/test_tosa_example.py

Whitespace-only changes.

backends/xnnpack/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Executorch XNNPACK Delegate
1+
# ExecuTorch XNNPACK Delegate
22

3-
This subtree contains the XNNPACK Delegate implementation for Executorch.
3+
This subtree contains the XNNPACK Delegate implementation for ExecuTorch.
44
XNNPACK is an optimized library of neural network inference operators for ARM
55
and x86 CPUs. It is an open source project used by PyTorch. The delegate is the
66
mechanism for leveraging the XNNPACK library to accelerate operators running on

backends/xnnpack/runtime/utils/utils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <executorch/backends/xnnpack/runtime/utils/utils.h>
1010
#include <executorch/runtime/platform/assert.h>
11+
#include <cinttypes>
1112

1213
namespace torch {
1314
namespace executor {
@@ -170,8 +171,8 @@ std::pair<float, float> GetMinMax(const Tensor& ft) {
170171
float max = -std::numeric_limits<float>::max();
171172
ET_CHECK_MSG(
172173
ft.scalar_type() == ScalarType::Float,
173-
"Expected float tensor but got %hhd",
174-
ft.scalar_type());
174+
"Expected float tensor but got %" PRId8,
175+
static_cast<int8_t>(ft.scalar_type()));
175176
const float* d = ft.const_data_ptr<float>();
176177
for (int i = 0; i < ft.numel(); ++i) {
177178
min = (d[i] < min) ? d[i] : min;

backends/xnnpack/test/tester/tester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def run_method(self, method="forward"):
359359
delegated_module = self.get_artifact(self._stage_name(Partition))
360360
self.reference_output = delegated_module(*self.inputs)
361361

362-
# Executorch
362+
# ExecuTorch
363363
inputs_flattened, _ = tree_flatten(self.inputs)
364364
serialized_buffer = self.get_artifact(self._stage_name(Serialize))
365365
executorch_module = _load_for_executorch_from_buffer(serialized_buffer)

build/cmake_deps.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ buck_targets = [
8686
filters = [
8787
".cpp$",
8888
]
89+
deps = [
90+
"executorch",
91+
]
8992

9093
[targets.xnn_executor_runner]
9194
buck_targets = [

bundled_program/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class BundledExecutionPlanTest:
8484

8585
@dataclass
8686
class BundledProgram:
87-
"""Executorch program bunlded with data for verification."""
87+
"""ExecuTorch program bunlded with data for verification."""
8888

8989
# Schema version.
9090
version: int
@@ -94,5 +94,5 @@ class BundledProgram:
9494
# Its length should be equal to the number of execution plans in program.
9595
execution_plan_tests: List[BundledExecutionPlanTest]
9696

97-
# The binary data of a serialized Executorch program.
97+
# The binary data of a serialized ExecuTorch program.
9898
program: bytes

codegen/tools/gen_all_oplist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
def main(argv: List[Any]) -> None:
1717
"""This binary is a wrapper for //xplat/caffe2/tools/code_analyzer/gen_oplist.py.
1818
This is needed because we intend to error out for the case where `model_file_list_path`
19-
is empty or invalid, so that the Executorch build will fail when no selective build target
20-
is provided as a dependency to Executorch build.
19+
is empty or invalid, so that the ExecuTorch build will fail when no selective build target
20+
is provided as a dependency to ExecuTorch build.
2121
"""
2222
parser = argparse.ArgumentParser(description="Generate operator lists")
2323
parser.add_argument(
@@ -66,7 +66,7 @@ def main(argv: List[Any]) -> None:
6666
model_file_names = model_list_file.read().split()
6767
assert (
6868
len(model_file_names) > 0
69-
), "BUCK was not able to find any `et_operator_library` in the dependency graph of the current Executorch "
69+
), "BUCK was not able to find any `et_operator_library` in the dependency graph of the current ExecuTorch "
7070
"build. Please refer to Selective Build wiki page to add at least one."
7171
gen_oplist.main(argv)
7272

codegen/tools/gen_ops_def.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def dump_yaml(model_file: str, output_file: str) -> None:
6363

6464

6565
def main(args: List[Any]) -> None:
66-
"""This binary generates a template functions.yaml which will be consumed by Executorch codegen.
66+
"""This binary generates a template functions.yaml which will be consumed by ExecuTorch codegen.
6767
It reads the model file, deserialize it and dumps all the operators into a new functions.yaml.
6868
The generated file contains placeholder kernels, it needs to be updated with proper kernel names.
6969
"""
Loading

docs/source/compiler-delegate-and-partitioner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ with open(save_path, "wb") as f:
251251

252252
## Runtime
253253

254-
The serialized flatbuffer model is loaded by the Executorch runtime. The
254+
The serialized flatbuffer model is loaded by the ExecuTorch runtime. The
255255
preprocessed blob is directly stored in the flatbuffer, which is loaded into a
256256
call to the backend's `init()` function during model initialization stage. At
257257
the model execution stage, the initialized handled can be executed through the

docs/source/conf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
sphinx_gallery_conf = {
7272
"examples_dirs": ["tutorials_source"],
7373
"gallery_dirs": ["tutorials"],
74-
"filename_pattern": "/tutorials/",
74+
"filename_pattern": "/tutorials_source/",
7575
"promote_jupyter_magic": True,
7676
"backreferences_dir": None,
7777
"first_notebook_cell": ("%matplotlib inline"),
@@ -90,6 +90,10 @@
9090
# This pattern also affects html_static_path and html_extra_path.
9191
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
9292

93+
# autosectionlabel throws warnings if section names are duplicated.
94+
# The following tells autosectionlabel to not throw a warning for
95+
# duplicated section names that are in different documents.
96+
autosectionlabel_prefix_document = True
9397

9498
# -- Options for HTML output -------------------------------------------------
9599

docs/source/executorch_stack.png

664 KB
Loading

docs/source/export-overview.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)