Skip to content

Commit 972ec0d

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 ``` Differential Revision: D49714823 fbshipit-source-id: 2fc6441a18d730a89abc7f90664d3bffab52d4e0
1 parent 974e2e3 commit 972ec0d

File tree

99 files changed

+404
-343
lines changed

Some content is hidden

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

99 files changed

+404
-343
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 3 additions & 4 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
BUILD_TOOLS = [
1616
"buck2",
@@ -55,8 +55,7 @@ def export_models_for_ci() -> None:
5555
}
5656
delegation_configs = {
5757
False,
58-
name in MODEL_NAME_TO_OPTIONS
59-
and MODEL_NAME_TO_OPTIONS[name].xnnpack_delegation,
58+
name in MODEL_NAME_TO_OPTIONS and MODEL_NAME_TO_OPTIONS[name].delegation,
6059
}
6160
for build_tool in BUILD_TOOLS:
6261
for q_config in quantization_configs:
@@ -66,7 +65,7 @@ def export_models_for_ci() -> None:
6665
"build-tool": build_tool,
6766
"model": name,
6867
"xnnpack_quantization": q_config,
69-
"xnnpack_delegation": d_config,
68+
"delegation": d_config,
7069
"runner": RUNNERS.get(name, DEFAULT_RUNNER),
7170
# demo_backend_delegation test only supports add_mul model
7271
"demo_backend_delegation": name == "add_mul",

.ci/scripts/test.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ build_cmake_executor_runner() {
5353
}
5454

5555
test_model() {
56-
"${PYTHON_EXECUTABLE}" -m examples.export.export_example --model_name="${MODEL_NAME}"
56+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}"
5757

5858
# Run test model
5959
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
60-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./${MODEL_NAME}.pte"
60+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./${MODEL_NAME}.pte"
6161
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
6262
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
6363
build_cmake_executor_runner
@@ -92,24 +92,24 @@ test_model_with_xnnpack() {
9292

9393
# Quantization-only
9494
if [[ ${WITH_QUANTIZATION} == true ]] && [[ ${WITH_DELEGATION} == false ]]; then
95-
bash examples/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
95+
bash examples/xnnpack/quantization/test_quantize.sh "${BUILD_TOOL}" "${MODEL_NAME}"
9696
exit 0
9797
fi
9898

9999
# Delegation
100100
if [[ ${WITH_QUANTIZATION} == true ]]; then
101101
SUFFIX="q8"
102-
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate --quantize
102+
"${PYTHON_EXECUTABLE}" -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate --quantize
103103
else
104104
SUFFIX="fp32"
105-
"${PYTHON_EXECUTABLE}" -m examples.backend.xnnpack_examples --model_name="${MODEL_NAME}" --delegate
105+
"${PYTHON_EXECUTABLE}" -m examples.xnnpack.aot_compiler --model_name="${MODEL_NAME}" --delegate
106106
fi
107107

108108
OUTPUT_MODEL_PATH="${MODEL_NAME}_xnnpack_${SUFFIX}.pte"
109109

110110
# Run test model
111111
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
112-
buck2 run //examples/backend:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
112+
buck2 run //examples/xnnpack:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
113113
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
114114
if [[ ! -f ${CMAKE_OUTPUT_DIR}/backends/xnnpack/xnn_executor_runner ]]; then
115115
build_cmake_xnn_executor_runner
@@ -123,15 +123,15 @@ test_model_with_xnnpack() {
123123

124124
test_demo_backend_delegation() {
125125
echo "Testing demo backend delegation on AddMul"
126-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "composite"
127-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "partition"
128-
"${PYTHON_EXECUTABLE}" -m examples.export.export_and_delegate --option "whole"
126+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "composite"
127+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "partition"
128+
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export_and_delegate --option "whole"
129129

130130
# Run test model
131131
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
132-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./composite_model.pte"
133-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
134-
buck2 run //examples/executor_runner:executor_runner -- --model_path "./whole.pte"
132+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./composite_model.pte"
133+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./partition_lowered_model.pte"
134+
buck2 run //examples/portable/executor_runner:executor_runner -- --model_path "./whole.pte"
135135
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
136136
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
137137
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
@@ -86,7 +86,7 @@ jobs:
8686
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
8787
8888
# Build and test custom ops
89-
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
89+
PYTHON_EXECUTABLE=python bash examples/portable/custom_ops/test_custom_ops.sh "${BUILD_TOOL}"
9090
popd
9191
9292
test-selective-build-macos:

CMakeLists.txt

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

7878
# Option to register custom operator `my_ops::mul3` or `my_ops::mul4` or no
7979
# custom ops at all. Custom ops are defined in
80-
# `examples/custom_ops/custom_ops_1.py` and
81-
# `examples/custom_ops/custom_ops_2.cpp`.
80+
# `examples/portable/custom_ops/custom_ops_1.py` and
81+
# `examples/portable/custom_ops/custom_ops_2.cpp`.
8282
option(
8383
REGISTER_EXAMPLE_CUSTOM_OP
8484
"Register whether custom op 1 (my_ops::mul3) or custom op 2 (my_ops::mul4) \
@@ -278,7 +278,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
278278

279279
# Generate custom_ops_lib based on REGISTER_EXAMPLE_CUSTOM_OP
280280
if(REGISTER_EXAMPLE_CUSTOM_OP EQUAL 1 OR REGISTER_EXAMPLE_CUSTOM_OP EQUAL 2)
281-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/custom_ops)
281+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples/portable/custom_ops)
282282
list(APPEND _executor_runner_libs custom_ops_lib)
283283
endif()
284284

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 (

0 commit comments

Comments
 (0)