Skip to content

Commit d7b7162

Browse files
committed
Update on "Introduce data schema to store raw tensors"
Differential Revision: [D65156641](https://our.internmc.facebook.com/intern/diff/D65156641) [ghstack-poisoned]
2 parents c8d6489 + 32d6602 commit d7b7162

File tree

320 files changed

+11408
-2241
lines changed

Some content is hidden

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

320 files changed

+11408
-2241
lines changed

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bd5482c7c3e1197e10c46ff739027f917d9c1fcc
1+
c8a648d4dffb9f0133ff4a2ea0e660b42105d3ad

.ci/docker/common/install_clang.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ install_ubuntu() {
1313
apt-get install -y --no-install-recommends clang-"$CLANG_VERSION"
1414
apt-get install -y --no-install-recommends llvm-"$CLANG_VERSION"
1515
# Also require LLD linker from llvm and libomp to build PyTorch from source
16-
apt-get install -y lld "libomp-${CLANG_VERSION}-dev"
16+
apt-get install -y lld "libomp-${CLANG_VERSION}-dev" "libc++-${CLANG_VERSION}-dev"
1717

1818
# Use update-alternatives to make this version the default
1919
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-"$CLANG_VERSION" 50

.ci/docker/requirements-ci.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mpmath==1.3.0
2-
numpy==1.22.0; python_version == '3.10'
2+
numpy==1.21.3; python_version == '3.10'
33
numpy==1.23.2; python_version == '3.11'
44
numpy; python_version >= '3.12'
55
PyYAML==6.0.1

.ci/scripts/build-qnn-sdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ set_up_aot() {
4242

4343
# Workaround for fbs files in exir/_serialize
4444
cp schema/program.fbs exir/_serialize/program.fbs
45-
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
45+
cp schema/common.fbs exir/_serialize/common.fbs
4646
}
4747

4848
build_qnn_backend

.ci/scripts/setup-linux.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ else
1919
fi
2020

2121
# As Linux job is running inside a Docker container, all of its dependencies
22-
# have already been installed
23-
install_executorch
22+
# have already been installed, so we use PyTorch build from source here instead
23+
# of nightly. This allows CI to test against latest commits from PyTorch
24+
install_executorch "use-pt-pinned-commit"
2425
build_executorch_runner "${BUILD_TOOL}"

.ci/scripts/setup-qnn-deps.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ install_qnn() {
3131
}
3232

3333
setup_libc++() {
34+
clang_version=$1
3435
sudo apt-get update
35-
pkgs_to_check=('libc++-dev')
36+
pkgs_to_check=("libc++-${clang_version}-dev")
3637
j=0
3738
while [ $j -lt ${#pkgs_to_check[*]} ]; do
3839
install_status=$(verify_pkg_installed ${pkgs_to_check[$j]})
@@ -47,5 +48,6 @@ setup_libc++() {
4748
done
4849
}
4950

50-
setup_libc++
51+
# This needs to match with the clang version from the Docker image
52+
setup_libc++ 12
5153
install_qnn

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ if [[ "${MODE}" =~ .*qnn.* ]]; then
7979
export LD_LIBRARY_PATH="${QNN_SDK_ROOT}/lib/x86_64-linux-clang"
8080
export PYTHONPATH=".."
8181
cp schema/program.fbs exir/_serialize/program.fbs
82-
cp schema/scalar_type.fbs exir/_serialize/scalar_type.fbs
82+
cp schema/common.fbs exir/_serialize/common.fbs
8383
cp -f build-x86/backends/qualcomm/PyQnnManagerAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
8484
cp -f build-x86/backends/qualcomm/PyQnnWrapperAdaptor.cpython-310-x86_64-linux-gnu.so backends/qualcomm/python
8585

.ci/scripts/test_llama_runner_eager.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ run_and_verify() {
4242
-d fp32 \
4343
--max_seq_length 32 \
4444
--temperature 0 \
45+
--show_tokens \
4546
--prompt "Once upon a time," > result.txt
4647

4748
# Verify result.txt
4849
RESULT=$(cat result.txt)
49-
EXPECTED_RESULT="there was a little girl"
50+
EXPECTED_RESULT="727, 471, 263, 2217, 7826, 4257, 365, 2354, 29889, 2296, 18012, 304, 1708, 5377, 297, 278, 6575, 845, 457, 29889, 3118, 2462, 29892, 1183, 4446, 263"
5051
if [[ "${RESULT}" == *"${EXPECTED_RESULT}"* ]]; then
5152
echo "Actual result: ${RESULT}"
5253
echo "Success"

.ci/scripts/utils.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ install_executorch() {
2020
which pip
2121
# Install executorch, this assumes that Executorch is checked out in the
2222
# current directory.
23-
# TODO(T199538337): clean up install scripts to use install_requirements.sh
24-
./install_requirements.sh --pybind xnnpack
23+
if [[ "${1:-}" == "use-pt-pinned-commit" ]]; then
24+
./install_requirements.sh --pybind xnnpack --use-pt-pinned-commit
25+
else
26+
./install_requirements.sh --pybind xnnpack
27+
fi
2528
# Just print out the list of packages for debugging
2629
pip list
2730
}

.github/pull_request_template.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Summary
2+
[PLEASE REMOVE] See [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests) for ExecuTorch PR guidelines.
3+
4+
[PLEASE REMOVE] If this PR closes an issue, please add a `Fixes #<issue-id>` line.
5+
6+
[PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: <area>" label. For a list of available release notes labels, check out [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests).
7+
8+
### Test plan
9+
[PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable.

.github/workflows/_unittest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
CMAKE_ARGS="-DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
3838
.ci/scripts/setup-linux.sh cmake
3939
40+
# Install llama3_2_vision dependencies.
41+
PYTHON_EXECUTABLE=python ./examples/models/llama3_2_vision/install_requirements.sh
42+
4043
# Run pytest with coverage
4144
pytest -n auto --cov=./ --cov-report=xml
4245
# Run gtest
@@ -67,6 +70,10 @@ jobs:
6770
${CONDA_RUN} --no-capture-output \
6871
.ci/scripts/setup-macos.sh cmake
6972
73+
# Install llama3_2_vision dependencies.
74+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
75+
./examples/models/llama3_2_vision/install_requirements.sh
76+
7077
# Run pytest with coverage
7178
${CONDA_RUN} pytest -n auto --cov=./ --cov-report=xml
7279
# Run gtest

.github/workflows/ghstack_land.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- 'gh/cccclai/[0-9]+/base'
77
- 'gh/dbort/[0-9]+/base'
8+
- 'gh/dvorjackz/[0-9]+/base'
89
- 'gh/guangy10/[0-9]+/base'
910
- 'gh/helunwencser/[0-9]+/base'
1011
- 'gh/jorgep31415/[0-9]+/base'

.github/workflows/trunk.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
docker-image: executorch-ubuntu-22.04-arm-sdk
138138
submodules: 'true'
139139
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
140+
timeout: 90
140141
script: |
141142
# The generic Linux job chooses to use base env, not the one setup by the image
142143
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
@@ -162,6 +163,7 @@ jobs:
162163
docker-image: executorch-ubuntu-22.04-arm-sdk
163164
submodules: 'true'
164165
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
166+
timeout: 90
165167
script: |
166168
# The generic Linux job chooses to use base env, not the one setup by the image
167169
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@
6464
[submodule "third-party/pybind11"]
6565
path = third-party/pybind11
6666
url = https://github.com/pybind/pybind11.git
67+
[submodule "third-party/ao"]
68+
path = third-party/ao
69+
url = https://github.com/pytorch/ao.git

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,10 +721,15 @@ if(EXECUTORCH_BUILD_PYBIND)
721721
-fPIC
722722
-frtti
723723
-fexceptions
724-
# libtorch is built with the old ABI, so we need to do the same for any
725-
# .cpp files that include torch, c10, or ATen targets.
726-
-D_GLIBCXX_USE_CXX11_ABI=0
727724
)
725+
if(EXECUTORCH_DO_NOT_USE_CXX11_ABI)
726+
# libtorch is built with the old ABI, so we need to do the same for any
727+
# .cpp files that include torch, c10, or ATen targets. Note that PyTorch
728+
# nightly binary is built with _GLIBCXX_USE_CXX11_ABI set to 0 while its
729+
# CI build sets this to 1 (default)
730+
list(APPEND _pybind_compile_options -D_GLIBCXX_USE_CXX11_ABI=0)
731+
endif()
732+
728733
# util lib
729734
add_library(
730735
util ${CMAKE_CURRENT_SOURCE_DIR}/extension/evalue_util/print_evalue.cpp

CONTRIBUTING.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,27 @@ for basics.
242242
- Give the PR a clear and thorough description. Don't just describe what the PR
243243
does: the diff will do that. Explain *why* you are making this change, in a
244244
way that will make sense to someone years from now.
245-
- Add the line `Test Plan:` (with that spelling, capitalization, and trailing
246-
colon character), followed by lines containing repeatable instructions for
245+
- Explain how you have tested your changes by including repeatable instructions for
247246
testing the PR.
248247
- If you added tests, this can be as simple as the command you used to run the
249248
tests.
250249
- If you tested the PR manually, include the steps and the outputs. Help a
251250
future editor understand how to test the code that you're modifying
252251
today.
252+
- If your PR contains or is representative of a feature/bug fix that should be
253+
called out in the release notes, please add a label for "Release notes: \<area\>",
254+
where \<area\> describes which part of ExecuTorch the change pertains to, e.g.
255+
"Release notes: runtime". Here are all of the categories:
256+
- `Release notes: runtime`: changes related to the core runtime which loads the program methods, initializes delegates, and runs the lowered graph.
257+
- `Release notes: exir`: changes to any internal representations, such as any edge-related dialects. Also any changes to passes that may modify the exir, such as memory planning.
258+
- `Release notes: quantization`: changes to quantization.
259+
- `Release notes: ops & kernels`: changes to the opset and any new / changed kernel implementations.
260+
- `Release notes: api`: changes to public facing apis (any interfaces, pybinded runtime methods, etc.).
261+
- `Release notes: backends`: changes to any of the backend delegates.
262+
- `Release notes: build`: changes related to the build system, including major dependency upgrades, notable build flags, optimizations, etc.
263+
- `Release notes: devtools`: changes to any of ExecuTorch's developer tools, for example the debugger & profiler.
264+
- `Release notes: examples`: changes to any code under `examples/`.
265+
- `Release notes: misc`: anything notable that doesn't belong in the above categories.
253266
- See https://github.com/pytorch/executorch/pull/3612 for an example PR that
254267
follows this advice.
255268
1. Before asking for a review, ensure that all [CI (continuous integration)

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ We recommend using the latest release tag from the
4343
See [CONTRIBUTING.md](CONTRIBUTING.md) for details about issues, PRs, code
4444
style, CI jobs, and other development topics.
4545

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.
49+
50+
4651
## Directory Structure
4752

4853
```

backends/apple/coreml/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ To quantize a Program in a Core ML favored way, the client may utilize **CoreMLQ
6565
import torch
6666
import executorch.exir
6767

68-
from torch._export import capture_pre_autograd_graph
68+
from torch.export import export_for_training
6969
from torch.ao.quantization.quantize_pt2e import (
7070
convert_pt2e,
7171
prepare_pt2e,
@@ -93,7 +93,7 @@ class Model(torch.nn.Module):
9393
source_model = Model()
9494
example_inputs = (torch.randn((1, 3, 256, 256)), )
9595

96-
pre_autograd_aten_dialect = capture_pre_autograd_graph(model, example_inputs)
96+
pre_autograd_aten_dialect = export_for_training(model, example_inputs).module()
9797

9898
quantization_config = LinearQuantizerConfig.from_dict(
9999
{

backends/arm/TARGETS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# @noautodeps
12
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")
23

34
python_library(
@@ -69,6 +70,18 @@ python_library(
6970
],
7071
)
7172

73+
python_library(
74+
name = "tosa_specification",
75+
srcs = [
76+
"tosa_specification.py",
77+
],
78+
typing = True,
79+
deps = [
80+
"fbsource//third-party/pypi/packaging:packaging",
81+
"//executorch/exir/backend:compile_spec_schema",
82+
],
83+
)
84+
7285
python_library(
7386
name = "tosa_utils",
7487
srcs = [

backends/arm/_passes/TARGETS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ python_library(
77
deps = [
88
"//executorch/backends/arm:tosa_quant_utils",
99
"//executorch/backends/arm:tosa_utils",
10+
"//executorch/backends/xnnpack/_passes:xnnpack_passes",
1011
"//executorch/exir:lib",
1112
],
1213
)

backends/arm/_passes/annotate_channels_last_dim_order_pass.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
get_first_fake_tensor,
1515
insert_q_dq_pair,
1616
)
17-
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op
17+
from executorch.backends.arm.tosa_quant_utils import dq_op, q_op, register_passable_op
1818
from executorch.backends.arm.tosa_utils import is_consumer_node_depthwise_conv2d
1919
from executorch.exir.dialects._ops import ops as exir_ops
2020
from executorch.exir.pass_base import ExportPass, PassResult
@@ -42,6 +42,9 @@ def _transpose_impl(*args, **kwargs):
4242
return args[0]
4343

4444

45+
register_passable_op(torch.ops.passthrough_to_tosa._transpose)
46+
47+
4548
class AnnotateChannelsLastDimOrder(ExportPass):
4649
"""
4750
Annotates each node with a tosa_dim_order. tosa_dim_order can be seen as a channels-last dim-order

backends/arm/_passes/arm_pass_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from executorch.backends.arm._passes.decompose_layernorm_pass import (
2424
DecomposeLayerNormPass,
2525
)
26+
from executorch.backends.arm._passes.decompose_linear_pass import DecomposeLinearPass
2627
from executorch.backends.arm._passes.decompose_meandim_pass import DecomposeMeanDimPass
2728
from executorch.backends.arm._passes.decompose_softmaxes_pass import (
2829
DecomposeSoftmaxesPass,
@@ -43,6 +44,7 @@
4344
from executorch.backends.arm._passes.unsqueeze_scalar_placeholders_pass import (
4445
UnsqueezeScalarPlaceholdersPass,
4546
)
47+
from executorch.backends.xnnpack._passes.remove_getitem_op import RemoveGetItemPass
4648
from executorch.exir import ExportedProgram
4749
from executorch.exir.backend.compile_spec_schema import CompileSpec
4850
from executorch.exir.pass_manager import PassManager
@@ -58,6 +60,7 @@ def transform_to_backend_pipeline(
5860
):
5961
"""Apply passes before transforming program to backend"""
6062
self.add_pass(CastInt64ToInt32Pass(exported_program))
63+
self.add_pass(RemoveGetItemPass())
6164
self.add_pass(UnsqueezeScalarPlaceholdersPass(exported_program))
6265
self.add_pass(SizeAdjustConv2DPass())
6366
self.add_pass(RemoveClonePass())
@@ -72,6 +75,7 @@ def transform_to_backend_pipeline(
7275
self.add_pass(ConvertSplitToSlicePass())
7376
self.add_pass(Conv1dUnsqueezePass(exported_program))
7477
self.add_pass(DecomposeSoftmaxesPass())
78+
self.add_pass(DecomposeLinearPass())
7579
for spec in compile_spec:
7680
if spec.key == "permute_memory_format":
7781
memory_format = spec.value.decode()

0 commit comments

Comments
 (0)