Skip to content

Commit 012d4b8

Browse files
guangy10facebook-github-bot
authored andcommitted
Restructuring demos (#531)
Summary: Pull Request resolved: #531 ----- ## Confusion arising from the current code structure: Reference to current code structure: https://github.com/pytorch/executorch/tree/main/examples The current code structure under `executorch/examples` mixes different levels of detail. For instance, the directories `backend/`, `quantization/`, and `export/` are intended for component-level demo code, such as showcasing quantization/export/delegation workflows or providing sample backend/quantizer/partitioner implementations. Assembling them to create a AOT path should not belong to any of it. However, the current structure combines recipes and individual components: - All contents of `backend/` are exclusively tailored for [xnnpack](https://github.com/pytorch/executorch/tree/main/examples/backend). - [export+delegate+composite](https://github.com/pytorch/executorch/blob/main/examples/export/export_and_delegate.py) and [bundled program example](https://github.com/pytorch/executorch/blob/main/examples/export/export_bundled_program.py) are placed in `export/` - Different runtimes are placed haphazardly., with items like [executor_runner](https://github.com/pytorch/executorch/tree/main/examples/executor_runner), [bundled_executor_runner](https://github.com/pytorch/executorch/tree/main/examples/bundled_executor_runner), and [xnn_executor_runner](https://github.com/pytorch/executorch/tree/main/examples/backend) - Backend-specific demos are scattered in the top-level directory, such as [arm's demo](https://github.com/pytorch/executorch/tree/main/examples/arm) and [partitioner/quantizer demo](https://github.com/pytorch/executorch/tree/main/examples/example_quantizer_and_delegate) Issues that are not directly tie to code restructuring but will need to be addressed as well. **Non-functional code/demo** (fix or hide): - [Unit tests](https://github.com/pytorch/executorch/tree/main/examples/export/test) under the `export/` directory are not runnable in the OSS environment. - The [example_quantizer_and_delegate](https://github.com/pytorch/executorch/tree/main/examples/example_quantizer_and_delegate) is not functioning and should be rectified or hidden. - The [arm's demo](https://github.com/pytorch/executorch/tree/main/examples/arm) is not runnable directly w/o additional guide. ----- ## Proposed code structure: organize demos in a way that is easier for users to understand how pieces are put together to create an e2e experience. We can go with this "vertical" structure if we could come up and agree on guidelines of whether a new demo should be considered as "adding a new demo" or "extending an existing demo". The purpose is to prevent randomly dumping demos in the top-level executorch/examples folder with boilerplate code. While this doesn't violate the rule of structuring demos vertically for user understanding, , but it literally has no structure at all, and it will quickly grow of out our maintenance. In my opinion, it would make sense to consider the following cases as **"adding a new demo"**: 1. Demo of a new 1st/3rd party backend, e.g. portable (default backend), xnnpack, arm, coreml, etc. 2. Demo of toolings, e.g. selective build, productivity sdk, etc. 3. Target specific apps, e.g. playground apps for Android/iOS/Embedded The rests will be considered as **"extending an existing demo"**, for example: - Demo of composibitlity, e.g. delegate and composite, whole/partial graph lowering, custom ops - Demo of specific components, e.g. quantization workflow, 2-stage export flow, example quantizer/partitioner, etc. After PTC we will spend more efforts on expanding and polishing the two major 1st-party demos (`examples/portable/` & `examples/xnnpack/`) we own in the long run. Maybe `examples/sdk` as well. So with the guidelines, the new top-level structure will looks like: ``` executorch/examples/ ├── README.md # top-level description for demos and folder structures ├── models/ ├── xnnpack/ # 1p e2e ├── portable/ # 1p e2e ├── arm/ # 3p backend e2e ├── qualcomm/ # 3p backend e2e ├── apple/ # 3p backend e2e ├── third-party/ # for the short-term, we can assume a centralized place for all third-party libs required by demos, e.g. sam, llama, etc. ├── selective_build/ ├── ios_demo_apps/ ├── android_demo_apps/ # future ├── productivity_sdk/ # future └── utils/ # future ``` If we zoom in to `examples/portable/`, it will look like: ``` executorch/examples/portable/ ├── executor_runner/ ├── bundled_executor_runner/ ├── custom_ops/ ├── scripts/ │ ├── export_and_delegate.py │ ├── export_bundled_program.py │ └── export.py ├── test/ ├── __init__.py ├── utils.py └── README.md ``` If we zoom in to `examples/xnnpack/`, it will look like: ``` executorch/examples/xnnpack/ ├── quantization/ │ ├── example.py │ ├── TARGETS │ ├── test_quantize.sh │ └── utils.py ├── __init__.py ├── aot_compiler.py └── README.md ``` Reviewed By: mergennachin Differential Revision: D49714823 fbshipit-source-id: 592d94b1e0269b14641a6a98d2dc81be21e77734
1 parent fd82f21 commit 012d4b8

File tree

98 files changed

+712
-342
lines changed

Some content is hidden

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

98 files changed

+712
-342
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from typing import Any
1111

1212
from examples.models import MODEL_NAME_TO_MODEL
13-
from examples.recipes.xnnpack_optimization import MODEL_NAME_TO_OPTIONS
13+
from examples.xnnpack import MODEL_NAME_TO_OPTIONS
1414

1515
# NB: Skip buck2 on MacOS to cut down the number of combinations we
1616
# need to run there as the number of MacOS runner is limited. Buck2
@@ -80,8 +80,7 @@ def export_models_for_ci() -> None:
8080
}
8181
delegation_configs = {
8282
False,
83-
name in MODEL_NAME_TO_OPTIONS
84-
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation,
83+
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].delegation,
8584
}
8685
for build_tool in BUILD_TOOLS.keys():
8786
if target_os not in BUILD_TOOLS[build_tool]:

