Skip to content

Commit f51b01a

Browse files
Gasoonjiafacebook-github-bot
authored andcommitted
put bundled program under executorch/sdk (#1014)
Summary: Pull Request resolved: #1014 This stack aims to restructure bundledprogram codebase. The target structure should be like D49605947. This diff moves bundled program codebase from executorch/ to executorch/sdk/ Differential Revision: D50422728 fbshipit-source-id: b22659914ef0278aa8521f3be3b084e6d9edeb45
1 parent f78530b commit f51b01a

File tree

26 files changed

+103
-96
lines changed

26 files changed

+103
-96
lines changed

backends/apple/mps/test/test_mps.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
TestMPS,
2626
)
2727

28-
from executorch.bundled_program.config import MethodTestCase, MethodTestSuite
29-
from executorch.bundled_program.core import create_bundled_program
30-
from executorch.bundled_program.serialize import (
28+
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
29+
from executorch.sdk.bundled_program.core import create_bundled_program
30+
from executorch.sdk.bundled_program.serialize import (
3131
serialize_from_bundled_program_to_flatbuffer,
3232
)
3333
from executorch.exir import ExirExportedProgram

backends/apple/mps/test/test_mps_utils.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
import torch
1414
from executorch.backends.apple.mps.mps_preprocess import MPSBackend
15-
from executorch.bundled_program.config import MethodTestCase, MethodTestSuite
16-
from executorch.bundled_program.core import create_bundled_program
17-
from executorch.bundled_program.serialize import (
18-
serialize_from_bundled_program_to_flatbuffer,
19-
)
2015
from executorch.exir import ExecutorchProgram, ExirExportedProgram
2116
from executorch.exir.backend.backend_api import to_backend, validation_disabled
2217

2318
from executorch.exir.print_program import print_program
19+
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
20+
from executorch.sdk.bundled_program.core import create_bundled_program
21+
from executorch.sdk.bundled_program.serialize import (
22+
serialize_from_bundled_program_to_flatbuffer,
23+
)
2424

2525
# Config for Capturing the weights, will be moved in the future
2626
_CAPTURE_CONFIG = exir.CaptureConfig(enable_aot=True, _unlift=True)
@@ -191,9 +191,14 @@ def forward(self, *args):
191191
)
192192

193193
method_test_suites = [
194-
MethodTestSuite(method_name="forward", test_cases=[
195-
MethodTestCase(input=sample_inputs, expected_outputs=[module(*sample_inputs)])
196-
])
194+
MethodTestSuite(
195+
method_name="forward",
196+
test_cases=[
197+
MethodTestCase(
198+
input=sample_inputs, expected_outputs=[module(*sample_inputs)]
199+
)
200+
],
201+
)
197202
]
198203

199204
logging.info(" -> Test suites generated successfully")

backends/xnnpack/test/TARGETS

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ python_unittest(
2121
"//executorch/backends/xnnpack:xnnpack_preprocess",
2222
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
2323
"//executorch/backends/xnnpack/utils:xnnpack_utils",
24-
"//executorch/bundled_program:config",
25-
"//executorch/bundled_program:core",
26-
"//executorch/bundled_program/serialize:lib",
2724
"//executorch/exir:lib",
2825
"//executorch/exir/backend:backend_api",
2926
"//executorch/exir/passes:spec_prop_pass",
3027
"//executorch/extension/pybindings:portable_lib", # @manual
3128
"//executorch/extension/pytree:pylib",
29+
"//executorch/sdk/bundled_program:config",
30+
"//executorch/sdk/bundled_program:core",
31+
"//executorch/sdk/bundled_program/serialize:lib",
3232
],
3333
)
3434

@@ -49,15 +49,15 @@ python_unittest(
4949
"//executorch/backends/xnnpack:xnnpack_preprocess",
5050
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
5151
"//executorch/backends/xnnpack/utils:xnnpack_utils",
52-
"//executorch/bundled_program:config",
53-
"//executorch/bundled_program:core",
54-
"//executorch/bundled_program/serialize:lib",
5552
"//executorch/exir:lib",
5653
"//executorch/exir/backend:backend_api",
5754
"//executorch/exir/dialects:lib",
5855
"//executorch/exir/passes:spec_prop_pass",
5956
"//executorch/extension/pybindings:portable_lib", # @manual
6057
"//executorch/extension/pytree:pylib",
58+
"//executorch/sdk/bundled_program:config",
59+
"//executorch/sdk/bundled_program:core",
60+
"//executorch/sdk/bundled_program/serialize:lib",
6161
],
6262
)
6363

