Skip to content

Commit 8d34237

Browse files
authored
Merge branch 'main' into export-D68937637
2 parents 1b5b3ee + 1d43d91 commit 8d34237

File tree

69 files changed

+1423
-754
lines changed

Some content is hidden

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

69 files changed

+1423
-754
lines changed

.github/workflows/doc-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ jobs:
8484
needs: build
8585
if: github.repository == 'pytorch/executorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
8686
permissions:
87+
id-token: write
8788
contents: write
88-
contents: read
8989
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
9090
with:
9191
repository: pytorch/executorch

.github/workflows/pull.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ jobs:
221221
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
222222
223223
# install pybind
224-
bash install_executorch.sh --pybind xnnpack
224+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
225225
226226
# install Llava requirements
227227
bash examples/models/llama/install_requirements.sh
@@ -484,7 +484,7 @@ jobs:
484484
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
485485
486486
# install pybind
487-
bash install_executorch.sh --pybind xnnpack
487+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
488488
489489
# install phi-3-mini requirements
490490
bash examples/models/phi-3-mini/install_requirements.sh
@@ -514,7 +514,7 @@ jobs:
514514
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
515515
516516
# install pybind
517-
bash install_executorch.sh --pybind xnnpack
517+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
518518
519519
# install llama requirements
520520
bash examples/models/llama/install_requirements.sh
@@ -544,7 +544,7 @@ jobs:
544544
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
545545
546546
# install pybind
547-
bash install_executorch.sh --pybind xnnpack
547+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
548548
549549
# install llama requirements
550550
bash examples/models/llama/install_requirements.sh
@@ -574,7 +574,7 @@ jobs:
574574
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "cmake"
575575
576576
# install pybind
577-
bash install_executorch.sh --pybind xnnpack
577+
bash install_executorch.sh --pybind xnnpack --use-pt-pinned-commit
578578
579579
# install llama requirements
580580
bash examples/models/llama/install_requirements.sh

.github/workflows/trunk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
conda activate "${CONDA_ENV}"
151151
152152
source .ci/scripts/utils.sh
153-
install_executorch
153+
install_executorch "use-pt-pinned-commit"
154154
155155
.ci/scripts/setup-arm-baremetal-tools.sh
156156
@@ -180,7 +180,7 @@ jobs:
180180
conda activate "${CONDA_ENV}"
181181
182182
source .ci/scripts/utils.sh
183-
install_executorch
183+
install_executorch "use-pt-pinned-commit"
184184
185185
.ci/scripts/setup-arm-baremetal-tools.sh
186186

.mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ ignore_missing_imports = True
7777
[mypy-ruamel]
7878
ignore_missing_imports = True
7979

80+
[mypy-serializer.*]
81+
ignore_missing_imports = True
82+
8083
[mypy-setuptools.*]
8184
ignore_missing_imports = True
8285

README.md

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
1-
# ExecuTorch
2-
3-
**ExecuTorch** is an end-to-end solution for enabling on-device inference
4-
capabilities across mobile and edge devices including wearables, embedded
5-
devices and microcontrollers. It is part of the PyTorch Edge ecosystem and
6-
enables efficient deployment of PyTorch models to edge devices.
1+
<div align="center">
2+
<img src="./docs/source/_static/img/et-logo.png" alt="Logo" width="200">
3+
<h1 align="center">ExecuTorch: A powerful on-device AI Framework</h1>
4+
</div>
5+
6+
7+
<div align="center">
8+
<a href="https://github.com/pytorch/executorch/graphs/contributors"><img src="https://img.shields.io/github/contributors/pytorch/executorch?style=for-the-badge&color=blue" alt="Contributors"></a>
9+
<a href="https://github.com/pytorch/executorch/stargazers"><img src="https://img.shields.io/github/stars/pytorch/executorch?style=for-the-badge&color=blue" alt="Stargazers"></a>
10+
<a href="https://discord.gg/MeacgB7A"><img src="https://img.shields.io/badge/Discord-Join%20Us-purple?logo=discord&logoColor=white&style=for-the-badge" alt="Join our Discord community"></a>
11+
<a href="https://pytorch.org/executorch/stable/index.html"><img src="https://img.shields.io/badge/Documentation-000?logo=googledocs&logoColor=FFE165&style=for-the-badge" alt="Check out the documentation"></a>
12+
<hr>
13+
</div>
14+
15+
**ExecuTorch** is an end-to-end solution for on-device inference and training. It powers much of Meta's on-device AI experiences across Facebook, Instagram, Meta Quest, Ray-Ban Meta Smart Glasses, WhatsApp, and more.
16+
17+
It supports a wide range of models including LLMs (Large Language Models), CV (Computer Vision), ASR (Automatic Speech Recognition), and TTS (Text to Speech).
18+
19+
Platform Support:
20+
- Operating Systems:
21+
- iOS
22+
- Mac
23+
- Android
24+
- Linux
25+
- Microcontrollers
26+
27+
- Hardware Acceleration:
28+
- Apple
29+
- Arm
30+
- Cadence
31+
- MediaTek
32+
- Qualcomm
33+
- Vulkan
34+
- XNNPACK
735