.ci/scripts/test.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ test_model() {
5959
cd ../../..
6060
fi
6161

62-
"${PYTHON_EXECUTABLE}" -m examples.export.export_example --model_name="${MODEL_NAME}"
62+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}"
6363

6464
# Run test model
6565
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
66-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./${MODEL_NAME}.pte"
66+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./${MODEL_NAME}.pte"
6767
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
6868
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
6969
build_cmake_executor_runner
@@ -98,24 +98,24 @@ test_model_with_xnnpack() {
9898

9999
# Quantization-only
100100
if [[ ${WITH_QUANTIZATION} == true ]] && [[ ${WITH_DELEGATION} == false ]]; then
101-
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
101+
bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
102102
exit 0
103103
fi
104104

105105
# Delegation
106106
if [[ ${WITH_QUANTIZATION} == true ]]; then
107107
SUFFIX="q8"
108-
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate --quantize
108+
"${PYTHON_EXECUTABLE}" -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate --quantize
109109
else
110110
SUFFIX="fp32"
111-
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate
111+
"${PYTHON_EXECUTABLE}" -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate
112112
fi
113113

114114
OUTPUT_MODEL_PATH="${MODEL_NAME}_xnnpack_${SUFFIX}.pte"
115115

116116
# Run test model
117117
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
118-
buck2 run //examples/backend:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
118+
buck2 run //examples/xnnpack:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
119119
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
120120
if [[ ! -f ${CMAKE_OUTPUT_DIR}/backends/xnnpack/xnn_executor_runner ]]; then
121121
build_cmake_xnn_executor_runner
@@ -129,15 +129,15 @@ test_model_with_xnnpack() {
129129

130130
test_demo_backend_delegation() {
131131
echo "Testing demo backend delegation on AddMul"
132-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "composite"
133-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "partition"
134-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "whole"
132+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "composite"
133+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "partition"
134+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "whole"
135135

136136
# Run test model
137137
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
138-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./composite_model.pte"
139-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
140-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./whole.pte"
138+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./composite_model.pte"
139+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
140+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./whole.pte"
141141
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
142142
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
143143
build_cmake_executor_runner

.ci/scripts/utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ install_flatc_from_source() {
7070

7171
build_executorch_runner_buck2() {
7272
# Build executorch runtime with retry as this step is flaky on macos CI
73-
retry buck2 build //examples/executor_runner:executor_runner
73+
retry buck2 build //examples/portable/executor_runner:executor_runner
7474
}
7575

7676
build_executorch_runner_cmake() {

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
MODEL_NAME=${{ matrix.model }}
5959
BUILD_TOOL=${{ matrix.build-tool }}
6060
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
61-
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
61+
XNNPACK_DELEGATION=${{ matrix.delegation }}
6262
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
6363
6464
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
@@ -87,7 +87,7 @@ jobs:
8787
BUILD_TOOL=${{ matrix.build-tool }}
8888
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
8989
# Test custom ops
90-
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
90+
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
9191
9292
test-selective-build-linux:
9393
name: test-selective-build-linux

.github/workflows/trunk.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
MODEL_NAME=${{ matrix.model }}
5656
BUILD_TOOL=${{ matrix.build-tool }}
5757
XNNPACK_QUANTIZATION=${{ matrix.xnnpack_quantization }}
58-
XNNPACK_DELEGATION=${{ matrix.xnnpack_delegation }}
58+
XNNPACK_DELEGATION=${{ matrix.delegation }}
5959
DEMO_BACKEND_DELEGATION=${{ matrix.demo_backend_delegation }}
6060
6161
# Setup MacOS dependencies as there is no Docker support on MacOS atm
@@ -85,7 +85,7 @@ jobs:
8585
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
8686
8787
# Build and test custom ops
88-
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
88+
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
8989
popd
9090
9191
test-selective-build-macos:

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
9393

9494
# Option to register custom operator `my_ops::mul3` or `my_ops::mul4` or no
9595
# custom ops at all. Custom ops are defined in
96-
# `examples/custom_ops/custom_ops_1.py` and
97-
# `examples/custom_ops/custom_ops_2.cpp`.
96+
# `examples/portable/custom_ops/custom_ops_1.py` and
97+
# `examples/portable/custom_ops/custom_ops_2.cpp`.
9898
option(
9999
REGISTER_EXAMPLE_CUSTOM_OP
100100
"Register whether custom op 1 (my_ops::mul3) or custom op 2 (my_ops::mul4) \
@@ -296,7 +296,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
296296

297297
# Generate custom_ops_lib based on REGISTER_EXAMPLE_CUSTOM_OP
298298
if(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 1 OR REGISTER_EXAMPLE_CUSTOM_OP EQUAL 2)
299-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_ops)
299+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/portable/custom_ops)
300300
list(APPEND _executor_runner_libs custom_ops_lib)
301301
endif()
302302

examples/example_quantizer_and_delegate/TARGETS renamed to backends/example/TARGETS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ python_library(
88
],
99
deps = [
1010
"//caffe2:torch",
11-
"//executorch/examples/example_quantizer_and_delegate/example_operators:example_operators_lib",
11+
"//executorch/backends/example/example_operators:example_operators_lib",
1212
],
1313
)
1414

@@ -18,7 +18,7 @@ python_library(
1818
"example_backend.py",
1919
],
2020
deps = [
21-
"//executorch/examples/example_quantizer_and_delegate/example_backend_delegate_passes:lib",
21+
"//executorch/backends/example/example_backend_delegate_passes:lib",
2222
"//executorch/exir/backend:backend_details",
2323
"//executorch/exir/backend:compile_spec_schema",
2424
],
@@ -32,7 +32,7 @@ python_library(
3232
deps = [
3333
":example_backend",
3434
"//caffe2:torch",
35-
"//executorch/examples/example_quantizer_and_delegate/example_operators:example_operators_lib",
35+
"//executorch/backends/example/example_operators:example_operators_lib",
3636
"//executorch/exir:graph_module",
3737
"//executorch/exir/backend:partitioner",
3838
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",

examples/example_quantizer_and_delegate/example_backend.py renamed to backends/example/example_backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import copy
88
from typing import final, List
99

10-
from executorch.examples.example_quantizer_and_delegate.example_backend_delegate_passes.merge_to_dim_pass import (
10+
from executorch.backends.example.example_backend_delegate_passes.merge_to_dim_pass import (
1111
MergeToDimPass,
1212
)
13-
from executorch.examples.example_quantizer_and_delegate.example_backend_delegate_passes.permute_memory_formats_pass import (
13+
from executorch.backends.example.example_backend_delegate_passes.permute_memory_formats_pass import (
1414
PermuteMemoryFormatsPass,
1515
)
1616

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ python_library(
88
],
99
deps = [
1010
"//caffe2:torch",
11-
"//executorch/examples/example_quantizer_and_delegate/example_operators:example_operators_lib",
11+
"//executorch/backends/example/example_operators:example_operators_lib",
1212
"//executorch/exir:dim_order_utils",
1313
"//executorch/exir:pass_base",
1414
"//executorch/exir/dialects:lib",
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
from itertools import chain
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.ops import (
11-
module_to_annotator,
12-
)
10+
from executorch.backends.example.example_operators.ops import module_to_annotator
1311
from executorch.exir.dialects._ops import ops as exir_ops
1412
from executorch.exir.dim_order_utils import get_dim_order
1513
from executorch.exir.pass_base import ExportPass, PassResult
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/add.py renamed to backends/example/example_operators/add.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/conv2d.py renamed to backends/example/example_operators/conv2d.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/conv_relu.py renamed to backends/example/example_operators/conv_relu.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/dropout.py renamed to backends/example/example_operators/dropout.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/flatten.py renamed to backends/example/example_operators/flatten.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/linear.py renamed to backends/example/example_operators/linear.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
from dataclasses import dataclass
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_operators.op_base import (
11-
OpBase,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.utils import (
10+
from executorch.backends.example.example_operators.op_base import OpBase
11+
from executorch.backends.example.example_operators.utils import (
1412
_annotate_nodes,
1513
_nodes_are_annotated,
1614
)

examples/example_quantizer_and_delegate/example_operators/ops.py renamed to backends/example/example_operators/ops.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,16 @@
66

77
from collections import OrderedDict
88

9-
from executorch.examples.example_quantizer_and_delegate.example_operators.adaptive_avg_pool2d import (
9+
from executorch.backends.example.example_operators.adaptive_avg_pool2d import (
1010
AdaptiveAvgPool2dNode,
1111
)
1212

13-
from executorch.examples.example_quantizer_and_delegate.example_operators.add import (
14-
AddNode,
15-
)
16-
from executorch.examples.example_quantizer_and_delegate.example_operators.conv2d import (
17-
Conv2DNode,
18-
)
19-
from executorch.examples.example_quantizer_and_delegate.example_operators.conv_relu import (
20-
ConvReluNode,
21-
)
22-
from executorch.examples.example_quantizer_and_delegate.example_operators.dropout import (
23-
DropOutNode,
24-
)
25-
from executorch.examples.example_quantizer_and_delegate.example_operators.flatten import (
26-
FlattenNode,
27-
)
28-
from executorch.examples.example_quantizer_and_delegate.example_operators.linear import (
29-
LinearNode,
30-
)
13+
from executorch.backends.example.example_operators.add import AddNode
14+
from executorch.backends.example.example_operators.conv2d import Conv2DNode
15+
from executorch.backends.example.example_operators.conv_relu import ConvReluNode
16+
from executorch.backends.example.example_operators.dropout import DropOutNode
17+
from executorch.backends.example.example_operators.flatten import FlattenNode
18+
from executorch.backends.example.example_operators.linear import LinearNode
3119

3220
# The ordering of this is important as the quantizer will try to match the patterns in this order.
3321
# That's why we want to match the fused patterns first and then the non-fused ones.

examples/example_quantizer_and_delegate/example_partitioner.py renamed to backends/example/example_partitioner.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
from typing import Dict, final
88

99
import torch
10-
from executorch.examples.example_quantizer_and_delegate.example_backend import (
11-
TosaBackend,
12-
)
13-
from executorch.examples.example_quantizer_and_delegate.example_operators.ops import (
14-
module_to_annotator,
15-
)
10+
from executorch.backends.example.example_backend import TosaBackend
11+
from executorch.backends.example.example_operators.ops import module_to_annotator
1612
from executorch.exir.backend.canonical_partitioners.pattern_op_partitioner import (
1713
generate_partitions_from_list_of_nodes,
1814
)

examples/example_quantizer_and_delegate/example_quantizer.py renamed to backends/example/example_quantizer.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
from typing import List
99

1010
import torch
11-
from executorch.examples.example_quantizer_and_delegate.example_operators.ops import (
12-
module_to_annotator,
13-
)
11+
from executorch.backends.example.example_operators.ops import module_to_annotator
1412
from torch import fx
1513
from torch.ao.quantization.observer import HistogramObserver, MinMaxObserver
1614
from torch.ao.quantization.pt2e.graph_utils import find_sequential_partitions

examples/example_quantizer_and_delegate/test_example_delegate.py renamed to backends/example/test_example_delegate.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
import torch
1111
import torch._export as export
1212
from executorch import exir
13-
from executorch.examples.example_quantizer_and_delegate.example_partitioner import (
14-
ExamplePartitioner,
15-
)
16-
from executorch.examples.example_quantizer_and_delegate.example_quantizer import (
17-
ExampleQuantizer,
18-
)
13+
from executorch.backends.example.example_partitioner import ExamplePartitioner
14+
from executorch.backends.example.example_quantizer import ExampleQuantizer
1915
from executorch.exir.backend.backend_api import to_backend
2016

2117
from executorch.exir.backend.canonical_partitioners.duplicate_dequant_node_pass import (

build/cmake_deps.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ excludes = [
1313

1414
[targets.executor_runner]
1515
buck_targets = [
16-
"//examples/executor_runner:executor_runner",
16+
"//examples/portable/executor_runner:executor_runner",
1717
]
1818
filters = [
1919
".cpp$",
@@ -104,7 +104,7 @@ deps = [
104104

105105
[targets.xnn_executor_runner]
106106
buck_targets = [
107-
"//examples/backend:xnn_executor_runner",
107+
"//examples/xnnpack:xnn_executor_runner",
108108
]
109109
filters = [
110110
".cpp$",

0 commit comments

Comments
 (0)