@@ -78,14 +78,14 @@ python_unittest(
7878
"//executorch/backends/xnnpack:xnnpack_preprocess",
7979
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
8080
"//executorch/backends/xnnpack/utils:xnnpack_utils",
81-
"//executorch/bundled_program:config",
82-
"//executorch/bundled_program:core",
83-
"//executorch/bundled_program/serialize:lib",
8481
"//executorch/exir:lib",
8582
"//executorch/exir/backend:backend_api",
8683
"//executorch/exir/passes:spec_prop_pass",
8784
"//executorch/extension/pybindings:portable_lib", # @manual
8885
"//executorch/extension/pytree:pylib",
86+
"//executorch/sdk/bundled_program:config",
87+
"//executorch/sdk/bundled_program:core",
88+
"//executorch/sdk/bundled_program/serialize:lib",
8989
"//pytorch/vision:torchvision",
9090
],
9191
)

backends/xnnpack/test/test_xnnpack_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@
2525

2626
# import the xnnpack backend implementation
2727
from executorch.backends.xnnpack.xnnpack_preprocess import XnnpackBackend
28-
29-
from executorch.bundled_program.config import MethodTestCase, MethodTestSuite
30-
from executorch.bundled_program.core import create_bundled_program
31-
from executorch.bundled_program.serialize import (
32-
serialize_from_bundled_program_to_flatbuffer,
33-
)
3428
from executorch.exir import ExecutorchProgram, ExirExportedProgram
3529
from executorch.exir.backend.backend_api import to_backend, validation_disabled
3630

@@ -41,6 +35,12 @@
4135
)
4236
from executorch.extension.pytree import tree_flatten
4337

