Skip to content

Commit 4197fc1

Browse files
pytorchbotabhinaykukkadapuGasoonjia
authored
[ExecuTorch][Export][1/N] Export API pipeline re-architecture, making it composable (#13055)
Co-authored-by: Abhinay Kukkadapu <[email protected]> Co-authored-by: Gasoonjia <[email protected]>
1 parent 43d90e5 commit 4197fc1

File tree

10 files changed

+1513
-907
lines changed

10 files changed

+1513
-907
lines changed

backends/xnnpack/recipes/xnnpack_recipe_provider.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from executorch.export import (
2828
BackendRecipeProvider,
2929
ExportRecipe,
30+
LoweringRecipe,
3031
QuantizationRecipe,
3132
RecipeType,
3233
)
@@ -88,12 +89,19 @@ def create_recipe(
8889
)
8990
return None
9091

92+
def _get_xnnpack_lowering_recipe(
93+
self, precision_type: Optional[ConfigPrecisionType] = None
94+
) -> LoweringRecipe:
95+
return LoweringRecipe(
96+
partitioners=[XnnpackPartitioner(precision_type=precision_type)],
97+
edge_compile_config=get_xnnpack_edge_compile_config(),
98+
)
99+
91100
def _build_fp32_recipe(self, recipe_type: RecipeType) -> ExportRecipe:
92101
return ExportRecipe(
93102
name=recipe_type.value,
94-
edge_compile_config=get_xnnpack_edge_compile_config(),
103+
lowering_recipe=self._get_xnnpack_lowering_recipe(),
95104
executorch_backend_config=get_xnnpack_executorch_backend_config(),
96-
partitioners=[XnnpackPartitioner()],
97105
)
98106

99107
def _build_quantized_recipe(
@@ -120,9 +128,8 @@ def _build_quantized_recipe(
120128
return ExportRecipe(
121129
name=recipe_type.value,
122130
quantization_recipe=quant_recipe,
123-
edge_compile_config=get_xnnpack_edge_compile_config(),
131+
lowering_recipe=self._get_xnnpack_lowering_recipe(precision_type),
124132
executorch_backend_config=get_xnnpack_executorch_backend_config(),
125-
partitioners=[XnnpackPartitioner(config_precision=precision_type)],
126133
)
127134

128135
def _build_int8da_intx_weight_recipe(
@@ -150,9 +157,8 @@ def _build_int8da_intx_weight_recipe(
150157
return ExportRecipe(
151158
name=recipe_type.value,
152159
quantization_recipe=quant_recipe,
153-
edge_compile_config=get_xnnpack_edge_compile_config(),
160+
lowering_recipe=self._get_xnnpack_lowering_recipe(),
154161
executorch_backend_config=get_xnnpack_executorch_backend_config(),
155-
partitioners=[XnnpackPartitioner()],
156162
)
157163

158164
def _validate_recipe_kwargs(self, recipe_type: RecipeType, **kwargs: Any) -> None:

export/TARGETS

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ runtime.python_library(
1515
"//caffe2:torch",
1616
"//executorch/exir/backend:backend_api",
1717
"//executorch/exir:pass_manager",
18-
"//executorch/devtools/backend_debug:delegation_info",
1918
"//executorch/extension/export_util:export_util",
2019
]
2120
)
@@ -31,11 +30,35 @@ runtime.python_library(
3130
],
3231
deps = [
3332
":recipe",
33+
":stages",
34+
":types",
3435
"//executorch/runtime:runtime",
3536
":recipe_registry"
3637
]
3738
)
3839

40+
41+
runtime.python_library(
42+
name = "stages",
43+
srcs = [
44+
"stages.py",
45+
],
46+
visibility = [
47+
"//executorch/...",
48+
"@EXECUTORCH_CLIENTS",
49+
],
50+
deps = [
51+
":recipe",
52+
":types",
53+
"//executorch/devtools/backend_debug:delegation_info",
54+
"//executorch/exir/backend:backend_api",
55+
"//executorch/exir:pass_manager",
56+
"//caffe2:torch",
57+
"//executorch/devtools/backend_debug:delegation_info",
58+
]
59+
)
60+
61+
3962
runtime.python_library(
4063
name = "lib",
4164
srcs = [
@@ -48,8 +71,10 @@ runtime.python_library(
4871
deps = [
4972
":export",
5073
":recipe",
74+
":stages",
5175
":recipe_registry",
52-
":recipe_provider"
76+
":recipe_provider",
77+
":types",
5378
],
5479
)
5580

@@ -78,3 +103,10 @@ runtime.python_library(
78103
":recipe",
79104
]
80105
)
106+
107+
runtime.python_library(
108+
name = "types",
109+
srcs = [
110+
"types.py",
111+
],
112+
)

export/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
"""
1616

1717
from .export import export, ExportSession
18-
from .recipe import ExportRecipe, QuantizationRecipe, RecipeType
18+
from .recipe import ExportRecipe, LoweringRecipe, QuantizationRecipe, RecipeType
1919
from .recipe_provider import BackendRecipeProvider
2020
from .recipe_registry import recipe_registry
21-
21+
from .types import StageType
2222

2323
__all__ = [
24+
"StageType",
2425
"ExportRecipe",
26+
"LoweringRecipe",
2527
"QuantizationRecipe",
2628
"ExportSession",
2729
"export",

0 commit comments

Comments
 (0)