Skip to content

Commit a9d149c

Browse files
committed
Update on "migrate etrecord generation after to_edge_transform_and_lower to new infra"
Differential Revision: [D79420502](https://our.internmc.facebook.com/intern/diff/D79420502/) [ghstack-poisoned]
2 parents 8ffa797 + ac36273 commit a9d149c

File tree

16 files changed

+1577
-922
lines changed

16 files changed

+1577
-922
lines changed

backends/apple/coreml/runtime/delegate/multiarray.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ bool init_bnns_descriptor(BNNSNDArrayDescriptor& bnns_descriptor, const MultiArr
123123
}
124124

125125
bool copy_using_bnns(const MultiArray& src, MultiArray& dst) {
126+
if (src.layout().dataType() != dst.layout().dataType()) {
127+
return false;
128+
}
126129
if (dst.layout().num_bytes() < src.layout().num_bytes()) {
127130
return false;
128131
}

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:

examples/xnnpack/aot_compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@
101101
_check_ir_validity=False if args.quantize else True,
102102
_skip_dim_order=True, # TODO(T182187531): enable dim order in xnnpack
103103
),
104-
generate_etrecord=args.etrecord is not None,
104+
generate_etrecord=args.etrecord is not False,
105105
)
106106
logging.info(f"Exported and lowered graph:\n{edge.exported_program().graph}")
107107

108108
exec_prog = edge.to_executorch(
109109
config=ExecutorchBackendConfig(extract_delegate_segments=False)
110110
)
111111

112-
if args.etrecord is not None:
112+
if args.etrecord is not False:
113113
edge.get_etrecord().save(args.etrecord)
114114
logging.info(f"Saved ETRecord to {args.etrecord}")
115115

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)