38+
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
39+
from executorch.sdk.bundled_program.core import create_bundled_program
40+
from executorch.sdk.bundled_program.serialize import (
41+
serialize_from_bundled_program_to_flatbuffer,
42+
)
43+
4444
from torch.ao.quantization import ( # @manual
4545
default_per_channel_symmetric_qnnpack_qconfig,
4646
PlaceholderObserver,

docs/source/sdk-bundled-io.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ Here is a flow highlighting how to generate a `BundledProgram` given a PyTorch m
8686

8787
import torch
8888

89-
from executorch.bundled_program.config import MethodTestCase, MethodTestSuite
90-
from executorch.bundled_program.core import create_bundled_program
91-
from executorch.bundled_program.serialize import (
89+
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
90+
from executorch.sdk.bundled_program.core import create_bundled_program
91+
from executorch.sdk.bundled_program.serialize import (
9292
serialize_from_bundled_program_to_flatbuffer,
9393
)
9494

@@ -195,7 +195,7 @@ with open(save_path, "wb") as f:
195195
We can also regenerate `BundledProgram` from flatbuffer file if needed:
196196

197197
```python
198-
from executorch.bundled_program.serialize import deserialize_from_flatbuffer_to_bundled_program
198+
from executorch.sdk.bundled_program.serialize import deserialize_from_flatbuffer_to_bundled_program
199199
save_path = "bundled_program.bp"
200200
with open(save_path, "rb") as f:
201201
serialized_bundled_program = f.read()
@@ -325,8 +325,8 @@ Here's the example of the dtype of test input not meet model's requirement:
325325
import torch
326326
from torch.export import export
327327
328-
from executorch.bundled_program.config import BundledConfig
329-
from executorch.bundled_program.core import create_bundled_program
328+
from executorch.sdk.bundled_program.config import BundledConfig
329+
from executorch.sdk.bundled_program.core import create_bundled_program
330330
331331
from executorch.exir import to_edge
332332
@@ -449,8 +449,8 @@ Another common error would be the method name in `BundledConfig` does not exist
449449
import torch
450450
from torch.export import export
451451

452-
from executorch.bundled_program.config import BundledConfig
453-
from executorch.bundled_program.core import create_bundled_program
452+
from executorch.sdk.bundled_program.config import BundledConfig
453+
from executorch.sdk.bundled_program.core import create_bundled_program
454454

455455
from executorch.exir import to_edge
456456

examples/apple/mps/scripts/mps_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
import torch._export as export
1414
from executorch import exir
1515
from executorch.backends.apple.mps.mps_preprocess import MPSBackend
16-
from executorch.bundled_program.config import BundledConfig
17-
from executorch.bundled_program.core import create_bundled_program
18-
from executorch.bundled_program.serialize import (
16+
from executorch.sdk.bundled_program.config import BundledConfig
17+
from executorch.sdk.bundled_program.core import create_bundled_program
18+
from executorch.sdk.bundled_program.serialize import (
1919
serialize_from_bundled_program_to_flatbuffer,
2020
)
2121

examples/sdk/scripts/export_bundled_program.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
from typing import List
1212

1313
import torch
14-
from executorch.bundled_program.config import (
14+
from executorch.exir.schema import Program
15+
from executorch.sdk.bundled_program.config import (
1516
MethodInputType,
1617
MethodTestCase,
1718
MethodTestSuite,
1819
)
19-
from executorch.bundled_program.core import create_bundled_program
20-
from executorch.bundled_program.serialize import (
20+
from executorch.sdk.bundled_program.core import create_bundled_program
21+
from executorch.sdk.bundled_program.serialize import (
2122
serialize_from_bundled_program_to_flatbuffer,
2223
)
23-
from executorch.exir.schema import Program
2424

2525
from ...models import MODEL_NAME_TO_MODEL
2626
from ...models.model_factory import EagerModelFactory

exir/_serialize/TARGETS

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cpp_python_extension(
1414
"//executorch/backends/fb/qnnpack/...",
1515
"//executorch/backends/vulkan/...",
1616
"//executorch/backends/xnnpack/...",
17-
"//executorch/bundled_program/...",
17+
"//executorch/sdk/bundled_program/...",
1818
"//executorch/sdk/etdump/...",
1919
],
2020
deps = [
@@ -43,9 +43,6 @@ runtime.python_library(
4343
# Please ask before changing this.
4444
visibility = [
4545
"//executorch/backends/...",
46-
"//executorch/bundled_program:core",
47-
"//executorch/bundled_program/serialize:lib",
48-
"//executorch/bundled_program/tests/...",
4946
"//executorch/codegen/...",
5047
"//executorch/examples/async_exec:emit_program_lib",
5148
"//executorch/exir/...",
@@ -54,6 +51,9 @@ runtime.python_library(
5451
"//executorch/extension/pybindings/test:test",
5552
"//executorch/extension/pybindings/test:test-library",
5653
"//executorch/profiler/...",
54+
"//executorch/sdk/bundled_program:core",
55+
"//executorch/sdk/bundled_program/serialize:lib",
56+
"//executorch/sdk/bundled_program/tests/...",
5757
"//executorch/sdk/experimental/...",
5858
"//executorch/test/...",
5959
"@EXECUTORCH_CLIENTS",

schema/targets.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def define_common_targets():
6161
runtime.export_file(
6262
name = INPUT_BUNDLED,
6363
visibility = [
64-
"//executorch/bundled_program/serialize/...",
64+
"//executorch/sdk/bundled_program/serialize/...",
6565
],
6666
)
6767
runtime.export_file(
6868
name = INPUT_SCALAR_TYPE,
6969
visibility = [
70-
"//executorch/bundled_program/serialize/...",
70+
"//executorch/sdk/bundled_program/serialize/...",
7171
"//executorch/exir/_serialize/...",
7272
"//executorch/sdk/etdump/...",
7373
],
@@ -110,7 +110,7 @@ def define_common_targets():
110110
name = BUNDLED_LIBRARY_NAME,
111111
srcs = [],
112112
visibility = [
113-
"//executorch/bundled_program/...",
113+
"//executorch/sdk/bundled_program/...",
114114
"//executorch/extension/pybindings/...",
115115
"//executorch/examples/bundled_executor_runner/...",
116116
"//executorch/util/...", # bundled_program_verification
File renamed without changes.
File renamed without changes.

bundled_program/core.py renamed to sdk/bundled_program/core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
import typing
99
from typing import Dict, List, Sequence, Type
1010

11-
import executorch.bundled_program.schema as bp_schema
1211
import executorch.exir.schema as core_schema
1312

13+
import executorch.sdk.bundled_program.schema as bp_schema
14+
1415
import torch
1516
import torch.fx
16-
from executorch.bundled_program.config import ConfigValue, MethodTestSuite
17-
18-
from executorch.bundled_program.version import BUNDLED_PROGRAM_SCHEMA_VERSION
1917
from executorch.exir._serialize import _serialize_pte_binary
2018

2119
from executorch.exir.tensor import get_scalar_type, scalar_type_enum, TensorSpec
20+
from executorch.sdk.bundled_program.config import ConfigValue, MethodTestSuite
21+
22+
from executorch.sdk.bundled_program.version import BUNDLED_PROGRAM_SCHEMA_VERSION
2223

2324
# pyre-ignore
2425
supported_program_type_table: Dict[Type[core_schema.KernelTypes], ConfigValue] = {
File renamed without changes.

bundled_program/serialize/TARGETS renamed to sdk/bundled_program/serialize/TARGETS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ runtime.python_library(
1919
visibility = [
2020
"//executorch/bacends/...",
2121
"//executorch/backends/xnnpack/test/...",
22-
"//executorch/bundled_program/tests/...",
2322
"//executorch/codegen/...",
2423
"//executorch/examples/async_exec:emit_program_lib",
2524
"//executorch/exir:lib",
2625
"//executorch/extension/pybindings/test:test",
2726
"//executorch/extension/pybindings/test:test-library",
2827
"//executorch/profiler/...",
28+
"//executorch/sdk/bundled_program/tests/...",
2929
"//executorch/test/...",
3030
"@EXECUTORCH_CLIENTS",
3131
],
3232
deps = [
3333
"fbsource//third-party/pypi/setuptools:setuptools",
34-
"//executorch/bundled_program:schema",
3534
"//executorch/exir/_serialize:lib",
35+
"//executorch/sdk/bundled_program:schema",
3636
],
3737
)

bundled_program/serialize/__init__.py renamed to sdk/bundled_program/serialize/__init__.py

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

1515
# @manual=fbsource//third-party/pypi/setuptools:setuptools
1616
import pkg_resources
17-
from executorch.bundled_program.schema import BundledProgram
1817

1918
from executorch.exir._serialize._dataclass import _DataclassEncoder, _json_to_dataclass
2019
from executorch.exir._serialize._flatbuffer import _flatc_compile, _flatc_decompile
20+
from executorch.sdk.bundled_program.schema import BundledProgram
2121

2222
# The prefix of schema files used for bundled program
2323
BUNDLED_PROGRAM_SCHEMA_NAME = "bundled_program_schema"

bundled_program/tests/TARGETS renamed to sdk/bundled_program/tests/TARGETS

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ python_library(
1414
deps = [
1515
"fbsource//third-party/pypi/typing-extensions:typing-extensions",
1616
"//caffe2:torch",
17-
"//executorch/bundled_program:config",
1817
"//executorch/exir:lib",
1918
"//executorch/exir:schema",
19+
"//executorch/sdk/bundled_program:config",
2020
],
2121
)
2222

@@ -28,10 +28,10 @@ python_unittest(
2828
deps = [
2929
":lib",
3030
"//caffe2:torch",
31-
"//executorch/bundled_program:config",
32-
"//executorch/bundled_program:core",
33-
"//executorch/bundled_program:schema",
3431
"//executorch/exir/_serialize:lib",
32+
"//executorch/sdk/bundled_program:config",
33+
"//executorch/sdk/bundled_program:core",
34+
"//executorch/sdk/bundled_program:schema",
3535
],
3636
)
3737

@@ -42,9 +42,9 @@ python_unittest(
4242
],
4343
deps = [
4444
":lib",
45-
"//executorch/bundled_program:core",
46-
"//executorch/bundled_program/serialize:lib",
4745
"//executorch/exir:print_program",
46+
"//executorch/sdk/bundled_program:core",
47+
"//executorch/sdk/bundled_program/serialize:lib",
4848
],
4949
)
5050

@@ -56,8 +56,8 @@ python_unittest(
5656
deps = [
5757
":lib",
5858
"//caffe2:torch",
59-
"//executorch/bundled_program:config",
6059
"//executorch/extension/pytree:pylib",
60+
"//executorch/sdk/bundled_program:config",
6161
],
6262
)
6363

@@ -69,9 +69,6 @@ python_unittest(
6969
deps = [
7070
":lib",
7171
"//caffe2:torch",
72-
"//executorch/bundled_program:config",
73-
"//executorch/bundled_program:core",
74-
"//executorch/bundled_program/serialize:lib",
7572
"//executorch/exir:dynamic_shape",
7673
"//executorch/exir:lib",
7774
"//executorch/exir:memory",
@@ -88,5 +85,8 @@ python_unittest(
8885
"//executorch/extension/pybindings:portable_lib",
8986
"//executorch/extension/pytree:pybindings",
9087
"//executorch/kernels/portable:custom_ops_generated_lib",
88+
"//executorch/sdk/bundled_program:config",
89+
"//executorch/sdk/bundled_program:core",
90+
"//executorch/sdk/bundled_program/serialize:lib",
9191
],
9292
)

0 commit comments

Comments
 (0)