Skip to content

Commit be65901

Browse files
cccclaifacebook-github-bot
authored andcommitted
move backend aot api to exir
Summary: As part of the directory restructure, we want to move the backend aot interface to exir https://www.internalfb.com/code/fbsource/[a482be103d853a0aba1c5432b94222f398f2782c][history]/fbcode/executorch/README.md?lines=56-58 Reviewed By: JacobSzwejbka Differential Revision: D48006877 fbshipit-source-id: fcd92f38457ad37389d1037416f4c93b2e177984
1 parent 1538910 commit be65901

Some content is hidden

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

76 files changed

+253
-204
lines changed

backends/qnnpack/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ runtime.python_library(
1717
"//executorch/...",
1818
],
1919
deps = [
20-
"//executorch/backends:backend_details",
2120
"//executorch/backends/transforms:lib",
2221
"//executorch/exir:graph_module",
22+
"//executorch/exir/backend:backend_details",
2323
"//executorch/exir/serialize:bindings",
2424
"//executorch/exir/serialize:lib",
2525
],

backends/qnnpack/partition/TARGETS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ runtime.python_library(
1111
],
1212
deps = [
1313
"//caffe2:torch",
14-
"//executorch/backends:utils",
1514
"//executorch/backends/transforms:lib",
15+
"//executorch/exir/backend:utils",
1616
],
1717
)
1818

@@ -27,12 +27,12 @@ runtime.python_library(
2727
],
2828
deps = [
2929
":support_patterns",
30-
"//executorch/backends:partitioner",
31-
"//executorch/backends/canonical_partitioners:canonical_partitioner_lib",
3230
"//executorch/backends/qnnpack:qnnpack_preprocess",
3331
"//executorch/backends/transforms:lib",
3432
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
3533
"//executorch/exir:delegate",
3634
"//executorch/exir:lib",
35+
"//executorch/exir/backend:partitioner",
36+
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",
3737
],
3838
)

backends/qnnpack/qnnpack_preprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
import torch
1111

12-
from executorch.backends.backend_details import BackendDetails, CompileSpec
13-
1412
from executorch.backends.qnnpack.serialization.qnnpack_graph_schema import (
1513
ConstTensor,
1614
QNNDynamicLinear,
@@ -21,6 +19,8 @@
2119

2220
from executorch.backends.transforms import get_shape
2321

22+
from executorch.exir.backend.backend_details import BackendDetails, CompileSpec
23+
2424
from executorch.exir.dialects._ops import ops as exir_ops
2525
from torch._export.exported_program import ExportedProgram
2626

backends/qnnpack/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def define_common_targets():
7373
"serialization/schema.fbs",
7474
],
7575
visibility = [
76-
"//executorch/backends:backend_lib",
76+
"//executorch/exir/backend:backend_lib",
7777
"//executorch/backends/qnnpack/test/...",
78-
"//executorch/backends/test/...",
78+
"//executorch/exir/backend/test/...",
7979
"//executorch/extension/pybindings/...",
8080
"@EXECUTORCH_CLIENTS",
8181
],

