Skip to content

Commit 53b7c08

Browse files
committed
Update base for Update on "[cortex-m] Add scalar c++ op for quantize_per_tensor"
Only buck build for now, CMake is next. No MVE, scalar only. Strictly the dtypes we care about update arg_meta to reflect that. Differential Revision: [D73141767](https://our.internmc.facebook.com/intern/diff/D73141767/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D73141767/)! [ghstack-poisoned]
2 parents 27c2324 + 06f912d commit 53b7c08

File tree

93 files changed

+876
-402
lines changed

Some content is hidden

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

93 files changed

+876
-402
lines changed

.github/workflows/android-release-artifacts.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
description: Upload the AAR to maven staging repository
1212
required: false
1313
type: boolean
14+
flavor:
15+
type: choice
16+
options:
17+
- "xnnpack"
18+
- "vulkan+xnnpack"
1419
schedule:
1520
- cron: 0 10 * * *
1621

@@ -86,6 +91,11 @@ jobs:
8691
sed -i "s/\(coordinates(\"org.pytorch\", \"executorch-android\", \"\)\([0-9]\+.[0-9]\+.[0-9]\+\)\(\")\)/\1$VERSION\3/" extension/android/executorch_android/build.gradle
8792
fi
8893
94+
FLAVOR="${{ inputs.flavor }}"
95+
if [[ "$FLAVOR" == "vulkan+xnnpack" ]]; then
96+
export EXECUTORCH_BUILD_VULKAN=ON
97+
fi
98+
8999
# Build AAR Package
90100
mkdir aar-out
91101
export BUILD_AAR_DIR=aar-out

.github/workflows/doc-build.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ on:
1414
- cron: '0 0 * * *'
1515

1616
jobs:
17+
check-urls:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Check URLs
22+
run: bash ./scripts/check_urls.sh
23+
24+
check-links:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Check Links
29+
run: bash ./scripts/check_links.sh
30+
1731
build:
1832
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
1933
permissions:

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ executorch
4545
│ └── <a href="devtools/visualization">visualization</a> - Visualization tools for representing model structure and performance metrics.
4646
├── <a href="docs">docs</a> - Static docs tooling and documentation source files.
4747
├── <a href="examples">examples</a> - Examples of various user flows, such as model export, delegates, and runtime execution.
48-
├── <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/stable/export.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.
48+
├── <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/stable/export.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.
4949
│ ├── <a href="exir/_serialize">_serialize</a> - Serialize final export artifact.
5050
│ ├── <a href="exir/backend">backend</a> - Backend delegate ahead of time APIs.
5151
│ ├── <a href="exir/capture">capture</a> - Program capture.
52-
│ ├── <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.
52+
│ ├── <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.
5353
│ ├── <a href="exir/emit">emit</a> - Conversion from ExportedProgram to ExecuTorch execution instructions.
5454
│ ├── <a href="exir/operator">operator</a> - Operator node manipulation utilities.
5555
│ ├── <a href="exir/passes">passes</a> - Built-in compiler passes.
@@ -68,7 +68,7 @@ executorch
6868
│ ├── <a href="extension/memory_allocator">memory_allocator</a> - 1st party memory allocator implementations.
6969
│ ├── <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.
7070
│ ├── <a href="extension/parallel">parallel</a> - C++ threadpool integration.
71-
│ ├── <a href="extension/pybindings">pybindings</a> - Python API for executorch runtime. This is powering up the <a href="docs/source/runtime-python-api-reference.md">runtime Python API</a> for ExecuTorch.
71+
│ ├── <a href="extension/pybindings">pybindings</a> - Python API for executorch runtime. This is powering up the <a href="docs/source/runtime-python-api-reference.rst">runtime Python API</a> for ExecuTorch.
7272
│ ├── <a href="extension/pytree">pytree</a> - C++ and Python flattening and unflattening lib for pytrees.
7373
│ ├── <a href="extension/runner_util">runner_util</a> - Helpers for writing C++ PTE-execution tools.
7474
│ ├── <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.
@@ -114,7 +114,7 @@ If you're completely new to open-source projects, GitHub, or ExecuTorch, please
114114
1. If you've changed APIs or added a new tool or feature, [update the
115115
documentation](#updating-documentation).
116116
1. If you added an experimental API or deprecated an existing API, follow the
117-
[API Life Cycle and Deprecation Policy](/docs/source/api-life-cycle.md).
117+
[API Life Cycle and Deprecation Policy](docs/source/api-life-cycle.md).
118118
1. Make sure your code follows the [style guides](#coding-style) and passes the
119119
[lint checks](#lintrunner).
120120
1. If you haven't already, complete the [Contributor License Agreement ("CLA")](#contributor-license-agreement-cla).

README-wheel.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ tutorials and documentation. Here are some starting points:
2525
* [Exporting to ExecuTorch](https://pytorch.org/executorch/main/tutorials/export-to-executorch-tutorial)
2626
* Learn the fundamentals of exporting a PyTorch `nn.Module` to ExecuTorch, and
2727
optimizing its performance using quantization and hardware delegation.
28-
* Running LLaMA on [iOS](docs/source/llm/llama-demo-ios) and [Android](docs/source/llm/llama-demo-android) devices.
28+
* Running LLaMA on [iOS](docs/source/llm/llama-demo-ios.md) and [Android](docs/source/llm/llama-demo-android.md) devices.
2929
* Build and run LLaMA in a demo mobile app, and learn how to integrate models
3030
with your own apps.

backends/apple/coreml/runtime/test/setup.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ This is a tutorial for setting up tests for the **Core ML** backend.
44

55
## Running tests
66

7-
1. Follow the instructions described in [Setting Up ExecuTorch](/docs/source/getting-started-setup.md) to set up ExecuTorch environment.
7+
1. Follow the instructions described in [Setting Up ExecuTorch](../../../../../docs/source/getting-started-setup.rst) to set up ExecuTorch environment.
88

99
2. Run `install_requirements.sh` to install dependencies required by the **Core ML** backend.
1010

1111
```bash
1212
cd executorch
1313

14-
sh backends/apple/coreml/scripts/install_requirements.sh
14+
sh backends/apple/coreml/scripts/install_requirements.sh
1515

16-
```
16+
```
1717

18-
3. Follow the instructions described in [Building with CMake](/docs/source/runtime-build-and-cross-compilation.md#building-with-cmake) to set up CMake build system.
18+
3. Follow the instructions described in [Building with CMake](../../../../../docs/source/using-executorch-cpp.md#building-with-cmake) to set up CMake build system.
1919

2020
4. Install [Xcode](https://developer.apple.com/xcode/).
2121

@@ -26,7 +26,7 @@ sh backends/apple/coreml/scripts/install_requirements.sh
2626
```bash
2727
cd executorch
2828

29-
# Builds macOS universal test bundle.
29+
# Builds macOS universal test bundle.
3030

3131
sh backends/apple/coreml/srcipts/build_tests.sh
3232

@@ -40,15 +40,15 @@ cd executorch
4040
sh backends/apple/coreml/srcipts/run_tests.sh
4141
4242
```
43-
43+
4444
## Updating tests
4545

4646
1. Open the Xcode workspace.
4747

4848
```bash
4949
cd executorch
5050

51-
# Builds macOS universal test bundle.
51+
# Builds macOS universal test bundle.
5252

5353
open backends/apple/coreml/runtime/workspace/executorchcoreml.xcworkspace
5454

@@ -62,4 +62,4 @@ cd executorch
6262
# There is no need to build the tests.
6363
sh backends/apple/coreml/srcipts/run_tests.sh
6464

65-
```
65+
```

backends/apple/coreml/setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is a tutorial for setting up the Core ML backend.
44

55
## AOT Setup
66

7-
1. Follow the instructions described in [Setting Up ExecuTorch](/docs/source/getting-started-setup.md) to set up ExecuTorch environment.
7+
1. Follow the instructions described in [Setting Up ExecuTorch](../../../docs/source/getting-started-setup.rst) to set up ExecuTorch environment.
88

99

1010
2. Run the example script to validate that the **Core ML** backend is set up correctly.
@@ -28,7 +28,7 @@ delegated_program_manager = edge_program_manager.to_backend(CoreMLPartitioner())
2828

2929
## Integrating Core ML delegate into runtime.
3030

31-
1. Follow the instructions described in [Building with CMake](/docs/source/runtime-build-and-cross-compilation.md#building-with-cmake) to set up CMake build system.
31+
1. Follow the instructions described in [Building with CMake](../../../docs/source/using-executorch-cpp.md#building-with-cmake) to set up CMake build system.
3232

3333
2. Install [Xcode](https://developer.apple.com/xcode/).
3434

backends/apple/mps/setup.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ The MPS backend device maps machine learning computational graphs and primitives
1212
:::
1313
:::{grid-item-card} Tutorials we recommend you complete before this:
1414
:class-card: card-prerequisites
15-
* [Introduction to ExecuTorch](intro-how-it-works.md)
16-
* [Setting up ExecuTorch](getting-started-setup.md)
17-
* [Building ExecuTorch with CMake](runtime-build-and-cross-compilation.md)
18-
* [ExecuTorch iOS Demo App](demo-apps-ios.md)
19-
* [ExecuTorch iOS LLaMA Demo App](llm/llama-demo-ios.md)
15+
* [Introduction to ExecuTorch](../../../docs/source/intro-how-it-works.md)
16+
* [Setting up ExecuTorch](../../../docs/source/getting-started-setup.rst)
17+
* [Building ExecuTorch with CMake](../../../docs/source/using-executorch-cpp.md#building-with-cmake)
18+
* [ExecuTorch iOS Demo App](../../../docs/source/demo-apps-ios.md)
19+
* [ExecuTorch iOS LLaMA Demo App](../../../docs/source/llm/llama-demo-ios.md)
2020
:::
2121
::::
2222

@@ -111,12 +111,12 @@ python3 -m examples.apple.mps.scripts.mps_example --model_name="mv3" --no-use_fp
111111
```
112112

113113
### Profiling:
114-
1. [Optional] Generate an [ETRecord](./etrecord.rst) while you're exporting your model.
114+
1. [Optional] Generate an [ETRecord](../../../docs/source/etrecord.rst) while you're exporting your model.
115115
```bash
116116
cd executorch
117117
python3 -m examples.apple.mps.scripts.mps_example --model_name="mv3" --generate_etrecord -b
118118
```
119-
2. Run your Program on the ExecuTorch runtime and generate an [ETDump](./etdump.md).
119+
2. Run your Program on the ExecuTorch runtime and generate an [ETDump](../../../docs/source/etdump.md).
120120
```
121121
./cmake-out/examples/apple/mps/mps_executor_runner --model_path mv3_mps_bundled_fp16.pte --bundled_program --dump-outputs
122122
```

backends/cadence/aot/pass_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class CadencePassAttribute:
3535
ALL_CADENCE_PASSES: dict[ExportPass, CadencePassAttribute] = {}
3636

3737

38-
def get_cadence_pass_attribute(p: ExportPass) -> CadencePassAttribute:
39-
return ALL_CADENCE_PASSES[p]
38+
def get_cadence_pass_attribute(p: ExportPass) -> Optional[CadencePassAttribute]:
39+
return ALL_CADENCE_PASSES.get(p, None)
4040

4141

4242
# A decorator that registers a pass.
@@ -61,7 +61,8 @@ def create_cadence_pass_filter(
6161
def _filter(p: ExportPass) -> bool:
6262
pass_attribute = get_cadence_pass_attribute(p)
6363
return (
64-
pass_attribute.opt_level is not None
64+
pass_attribute is not None
65+
and pass_attribute.opt_level is not None
6566
and pass_attribute.opt_level <= opt_level
6667
and (not pass_attribute.debug_pass or debug)
6768
)

backends/example/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ In the following diagram, we show how to quantize a mobile net v2 model and lowe
1717

1818
We can define patterns based on the operators supported by the backend, which will be used by the quantizer and delegate.
1919

20-
![](./diagrams/quantize_delegate.png)
20+
![](diagrams/quantize_delegate.png)
2121

2222
### Partitioner and Backend
2323

2424
The way partitioner and backend is, partitioner will tag the nodes to lower to the backend and backend will will receive all tagged nodes and preprocess them as a delegate.
2525

26-
![](./diagrams/delegate.png)
26+
![](diagrams/delegate.png)
2727

2828
### Memory format permute
2929

3030
Some operators may have better performance in the memory format other than contiguous. One way to do that is to insert `to_dim_op` to describe memory format permutation and merge if there two opposite one next to each other.
3131

32-
![](./diagrams/memory_permute.png)
32+
![](diagrams/memory_permute.png)

backends/qualcomm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A website version of the tutorial is [here](https://pytorch.org/executorch/main/
1313
## Delegate Options
1414

1515
Please check `generate_qnn_executorch_compiler_spec()` in
16-
[utils.py](./utils/utils.py) for supported SoC and inference type.
16+
[utils.py](utils/utils.py) for supported SoC and inference type.
1717

1818
### Supported Chipset
1919
- Snapdragon 8 Gen 1

backends/vulkan/docs/android_demo.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Building and Running ExecuTorch with the Vulkan Backend
22

3-
The [ExecuTorch Vulkan Delegate](./native-delegates-executorch-vulkan-delegate.md)
3+
The [ExecuTorch Vulkan Delegate](../../../docs/source/native-delegates-executorch-vulkan-delegate.md)
44
is a native GPU delegate for ExecuTorch.
55

66
<!----This will show a grid card on the page----->
@@ -12,8 +12,8 @@ is a native GPU delegate for ExecuTorch.
1212
:::
1313
:::{grid-item-card} Prerequisites:
1414
:class-card: card-prerequisites
15-
* Follow [**Setting up ExecuTorch**](./getting-started-setup.md)
16-
* It is also recommended that you read through [**ExecuTorch Vulkan Delegate**](./native-delegates-executorch-vulkan-delegate.md) and follow the example in that page
15+
* Follow [**Setting up ExecuTorch**](../../../docs/source/getting-started-setup.rst)
16+
* It is also recommended that you read through [**ExecuTorch Vulkan Delegate**](../../../docs/source/native-delegates-executorch-vulkan-delegate.md) and follow the example in that page
1717
:::
1818
::::
1919

@@ -59,7 +59,7 @@ partially lower the Llama model to Vulkan.
5959
# The files will usually be downloaded to ~/.llama
6060
python -m examples.models.llama.export_llama \
6161
--disable_dynamic_shape --vulkan -kv --use_sdpa_with_kv_cache -d fp32 \
62-
--model "llama3_2" \
62+
--model "llama3_2" \
6363
-c ~/.llama/checkpoints/Llama3.2-1B/consolidated.00.pth \
6464
-p ~/.llama/checkpoints/Llama3.2-1B/params.json \
6565
--metadata '{"get_bos_id":128000, "get_eos_ids":[128009, 128001]}'

devtools/bundled_program/bundled_program.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using ::executorch::runtime::EValue;
3333
using ::executorch::runtime::Result;
3434

3535
namespace executorch {
36-
namespace bundled_program {
36+
namespace BUNDLED_PROGRAM_NAMESPACE {
3737

3838
namespace {
3939

@@ -433,5 +433,5 @@ bool is_bundled_program(void* file_data, ET_UNUSED size_t file_data_len) {
433433
file_data);
434434
}
435435

436-
} // namespace bundled_program
436+
} // namespace BUNDLED_PROGRAM_NAMESPACE
437437
} // namespace executorch

devtools/bundled_program/bundled_program.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@
1010

1111
#include <executorch/runtime/core/memory_allocator.h>
1212
#include <executorch/runtime/executor/method.h>
13+
#ifdef USE_ATEN_LIB
14+
#define BUNDLED_PROGRAM_NAMESPACE bundled_program::aten
15+
#else // !USE_ATEN_LIB
16+
#define BUNDLED_PROGRAM_NAMESPACE bundled_program
17+
#endif // USE_ATEN_LIB
1318

1419
namespace executorch {
15-
namespace bundled_program {
20+
namespace BUNDLED_PROGRAM_NAMESPACE {
1621

1722
/**
1823
* An opaque pointer to a serialized bundled program.
@@ -94,7 +99,7 @@ ET_DEPRECATED inline bool is_bundled_program(void* file_data) {
9499
return is_bundled_program(file_data, 128);
95100
}
96101

97-
} // namespace bundled_program
102+
} // namespace BUNDLED_PROGRAM_NAMESPACE
98103
} // namespace executorch
99104

100105
namespace torch {
@@ -103,13 +108,13 @@ namespace bundled_program {
103108
// TODO(T197294990): Remove these deprecated aliases once all users have moved
104109
// to the new `::executorch` namespaces.
105110
using serialized_bundled_program =
106-
::executorch::bundled_program::SerializedBundledProgram;
111+
::executorch::BUNDLED_PROGRAM_NAMESPACE::SerializedBundledProgram;
107112

108113
ET_NODISCARD inline ::executorch::runtime::Error LoadBundledInput(
109114
Method& method,
110115
serialized_bundled_program* bundled_program_ptr,
111116
size_t testset_idx) {
112-
return ::executorch::bundled_program::load_bundled_input(
117+
return ::executorch::BUNDLED_PROGRAM_NAMESPACE::load_bundled_input(
113118
method, bundled_program_ptr, testset_idx);
114119
}
115120

@@ -120,7 +125,7 @@ VerifyResultWithBundledExpectedOutput(
120125
size_t testset_idx,
121126
double rtol = 1e-5,
122127
double atol = 1e-8) {
123-
return ::executorch::bundled_program::verify_method_outputs(
128+
return ::executorch::BUNDLED_PROGRAM_NAMESPACE::verify_method_outputs(
124129
method, bundled_program_ptr, testset_idx, rtol, atol);
125130
}
126131

@@ -129,13 +134,14 @@ ET_NODISCARD inline ::executorch::runtime::Error GetProgramData(
129134
size_t file_data_len,
130135
const void** out_program_data,
131136
size_t* out_program_data_len) {
132-
return ::executorch::bundled_program::get_program_data(
137+
return ::executorch::BUNDLED_PROGRAM_NAMESPACE::get_program_data(
133138
file_data, file_data_len, out_program_data, out_program_data_len);
134139
}
135140

136141
inline bool IsBundledProgram(void* file_data) {
137142
// 128 is enough data to contain the identifier in the flatbuffer header.
138-
return ::executorch::bundled_program::is_bundled_program(file_data, 128);
143+
return ::executorch::BUNDLED_PROGRAM_NAMESPACE::is_bundled_program(
144+
file_data, 128);
139145
}
140146
} // namespace bundled_program
141147
} // namespace executor

0 commit comments

Comments
 (0)