836
Key value propositions of ExecuTorch are:
937

@@ -17,35 +45,21 @@ Key value propositions of ExecuTorch are:
1745
experience due to a lightweight runtime and utilizing full hardware
1846
capabilities such as CPUs, NPUs, and DSPs.
1947

20-
For a comprehensive technical overview of ExecuTorch and step-by-step tutorials,
21-
please visit our documentation website [for the latest release](https://pytorch.org/executorch/stable/index.html) (or the [main branch](https://pytorch.org/executorch/main/index.html)).
22-
23-
Check out the [Getting Started](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) page for a quick spin.
24-
25-
Check out the examples of [Llama](./examples/models/llama/README.md), [Llava](./examples/models/llava/README.md) and [other models](./examples/README.md) running on edge devices using ExecuTorch.
48+
## Getting Started
49+
To get started you can:
2650

51+
- Visit the [Step by Step Tutorial](https://pytorch.org/executorch/main/index.html) on getting things running locally and deploy a model to a device
52+
- Use this [Colab Notebook](https://pytorch.org/executorch/stable/getting-started-setup.html#quick-setup-colab-jupyter-notebook-prototype) to start playing around right away
53+
- Jump straight into LLMs use cases by following specific instructions for [Llama](./examples/models/llama/README.md) and [Llava](./examples/models/llava/README.md)
2754

28-
**[UPDATE - 10/24]** We have added support for running [Llama 3.2 Quantized 1B/3B](./examples/models/llama/README.md) models via ExecuTorch.
29-
30-
## Feedback
55+
## Feedback and Engagement
3156

3257
We welcome any feedback, suggestions, and bug reports from the community to help
33-
us improve our technology. Please use the [PyTorch
34-
Forums](https://discuss.pytorch.org/c/executorch) for discussion and feedback
35-
about ExecuTorch using the **ExecuTorch** category, and our [GitHub
36-
repository](https://github.com/pytorch/executorch/issues) for bug reporting.
37-
38-
We recommend using the latest release tag from the
39-
[Releases](https://github.com/pytorch/executorch/releases) page when developing.
58+
us improve our technology. Check out the [Discussion Board](https://github.com/pytorch/executorch/discussions) or chat real time with us on [Discord](https://discord.gg/MeacgB7A)
4059

4160
## Contributing
4261

43-
See [CONTRIBUTING.md](CONTRIBUTING.md) for details about issues, PRs, code
44-
style, CI jobs, and other development topics.
45-
46-
To connect with us and other community members, we invite you to join PyTorch Slack community by filling out this [form](https://docs.google.com/forms/d/e/1FAIpQLSeADnUNW36fjKjYzyHDOzEB_abKQE9b6gqqW9NXse6O0MWh0A/viewform). Once you've joined, you can:
47-
* Head to the `#executorch-general` channel for general questions, discussion, and community support.
48-
* Join the `#executorch-contributors` channel if you're interested in contributing directly to project development.
62+
We welcome contributions. To get started review the [guidelines](CONTRIBUTING.md) and chat with us on [Discord](https://discord.gg/MeacgB7A)
4963

5064

5165
## Directory Structure

backends/cadence/fusion_g3/operators/op_mean.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int prepare_data(
6060
return num_axis_dims;
6161
}
6262

63-
Tensor& mean_dim_out(
63+
Tensor& mean_out(
6464
KernelRuntimeContext& ctx,
6565
const Tensor& in,
6666
optional<ArrayRef<int64_t>> dim_list,
@@ -169,29 +169,32 @@ Tensor& mean_dim_out(
169169
InvalidArgument,
170170
out);
171171

172-
ET_SWITCH_REALHB_TYPES(in.scalar_type(), ctx, "mean.out", CTYPE_IN, [&] {
173-
ET_SWITCH_FLOATH_TYPES(
174-
out.scalar_type(), ctx, "mean.out", CTYPE_OUT, [&] {
175-
CTYPE_OUT* out_data = out.mutable_data_ptr<CTYPE_OUT>();
176-
const size_t num =
177-
torch::executor::get_reduced_dim_product(in, dim_list);
178-
for (size_t out_ix = 0; out_ix < out.numel(); ++out_ix) {
179-
CTYPE_OUT sum = 0;
180-
if (in.numel() > 0) {
181-
sum = torch::executor::
182-
map_reduce_over_dim_list<CTYPE_IN, CTYPE_OUT>(
183-
[](CTYPE_IN v) { return static_cast<CTYPE_OUT>(v); },
184-
[](CTYPE_OUT outv, CTYPE_OUT acc) {
185-
return acc + outv;
186-
},
187-
in,
188-
dim_list,
189-
out_ix);
190-
}
191-
out_data[out_ix] = sum / static_cast<float>(num);
192-
}
193-
});
194-
});
172+
ET_SWITCH_REALHBBF16_TYPES(
173+
in.scalar_type(), ctx, "mean.out", CTYPE_IN, [&] {
174+
ET_SWITCH_FLOATHBF16_TYPES(
175+
out.scalar_type(), ctx, "mean.out", CTYPE_OUT, [&] {
176+
CTYPE_OUT* out_data = out.mutable_data_ptr<CTYPE_OUT>();
177+
const size_t num =
178+
torch::executor::get_reduced_dim_product(in, dim_list);
179+
for (size_t out_ix = 0; out_ix < out.numel(); ++out_ix) {
180+
CTYPE_OUT sum = 0;
181+
if (in.numel() > 0) {
182+
sum = torch::executor::
183+
map_reduce_over_dim_list<CTYPE_IN, CTYPE_OUT>(
184+
[](CTYPE_IN v) {
185+
return static_cast<CTYPE_OUT>(v);
186+
},
187+
[](CTYPE_OUT outv, CTYPE_OUT acc) {
188+
return acc + outv;
189+
},
190+
in,
191+
dim_list,
192+
out_ix);
193+
}
194+
out_data[out_ix] = sum / static_cast<float>(num);
195+
}
196+
});
197+
});
195198
}
196199

197200
return out;

backends/cadence/hifi/third-party/nnlib/xa_nn_elm_minimum_maximum_f32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,4 +843,3 @@ WORD32 xa_nn_elm_minimum_broadcast_4D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
843843
}
844844

845845
#endif
846-

backends/qualcomm/_passes/__init__.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from .annotate_and_quant_scalar import AnnotateAndQuantScalar
2+
from .annotate_decomposed import AnnotateDecomposed
3+
from .annotate_quant_attrs import AnnotateQuantAttrs
4+
from .convert_bmm_to_matmul import ConvertBmmToMatmul
5+
from .convert_interpolate_with_upsample2d import ConvertInterpolateWithUpsample2D
6+
from .convert_prelu import ConvertPReLU
7+
from .convert_to_linear import ConvertToLinear
8+
from .expand_broadcast_tensor_shape import ExpandBroadcastTensorShape
9+
from .fold_qdq import FoldQDQ
10+
from .i64_to_i32 import I64toI32
11+
from .layout_transform import LayoutTransform
12+
from .recompose_pixel_unshuffle import RecomposePixelUnshuffle
13+
from .recompose_rms_norm import RecomposeRmsNorm
14+
from .remove_redundancy import RemoveRedundancy
15+
from .replace_index_put_input import ReplaceIndexPutInput
16+
17+
18+
__all__ = [
19+
AnnotateAndQuantScalar,
20+
AnnotateDecomposed,
21+
AnnotateQuantAttrs,
22+
ConvertBmmToMatmul,
23+
ConvertInterpolateWithUpsample2D,
24+
ConvertPReLU,
25+
ConvertToLinear,
26+
ExpandBroadcastTensorShape,
27+
FoldQDQ,
28+
I64toI32,
29+
LayoutTransform,
30+
RecomposePixelUnshuffle,
31+
RecomposeRmsNorm,
32+
RemoveRedundancy,
33+
ReplaceIndexPutInput,
34+
]

backends/qualcomm/_passes/annotate_and_quant_scalar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def _get_source_scalar_node(self, node: torch.fx.Node) -> torch.fx.Node:
5353
if node.op == "placeholder":
5454
if not (shape := node.meta["val"].size()):
5555
return node
56-
assert f"The output of node {node} is not a scalar, but a tensor with shape {shape}"
56+
assert (
57+
not shape
58+
), f"The output of node {node} is not a scalar, but a tensor with shape {shape}"
5759
return self._get_source_scalar_node(node.args[0])
5860

5961
def _update_scalar_node_attrs(self, node: torch.fx.Node, quant_attrs: Dict) -> Dict:

backends/qualcomm/_passes/i64_to_i32.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
6+
from typing import FrozenSet
7+
68
import torch
79
from executorch.backends.qualcomm.builders.utils import get_parameter, is_constant
810
from executorch.exir.dialects._ops import ops as exir_ops
@@ -15,9 +17,14 @@ class I64toI32(ExportPass):
1517
Cast unsupported int64 datatype into int32.
1618
"""
1719

18-
def __init__(self, edge_program: torch.export.ExportedProgram):
20+
def __init__(
21+
self,
22+
edge_program: torch.export.ExportedProgram,
23+
skip_node: FrozenSet[str] = frozenset(),
24+
):
1925
super(I64toI32, self).__init__()
2026
self.edge_program = edge_program
27+
self.skip_node = skip_node
2128
# pyre-ignore[4]
2229
self.copy_op = exir_ops.edge.aten._to_copy.default
2330

@@ -42,6 +49,8 @@ def _is_tensor_of_dtype(self, node_val, dtype: torch.dtype) -> bool:
4249

4350
def _cast_to_int32(self, graph_module: torch.fx.GraphModule):
4451
for n in graph_module.graph.nodes:
52+
if n.target in self.skip_node:
53+
continue
4554
if is_constant(n, self.edge_program):
4655
param = get_parameter(n, self.edge_program)
4756
if param.dtype == torch.int64:

backends/qualcomm/_passes/utils.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,63 @@ def get_quant_attrs(
4343

4444
quant_attrs[QCOM_ENCODING] = quant_node.target
4545
return quant_attrs
46+
47+
48+
def get_passes_dependency_for_capture_program():
49+
"""
50+
This function records the dependencies for passes used in the capture_program.
51+
52+
It returns a dictionary where the keys are pass classes and the values are lists of
53+
dependencies required by each pass. This helps in managing and organizing the sequence
54+
of passes needed for the capture_program to function correctly.
55+
56+
Returns:
57+
dict: A dictionary mapping each pass to its corresponding list of dependencies.
58+
"""
59+
from executorch.backends.qualcomm._passes import (
60+
AnnotateAndQuantScalar,
61+
AnnotateDecomposed,
62+
AnnotateQuantAttrs,
63+
ConvertBmmToMatmul,
64+
ConvertInterpolateWithUpsample2D,
65+
ConvertPReLU,
66+
ConvertToLinear,
67+
ExpandBroadcastTensorShape,
68+
FoldQDQ,
69+
I64toI32,
70+
LayoutTransform,
71+
RecomposePixelUnshuffle,
72+
RecomposeRmsNorm,
73+
RemoveRedundancy,
74+
ReplaceIndexPutInput,
75+
)
76+
77+
return {
78+
RecomposePixelUnshuffle: [RemoveRedundancy],
79+
RecomposeRmsNorm: [RemoveRedundancy],
80+
ConvertToLinear: [RecomposePixelUnshuffle],
81+
ConvertPReLU: [RemoveRedundancy],
82+
ConvertBmmToMatmul: [ConvertToLinear],
83+
ConvertInterpolateWithUpsample2D: [RemoveRedundancy],
84+
I64toI32: [RemoveRedundancy],
85+
AnnotateQuantAttrs: [
86+
RecomposePixelUnshuffle,
87+
RecomposeRmsNorm,
88+
ConvertToLinear,
89+
ConvertPReLU,
90+
ConvertBmmToMatmul,
91+
ConvertInterpolateWithUpsample2D,
92+
],
93+
AnnotateAndQuantScalar: [
94+
AnnotateQuantAttrs,
95+
],
96+
AnnotateDecomposed: [RemoveRedundancy],
97+
FoldQDQ: [AnnotateQuantAttrs, AnnotateAndQuantScalar, AnnotateDecomposed],
98+
ExpandBroadcastTensorShape: [RemoveRedundancy],
99+
LayoutTransform: [
100+
AnnotateQuantAttrs,
101+
AnnotateAndQuantScalar,
102+
ExpandBroadcastTensorShape,
103+
],
104+
ReplaceIndexPutInput: [LayoutTransform],
105+
}

0 commit comments

Comments
 (0)