backends/qnnpack/test/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ python_unittest(
1414
tags = ["long_running"],
1515
deps = [
1616
"//caffe2:torch",
17-
"//executorch/backends:backend_api",
1817
"//executorch/backends/qnnpack:qnnpack_backend",
1918
"//executorch/backends/qnnpack:qnnpack_preprocess",
2019
"//executorch/backends/qnnpack/partition:qnnpack_partitioner",
2120
"//executorch/exir:lib",
21+
"//executorch/exir/backend:backend_api",
2222
"//executorch/exir/serialize:lib",
2323
"//executorch/extension/pybindings:portable", # @manual
2424
"//executorch/extension/pytree:pylib",

backends/qnnpack/test/test_qnnpack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import torch
1212
import torch.nn.functional as F
1313

14-
from executorch.backends.backend_api import to_backend, validation_disabled
15-
1614
from executorch.backends.qnnpack.partition.qnnpack_partitioner import QnnpackPartitioner
1715

1816
# import the xnnpack backend implementation
1917
from executorch.backends.qnnpack.qnnpack_preprocess import QnnpackBackend
2018
from executorch.exir import CaptureConfig
2119

20+
from executorch.exir.backend.backend_api import to_backend, validation_disabled
21+
2222
from executorch.exir.serialize import serialize_to_flatbuffer
2323

2424
# pyre-ignore[21]: Could not find module `executorch.extension.pybindings.portable`.

backends/vulkan/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ runtime.python_library(
3636
"//executorch/vulkan/...",
3737
],
3838
deps = [
39-
"//executorch/backends:backend_details",
4039
"//executorch/exir:graph_module",
40+
"//executorch/exir/backend:backend_details",
4141
"//executorch/exir/serialize:bindings",
4242
"//executorch/exir/serialize:lib",
4343
],

backends/vulkan/test/TARGETS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ python_unittest(
1212
],
1313
deps = [
1414
"//caffe2:torch",
15-
"//executorch/backends:backend_api",
1615
"//executorch/backends/vulkan:vulkan_preprocess",
1716
"//executorch/exir:lib",
17+
"//executorch/exir/backend:backend_api",
1818
"//executorch/exir/serialize:lib",
1919
"//executorch/extension/pybindings:portable", # @manual
2020
"//executorch/extension/pytree:pylib",
21-
"//executorch/runtime/executor/test:test_backend_compiler_lib",
21+
"//executorch/kernels/portable:custom_ops_generated_lib",
2222
],
2323
)

backends/vulkan/test/test_vulkan_delegate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
import executorch.exir as exir
1212
import torch
13-
from executorch.backends.backend_api import to_backend
1413

1514
# import the vulkan backend implementation
1615
from executorch.backends.vulkan.vulkan_preprocess import VulkanBackend
16+
from executorch.exir.backend.backend_api import to_backend
1717

1818
from executorch.exir.serialize import serialize_to_flatbuffer
1919

backends/vulkan/vulkan_preprocess.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
from typing import final, List
99

1010
import executorch.backends.vulkan.serialization.vulkan_graph_schema as vk_graph_schema
11+
from executorch.backends.vulkan.serialization.vulkan_graph_serialize import (
12+
convert_to_flatbuffer,
13+
)
1114

12-
from executorch.backends.backend_details import (
15+
from executorch.exir.backend.backend_details import (
1316
BackendDetails,
1417
CompileSpec,
1518
ExportedProgram,
1619
)
17-
from executorch.backends.vulkan.serialization.vulkan_graph_serialize import (
18-
convert_to_flatbuffer,
19-
)
2020
from torch import dtype, float32, Tensor
2121
from torch.fx import Node
2222

backends/xnnpack/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ runtime.python_library(
1818
"@EXECUTORCH_CLIENTS",
1919
],
2020
deps = [
21-
"//executorch/backends:backend_details",
2221
"//executorch/backends/transforms:lib",
2322
"//executorch/backends/xnnpack/operators:operators",
2423
"//executorch/backends/xnnpack/passes:xnnpack_passes",
2524
"//executorch/exir:graph_module",
25+
"//executorch/exir/backend:backend_details",
2626
"//executorch/exir/serialize:bindings",
2727
"//executorch/exir/serialize:lib",
2828
],

backends/xnnpack/operators/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ runtime.python_library(
88
"@EXECUTORCH_CLIENTS",
99
],
1010
deps = [
11-
"//executorch/backends:backend_details",
1211
"//executorch/backends/xnnpack/utils:xnnpack_utils",
1312
"//executorch/exir:graph_module",
13+
"//executorch/exir/backend:backend_details",
1414
"//executorch/exir/serialize:bindings",
1515
"//executorch/exir/serialize:lib",
1616
],

backends/xnnpack/partition/TARGETS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runtime.python_library(
1111
],
1212
deps = [
1313
"//caffe2:torch",
14-
"//executorch/backends:utils",
14+
"//executorch/exir/backend:utils",
1515
],
1616
)
1717

@@ -26,11 +26,11 @@ runtime.python_library(
2626
],
2727
deps = [
2828
":support_patterns",
29-
"//executorch/backends:partitioner",
30-
"//executorch/backends:utils",
31-
"//executorch/backends/canonical_partitioners:canonical_partitioner_lib",
3229
"//executorch/backends/xnnpack:xnnpack_preprocess",
3330
"//executorch/exir:delegate",
3431
"//executorch/exir:lib",
32+
"//executorch/exir/backend:partitioner",
33+
"//executorch/exir/backend:utils",
34+
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",
3535
],
3636
)

backends/xnnpack/partition/support_patterns.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
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.
66

7-
import executorch.backends.utils as utils
7+
import executorch.exir.backend.utils as utils
88
import torch
99
import torch.nn.functional as F
1010
from executorch import exir
11-
from executorch.backends.canonical_partitioners.duplicate_dequant_node_pass import (
11+
from executorch.exir import CaptureConfig
12+
from executorch.exir.backend.canonical_partitioners.duplicate_dequant_node_pass import (
1213
DuplicateDequantNodePass,
1314
)
14-
from executorch.exir import CaptureConfig
1515
from executorch.exir.dialects._ops import ops as exir_ops
1616

1717
from torch.ao.quantization import PlaceholderObserver, QConfig, QConfigMapping

backends/xnnpack/partition/xnnpack_partitioner.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
from typing import Any, Callable, cast, Dict, List, Optional, Union
1111

1212
import torch
13-
14-
from executorch.backends.canonical_partitioners.pattern_op_partitioner import (
15-
generate_partitions_from_list_of_nodes,
16-
generate_pattern_op_partitions,
17-
)
18-
19-
from executorch.backends.partitioner import DelegationSpec, Partitioner
2013
from executorch.backends.xnnpack.partition.support_patterns import (
2114
get_add_graphs,
2215
get_all_dynamically_quantized_linear_pattern,
@@ -48,6 +41,13 @@
4841
)
4942
from executorch.backends.xnnpack.utils.utils import get_input_node
5043
from executorch.backends.xnnpack.xnnpack_preprocess import XnnpackBackend
44+
45+
from executorch.exir.backend.canonical_partitioners.pattern_op_partitioner import (
46+
generate_partitions_from_list_of_nodes,
47+
generate_pattern_op_partitions,
48+
)
49+
50+
from executorch.exir.backend.partitioner import DelegationSpec, Partitioner
5151
from executorch.exir.dialects._ops import ops as exir_ops
5252
from torch.fx.passes.infra.partitioner import Partition
5353
from torch.fx.passes.operator_support import chain, OperatorSupportBase

backends/xnnpack/targets.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def define_common_targets():
4444
"runtime/*.h",
4545
]),
4646
visibility = [
47-
"//executorch/backends:backend_lib",
48-
"//executorch/backends/test/...",
47+
"//executorch/exir/backend:backend_lib",
48+
"//executorch/exir/backend/test/...",
4949
"//executorch/backends/xnnpack/test/...",
5050
"//executorch/extension/pybindings/...",
5151
"@EXECUTORCH_CLIENTS",

backends/xnnpack/test/TARGETS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ python_unittest(
1414
tags = ["long_running"],
1515
deps = [
1616
"//caffe2:torch",
17-
"//executorch/backends:backend_api",
1817
"//executorch/backends/xnnpack:xnnpack_backend",
1918
"//executorch/backends/xnnpack:xnnpack_preprocess",
2019
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
@@ -23,6 +22,7 @@ python_unittest(
2322
"//executorch/bundled_program:core",
2423
"//executorch/bundled_program/serialize:lib",
2524
"//executorch/exir:lib",
25+
"//executorch/exir/backend:backend_api",
2626
"//executorch/exir/passes:spec_prop_pass",
2727
"//executorch/exir/serialize:lib",
2828
"//executorch/extension/pybindings:portable", # @manual
@@ -43,7 +43,6 @@ python_unittest(
4343
tags = ["long_running"],
4444
deps = [
4545
"//caffe2:torch",
46-
"//executorch/backends:backend_api",
4746
"//executorch/backends/xnnpack:xnnpack_backend",
4847
"//executorch/backends/xnnpack:xnnpack_preprocess",
4948
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
@@ -52,6 +51,7 @@ python_unittest(
5251
"//executorch/bundled_program:core",
5352
"//executorch/bundled_program/serialize:lib",
5453
"//executorch/exir:lib",
54+
"//executorch/exir/backend:backend_api",
5555
"//executorch/exir/dialects:lib",
5656
"//executorch/exir/passes:spec_prop_pass",
5757
"//executorch/exir/serialize:lib",
@@ -73,7 +73,6 @@ python_unittest(
7373
tags = ["long_running"],
7474
deps = [
7575
"//caffe2:torch",
76-
"//executorch/backends:backend_api",
7776
"//executorch/backends/xnnpack:xnnpack_backend",
7877
"//executorch/backends/xnnpack:xnnpack_preprocess",
7978
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
@@ -82,6 +81,7 @@ python_unittest(
8281
"//executorch/bundled_program:core",
8382
"//executorch/bundled_program/serialize:lib",
8483
"//executorch/exir:lib",
84+
"//executorch/exir/backend:backend_api",
8585
"//executorch/exir/passes:spec_prop_pass",
8686
"//executorch/exir/serialize:lib",
8787
"//executorch/extension/pybindings:portable", # @manual
@@ -98,10 +98,10 @@ python_unittest(
9898
],
9999
deps = [
100100
"//caffe2:torch",
101-
"//executorch/backends/canonical_partitioners:canonical_partitioner_lib",
102101
"//executorch/backends/xnnpack/passes:xnnpack_passes",
103102
"//executorch/backends/xnnpack/utils:xnnpack_utils",
104103
"//executorch/exir:lib",
104+
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",
105105
],
106106
)
107107

backends/xnnpack/test/test_xnnpack_passes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
import torch
1111
from executorch import exir
12-
from executorch.backends.canonical_partitioners.duplicate_dequant_node_pass import (
13-
DuplicateDequantNodePass,
14-
)
1512
from executorch.backends.xnnpack.passes.channels_last_tagged_reshape_pass import (
1613
ChannelsLastTaggedReshapePass,
1714
)
@@ -26,6 +23,9 @@
2623
)
2724
from executorch.backends.xnnpack.utils.configs import get_xnnpack_capture_config
2825
from executorch.backends.xnnpack.utils.utils import capture_graph_for_xnnpack
26+
from executorch.exir.backend.canonical_partitioners.duplicate_dequant_node_pass import (
27+
DuplicateDequantNodePass,
28+
)
2929
from torch.ao.quantization.backend_config.executorch import (
3030
get_executorch_backend_config,
3131
)

backends/xnnpack/test/test_xnnpack_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import torch
1212
import torch.nn.functional as F
1313
from executorch import exir
14-
from executorch.backends.backend_api import to_backend, validation_disabled
1514

1615
from executorch.backends.xnnpack.partition.xnnpack_partitioner import (
1716
XnnpackDynamicallyQuantizedPartitioner2,
@@ -32,6 +31,7 @@
3231
from executorch.bundled_program.serialize import (
3332
serialize_from_bundled_program_to_flatbuffer,
3433
)
34+
from executorch.exir.backend.backend_api import to_backend, validation_disabled
3535

3636
from executorch.exir.passes.spec_prop_pass import SpecPropPass
3737
from executorch.exir.serialize import serialize_to_flatbuffer

backends/xnnpack/test/tester/TARGETS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ runtime.python_library(
1313
],
1414
deps = [
1515
"//caffe2:torch",
16-
"//executorch/backends:backend_api",
17-
"//executorch/backends:partitioner",
1816
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
1917
"//executorch/backends/xnnpack/utils:xnnpack_utils",
2018
"//executorch/exir:lib",
19+
"//executorch/exir/backend:backend_api",
20+
"//executorch/exir/backend:partitioner",
2121
"//executorch/exir/passes:spec_prop_pass",
2222
"//executorch/exir/serialize:lib",
2323
"//executorch/extension/pybindings:portable", # @manual

backends/xnnpack/test/tester/tester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
import torch
1313
from executorch import exir
14-
from executorch.backends.backend_api import to_backend, validation_disabled
15-
from executorch.backends.partitioner import Partitioner
1614
from executorch.backends.xnnpack.partition.xnnpack_partitioner import (
1715
XnnpackFloatingPointPartitioner,
1816
)
@@ -27,6 +25,8 @@
2725
ExecutorchProgram,
2826
ExirExportedProgram,
2927
)
28+
from executorch.exir.backend.backend_api import to_backend, validation_disabled
29+
from executorch.exir.backend.partitioner import Partitioner
3030
from executorch.exir.passes.spec_prop_pass import SpecPropPass
3131
from executorch.exir.serialize import serialize_to_flatbuffer
3232

backends/xnnpack/utils/TARGETS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ python_library(
2424
srcs = glob(["*.py"]) + [":xnnpack_constants[xnnpack_constants.py]"],
2525
deps = [
2626
"//caffe2:torch",
27-
"//executorch/backends/canonical_partitioners:canonical_partitioner_lib",
2827
"//executorch/exir:lib",
28+
"//executorch/exir/backend/canonical_partitioners:canonical_partitioner_lib",
2929
"//executorch/exir/dialects:lib",
3030
],
3131
)

0 commit comments

Comments
 (0)